Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated schemas #2116

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
- [usd#2047](https://github.com/Autodesk/arnold-usd/issues/2047) - Shaders exports should be bound to a material
- [usd#2109](https://github.com/Autodesk/arnold-usd/issues/2109) - Expose hydra parameter in the procedural
- [usd#2107](https://github.com/Autodesk/arnold-usd/issues/2107) - Support procedural updates in hydra mode
- [usd#2088](https://github.com/Autodesk/arnold-usd/issues/2088) - Remove deprecated schemas
- [usd#2111](https://github.com/Autodesk/arnold-usd/issues/2111) - Add support for transform_keys in xform primitives


### Bug fixes
- [usd#1961](https://github.com/Autodesk/arnold-usd/issues/1961) - Random curves width in Hydra when radius primvars are authored
- [usd#1977](https://github.com/Autodesk/arnold-usd/issues/1977) - Aov shaders not set properly in hydra mode of the scene format
Expand Down
78 changes: 44 additions & 34 deletions schemas/createSchemaFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,6 @@ class ArnoldNodeGraph "ArnoldNodeGraph" (
}
) {
}
class ArnoldOptions "ArnoldOptions" (
inherits = [</Imageable>]
customData = {
dictionary extraPlugInfo = {
bool providesUsdShadeConnectableAPIBehavior = 1
}
}
) {
}

'''
)
Expand All @@ -301,6 +292,14 @@ def createArnoldClass(entryName, parentClass, paramList, nentry, parentParamList
file.write('class "{}"(\n'.format(schemaName))

file.write(' inherits = [</{}>]\n'.format(parentClass))

if isAPI == False and entryName == 'options':
file.write(' customData = {\n')
file.write(' dictionary extraPlugInfo = {\n')
file.write(' bool providesUsdShadeConnectableAPIBehavior = 1')
file.write(' }\n')
file.write(' }\n')

file.write(') {\n')

for param in paramList:
Expand Down Expand Up @@ -354,20 +353,15 @@ def createArnoldClass(entryName, parentClass, paramList, nentry, parentParamList
typeParams = {} # dictionary (key=nodeEntryTypeName, value= list of parameters which exist in ALL the corresponding nodeEntryName)

# Loop over node entries
nodeEntryIter = ai.AiUniverseGetNodeEntryIterator(ai.AI_NODE_ALL)

nodeEntryIter = ai.AiUniverseGetNodeEntryIterator(ai.AI_NODE_ALL & ~ai.AI_NODE_SHADER & ~ai.AI_NODE_IMAGER & ~ai.AI_NODE_OPERATOR & ~ai.AI_NODE_OVERRIDE)
while not ai.AiNodeEntryIteratorFinished(nodeEntryIter):
nentry = ai.AiNodeEntryIteratorGetNext(nodeEntryIter);

# Name of this AtNodeEntry (distant_light, skydome_light, etc...)
entryName = str(ai.AiNodeEntryGetName(nentry))
# Type of this AtNodeEntry (light, shape, shader, operator, etc...)
entryTypeName = str(ai.AiNodeEntryGetTypeName(nentry))

# we don't want to create schemas for shaders, as we're relying on UsdShade schemas
# Ignore material nodes for now. Also, "options" is being hardcoded above, so it
# doesn't need to be added here
if entryTypeName == 'shader' or entryTypeName == 'material' or entryTypeName == 'options':
continue

# Get the list of parameters for this node entry
paramsList = []
Expand All @@ -392,7 +386,8 @@ def createArnoldClass(entryName, parentClass, paramList, nentry, parentParamList

if typeParams.get(entryTypeName) is None:
# first time we find a node with this type, let's simply copy all parameters for this node entry
typeParams[entryTypeName] = paramsList
typeParams[entryTypeName] = [] if entryTypeName == 'options' else paramsList

else:
# We want the final list to be the union between the existing list and paramsList
# So first we copy the existing list for this type
Expand All @@ -414,6 +409,7 @@ def createArnoldClass(entryName, parentClass, paramList, nentry, parentParamList
ignoreLightAttributes = ['intensity', 'color', 'exposure', 'diffuse', 'specular', 'normalize', 'matrix']
ignoreCameraAttributes = ['matrix', 'shutter_start', 'shutter_end', 'near_clip', 'far_clip']

# List the parameters that should be skipped in the schemas as they exist in the usd counterpart
nativeUsdList = {
'shape': ignoreShapeAttributes,
'polymesh': ignoreShapeAttributes + ['nsides', 'vidxs', 'polygon_holes', 'nidxs', 'shader'],
Expand All @@ -433,14 +429,18 @@ def createArnoldClass(entryName, parentClass, paramList, nentry, parentParamList
'camera' : ignoreCameraAttributes,
'persp_camera': ignoreCameraAttributes + ['focus_distance'],
'ortho_camera': ignoreCameraAttributes,
'options': ['xres', 'yres', 'camera'],
'color_manager': []
}

'''
Now let's create a new class for each "type", let it inherit from a meaningful schema, and let's add its parameters based on the existing dictionary
'''
for key, paramList in typeParams.items():
if key == 'override':

if key == 'options':
continue

entryNames = entryByType[key] # list of entry names for this type
if entryNames == None or len(entryNames) == 0:
print('This script is not working...no entries found for type {}'.format(key))
Expand All @@ -451,46 +451,56 @@ def createArnoldClass(entryName, parentClass, paramList, nentry, parentParamList
print('Hey I could not find any AtNodeEntry called {}'.format(entryName))
continue

# these "base" arnold classes are typed but can't be instantiated
typeDict = {'shape' : 'Gprim',
'light' : 'Xformable',
'camera' : 'Xformable'}
createArnoldClass(key, typeDict[key] if key in typeDict else 'Typed', paramList, nentry, None, False, False)

# For the API schemas of arnold common types, we want to remove the attributes from the USD builtin
if key in nativeUsdList:
createArnoldClass(key, 'APISchemaBase', paramList, nentry, nativeUsdList[key], True)

########
# Now author all the API schemas for arnold node entries
for entry in entryList:
entryName = entry[0]
entryTypeName = entry[1]
parametersList = entry[2]
nentry = ai.AiNodeEntryLookUp(entryName)
if nentry == None:
print('I could not find any AtNodeEntry called {}'.format(entryName))
continue

parentClass = 'Arnold{}'.format(makeCamelCase(entryTypeName))
if entryName == 'options' or entryName == 'override':
continue # do we want to create schemas for the options ?

createArnoldClass(entryName, parentClass, parametersList, nentry, typeParams[entryTypeName], False)

if entryName in nativeUsdList:
createArnoldClass(entryName, 'APISchemaBase', parametersList, nentry,
nativeUsdList[entryName], True)

########
# Finally, add the typed schemas
includedTypedSchemas = ['shape', 'options']
excludedTypedEntry = ['polymesh', 'curves', 'points', 'list_aggregate']
for entry in entryList:
entryName = entry[0]
entryTypeName = entry[1]
if entryTypeName in includedTypedSchemas:

if entryName in excludedTypedEntry:
continue

parametersList = entry[2]
nentry = ai.AiNodeEntryLookUp(entryName)

parentClass = 'Imageable' if entryName == 'options' else 'Gprim'
createArnoldClass(entryName, parentClass, parametersList, nentry, None, False)

# --- Special case for custom procedurals. We want a schema ArnoldProceduralCustom,
# with a string attribute "node_type" returning the procedural node entry
proceduralCustomAttrs = typeParams['shape'] + ['override_nodes', 'namespace', 'operator']
createArnoldClass('procedural_custom', 'Gprim', proceduralCustomAttrs, ai.AiNodeEntryLookUp('procedural'), ignoreShapeAttributes, False)
'''
file.write('class ArnoldProceduralCustom "ArnoldProceduralCustom"(\n')
file.write(' inherits = [</ArnoldShape>]\n')
file.write(' inherits = [</Gprim>]\n')
file.write(') {\n')
file.write(' bool override_nodes = false (customData = {string apiName = "OverrideNodes"})\n')
file.write(' string arnold:namespace = "" (customData = {string apiName = "Namespace"})\n')
file.write(' string arnold:operator = "" (customData = {string apiName = "Operator"})\n')


file.write('}\n')
file_module.write(' TF_WRAP(UsdArnoldProceduralCustom);\n')
'''
#----

file_module.write('}\n')
Expand Down
36 changes: 26 additions & 10 deletions testsuite/test_0245/data/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,48 @@ def find_in_file(expectedTypes, filename):

def test_schemas(arnold_plugin):
expectedSchemas = ['ArnoldAlembic',
'ArnoldBox',
'ArnoldBoxAPI',
'ArnoldCameraAPI',
'ArnoldCamera',
'ArnoldColorManagerAPI',
'ArnoldCone',
'ArnoldCurves',
'ArnoldConeAPI',
'ArnoldCurvesAPI',
'ArnoldDriverExr',
'ArnoldCylinder',
'ArnoldCylinderAPI',
'ArnoldDisk',
'ArnoldDiskLightAPI',
'ArnoldDistantLightAPI',
'ArnoldGinstance',
'ArnoldImagerColorCorrect',
'ArnoldImagerDenoiserOidn',
'ArnoldImplicit',
'ArnoldInstancer',
'ArnoldLightAPI',
'ArnoldMaterialx',
'ArnoldMeshLightAPI',
'ArnoldNodeGraph',
'ArnoldOrthoCamera',
'ArnoldNurbs',
'ArnoldOptions',
'ArnoldOptionsAPI',
'ArnoldOrthoCameraAPI',
'ArnoldPerspCameraAPI',
'ArnoldPlane',
'ArnoldPointLightAPI',
'ArnoldPoints',
'ArnoldPointsAPI',
'ArnoldPolymesh',
'ArnoldPolymeshAPI',
'ArnoldProcedural',
'ArnoldProceduralCustom',
'ArnoldQuadLightAPI',
'ArnoldShapeAPI',
'ArnoldSkydomeLightAPI',
'ArnoldVrCamera']
'ArnoldSphere',
'ArnoldSphereAPI',
'ArnoldUsd',
'ArnoldUsdLuxLightFilter',
'ArnoldVolume',
'ArnoldVolumeImplicit']

filename = os.path.join(arnold_plugin, 'usdArnold', 'resources', 'plugInfo.json')
if not os.path.exists(filename):
print('schemas file not found {}'.format(filename))
return False
if not find_in_file(expectedSchemas, filename):
return False
Expand Down