Skip to content

Commit 6f4d673

Browse files
authored
Merge branch 'dev' into barbalt/dev/retain-ui-size-dt
2 parents a9a5833 + d618b57 commit 6f4d673

29 files changed

Lines changed: 838 additions & 163 deletions

cmake/modules/FindAdskUsdRenderSetup.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ message(STATUS "Finding Autodesk USD Render Setup")
1313

1414
find_path(ADSK_USD_RENDER_SETUP_INCLUDE_DIR
1515
NAMES
16-
RenderSetup/RenderSetupVersion.h
16+
AdskUsdRenderSetup/AdskUsdRenderSetupVersion.h
1717
HINTS
1818
$ENV{ADSK_USD_RENDER_SETUP_ROOT_DIR}
1919
${ADSK_USD_RENDER_SETUP_ROOT_DIR}
@@ -29,7 +29,7 @@ find_path(ADSK_USD_RENDER_SETUP_INCLUDE_DIR
2929

3030
find_library(ADSK_USD_RENDER_SETUP_LIBRARY
3131
NAMES
32-
RenderSetup
32+
AdskUsdRenderSetup
3333
HINTS
3434
$ENV{ADSK_USD_RENDER_SETUP_ROOT_DIR}
3535
${ADSK_USD_RENDER_SETUP_ROOT_DIR}
@@ -44,9 +44,10 @@ find_library(ADSK_USD_RENDER_SETUP_LIBRARY
4444
# Render Setup version
4545

4646
if(ADSK_USD_RENDER_SETUP_INCLUDE_DIR)
47+
set(adsk_rs_version_header "${ADSK_USD_RENDER_SETUP_INCLUDE_DIR}/AdskUsdRenderSetup/AdskUsdRenderSetupVersion.h")
4748
file(
4849
STRINGS
49-
${ADSK_USD_RENDER_SETUP_INCLUDE_DIR}/RenderSetup/RenderSetupVersion.h
50+
${adsk_rs_version_header}
5051
ADSK_USD_RENDER_SETUP_VERSION
5152
REGEX "define RENDER_SETUP_VERSION .*")
5253
if(ADSK_USD_RENDER_SETUP_VERSION)

lib/mayaUsd/commands/Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ their own purposes, similar to the Alembic export chaser example.
212212
| `-selection` | `-sl` | noarg | false | When set, only selected nodes (and their descendants) will be exported |
213213
| `-stripNamespaces` | `-sn` | bool | false | Remove namespaces during export. By default, namespaces are exported to the USD file in the following format: nameSpaceExample_pPlatonic1 |
214214
| `-hideSourceData` | `-hsd` | bool | false | Hide the Maya nodes that were used as the source. |
215+
| `-copyAndRepathMaterials` | `-crm` | bool | false | Copy and repath materials. |
215216
| `-worldspace` | `-wsp` | bool | false | Export all root prim using their full worldspace transform instead of their local transform |
216217
| `-staticSingleSample` | `-sss` | bool | false | Converts animated values with a single time sample to be static instead |
217218
| `-geomSidedness` | `-gs` | string | derived | Determines how geometry sidedness is defined. Valid values are: `derived` - Value is taken from the shapes doubleSided attribute, `single` - Export single sided, `double` - Export double sided |

lib/mayaUsd/commands/baseExportCommand.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ MSyntax MayaUSDExportCommand::createSyntax()
135135
kHideSourceDataFlag,
136136
UsdMayaJobExportArgsTokens->hideSourceData.GetText(),
137137
MSyntax::kBoolean);
138+
syntax.addFlag(
139+
kCopyAndRepathMaterialsFlag,
140+
UsdMayaJobExportArgsTokens->copyAndRepathMaterials.GetText(),
141+
MSyntax::kBoolean);
138142
syntax.addFlag(
139143
kEulerFilterFlag, UsdMayaJobExportArgsTokens->eulerFilter.GetText(), MSyntax::kBoolean);
140144
syntax.addFlag(

lib/mayaUsd/commands/baseExportCommand.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class MAYAUSD_CORE_PUBLIC MayaUSDExportCommand : public MPxCommand
6060
static constexpr auto kMergeTransformAndShapeFlag = "mt";
6161
static constexpr auto kStripNamespacesFlag = "sn";
6262
static constexpr auto kHideSourceDataFlag = "hsd";
63+
static constexpr auto kCopyAndRepathMaterialsFlag = "crm";
6364
static constexpr auto kExportRefsAsInstanceableFlag = "eri";
6465
static constexpr auto kExportDisplayColorFlag = "dsp";
6566
static constexpr auto kExportDistanceUnitFlag = "edu";

lib/mayaUsd/fileio/jobs/jobArgs.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,8 @@ UsdMayaJobExportArgs::UsdMayaJobExportArgs(
765765
, preserveUVSetNames(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->preserveUVSetNames))
766766
, stripNamespaces(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->stripNamespaces))
767767
, hideSourceData(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->hideSourceData))
768+
, copyAndRepathMaterials(
769+
extractBoolean(userArgs, UsdMayaJobExportArgsTokens->copyAndRepathMaterials))
768770
, worldspace(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->worldspace))
769771
, writeDefaults(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->writeDefaults))
770772
, parentScope(extractAbsolutePath(userArgs, UsdMayaJobExportArgsTokens->parentScope))
@@ -936,6 +938,7 @@ std::ostream& operator<<(std::ostream& out, const UsdMayaJobExportArgs& exportAr
936938
out << "stripNamespaces: " << TfStringify(exportArgs.stripNamespaces) << std::endl
937939
<< "worldspace: " << TfStringify(exportArgs.worldspace) << std::endl
938940
<< "hideSourceData: " << TfStringify(exportArgs.hideSourceData) << std::endl
941+
<< "copyAndRepathMaterials: " << TfStringify(exportArgs.copyAndRepathMaterials) << std::endl
939942
<< "timeSamples: " << exportArgs.timeSamples.size() << " sample(s)" << std::endl
940943
<< "staticSingleSample: " << TfStringify(exportArgs.staticSingleSample) << std::endl
941944
<< "geomSidedness: " << TfStringify(exportArgs.geomSidedness) << std::endl
@@ -1228,6 +1231,7 @@ const VtDictionary& UsdMayaJobExportArgs::GetDefaultDictionary()
12281231
d[UsdMayaJobExportArgsTokens->jobContext] = std::vector<VtValue>();
12291232
d[UsdMayaJobExportArgsTokens->stripNamespaces] = false;
12301233
d[UsdMayaJobExportArgsTokens->hideSourceData] = false;
1234+
d[UsdMayaJobExportArgsTokens->copyAndRepathMaterials] = false;
12311235
d[UsdMayaJobExportArgsTokens->worldspace] = false;
12321236
d[UsdMayaJobExportArgsTokens->verbose] = false;
12331237
d[UsdMayaJobExportArgsTokens->staticSingleSample] = false;
@@ -1336,6 +1340,7 @@ const VtDictionary& UsdMayaJobExportArgs::GetGuideDictionary()
13361340
d[UsdMayaJobExportArgsTokens->jobContext] = _stringVector;
13371341
d[UsdMayaJobExportArgsTokens->stripNamespaces] = _boolean;
13381342
d[UsdMayaJobExportArgsTokens->hideSourceData] = _boolean;
1343+
d[UsdMayaJobExportArgsTokens->copyAndRepathMaterials] = _boolean;
13391344
d[UsdMayaJobExportArgsTokens->worldspace] = _boolean;
13401345
d[UsdMayaJobExportArgsTokens->verbose] = _boolean;
13411346
d[UsdMayaJobExportArgsTokens->staticSingleSample] = _boolean;

lib/mayaUsd/fileio/jobs/jobArgs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ TF_DECLARE_PUBLIC_TOKENS(
123123
(remapUVSetsTo) \
124124
(stripNamespaces) \
125125
(hideSourceData) \
126+
(copyAndRepathMaterials) \
126127
(verbose) \
127128
(staticSingleSample) \
128129
(geomSidedness) \
@@ -289,6 +290,7 @@ struct UsdMayaJobExportArgs
289290
const bool preserveUVSetNames;
290291
const bool stripNamespaces;
291292
const bool hideSourceData;
293+
const bool copyAndRepathMaterials;
292294
// Export root prims using their worldspace transform instead of local transform.
293295
const bool worldspace;
294296
// Write default values at default time.

lib/mayaUsd/nodes/proxyShapeBase.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,19 @@ class MayaUsdProxyShapeBase
264264
bool* drawProxyPurpose,
265265
bool* drawGuidePurpose);
266266

267+
/// Returns true if the Maya DAG path already accounts for the USD root
268+
/// prim's world transform. When true, the rendering delegate shouldn't
269+
/// multiply by GetLocalToWorldTransform(rootPrim), as that would double the
270+
/// transforms already present in the Maya DAG.
271+
///
272+
/// Defaults to false, which is correct for proxy shapes that reference a USD
273+
/// stage without replicating prim transforms into the Maya DAG hierarchy.
274+
/// Override to return true only when your plugin expands assembly/subcomponent
275+
/// prims as Maya DAG nodes whose transforms already reflect the root prim
276+
/// (e.g., Pixar's scene assembly workflow).
277+
MAYAUSD_CORE_PUBLIC
278+
virtual bool isRootPrimTransformInDagPath() const { return false; }
279+
267280
MAYAUSD_CORE_PUBLIC
268281
MStatus
269282
preEvaluation(const MDGContext& context, const MEvaluationNode& evaluationNode) override;

lib/mayaUsd/render/pxrUsdMayaGL/proxyDrawOverride.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ UsdMayaProxyDrawOverride::transform(const MDagPath& objPath, const MDagPath& cam
9696
GfMatrix4d rootXform(transform.matrix);
9797

9898
MayaUsdProxyShapeBase* pShape = MayaUsdProxyShapeBase::GetShapeAtDagPath(objPath);
99-
if (pShape && pShape->usdPrim().GetPath() != SdfPath::AbsoluteRootPath()) {
100-
// If we're not computing the transform of the root of the Usd
101-
// scene, apply the usdPrim transform from within the scene
99+
if (pShape && pShape->usdPrim().GetPath() != SdfPath::AbsoluteRootPath()
100+
&& !pShape->isRootPrimTransformInDagPath()) {
102101
const UsdTimeCode timeCode = pShape->getTime();
103102
UsdGeomXformCache xformCache(timeCode);
104103
GfMatrix4d primTransform = xformCache.GetLocalToWorldTransform(pShape->usdPrim());

lib/mayaUsd/render/pxrUsdMayaGL/usdProxyShapeAdapter.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,17 @@ bool PxrMayaHdUsdProxyShapeAdapter::_Sync(
171171
_renderTags.push_back(HdRenderTagTokens->guide);
172172
}
173173

174-
// Update the root transform used to render by the delagate.
175-
// USD considers that the root prim transform is always the Identity matrix so that means
176-
// the root transform define the root prim transform. When the real stage root is used to
177-
// render this is not a issue because the root transform will be the maya transform.
178-
// The problem is when using a primPath as the root prim, we are losing
179-
// the prim path world transform. So we need to set the root transform as the world
180-
// transform of the prim used for rendering.
174+
// Update the root transform used to render by the delegate.
175+
// When using a primPath as the root prim, USD treats it as identity, so we
176+
// compensate by including its world transform in the root transform — unless
177+
// the Maya DAG already accounts for it (isRootPrimTransformInDagPath).
181178
MStatus status;
182179
const MMatrix transform = GetDagPath().inclusiveMatrix(&status);
183180
if (status == MS::kSuccess) {
184181
_rootXform = GfMatrix4d(transform.matrix);
185182

186-
if (usdProxyShape->usdPrim().GetPath() != SdfPath::AbsoluteRootPath()) {
183+
if (usdProxyShape->usdPrim().GetPath() != SdfPath::AbsoluteRootPath()
184+
&& !usdProxyShape->isRootPrimTransformInDagPath()) {
187185
const UsdTimeCode timeCode = usdProxyShape->getTime();
188186
UsdGeomXformCache xformCache(timeCode);
189187
GfMatrix4d primTransform

lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -841,17 +841,15 @@ void ProxyRenderDelegate::_UpdateSceneDelegate()
841841
_sceneDelegate->SetTime(timeCode);
842842
}
843843

844-
// Update the root transform used to render by the delagate.
845-
// USD considers that the root prim transform is always the Identity matrix so that means
846-
// the root transform define the root prim transform. When the real stage root is used to
847-
// render this is not a issue because the root transform will be the maya transform.
848-
// The problem is when using a primPath as the root prim, we are losing
849-
// the prim path world transform. So we need to set the root transform as the world
850-
// transform of the prim used for rendering.
844+
// Update the root transform used to render by the delegate.
845+
// When using a primPath as the root prim, USD treats it as identity, so we
846+
// compensate by including its world transform in the root transform — unless
847+
// the Maya DAG already accounts for it (isRootPrimTransformInDagPath).
851848
const MMatrix inclusiveMatrix = _proxyShapeData->ProxyDagPath().inclusiveMatrix();
852849
GfMatrix4d transform(inclusiveMatrix.matrix);
853850

854-
if (_proxyShapeData->ProxyShape()->usdPrim().GetPath() != SdfPath::AbsoluteRootPath()) {
851+
if (_proxyShapeData->ProxyShape()->usdPrim().GetPath() != SdfPath::AbsoluteRootPath()
852+
&& !_proxyShapeData->ProxyShape()->isRootPrimTransformInDagPath()) {
855853
const UsdTimeCode timeCode = _proxyShapeData->ProxyShape()->getTime();
856854
UsdGeomXformCache xformCache(timeCode);
857855
GfMatrix4d m

0 commit comments

Comments
 (0)