Skip to content

Commit 9895b73

Browse files
authored
Merge pull request #1522 from murraystevenson/usd2603
USD 25.11 and 26.03 compatibility
2 parents f913366 + 1d7bd44 commit 9895b73

6 files changed

Lines changed: 14 additions & 57 deletions

File tree

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Breaking Changes
88
- SweepAndPrune.h : Removed.
99
- RadixSort.h : Removed.
1010

11+
Build
12+
-----
13+
14+
- Added compatibility with USD 25.11 and 26.03.
15+
1116
10.7.0.0a6 (relative to 10.7.0.0a5)
1217
==========
1318

contrib/IECoreUSD/include/IECoreUSD/ShaderAlgo.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
IECORE_PUSH_DEFAULT_VISIBILITY
4343
#include "pxr/usd/usdShade/material.h"
4444
#include "pxr/usd/usdShade/output.h"
45-
#if PXR_VERSION >= 2111
4645
#include "pxr/usd/usdLux/lightAPI.h"
47-
#endif
4846
IECORE_POP_DEFAULT_VISIBILITY
4947

5048
namespace IECoreUSD
@@ -64,15 +62,12 @@ IECOREUSD_API IECoreScene::ShaderNetworkPtr readShaderNetwork( const pxr::UsdSha
6462
bool canReadShaderNetwork( const pxr::UsdShadeOutput &output );
6563
IECOREUSD_API bool shaderNetworkMightBeTimeVarying( const pxr::UsdShadeOutput &output );
6664

67-
#if PXR_VERSION >= 2111
6865
/// Writes a UsdLuxLight from a shader network.
6966
IECOREUSD_API void writeLight( const IECoreScene::ShaderNetwork *shaderNetwork, pxr::UsdPrim prim );
7067
/// Reads a ShaderNetwork from a light.
7168
IECOREUSD_API IECoreScene::ShaderNetworkPtr readLight( const pxr::UsdLuxLightAPI &light, pxr::UsdTimeCode timeCode = pxr::UsdTimeCode::Default() );
7269
IECOREUSD_API bool lightMightBeTimeVarying( const pxr::UsdLuxLightAPI &light );
7370

74-
#endif
75-
7671
} // namespace ShaderAlgo
7772

7873
} // namespace IECoreUSD

contrib/IECoreUSD/src/IECoreUSD/PrimitiveAlgo.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,7 @@ bool readPrimitiveVariables( const pxr::UsdSkelRoot &skelRoot, const pxr::UsdGeo
385385
}
386386

387387
Canceller::check( canceller );
388-
#if PXR_VERSION < 2011
389-
::skelCache()->Populate( skelRoot );
390-
#else
391388
::skelCache()->Populate( skelRoot, pxr::UsdTraverseInstanceProxies() );
392-
#endif
393389

394390
Canceller::check( canceller );
395391
pxr::UsdSkelSkinningQuery skinningQuery = ::skelCache()->GetSkinningQuery( pointBased.GetPrim() );

contrib/IECoreUSD/src/IECoreUSD/SceneCacheFileFormat.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
5757
#include "pxr/usd/sdf/layer.h"
5858
#include "pxr/usd/usd/clipsAPI.h"
5959
#include "pxr/usd/usd/prim.h"
60+
#if PXR_VERSION >= 2511
61+
#include "pxr/usd/sdf/usdaFileFormat.h"
62+
#else
6063
#include "pxr/usd/usd/usdaFileFormat.h"
64+
#endif
6165
#include "pxr/usd/usdGeom/tokens.h"
6266

6367
ARCH_PRAGMA_POP
@@ -92,7 +96,11 @@ TF_REGISTRY_FUNCTION(TfType)
9296

9397
UsdSceneCacheFileFormat::UsdSceneCacheFileFormat()
9498
: SdfFileFormat( UsdSceneCacheFileFormatTokens->Id, UsdSceneCacheFileFormatTokens->Version, UsdSceneCacheFileFormatTokens->Target, UsdSceneCacheFileFormatTokens->Id),
99+
#if PXR_VERSION >= 2511
100+
m_usda(SdfFileFormat::FindById(SdfUsdaFileFormatTokens->Id))
101+
#else
95102
m_usda(SdfFileFormat::FindById(UsdUsdaFileFormatTokens->Id))
103+
#endif
96104
{
97105
}
98106

contrib/IECoreUSD/src/IECoreUSD/ShaderAlgo.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@
4141
#include "IECore/MessageHandler.h"
4242
#include "IECore/SimpleTypedData.h"
4343

44-
#if PXR_VERSION >= 2111
4544
#include "pxr/usd/usdLux/cylinderLight.h"
4645
#include "pxr/usd/usdLux/nonboundableLightBase.h"
4746
#include "pxr/usd/usdLux/sphereLight.h"
4847

4948
#include "pxr/usd/usd/schemaRegistry.h"
50-
#endif
5149

5250
#include "pxr/usd/usdGeom/primvarsAPI.h"
5351
#include "pxr/usd/usdShade/utils.h"
@@ -58,10 +56,6 @@
5856

5957
#include <regex>
6058

61-
#if PXR_VERSION < 2102
62-
#define IsContainer IsNodeGraph
63-
#endif
64-
6559
namespace
6660
{
6761

@@ -82,20 +76,17 @@ std::pair<pxr::TfToken, std::string> shaderIdAndType( const pxr::UsdShadeConnect
8276
shader.GetShaderId( &id );
8377
type = "surface";
8478
}
85-
#if PXR_VERSION >= 2111
8679
else if( auto light = pxr::UsdLuxLightAPI( connectable ) )
8780
{
8881
light.GetShaderIdAttr().Get( &id );
8982
type = "light";
9083
}
91-
#endif
9284

9385
return std::make_pair( id, type );
9486
}
9587

9688
bool writeNonStandardLightParameter( const std::string &name, const IECore::Data *value, pxr::UsdShadeConnectableAPI usdShader )
9789
{
98-
#if PXR_VERSION >= 2111
9990

10091
if( auto sphereLight = pxr::UsdLuxSphereLight( usdShader.GetPrim() ) )
10192
{
@@ -125,15 +116,13 @@ bool writeNonStandardLightParameter( const std::string &name, const IECore::Data
125116
}
126117
}
127118

128-
#endif
129119
return false;
130120
}
131121

132122
void readNonStandardLightParameters( const pxr::UsdPrim &prim, IECore::CompoundDataMap &parameters )
133123
{
134124
// Just to keep us on our toes, not all light parameters are stored as UsdShade inputs,
135125
// so we have special-case code for loading those here.
136-
#if PXR_VERSION >= 2111
137126
if( auto sphereLight = pxr::UsdLuxSphereLight( prim ) )
138127
{
139128
bool treatAsPoint = false;
@@ -165,12 +154,10 @@ void readNonStandardLightParameters( const pxr::UsdPrim &prim, IECore::CompoundD
165154
}
166155
}
167156
}
168-
#endif
169157
}
170158

171159
bool nonStandardLightParametersMightBeTimeVarying( const pxr::UsdPrim &prim )
172160
{
173-
#if PXR_VERSION >= 2111
174161
if( auto sphereLight = pxr::UsdLuxSphereLight( prim ) )
175162
{
176163
if( sphereLight.GetTreatAsPointAttr().ValueMightBeTimeVarying() )
@@ -203,7 +190,7 @@ bool nonStandardLightParametersMightBeTimeVarying( const pxr::UsdPrim &prim )
203190
}
204191
}
205192
}
206-
#endif
193+
207194
return false;
208195
}
209196

@@ -636,8 +623,6 @@ bool IECoreUSD::ShaderAlgo::shaderNetworkMightBeTimeVarying( const pxr::UsdShade
636623
return shaderNetworkMightBeTimeVaryingWalk( usdSource, visited );
637624
}
638625

639-
#if PXR_VERSION >= 2111
640-
641626
// This is very similar to `writeShaderNetwork` but with these key differences :
642627
//
643628
// - The output shader is written as a UsdLight-derived prim rather than a UsdShadeShader.
@@ -708,5 +693,3 @@ bool IECoreUSD::ShaderAlgo::lightMightBeTimeVarying( const pxr::UsdLuxLightAPI &
708693
std::unordered_set<pxr::UsdPrim, pxr::TfHash> visited;
709694
return shaderNetworkMightBeTimeVaryingWalk( pxr::UsdShadeConnectableAPI( light ), visited );
710695
}
711-
712-
#endif

contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ IECORE_PUSH_DEFAULT_VISIBILITY
6565
#include "pxr/usd/usdGeom/scope.h"
6666
#include "pxr/usd/usdGeom/tokens.h"
6767
#include "pxr/usd/usdGeom/xform.h"
68-
#if PXR_VERSION >= 2111
6968
#include "pxr/usd/usdLux/lightAPI.h"
70-
#endif
7169
#include "pxr/usd/usdShade/material.h"
7270
#include "pxr/usd/usdShade/materialBindingAPI.h"
7371
#include "pxr/usd/usdShade/connectableAPI.h"
@@ -96,10 +94,6 @@ using namespace IECore;
9694
using namespace IECoreScene;
9795
using namespace IECoreUSD;
9896

99-
#if PXR_VERSION < 2011
100-
#define GetPrimInPrototype GetPrimInMaster
101-
#endif
102-
10397
namespace
10498
{
10599

@@ -262,26 +256,15 @@ void writeSetInternal( const pxr::UsdPrim &prim, const pxr::TfToken &name, const
262256
targets.push_back( USDScene::toUSD( *it, /* relative = */ true ) );
263257
}
264258

265-
#if PXR_VERSION < 2009
266-
267-
pxr::UsdCollectionAPI collection = pxr::UsdCollectionAPI::ApplyCollection( prim, validNamespacedName( name ), pxr::UsdTokens->explicitOnly );
268-
269-
#else
270-
271259
pxr::UsdCollectionAPI collection = pxr::UsdCollectionAPI::Apply( prim, validNamespacedName( name ) );
272260
collection.CreateExpansionRuleAttr( pxr::VtValue( pxr::UsdTokens->explicitOnly ) );
273-
274-
#endif
275-
276261
collection.CreateIncludesRel().SetTargets( targets );
277262
}
278263

279264
using PrimPredicate = bool (pxr::UsdPrim::*)() const;
280265
boost::container::flat_map<pxr::TfToken, PrimPredicate> g_schemaTypeSetPredicates = {
281266
{ pxr::TfToken( "__cameras" ), &pxr::UsdPrim::IsA<pxr::UsdGeomCamera> },
282-
#if PXR_VERSION >= 2111
283267
{ pxr::TfToken( "__lights" ), &pxr::UsdPrim::HasAPI<pxr::UsdLuxLightAPI> },
284-
#endif
285268
{ pxr::TfToken( "usd:pointInstancers" ), &pxr::UsdPrim::IsA<pxr::UsdGeomPointInstancer> }
286269
};
287270

@@ -1117,12 +1100,10 @@ bool USDScene::hasAttribute( const SceneInterface::Name &name ) const
11171100
pxr::TfToken kind;
11181101
return model.GetKind( &kind );
11191102
}
1120-
#if PXR_VERSION >= 2111
11211103
else if( name == g_lightAttributeName )
11221104
{
11231105
return m_location->prim.HasAPI<pxr::UsdLuxLightAPI>();
11241106
}
1125-
#endif
11261107
else if( name == g_doubleSidedAttributeName )
11271108
{
11281109
return pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr().HasAuthoredValue();
@@ -1170,12 +1151,10 @@ void USDScene::attributeNames( SceneInterface::NameList &attrs ) const
11701151
attrs.push_back( g_kindAttributeName );
11711152
}
11721153

1173-
#if PXR_VERSION >= 2111
11741154
if( m_location->prim.HasAPI<pxr::UsdLuxLightAPI>() )
11751155
{
11761156
attrs.push_back( g_lightAttributeName );
11771157
}
1178-
#endif
11791158

11801159
if( pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr().HasAuthoredValue() )
11811160
{
@@ -1265,12 +1244,10 @@ ConstObjectPtr USDScene::readAttribute( const SceneInterface::Name &name, double
12651244
pxr::TfToken value; attr.Get( &value );
12661245
return new StringData( value.GetString() );
12671246
}
1268-
#if PXR_VERSION >= 2111
12691247
else if( name == g_lightAttributeName )
12701248
{
12711249
return ShaderAlgo::readLight( pxr::UsdLuxLightAPI( m_location->prim ), m_root->timeCode( time ) );
12721250
}
1273-
#endif
12741251
else if( name == g_kindAttributeName )
12751252
{
12761253
pxr::TfToken kind;
@@ -1367,7 +1344,6 @@ void USDScene::writeAttribute( const SceneInterface::Name &name, const Object *a
13671344
}
13681345
else if( const IECoreScene::ShaderNetwork *shaderNetwork = runTimeCast<const ShaderNetwork>( attribute ) )
13691346
{
1370-
#if PXR_VERSION >= 2111
13711347
if( name == g_lightAttributeName )
13721348
{
13731349
ShaderAlgo::writeLight( shaderNetwork, m_location->prim );
@@ -1377,10 +1353,6 @@ void USDScene::writeAttribute( const SceneInterface::Name &name, const Object *a
13771353
const auto &[output, purpose] = materialOutputAndPurpose( name.string() );
13781354
m_materials[purpose][output] = shaderNetwork;
13791355
}
1380-
#else
1381-
const auto &[output, purpose] = materialOutputAndPurpose( name.string() );
1382-
m_materials[purpose][output] = shaderNetwork;
1383-
#endif
13841356
}
13851357
else if( name.string() == "gaffer:globals" )
13861358
{
@@ -1750,13 +1722,11 @@ void USDScene::attributesHash( double time, IECore::MurmurHash &h ) const
17501722
// Kind can not be animated so no need to update `mightBeTimeVarying`.
17511723
}
17521724

1753-
#if PXR_VERSION >= 2111
17541725
if( m_location->prim.HasAPI<pxr::UsdLuxLightAPI>() )
17551726
{
17561727
mightBeTimeVarying = mightBeTimeVarying || ShaderAlgo::lightMightBeTimeVarying( pxr::UsdLuxLightAPI( m_location->prim ) );
17571728
haveAttributes = true;
17581729
}
1759-
#endif
17601730

17611731
auto doubleSidedAttr = pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr();
17621732
if( doubleSidedAttr && doubleSidedAttr.HasAuthoredValue() )

0 commit comments

Comments
 (0)