Skip to content

Commit

Permalink
Merge pull request #3576 from Autodesk/bailp/MAYA-132438/slow-scene-l…
Browse files Browse the repository at this point in the history
…oad-perf

MAYA-132438 fix slow scene load performance
  • Loading branch information
seando-adsk authored Jan 29, 2024
2 parents e9b7bc0 + 658f263 commit 2514864
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/mayaUsd/nodes/proxyShapeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ const MString MayaUsdProxyShapeBase::displayFilterName(
TfStringPrintf("%sDisplayFilter", MayaUsdProxyShapeBaseTokens->MayaTypeName.GetText()).c_str());
const MString MayaUsdProxyShapeBase::displayFilterLabel("USD Proxies");

std::atomic<int> g_proxyShapeInstancesCount;

// Attributes
MObject MayaUsdProxyShapeBase::filePathAttr;
MObject MayaUsdProxyShapeBase::filePathRelativeAttr;
Expand Down Expand Up @@ -535,6 +537,9 @@ MayaUsdProxyShapeBase* MayaUsdProxyShapeBase::GetShapeAtDagPath(const MDagPath&
return pShape;
}

/* static */
int MayaUsdProxyShapeBase::countProxyShapeInstances() { return g_proxyShapeInstancesCount; }

/* static */
void MayaUsdProxyShapeBase::SetClosestPointDelegate(ClosestPointDelegate delegate)
{
Expand Down Expand Up @@ -1971,6 +1976,8 @@ MayaUsdProxyShapeBase::MayaUsdProxyShapeBase(
, _unsharedStageRootSublayers()
, _incomingLayers()
{
g_proxyShapeInstancesCount += 1;

TfRegistryManager::GetInstance().SubscribeTo<MayaUsdProxyShapeBase>();

if (useLoadRulesHandling) {
Expand Down Expand Up @@ -1998,6 +2005,8 @@ MayaUsdProxyShapeBase::~MayaUsdProxyShapeBase()
// Deregister from the load-rules handling used to transfer load rules
// between the USD stage and a dynamic attribute on the proxy shape.
MayaUsdProxyShapeStageExtraData::removeProxyShape(*this);

g_proxyShapeInstancesCount -= 1;
}

MSelectionMask MayaUsdProxyShapeBase::getShapeSelectionMask() const
Expand Down
3 changes: 3 additions & 0 deletions lib/mayaUsd/nodes/proxyShapeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class MayaUsdProxyShapeBase
MAYAUSD_CORE_PUBLIC
static MayaUsdProxyShapeBase* GetShapeAtDagPath(const MDagPath& dagPath);

MAYAUSD_CORE_PUBLIC
static int countProxyShapeInstances();

MAYAUSD_CORE_PUBLIC
static void SetClosestPointDelegate(ClosestPointDelegate delegate);

Expand Down
6 changes: 6 additions & 0 deletions lib/mayaUsd/ufe/UsdStageMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ UsdStageWeakPtr UsdStageMap::stage(const Ufe::Path& path)

MObject UsdStageMap::proxyShape(const Ufe::Path& path)
{
// Optimization: if there are not proxy shape instances,
// there is nothing that can be mapped. Avoid trying to
// build the proxy shape map.
if (MayaUsdProxyShapeBase::countProxyShapeInstances() == 0)
return MObject();

rebuildIfDirty();

// In additional to the explicit dirty system it is possible that
Expand Down

0 comments on commit 2514864

Please sign in to comment.