@@ -66,6 +66,7 @@ namespace {
6666 const char * apiSchemaCanOnlyApplyToStr = " apiSchemaCanOnlyApplyTo" ;
6767 const char * apiSchemasForAttrPruningStr = " apiSchemasForAttrPruning" ;
6868 const char * sdrGlobalConfigStr = " sdrGlobalConfig" ;
69+ const char * sdrIgnoreStr = " sdrIgnore" ;
6970
7071 // Helper to make comparisons of `const char*` easier to read; there are
7172 // lots of these comparisons
@@ -96,6 +97,7 @@ TF_DEFINE_PRIVATE_TOKENS(
9697 ((tagAttr, " tag" ))
9798 ((vstructmemberAttr, " vstructmember" ))
9899 ((sdrDefinitionNameAttr, " sdrDefinitionName" ))
100+ ((sdrUsdDefaultAttr, " sdrUsdDefault" ))
99101);
100102
101103// Data that represents an SdrShaderNode before it is turned into one. The
@@ -567,19 +569,28 @@ _Parse(
567569 // <param> and <output>
568570 // ---------------------------------------------------------------------
569571 if (isInput || isOutput) {
570- shaderRep.properties .emplace_back (
571- _ParseChildElem (shaderRep, isOutput, childElement, parentPage)
572- );
573- // Query the emplaced property to see if ImplementationName metadata
574- // is added, which would imply sdrDefinitionName was set for this
575- // property, if so save the information in shaderRep.
576- const NdrTokenMap& propMetadata =
577- shaderRep.properties .back ()->GetMetadata ();
578- if (propMetadata.find (SdrPropertyMetadata->ImplementationName ) !=
579- propMetadata.end ()) {
580- // We do this here so as to maintain constness for shaderRep in
581- // _ParseChildElem
582- shaderRep.hasSdrDefinitionNameProperty = true ;
572+ // If we have an ignore flag skip this property. Certain settings like
573+ // CropWindow and FormatResolution exist already in USD.
574+ bool ignore = false ;
575+ if (xml_attribute ignoreAttr = childElement.attribute (sdrIgnoreStr)) {
576+ ignore = EQUALS (ignoreAttr.value (), " True" );
577+ }
578+
579+ if (!ignore) {
580+ shaderRep.properties .emplace_back (
581+ _ParseChildElem (shaderRep, isOutput, childElement, parentPage)
582+ );
583+ // Query the emplaced property to see if ImplementationName metadata
584+ // is added, which would imply sdrDefinitionName was set for this
585+ // property, if so save the information in shaderRep.
586+ const NdrTokenMap& propMetadata =
587+ shaderRep.properties .back ()->GetMetadata ();
588+ if (propMetadata.find (SdrPropertyMetadata->ImplementationName ) !=
589+ propMetadata.end ()) {
590+ // We do this here so as to maintain constness for shaderRep in
591+ // _ParseChildElem
592+ shaderRep.hasSdrDefinitionNameProperty = true ;
593+ }
583594 }
584595 }
585596
@@ -779,14 +790,14 @@ _GetVtValue(
779790 if (type == SdrPropertyTypes->Int ) {
780791 if (!isArray) {
781792 // If the conversion fails, we get zero
782- return VtValue (atoi (stringValue.c_str ()));
793+ return VtValue (std::stoi (stringValue.c_str ()));
783794 } else {
784795 NdrStringVec parts = TfStringTokenize (stringValue, " ," );
785796 int numValues = parts.size ();
786797 VtIntArray ints (numValues);
787798
788799 for (int i = 0 ; i < numValues; ++i) {
789- ints[i] = atoi (parts[i].c_str ());
800+ ints[i] = std::stoi (parts[i].c_str ());
790801 }
791802
792803 return VtValue::Take (ints);
@@ -819,14 +830,14 @@ _GetVtValue(
819830 else if (type == SdrPropertyTypes->Float ) {
820831 if (!isArray) {
821832 // If the conversion fails, we get zero
822- return VtValue (static_cast < float >( atof ( stringValue.c_str () )));
833+ return VtValue (std::stof ( stringValue.c_str ()));
823834 } else {
824835 NdrStringVec parts = TfStringTokenize (stringValue, " ," );
825836 int numValues = parts.size ();
826837
827838 VtFloatArray floats (numValues);
828839 for (int i = 0 ; i < numValues; ++i) {
829- floats[i] = static_cast < float >( atof ( parts[i].c_str () ));
840+ floats[i] = std::stof ( parts[i].c_str ());
830841 }
831842
832843 return VtValue::Take (floats);
@@ -845,9 +856,9 @@ _GetVtValue(
845856 if (!isArray) {
846857 if (parts.size () == 3 ) {
847858 return VtValue (
848- GfVec3f (atof (parts[0 ].c_str ()),
849- atof (parts[1 ].c_str ()),
850- atof (parts[2 ].c_str ()))
859+ GfVec3f (std::stof (parts[0 ].c_str ()),
860+ std::stof (parts[1 ].c_str ()),
861+ std::stof (parts[2 ].c_str ()))
851862 );
852863 } else {
853864 TF_DEBUG (NDR_PARSING).Msg (
@@ -861,9 +872,9 @@ _GetVtValue(
861872 VtVec3fArray array (numElements);
862873
863874 for (int i = 0 ; i < numElements; ++i) {
864- array[i] = GfVec3f (atof (parts[3 *i + 0 ].c_str ()),
865- atof (parts[3 *i + 1 ].c_str ()),
866- atof (parts[3 *i + 2 ].c_str ()));
875+ array[i] = GfVec3f (std::stof (parts[3 *i + 0 ].c_str ()),
876+ std::stof (parts[3 *i + 1 ].c_str ()),
877+ std::stof (parts[3 *i + 2 ].c_str ()));
867878 }
868879
869880 return VtValue::Take (array);
@@ -881,7 +892,7 @@ _GetVtValue(
881892 double * values = mat.GetArray ();
882893
883894 for (int i = 0 ; i < 16 ; ++i) {
884- values[i] = atof (parts[i].c_str ());
895+ values[i] = std::stof (parts[i].c_str ());
885896 }
886897
887898 return VtValue::Take (mat);
@@ -1050,13 +1061,23 @@ _CreateProperty(
10501061
10511062 // Determine the default value; leave empty if a default isn't found
10521063 // -------------------------------------------------------------------------
1053- const VtValue defaultValue =
1054- attributes.count (_xmlAttributeNames->defaultAttr )
1055- ? _GetVtValue (attributes.at (_xmlAttributeNames->defaultAttr ),
1056- typeName,
1057- arraySize,
1058- attributes)
1059- : VtValue ();
1064+ VtValue defaultValue = VtValue ();
1065+ // Use sdrUsdDefault over regular default if it exists
1066+ if (attributes.count (_xmlAttributeNames->sdrUsdDefaultAttr )) {
1067+ defaultValue = _GetVtValue (
1068+ attributes.at (_xmlAttributeNames->sdrUsdDefaultAttr ),
1069+ typeName,
1070+ arraySize,
1071+ attributes
1072+ );
1073+ } else if (attributes.count (_xmlAttributeNames->defaultAttr )) {
1074+ defaultValue = _GetVtValue (
1075+ attributes.at (_xmlAttributeNames->defaultAttr ),
1076+ typeName,
1077+ arraySize,
1078+ attributes
1079+ );
1080+ }
10601081
10611082 return SdrShaderPropertyUniquePtr (
10621083 new SdrShaderProperty (
0 commit comments