Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmake/modules/FindMaya.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ if (MAYA_API_VERSION VERSION_GREATER_EQUAL 20230200)
message(STATUS "Maya has UFE gizmo drawing")
endif()

set(MAYA_HAS_SCENE_RENDER_SETTINGS FALSE CACHE INTERNAL "sceneRenderSettings")
if (MAYA_API_VERSION VERSION_GREATER_EQUAL 20270000)
set(MAYA_HAS_SCENE_RENDER_SETTINGS TRUE CACHE INTERNAL "sceneRenderSettings")
message(STATUS "Maya has scene render settings support")
endif()

set(MAYA_LINUX_BUILT_WITH_CXX11_ABI FALSE CACHE INTERNAL "MayaLinuxBuiltWithCxx11ABI")
if(IS_LINUX AND MAYA_Foundation_LIBRARY)
# Determine if Maya (on Linux) was built using the new CXX11 ABI.
Expand Down
1 change: 1 addition & 0 deletions lib/mayaUsd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ target_compile_definitions(${PROJECT_NAME}
$<$<BOOL:${IS_LINUX}>:GL_GLEXT_PROTOTYPES>
$<$<BOOL:${IS_LINUX}>:GLX_GLXEXT_PROTOTYPES>
$<$<BOOL:${CMAKE_WANT_MATERIALX_BUILD}>:WANT_MATERIALX_BUILD>
$<$<BOOL:${MAYA_HAS_SCENE_RENDER_SETTINGS}>:MAYA_HAS_SCENE_RENDER_SETTINGS>
$<$<BOOL:${Qt_FOUND}>:WANT_QT_BUILD>
$<$<BOOL:${BUILD_HDMAYA}>:BUILD_HDMAYA>
$<$<BOOL:${AdskUsdAssetResolver_FOUND}>:WANT_ADSK_USD_ASSET_RESOLVER_BUILD>
Expand Down
11 changes: 10 additions & 1 deletion lib/mayaUsd/fileio/jobs/writeJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,17 @@ class AutoUpAxisChanger : public MayaUsd::AutoUndoCommands
static const char scriptPrefix[] =
// Preserve the selection. Grouping and ungrouping changes it.
"string $selection[] = `ls -selection`;\n"
// Find all root nodes.
"string $rootNodeNames[] = `ls -assemblies`;\n"
#ifdef MAYA_HAS_SCENE_RENDER_SETTINGS
// Exclude the internal SceneRenderSettings singleton which is not
// scene content and must not be grouped.
"string $filteredRoots[];\n"
"for ($r in $rootNodeNames) {\n"
" string $shapes[] = `listRelatives -shapes -type mayaUsdSceneRenderSettings $r`;\n"
" if (size($shapes) == 0) $filteredRoots[size($filteredRoots)] = $r;\n"
"}\n"
"$rootNodeNames = $filteredRoots;\n"
#endif
// Group all root node under a new group:
//
// - Use -absolute to keep the grouped node world positions
Expand Down
26 changes: 26 additions & 0 deletions lib/mayaUsd/fileio/writeJobContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <mayaUsd/utils/stageCache.h>
#include <mayaUsd/utils/util.h>

#ifdef MAYA_HAS_SCENE_RENDER_SETTINGS
#include <mayaUsd/nodes/sceneRenderSettings.h>
#endif

#include <pxr/base/tf/staticTokens.h>
#include <pxr/base/tf/stringUtils.h>
#include <pxr/base/tf/token.h>
Expand Down Expand Up @@ -399,6 +403,28 @@ bool UsdMayaWriteJobContext::_NeedToTraverse(const MDagPath& curDag) const
}
}

// Always skip the SceneRenderSettings singleton node and its parent
// transform – its internal USD stage is not part of the scene content
// that should be exported.
#ifdef MAYA_HAS_SCENE_RENDER_SETTINGS
{
MFnDependencyNode mfnNode(ob);
if (mfnNode.typeId() == MAYAUSD_NS::UsdSceneRenderSettings::typeId) {
return false;
}
// Also skip the parent transform of the SceneRenderSettings shape.
if (ob.hasFn(MFn::kTransform)) {
MFnDagNode dagNode(curDag);
for (unsigned int i = 0; i < dagNode.childCount(); ++i) {
MFnDependencyNode childFn(dagNode.child(i));
if (childFn.typeId() == MAYAUSD_NS::UsdSceneRenderSettings::typeId) {
return false;
}
}
}
}
#endif

if (!mArgs.filteredTypeIds.empty()) {
MFnDependencyNode mfnNode(ob);
if (mArgs.filteredTypeIds.find(mfnNode.typeId().id()) != mArgs.filteredTypeIds.end()) {
Expand Down
11 changes: 11 additions & 0 deletions lib/mayaUsd/nodes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ target_sources(${PROJECT_NAME}
usdPrimProvider.cpp
)

if(MAYA_HAS_SCENE_RENDER_SETTINGS)
target_sources(${PROJECT_NAME}
PRIVATE
sceneRenderSettings.cpp
)
endif()

set(HEADERS
hdImagingShape.h
layerManager.h
Expand All @@ -31,6 +38,10 @@ set(HEADERS
usdPrimProvider.h
)

if(MAYA_HAS_SCENE_RENDER_SETTINGS)
list(APPEND HEADERS sceneRenderSettings.h)
endif()

# -----------------------------------------------------------------------------
# promoted headers
# -----------------------------------------------------------------------------
Expand Down
28 changes: 28 additions & 0 deletions lib/mayaUsd/nodes/proxyShapePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <mayaUsd/nodes/proxyShapeStageExtraData.h>
#include <mayaUsd/nodes/stageData.h>
#include <mayaUsd/nodes/stageNode.h>
#ifdef MAYA_HAS_SCENE_RENDER_SETTINGS
#include <mayaUsd/nodes/sceneRenderSettings.h>
#endif
#include <mayaUsd/render/pxrUsdMayaGL/hdImagingShapeDrawOverride.h>
#include <mayaUsd/render/pxrUsdMayaGL/hdImagingShapeUI.h>
#include <mayaUsd/render/pxrUsdMayaGL/proxyDrawOverride.h>
Expand Down Expand Up @@ -171,6 +174,23 @@ MStatus MayaUsdProxyShapePlugin::initialize(MFnPlugin& plugin)
status = MayaUsd::MayaUsdProxyShapeStageExtraData::initialize();
CHECK_MSTATUS(status);

#ifdef MAYA_HAS_SCENE_RENDER_SETTINGS
// Only register and activate the SceneRenderSettings node for mayaUsdPlugin.
if (plugin.name() == "mayaUsdPlugin") {
status = plugin.registerNode(
MayaUsd::UsdSceneRenderSettings::typeName,
MayaUsd::UsdSceneRenderSettings::typeId,
MayaUsd::UsdSceneRenderSettings::creator,
MayaUsd::UsdSceneRenderSettings::initialize,
MPxNode::kLocatorNode);
CHECK_MSTATUS(status);

MayaUsd::UsdSceneRenderSettings::installCallbacks();
// Maya doesn't send kAfterNew for the default scene that exists at startup.
MayaUsd::UsdSceneRenderSettings::findOrCreateInstance();
}
#endif

return status;
}

Expand All @@ -192,6 +212,14 @@ MStatus MayaUsdProxyShapePlugin::finalize(MFnPlugin& plugin)
return MS::kSuccess;
}

#ifdef MAYA_HAS_SCENE_RENDER_SETTINGS
if (plugin.name() == "mayaUsdPlugin") {
MayaUsd::UsdSceneRenderSettings::removeCallbacks();
MStatus srsStatus = plugin.deregisterNode(MayaUsd::UsdSceneRenderSettings::typeId);
CHECK_MSTATUS(srsStatus);
}
#endif

MStatus status = HdVP2ShaderFragments::deregisterFragments();
CHECK_MSTATUS(status);

Expand Down
Loading
Loading