Skip to content

Commit f4773c1

Browse files
committed
Merge branch 'RB-10.3' into main
2 parents 3bb0325 + e3ee519 commit f4773c1

File tree

5 files changed

+195
-0
lines changed

5 files changed

+195
-0
lines changed

Changes

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,30 @@ Breaking Changes
3636
- IECoreGL : Removed `PerspectiveCamera.h` header. The implementation was already removed in a Cortex 10.1.0.0 (#1241).
3737
- StringAlgo : Removed `join()` (#1221).
3838

39+
10.3.6.0 (relative to 10.3.5.1)
40+
========
41+
42+
Improvements
43+
------------
44+
45+
- USDScene : Added support for the `doubleSided` attribute.
46+
47+
10.3.5.1 (relative to 10.3.5.0)
48+
========
49+
50+
Fixes
51+
-----
52+
53+
- USDScene : Fixed compatibility with USD 21.08 (#1259).
54+
55+
10.3.5.0 (relative to 10.3.4.1)
56+
========
57+
58+
Improvements
59+
------------
60+
61+
- USDScene : Registered .usdz file format (#1257).
62+
3963
10.3.4.1 (relative to 10.3.4.0)
4064
========
4165

config/ie/options

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,30 @@ if targetApp=="maya" :
324324
INSTALL_COREMAYA_POST_COMMAND="scons -i -f config/ie/postCoreMayaInstall MAYA_VERSION='" + mayaVersion + "' INSTALLPREFIX="+appPrefix+" install"
325325
WITH_MAYA_PLUGIN_LOADER = 1
326326

327+
mayaUsdVersion = mayaReg.get( "mayaUsdVersion" )
328+
mayaUsdReg = IEEnv.registry["apps"]["mayaUsd"].get( mayaUsdVersion, {} ).get( platform )
329+
# If the Maya usd plugin is not in the registry we build against our standalone USD version
330+
if mayaUsdReg :
331+
pluginUsdVersion = mayaUsdReg["usdVersion"]
332+
# Maya ships the USD libraries with the installation, but not the header files... we use the one that are installed by standalone usd
333+
usdReg = IEEnv.registry["apps"]["usd"].get( pluginUsdVersion, {} ).get( platform )
334+
if usdReg :
335+
USD_INCLUDE_PATH = os.path.join( usdReg["location"], targetApp, compatibilityVersion, "include" )
336+
337+
mayaMajorVersion = mayaVersion.split(".")[0]
338+
mayaLooseVersion = distutils.version.LooseVersion(mayaVersion)
339+
if mayaLooseVersion >= "2022" and mayaLooseVersion < "2023":
340+
# Maya 2022 installs the USD libs and the maya plugin itself for python 2 and 3. This is not the case for the 2020 version
341+
# We make the assumption, that the python version suffix is for Maya 2022 only, because Maya 2023 will be python 3 exclusively.
342+
mayaPythonMajorVersion = mayaReg["pythonVersion"].split(".")[0]
343+
USD_LIB_PATH = os.path.join( mayaUsdReg["location"], mayaMajorVersion, "mayausd/USD{}/lib".format( mayaPythonMajorVersion ) )
344+
else:
345+
USD_LIB_PATH = os.path.join( mayaUsdReg["location"], mayaMajorVersion, "mayausd/USD/lib" )
346+
347+
# Pixar introduced a library prefix `usd_` in USD v21.11, which Autodesk does not use yet, so we have to reset the prefix.
348+
# See https://github.com/Autodesk/maya-usd/issues/2108 for reference
349+
USD_LIB_PREFIX = "" if mayaUsdReg.get( "usdLibPrefix" ) == "" else mayaUsdReg.get( "usdLibPrefix" ) or USD_LIB_PREFIX
350+
327351
# find nuke if we're building for nuke
328352
if targetApp=="nuke" :
329353

contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
@@ -796,6 +797,7 @@ namespace
796797
const IECore::InternedString g_purposeAttributeName( "usd:purpose" );
797798
const IECore::InternedString g_kindAttributeName( "usd:kind" );
798799
const IECore::InternedString g_lightAttributeName( "light" );
800+
const IECore::InternedString g_doubleSidedAttributeName( "doubleSided" );
799801

800802
} // namespace
801803

@@ -827,6 +829,10 @@ bool USDScene::hasAttribute( const SceneInterface::Name &name ) const
827829
return m_location->prim.HasAPI<pxr::UsdLuxLightAPI>();
828830
}
829831
#endif
832+
else if( name == g_doubleSidedAttributeName )
833+
{
834+
return pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr().HasAuthoredValue();
835+
}
830836
else if( auto attribute = AttributeAlgo::findUSDAttribute( m_location->prim, name.string() ) )
831837
{
832838
return attribute.HasAuthoredValue();
@@ -882,6 +888,11 @@ void USDScene::attributeNames( SceneInterface::NameList &attrs ) const
882888
}
883889
#endif
884890

891+
if( pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr().HasAuthoredValue() )
892+
{
893+
attrs.push_back( g_doubleSidedAttributeName );
894+
}
895+
885896
std::vector<pxr::UsdAttribute> attributes = m_location->prim.GetAuthoredAttributes();
886897
for( const auto &attribute : attributes )
887898
{
@@ -973,6 +984,16 @@ ConstObjectPtr USDScene::readAttribute( const SceneInterface::Name &name, double
973984
}
974985
return new StringData( kind.GetString() );
975986
}
987+
else if( name == g_doubleSidedAttributeName )
988+
{
989+
pxr::UsdAttribute attr = pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr();
990+
bool doubleSided;
991+
if( attr.HasAuthoredValue() && attr.Get( &doubleSided, m_root->getTime( time ) ) )
992+
{
993+
return new BoolData( doubleSided );
994+
}
995+
return nullptr;
996+
}
976997
else if( pxr::UsdAttribute attribute = AttributeAlgo::findUSDAttribute( m_location->prim, name.string() ) )
977998
{
978999
return DataAlgo::fromUSD( attribute, m_root->getTime( time ) );
@@ -1034,6 +1055,28 @@ void USDScene::writeAttribute( const SceneInterface::Name &name, const Object *a
10341055
}
10351056
}
10361057
}
1058+
else if( name == g_doubleSidedAttributeName )
1059+
{
1060+
if( auto *data = reportedCast<const BoolData>( attribute, "USDScene::writeAttribute", name.c_str() ) )
1061+
{
1062+
pxr::UsdGeomGprim gprim( m_location->prim );
1063+
if( gprim )
1064+
{
1065+
gprim.GetDoubleSidedAttr().Set( data->readable(), m_root->getTime( time ) );
1066+
}
1067+
else
1068+
{
1069+
// We're hamstrung by the fact that USD considers `doubleSided` to be a property
1070+
// of a Gprim and not an inheritable attribute as it was in RenderMan and is in Cortex.
1071+
// We can't author a Gprim here, because it isn't a concrete type, so we must rely on
1072+
// `writeObject()` having been called first to get a suitable concrete type in place.
1073+
IECore::msg(
1074+
IECore::Msg::Warning, "USDScene::writeAttribute",
1075+
boost::format( "Unable to write attribute \"%1%\" to \"%2%\", because it is not a Gprim" ) % name % m_location->prim.GetPath()
1076+
);
1077+
}
1078+
}
1079+
}
10371080
else if( const IECoreScene::ShaderNetwork *shaderNetwork = runTimeCast<const ShaderNetwork>( attribute ) )
10381081
{
10391082
m_shaders[name] = shaderNetwork;
@@ -1368,6 +1411,13 @@ void USDScene::attributesHash( double time, IECore::MurmurHash &h ) const
13681411
// Kind can not be animated so no need to update `mightBeTimeVarying`.
13691412
}
13701413

1414+
auto doubleSidedAttr = pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr();
1415+
if( doubleSidedAttr && doubleSidedAttr.HasAuthoredValue() )
1416+
{
1417+
haveAttributes = true;
1418+
mightBeTimeVarying |= doubleSidedAttr.ValueMightBeTimeVarying();
1419+
}
1420+
13711421
std::vector<pxr::UsdAttribute> attributes = m_location->prim.GetAuthoredAttributes();
13721422
for( const auto &attribute : attributes )
13731423
{
@@ -1456,5 +1506,6 @@ namespace
14561506
SceneInterface::FileFormatDescription<USDScene> g_descriptionUSD( ".usd", IndexedIO::Read | IndexedIO::Write );
14571507
SceneInterface::FileFormatDescription<USDScene> g_descriptionUSDA( ".usda", IndexedIO::Read | IndexedIO::Write );
14581508
SceneInterface::FileFormatDescription<USDScene> g_descriptionUSDC( ".usdc", IndexedIO::Read | IndexedIO::Write );
1509+
SceneInterface::FileFormatDescription<USDScene> g_descriptionUSDZ( ".usdz", IndexedIO::Read | IndexedIO::Write );
14591510

14601511
} // namespace

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,5 +3015,85 @@ def testLightAttribute( self ) :
30153015
} )
30163016
)
30173017

3018+
def testReadDoubleSidedAttribute( self ) :
3019+
3020+
root = IECoreScene.SceneInterface.create(
3021+
os.path.join( os.path.dirname( __file__ ), "data", "doubleSidedAttribute.usda" ),
3022+
IECore.IndexedIO.OpenMode.Read
3023+
)
3024+
3025+
for name, doubleSided in {
3026+
"sphere" : None,
3027+
"singleSidedSphere" : False,
3028+
"doubleSidedSphere" : True
3029+
}.items() :
3030+
object = root.child( name )
3031+
if doubleSided is None :
3032+
self.assertFalse( object.hasAttribute( "doubleSided" ) )
3033+
self.assertNotIn( "doubleSided", object.attributeNames() )
3034+
else :
3035+
self.assertTrue( object.hasAttribute( "doubleSided" ) )
3036+
self.assertIn( "doubleSided", object.attributeNames() )
3037+
self.assertEqual( object.readAttribute( "doubleSided", 1 ), IECore.BoolData( doubleSided ) )
3038+
3039+
def testWriteDoubleSidedAttribute( self ) :
3040+
3041+
# Write via SceneInterface
3042+
3043+
fileName = os.path.join( self.temporaryDirectory(), "doubleSidedAttribute.usda" )
3044+
root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Write )
3045+
3046+
toWrite = (
3047+
( "singleSidedSphere", "before", False ),
3048+
( "doubleSidedSphere", "before", True ),
3049+
( "doubleSidedSphereWrittenAfter", "after", True ),
3050+
( "doubleSidedNoObject", "never", True ),
3051+
( "sphere", "before", None ),
3052+
)
3053+
3054+
for name, writeObject, doubleSided in toWrite :
3055+
3056+
child = root.createChild( name )
3057+
if writeObject == "before" :
3058+
child.writeObject( IECoreScene.SpherePrimitive(), 1 )
3059+
3060+
if doubleSided is not None :
3061+
3062+
with IECore.CapturingMessageHandler() as mh :
3063+
child.writeAttribute( "doubleSided", IECore.BoolData( doubleSided ), 1 )
3064+
3065+
if writeObject != "before" :
3066+
self.assertEqual( len( mh.messages ), 1 )
3067+
self.assertEqual(
3068+
mh.messages[0].message,
3069+
'Unable to write attribute "doubleSided" to "/{}", because it is not a Gprim'.format(
3070+
name
3071+
)
3072+
)
3073+
3074+
if writeObject == "after" :
3075+
child.writeObject( IECoreScene.SpherePrimitive(), 1 )
3076+
3077+
del root, child
3078+
3079+
# Verify via USD API
3080+
3081+
stage = pxr.Usd.Stage.Open( fileName )
3082+
3083+
for name, writeObject, doubleSided in toWrite :
3084+
3085+
if writeObject != "before" :
3086+
doubleSided = None
3087+
3088+
if doubleSided is None :
3089+
self.assertFalse(
3090+
pxr.UsdGeom.Gprim( stage.GetPrimAtPath( "/" + name ) ).GetDoubleSidedAttr().HasAuthoredValue(),
3091+
)
3092+
else :
3093+
self.assertEqual(
3094+
pxr.UsdGeom.Gprim( stage.GetPrimAtPath( "/" + name ) ).GetDoubleSidedAttr().Get( 1 ),
3095+
doubleSided
3096+
)
3097+
30183098
if __name__ == "__main__":
30193099
unittest.main()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#usda 1.0
2+
3+
def Sphere "doubleSidedSphere"
4+
{
5+
uniform bool doubleSided = 1
6+
}
7+
8+
def Sphere "singleSidedSphere"
9+
{
10+
uniform bool doubleSided = 0
11+
}
12+
13+
def Sphere "sphere"
14+
{
15+
}
16+

0 commit comments

Comments
 (0)