Skip to content

Commit 37b6daf

Browse files
Merge branch 'OGN-schema-fix' into 'main'
Fix component schemas and docs for toolkit usage See merge request lightspeedrtx/dxvk-remix-nv!1728
2 parents 4bdc401 + 48d7489 commit 37b6daf

File tree

5 files changed

+81
-58
lines changed

5 files changed

+81
-58
lines changed

src/dxvk/rtx_render/graph/rtx_graph_ogn_writer.cpp

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,29 +114,34 @@ void writePropertyToOGN(std::ofstream& outputFile, const RtComponentPropertySpec
114114
if (!prop.enumValues.empty()) {
115115
// For enum documentation, we need to combine everything into the property docstring.
116116
outputFile << " \"description\": [\"" << escapeJsonString(prop.docString) << "\\n" << "Allowed values: ";
117+
std::string defaultEnumValueString = "";
117118
for (const auto& enumValue : prop.enumValues) {
118119
outputFile << " - " << enumValue.first << ": " << enumValue.second.docString << "\\n ";
120+
if (enumValue.second.value == prop.defaultValue) {
121+
defaultEnumValueString = enumValue.first;
122+
}
119123
}
120124
outputFile << "\"]," << std::endl;
125+
outputFile << " \"type\": \"token\"," << std::endl;
126+
127+
outputFile << " \"default\": \"" << defaultEnumValueString << "\"," << std::endl;
121128
} else {
122129
outputFile << " \"description\": [\"" << escapeJsonString(prop.docString) << "\"]," << std::endl;
123-
}
124-
outputFile << " \"uiName\": \"" << escapeJsonString(prop.uiName) << "\"," << std::endl;
125-
outputFile << " \"type\": \"" << propertyTypeToOgnType(prop.type) << "\"";
130+
outputFile << " \"type\": \"" << propertyTypeToOgnType(prop.type) << "\"," << std::endl;
126131

127-
// Target relationships don't have default values in OGN
128-
if (prop.type != RtComponentPropertyType::Prim) {
129-
outputFile << "," << std::endl;
130-
outputFile << " \"default\": " << getDefaultValueAsJson(prop.defaultValue, prop.type);
132+
// Target relationships don't have default values in OGN
133+
if (prop.type != RtComponentPropertyType::Prim) {
134+
outputFile << " \"default\": " << getDefaultValueAsJson(prop.defaultValue, prop.type) << "," << std::endl;
135+
}
131136
}
132137

138+
133139
// Add metadata if available
134140
bool hasMetadata = false;
135141
if (!prop.enumValues.empty() ||
136142
prop.type == RtComponentPropertyType::Color3 ||
137143
prop.type == RtComponentPropertyType::Color4) {
138144

139-
outputFile << "," << std::endl;
140145
outputFile << " \"metadata\": {" << std::endl;
141146

142147
// Add uiType for color properties
@@ -161,16 +166,17 @@ void writePropertyToOGN(std::ofstream& outputFile, const RtComponentPropertySpec
161166
}
162167

163168
outputFile << std::endl;
164-
outputFile << " }";
169+
outputFile << " }," << std::endl;
165170
}
166171

167172
// Optional properties
168173
if (prop.optional) {
169-
outputFile << "," << std::endl;
170-
outputFile << " \"optional\": true";
174+
outputFile << " \"optional\": true," << std::endl;
171175
}
172176

173-
outputFile << std::endl;
177+
outputFile << " \"uiName\": \"" << escapeJsonString(prop.uiName) << "\"" << std::endl;
178+
179+
174180
outputFile << " }";
175181
if (!isLast) {
176182
outputFile << ",";
@@ -205,6 +211,7 @@ bool writeOGNSchema(const RtComponentSpec* spec, const char* outputFolderPath) {
205211
outputFile << " \"version\": " << spec->version << "," << std::endl;
206212
outputFile << " \"uiName\": \"" << escapeJsonString(spec->uiName) << "\"," << std::endl;
207213
outputFile << " \"language\": \"python\"," << std::endl;
214+
outputFile << " \"categoryDefinitions\": \"config/CategoryDefinition.json\"," << std::endl;
208215
outputFile << " \"categories\": \"" << escapeJsonString(spec->categories) << "\"," << std::endl;
209216

210217
// Separate properties by IO type
@@ -236,18 +243,19 @@ bool writeOGNSchema(const RtComponentSpec* spec, const char* outputFolderPath) {
236243
outputFile << std::endl;
237244
}
238245

246+
// Disabled the state section - this shows up as editable properties in the Toolkit UI, and filtering them there is non-trivial.
239247
// Write state section
240-
if (!states.empty()) {
241-
outputFile << " \"state\": {" << std::endl;
242-
for (size_t i = 0; i < states.size(); ++i) {
243-
writePropertyToOGN(outputFile, *states[i], i == states.size() - 1);
244-
}
245-
outputFile << " }";
246-
if (!outputs.empty()) {
247-
outputFile << ",";
248-
}
249-
outputFile << std::endl;
250-
}
248+
// if (!states.empty()) {
249+
// outputFile << " \"state\": {" << std::endl;
250+
// for (size_t i = 0; i < states.size(); ++i) {
251+
// writePropertyToOGN(outputFile, *states[i], i == states.size() - 1);
252+
// }
253+
// outputFile << " }";
254+
// if (!outputs.empty()) {
255+
// outputFile << ",";
256+
// }
257+
// outputFile << std::endl;
258+
// }
251259

252260
// Write outputs section
253261
if (!outputs.empty()) {
@@ -282,9 +290,16 @@ bool writePythonStub(const RtComponentSpec* spec, const char* outputFolderPath)
282290

283291
std::ofstream& outputFile = *outputFileHolder;
284292

285-
outputFile << "from lightspeed.trex.omni.graph.ogn.OgnTemplateNodePyDatabase import OgnTemplateNodePyDatabase" << std::endl;
286293
outputFile << "# GENERATED FILE - DO NOT EDIT" << std::endl;
287294
outputFile << "# This file is a stub for OmniGraph editor compatibility, and is not used by the Remix Runtime." << std::endl;
295+
outputFile << "from __future__ import annotations" << std::endl;
296+
outputFile << std::endl;
297+
outputFile << "from typing import TYPE_CHECKING" << std::endl;
298+
outputFile << std::endl;
299+
outputFile << "if TYPE_CHECKING:" << std::endl;
300+
outputFile << " from lightspeed.trex.components.ogn.ogn.OgnTemplateNodePyDatabase import OgnTemplateNodePyDatabase" << std::endl;
301+
outputFile << std::endl;
302+
outputFile << std::endl;
288303
outputFile << "class "<< escapeJsonString(spec->getClassName()) << ":" << std::endl;
289304
outputFile << " @staticmethod" << std::endl;
290305
outputFile << " def compute(db: OgnTemplateNodePyDatabase):" << std::endl;

src/ogn/lightspeed.trex.components/AnimatedFloat.ogn

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,60 @@
44
"version": 1,
55
"uiName": "Animated Float",
66
"language": "python",
7+
"categoryDefinitions": "config/CategoryDefinition.json",
78
"categories": "animation",
89
"inputs": {
910
"enabled": {
1011
"description": ["If true, the float will be animated."],
11-
"uiName": "Enabled",
1212
"type": "bool",
1313
"default": true,
14-
"optional": true
14+
"optional": true,
15+
"uiName": "Enabled"
1516
},
1617
"initialValue": {
1718
"description": ["The value at time t=0."],
18-
"uiName": "Initial Value",
1919
"type": "float",
20-
"default": 0.000000
20+
"default": 0.000000,
21+
"uiName": "Initial Value"
2122
},
2223
"finalValue": {
2324
"description": ["The value at time t=duration."],
24-
"uiName": "Final Value",
2525
"type": "float",
26-
"default": 1.000000
26+
"default": 1.000000,
27+
"uiName": "Final Value"
2728
},
2829
"duration": {
2930
"description": ["How long it takes to animate from initial value to final value, in seconds."],
30-
"uiName": "Duration",
3131
"type": "float",
32-
"default": 1.000000
32+
"default": 1.000000,
33+
"uiName": "Duration"
3334
},
3435
"loopingType": {
3536
"description": ["What happens when the float reaches the final value.\nAllowed values: - Continue: The value will continue accumulating (a linear animation will preserve the velocity).\n - Freeze: The value will freeze at the final value.\n - Loop: The value will return to the initial value.\n - PingPong: The value will play in reverse until it reaches the initial value, then loop.\n "],
36-
"uiName": "Looping Type",
37-
"type": "uint",
38-
"default": 0,
37+
"type": "token",
38+
"default": "Loop",
3939
"metadata": {
4040
"allowedTokens": ["Continue", "Freeze", "Loop", "PingPong"]
41-
}
41+
},
42+
"uiName": "Looping Type"
4243
},
4344
"interpolation": {
4445
"description": ["How the float will change over time.\nAllowed values: - Bounce: Bouncy, playful motion.\n - Cubic: The float will change in a cubic curve over time.\n - EaseIn: The float will start slow, then accelerate.\n - EaseInOut: The float will start slow, accelerate, then decelerate.\n - EaseOut: The float will start fast, then decelerate.\n - Elastic: Spring-like motion.\n - Exponential: Dramatic acceleration effect.\n - Linear: The float will have a constant velocity.\n - Sine: Smooth, natural motion using sine wave.\n "],
45-
"uiName": "Interpolation",
46-
"type": "uint",
47-
"default": 0,
46+
"type": "token",
47+
"default": "Linear",
4848
"metadata": {
4949
"allowedTokens": ["Bounce", "Cubic", "EaseIn", "EaseInOut", "EaseOut", "Elastic", "Exponential", "Linear", "Sine"]
5050
},
51-
"optional": true
52-
}
53-
},
54-
"state": {
55-
"accumulatedTime": {
56-
"description": ["How much time has passed since the animation started."],
57-
"uiName": "",
58-
"type": "float",
59-
"default": 0.000000
51+
"optional": true,
52+
"uiName": "Interpolation"
6053
}
6154
},
6255
"outputs": {
6356
"currentValue": {
6457
"description": ["The animated float value."],
65-
"uiName": "Current Value",
6658
"type": "float",
67-
"default": 0.000000
59+
"default": 0.000000,
60+
"uiName": "Current Value"
6861
}
6962
}
7063
}

src/ogn/lightspeed.trex.components/AnimatedFloat.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
from lightspeed.trex.omni.graph.ogn.OgnTemplateNodePyDatabase import OgnTemplateNodePyDatabase
21
# GENERATED FILE - DO NOT EDIT
32
# This file is a stub for OmniGraph editor compatibility, and is not used by the Remix Runtime.
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
6+
7+
if TYPE_CHECKING:
8+
from lightspeed.trex.components.ogn.ogn.OgnTemplateNodePyDatabase import OgnTemplateNodePyDatabase
9+
10+
411
class AnimatedFloat:
512
@staticmethod
613
def compute(db: OgnTemplateNodePyDatabase):

src/ogn/lightspeed.trex.components/SphereLightOverride.ogn

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,27 @@
44
"version": 1,
55
"uiName": "Sphere Light",
66
"language": "python",
7+
"categoryDefinitions": "config/CategoryDefinition.json",
78
"categories": "light",
89
"inputs": {
910
"enabled": {
1011
"description": ["If true, the overrides will be applied"],
11-
"uiName": "Enabled",
1212
"type": "bool",
1313
"default": true,
14-
"optional": true
14+
"optional": true,
15+
"uiName": "Enabled"
1516
},
1617
"radius": {
1718
"description": ["The radius of the sphere light."],
18-
"uiName": "Radius",
1919
"type": "float",
2020
"default": 0.000000,
21-
"optional": true
21+
"optional": true,
22+
"uiName": "Radius"
2223
},
2324
"target": {
2425
"description": ["The sphere light to override."],
25-
"uiName": "Target",
26-
"type": "target"
26+
"type": "target",
27+
"uiName": "Target"
2728
}
2829
}
2930
}

src/ogn/lightspeed.trex.components/SphereLightOverride.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
from lightspeed.trex.omni.graph.ogn.OgnTemplateNodePyDatabase import OgnTemplateNodePyDatabase
21
# GENERATED FILE - DO NOT EDIT
32
# This file is a stub for OmniGraph editor compatibility, and is not used by the Remix Runtime.
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
6+
7+
if TYPE_CHECKING:
8+
from lightspeed.trex.components.ogn.ogn.OgnTemplateNodePyDatabase import OgnTemplateNodePyDatabase
9+
10+
411
class SphereLightOverride:
512
@staticmethod
613
def compute(db: OgnTemplateNodePyDatabase):

0 commit comments

Comments
 (0)