@@ -56,6 +56,7 @@ IECORE_PUSH_DEFAULT_VISIBILITY
5656#include " pxr/usd/usd/stage.h"
5757#include " pxr/usd/usdGeom/bboxCache.h"
5858#include " pxr/usd/usdGeom/camera.h"
59+ #include " pxr/usd/usdGeom/gprim.h"
5960#include " pxr/usd/usdGeom/metrics.h"
6061#include " pxr/usd/usdGeom/pointInstancer.h"
6162#include " pxr/usd/usdGeom/primvar.h"
@@ -803,6 +804,7 @@ namespace
803804
804805const IECore::InternedString g_purposeAttributeName ( " usd:purpose" );
805806const IECore::InternedString g_kindAttributeName ( " usd:kind" );
807+ const IECore::InternedString g_doubleSidedAttributeName ( " doubleSided" );
806808
807809} // namespace
808810
@@ -828,6 +830,10 @@ bool USDScene::hasAttribute( const SceneInterface::Name &name ) const
828830 pxr::TfToken kind;
829831 return model.GetKind ( &kind );
830832 }
833+ else if ( name == g_doubleSidedAttributeName )
834+ {
835+ return pxr::UsdGeomGprim ( m_location->prim ).GetDoubleSidedAttr ().HasAuthoredValue ();
836+ }
831837 else if ( auto attribute = AttributeAlgo::findUSDAttribute ( m_location->prim , name.string () ) )
832838 {
833839 return attribute.HasAuthoredValue ();
@@ -876,6 +882,11 @@ void USDScene::attributeNames( SceneInterface::NameList &attrs ) const
876882 attrs.push_back ( g_kindAttributeName );
877883 }
878884
885+ if ( pxr::UsdGeomGprim ( m_location->prim ).GetDoubleSidedAttr ().HasAuthoredValue () )
886+ {
887+ attrs.push_back ( g_doubleSidedAttributeName );
888+ }
889+
879890 std::vector<pxr::UsdAttribute> attributes = m_location->prim .GetAuthoredAttributes ();
880891 for ( const auto &attribute : attributes )
881892 {
@@ -961,6 +972,16 @@ ConstObjectPtr USDScene::readAttribute( const SceneInterface::Name &name, double
961972 }
962973 return new StringData ( kind.GetString () );
963974 }
975+ else if ( name == g_doubleSidedAttributeName )
976+ {
977+ pxr::UsdAttribute attr = pxr::UsdGeomGprim ( m_location->prim ).GetDoubleSidedAttr ();
978+ bool doubleSided;
979+ if ( attr.HasAuthoredValue () && attr.Get ( &doubleSided, m_root->getTime ( time ) ) )
980+ {
981+ return new BoolData ( doubleSided );
982+ }
983+ return nullptr ;
984+ }
964985 else if ( pxr::UsdAttribute attribute = AttributeAlgo::findUSDAttribute ( m_location->prim , name.string () ) )
965986 {
966987 return DataAlgo::fromUSD ( attribute, m_root->getTime ( time ) );
@@ -1022,6 +1043,28 @@ void USDScene::writeAttribute( const SceneInterface::Name &name, const Object *a
10221043 }
10231044 }
10241045 }
1046+ else if ( name == g_doubleSidedAttributeName )
1047+ {
1048+ if ( auto *data = reportedCast<const BoolData>( attribute, " USDScene::writeAttribute" , name.c_str () ) )
1049+ {
1050+ pxr::UsdGeomGprim gprim ( m_location->prim );
1051+ if ( gprim )
1052+ {
1053+ gprim.GetDoubleSidedAttr ().Set ( data->readable (), m_root->getTime ( time ) );
1054+ }
1055+ else
1056+ {
1057+ // We're hamstrung by the fact that USD considers `doubleSided` to be a property
1058+ // of a Gprim and not an inheritable attribute as it was in RenderMan and is in Cortex.
1059+ // We can't author a Gprim here, because it isn't a concrete type, so we must rely on
1060+ // `writeObject()` having been called first to get a suitable concrete type in place.
1061+ IECore::msg (
1062+ IECore::Msg::Warning, " USDScene::writeAttribute" ,
1063+ boost::format ( " Unable to write attribute \" %1%\" to \" %2%\" , because it is not a Gprim" ) % name % m_location->prim .GetPath ()
1064+ );
1065+ }
1066+ }
1067+ }
10251068 else if ( const IECoreScene::ShaderNetwork *shaderNetwork = runTimeCast<const ShaderNetwork>( attribute ) )
10261069 {
10271070 m_shaders[name] = shaderNetwork;
@@ -1356,6 +1399,13 @@ void USDScene::attributesHash( double time, IECore::MurmurHash &h ) const
13561399 // Kind can not be animated so no need to update `mightBeTimeVarying`.
13571400 }
13581401
1402+ auto doubleSidedAttr = pxr::UsdGeomGprim ( m_location->prim ).GetDoubleSidedAttr ();
1403+ if ( doubleSidedAttr && doubleSidedAttr.HasAuthoredValue () )
1404+ {
1405+ haveAttributes = true ;
1406+ mightBeTimeVarying |= doubleSidedAttr.ValueMightBeTimeVarying ();
1407+ }
1408+
13591409 std::vector<pxr::UsdAttribute> attributes = m_location->prim .GetAuthoredAttributes ();
13601410 for ( const auto &attribute : attributes )
13611411 {
0 commit comments