Skip to content

Commit

Permalink
Merge branch 'dev' into degiroa/MAYA-127355/delete-node-remove-connec…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
alicedegirolamo committed Feb 23, 2023
2 parents 1666d17 + 97f96aa commit be135b1
Show file tree
Hide file tree
Showing 60 changed files with 1,936 additions and 332 deletions.
2 changes: 1 addition & 1 deletion cmake/mayausd_version.info
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
set(MAYAUSD_MAJOR_VERSION 0)
set(MAYAUSD_MINOR_VERSION 22)
set(MAYAUSD_MINOR_VERSION 23)
set(MAYAUSD_PATCH_LEVEL 0)
64 changes: 63 additions & 1 deletion doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,67 @@
# Changelog

## [v0.22.0] - 2023-02-15

**Build:**
* Skip test if UFE attribute metadata not available [#2834](https://github.com/Autodesk/maya-usd/pull/2834)
* Use the PXR namespace directive [#2827](https://github.com/Autodesk/maya-usd/pull/2827)
* Bump UFE version to 4.0 [#2819](https://github.com/Autodesk/maya-usd/pull/2819)
* Fix VP2 test [#2787](https://github.com/Autodesk/maya-usd/pull/2787)
* Fix empty values for remapUVSetsTo [#2784](https://github.com/Autodesk/maya-usd/pull/2784)
* Fix USD Min build after outliner rework [#2781](https://github.com/Autodesk/maya-usd/pull/2781)

**Translation Framework:**
* Improve NURBS export [#2835](https://github.com/Autodesk/maya-usd/pull/2835)
* Import as anim cache [#2829](https://github.com/Autodesk/maya-usd/pull/2829)
* Token updates in preparation for Schema Versioning [#2826](https://github.com/Autodesk/maya-usd/pull/2826)
* Invalid beziers [#2813](https://github.com/Autodesk/maya-usd/pull/2813)
* Fix material export when preserving UVset names [#2776](https://github.com/Autodesk/maya-usd/pull/2776)
* Export Normals by default and modify docs to match code behaviour [#2768](https://github.com/Autodesk/maya-usd/pull/2768)

**Workflow:**
* Relative File Paths:
* Save USD root file relative to scene file [#2854](https://github.com/Autodesk/maya-usd/pull/2854) [#2839](https://github.com/Autodesk/maya-usd/pull/2839)
* Load my USD root file as relative to the scene file [#2848](https://github.com/Autodesk/maya-usd/pull/2848)
* Invalid extension in Layer editor would cause crash [#2847](https://github.com/Autodesk/maya-usd/pull/2847) [#2845](https://github.com/Autodesk/maya-usd/pull/2845)
* Clean options of materials scope name [#2840](https://github.com/Autodesk/maya-usd/pull/2840)
* Preserve NodeGraph boundaries on duplicate [#2836](https://github.com/Autodesk/maya-usd/pull/2836)
* Prevents a hang that can occur when forming certain connections [#2828](https://github.com/Autodesk/maya-usd/pull/2828)
* Prettify: Add space on lower to upper transition [#2824](https://github.com/Autodesk/maya-usd/pull/2824)
* Add Ufe log on console to notify shader attribute without default value [#2823](https://github.com/Autodesk/maya-usd/pull/2823)
* Prevent string conversions to throw exceptions with empty value [#2822](https://github.com/Autodesk/maya-usd/pull/2822)
* Fix plugInfo to use relative path [#2821](https://github.com/Autodesk/maya-usd/pull/2821)
* Fix USD export curve options [#2820](https://github.com/Autodesk/maya-usd/pull/2820)
* Shorten nice names by trimming schema name [#2818](https://github.com/Autodesk/maya-usd/pull/2818)
* Add reparenting rules for Shaders, NodeGraphs and Materials [#2811](https://github.com/Autodesk/maya-usd/pull/2811)
* Allow native file dialog when loading layers [#2807](https://github.com/Autodesk/maya-usd/pull/2807)
* Fix crash when editing two prims [#2806](https://github.com/Autodesk/maya-usd/pull/2806)
* Add scene index plugin code [#2805](https://github.com/Autodesk/maya-usd/pull/2805)
* Correctly identify orphaned edited prims [#2803](https://github.com/Autodesk/maya-usd/pull/2803)
* mayaUsd.ufe.stagePath() returns incorrect value [#2801](https://github.com/Autodesk/maya-usd/pull/2801)
* Delete compound attributes does not remove their connections [#2800](https://github.com/Autodesk/maya-usd/pull/2800)
* Improve diagnostics [#2799](https://github.com/Autodesk/maya-usd/pull/2799)
* Interaction between deactivation and cancel edit [#2794](https://github.com/Autodesk/maya-usd/pull/2794)
* Merge top UFE classification for glsfx and USD shader [#2791](https://github.com/Autodesk/maya-usd/pull/2791)
* UFE USD camera commands [#2789](https://github.com/Autodesk/maya-usd/pull/2789)
* Correctly expose Material and NodeGraph attributes in Maya Attribute Editor [#2788](https://github.com/Autodesk/maya-usd/pull/2788)
* Fix a bug where materials got created in the wrong scope [#2783](https://github.com/Autodesk/maya-usd/pull/2783)
* Outliner rework of Material items [#2775](https://github.com/Autodesk/maya-usd/pull/2775)
* Correctly disable merge to USD [#2769](https://github.com/Autodesk/maya-usd/pull/2769)
* merge-to-USD into variants [#2764](https://github.com/Autodesk/maya-usd/pull/2764)
* Auto re-edit when merging a Maya Reference [#2762](https://github.com/Autodesk/maya-usd/pull/2762)

**Render:**
* Adding a MaterialX v1.38.5 update for closures [#2858](https://github.com/Autodesk/maya-usd/pull/2858)
* Enable instances to determine non empty stage in preparation for USD v0.23.02 [#2844](https://github.com/Autodesk/maya-usd/pull/2844)
* UDIM: Use default LOD values in anisotropic mode [#2816](https://github.com/Autodesk/maya-usd/pull/2816)
* Remove frequent warning in Arnold/RenderMan shading workflows [#2814](https://github.com/Autodesk/maya-usd/pull/2814)
* Fix opacity computations for MaterialX and USD materials [#2790](https://github.com/Autodesk/maya-usd/pull/2790)
* Implement display layer's hide-on-playback flag for instanced geometry [#2780](https://github.com/Autodesk/maya-usd/pull/2780)

**Documentation:**
* Update documentation of the export command [#2808](https://github.com/Autodesk/maya-usd/pull/2808)


## [v0.21.0] - 2022-12-13

**Build:**
Expand Down Expand Up @@ -620,7 +682,7 @@
- Avoid opening duplicated usd stages on Maya file load [#1727](https://github.com/Autodesk/maya-usd/pull/1727)
- Fix excluded prim paths [#1726](https://github.com/Autodesk/maya-usd/pull/1726)
- Add duplicate check during translator context deserialise based on prim path match [#1710](https://github.com/Autodesk/maya-usd/pull/1710)
- Ignored setting playback range if no time code found from USD [\#1686](https://github.com/Autodesk/maya-usd/pull/1686)
- Ignored setting playback range if no time code found from USD [#1686](https://github.com/Autodesk/maya-usd/pull/1686)
- Use the API schema class UsdLuxLightAPI in place of USD typed class [#1701](https://github.com/Autodesk/maya-usd/pull/1701)
- Adopt use of references when passing ReaderContext when reading RfM [#1653](https://github.com/Autodesk/maya-usd/pull/1653)
- Update RfMLight translators to use codeless schemas [#1648](https://github.com/Autodesk/maya-usd/pull/1648)
Expand Down
32 changes: 32 additions & 0 deletions lib/mayaUsd/listeners/stageNoticeListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ void UsdMayaStageNoticeListener::SetStageLayerMutingChangedCallback(
_UpdateStageContentsChangedRegistration();
}

void UsdMayaStageNoticeListener::SetStageEditTargetChangedCallback(
const StageEditTargetChangedCallback& callback)
{
_stageEditTargetChangedCallback = callback;

_UpdateStageContentsChangedRegistration();
}

void UsdMayaStageNoticeListener::_UpdateStageContentsChangedRegistration()
{
if (_stage && _stageContentsChangedCallback) {
Expand Down Expand Up @@ -109,6 +117,22 @@ void UsdMayaStageNoticeListener::_UpdateStageContentsChangedRegistration()
TfNotice::Revoke(_stageLayerMutingChangedKey);
}
}

if (_stage && _stageEditTargetChangedCallback) {
// Register for notices if we're not already listening.
if (!_stageEditTargetChangedKey.IsValid()) {
_stageEditTargetChangedKey = TfNotice::Register(
TfCreateWeakPtr(this),
&UsdMayaStageNoticeListener::_OnStageEditTargetChanged,
_stage);
}
} else {
// Either the stage or the callback is invalid, so stop listening for
// notices.
if (_stageEditTargetChangedKey.IsValid()) {
TfNotice::Revoke(_stageEditTargetChangedKey);
}
}
}

void UsdMayaStageNoticeListener::_OnStageContentsChanged(
Expand Down Expand Up @@ -136,4 +160,12 @@ void UsdMayaStageNoticeListener::_OnStageLayerMutingChanged(
}
}

void UsdMayaStageNoticeListener::_OnStageEditTargetChanged(
const UsdNotice::StageEditTargetChanged& notice) const
{
if (notice.GetStage() == _stage && _stageEditTargetChangedCallback) {
_stageEditTargetChangedCallback(notice);
}
}

PXR_NAMESPACE_CLOSE_SCOPE
13 changes: 12 additions & 1 deletion lib/mayaUsd/listeners/stageNoticeListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class UsdMayaStageNoticeListener : public TfWeakBase
= std::function<void(const UsdNotice::ObjectsChanged& notice)>;
using StageLayerMutingChangedCallback
= std::function<void(const UsdNotice::LayerMutingChanged& notice)>;
using StageEditTargetChangedCallback
= std::function<void(const UsdNotice::StageEditTargetChanged& notice)>;

/// Sets the callback to be invoked when the listener receives a
/// StageContentsChanged notice.
Expand All @@ -66,10 +68,15 @@ class UsdMayaStageNoticeListener : public TfWeakBase
void SetStageObjectsChangedCallback(const StageObjectsChangedCallback& callback);

/// Sets the callback to be invoked when the listener receives a
/// ObjectsChanged notice.
/// LayerMutingChanged notice.
MAYAUSD_CORE_PUBLIC
void SetStageLayerMutingChangedCallback(const StageLayerMutingChangedCallback& callback);

/// Sets the callback to be invoked when the listener receives a
/// EditTargetChanged notice.
MAYAUSD_CORE_PUBLIC
void SetStageEditTargetChangedCallback(const StageEditTargetChangedCallback& callback);

private:
UsdMayaStageNoticeListener(const UsdMayaStageNoticeListener&) = delete;
UsdMayaStageNoticeListener& operator=(const UsdMayaStageNoticeListener&) = delete;
Expand All @@ -86,12 +93,16 @@ class UsdMayaStageNoticeListener : public TfWeakBase
TfNotice::Key _stageLayerMutingChangedKey {};
StageLayerMutingChangedCallback _stageLayerMutingChangedCallback {};

TfNotice::Key _stageEditTargetChangedKey {};
StageEditTargetChangedCallback _stageEditTargetChangedCallback {};

void _UpdateStageContentsChangedRegistration();
void _OnStageContentsChanged(const UsdNotice::StageContentsChanged& notice) const;
void _OnStageLayerMutingChanged(const UsdNotice::LayerMutingChanged& notice) const;
void _OnStageObjectsChanged(
const UsdNotice::ObjectsChanged& notice,
const UsdStageWeakPtr& sender) const;
void _OnStageEditTargetChanged(const UsdNotice::StageEditTargetChanged& notice) const;
};

PXR_NAMESPACE_CLOSE_SCOPE
Expand Down
34 changes: 33 additions & 1 deletion lib/mayaUsd/nodes/layerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ void convertAnonymousLayersRecursive(
convertAnonymousLayersRecursive(subL, basename, stage);

if (subL->IsAnonymous()) {
auto newLayer = MayaUsd::utils::saveAnonymousLayer(subL, parentPtr, basename);
auto newLayer
= MayaUsd::utils::saveAnonymousLayer(stage, subL, parentPtr, basename);
if (subL == currentTarget) {
stage->SetEditTarget(newLayer);
}
Expand Down Expand Up @@ -248,6 +249,7 @@ class LayerDatabase : public TfWeakBase
void saveUsdLayerToMayaFile(SdfLayerRefPtr layer, bool asAnonymous);
void clearProxies();
bool hasDirtyLayer() const;
void refreshProxiesToSave();

std::map<std::string, SdfLayerRefPtr> _idToLayer;
TfNotice::Key _onStageSetKey;
Expand Down Expand Up @@ -520,6 +522,27 @@ bool LayerDatabase::getProxiesToSave(bool isExport)

bool LayerDatabase::saveInteractionRequired() { return _proxiesToSave.size() > 0; }

static void refreshSavingInfo(StageSavingInfo& info)
{
MFnDependencyNode fn;
MObject mobj = info.dagPath.node();
fn.setObject(mobj);
if (!fn.isFromReferencedFile() && LayerDatabase::instance().supportedNodeType(fn.typeId())) {
MayaUsdProxyShapeBase* pShape = static_cast<MayaUsdProxyShapeBase*>(fn.userNode());
info.stage = pShape ? pShape->getUsdStage() : nullptr;
}
}

void LayerDatabase::refreshProxiesToSave()
{
for (StageSavingInfo& info : _proxiesToSave) {
refreshSavingInfo(info);
}
for (StageSavingInfo& info : _internalProxiesToSave) {
refreshSavingInfo(info);
}
}

bool LayerDatabase::saveUsd(bool isExport)
{
BatchSaveResult result = MayaUsd::kNotHandled;
Expand Down Expand Up @@ -555,6 +578,12 @@ bool LayerDatabase::saveUsd(bool isExport)
return true;
}

// After the potentially partial save, we need to refresh the stages
// to be saved because the saving might have modified the proxy shape
// attributes and we need to re-evaluate these nodes so that the stages
// are re-created with the new attribute values if needed.
refreshProxiesToSave();

if (MayaUsd::utils::kSaveToUSDFiles == opt) {
result = saveUsdToUsdFiles();
} else {
Expand Down Expand Up @@ -781,6 +810,9 @@ void LayerDatabase::convertAnonymousLayers(

convertAnonymousLayersRecursive(root, proxyName, stage);

// Note: retrieve root again since it may have been changed by the call
// to convertAnonymousLayersRecursive
root = stage->GetRootLayer();
if (root->IsAnonymous()) {
PXR_NS::SdfFileFormat::FileFormatArguments args;
std::string newFileName = MayaUsd::utils::generateUniqueFileName(proxyName);
Expand Down
68 changes: 62 additions & 6 deletions lib/mayaUsd/nodes/proxyShapeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <mayaUsd/utils/loadRules.h>
#include <mayaUsd/utils/query.h>
#include <mayaUsd/utils/stageCache.h>
#include <mayaUsd/utils/targetLayer.h>
#include <mayaUsd/utils/util.h>
#include <mayaUsd/utils/utilFileSystem.h>

Expand Down Expand Up @@ -214,6 +215,21 @@ const int _shapeBaseProfilerCategory = MProfiler::addCategory(
"ProxyShapeBase"
#endif
);

struct InComputeGuard
{
InComputeGuard(MayaUsdProxyShapeBase& proxy)
: _proxy(proxy)
{
_proxy.in_compute++;
}

~InComputeGuard() { _proxy.in_compute--; }

private:
MayaUsdProxyShapeBase& _proxy;
};

} // namespace

/* static */
Expand Down Expand Up @@ -510,6 +526,8 @@ void MayaUsdProxyShapeBase::postConstructor()
/* virtual */
MStatus MayaUsdProxyShapeBase::compute(const MPlug& plug, MDataBlock& dataBlock)
{
InComputeGuard inComputeGuard(*this);

if (plug == outTimeAttr || plug.isDynamic())
ProxyAccessor::compute(_usdAccessor, plug, dataBlock);

Expand Down Expand Up @@ -990,6 +1008,7 @@ MStatus MayaUsdProxyShapeBase::computeInStageDataCached(MDataBlock& dataBlock)
primPath = finalUsdStage->GetPseudoRoot().GetPath();
copyLoadRulesFromAttribute(*this, *finalUsdStage);
copyLayerMutingFromAttribute(*this, *finalUsdStage);
copyTargetLayerFromAttribute(*this, *finalUsdStage);
updateShareMode(sharedUsdStage, unsharedUsdStage, loadSet);
}

Expand Down Expand Up @@ -1089,12 +1108,6 @@ MStatus MayaUsdProxyShapeBase::computeOutStageData(MDataBlock& dataBlock)
MProfilingScope computeOutStageDatacomputeOutStageData(
_shapeBaseProfilerCategory, MProfiler::kColorE_L3, "Compute outStageData plug");

struct in_computeGuard
{
in_computeGuard() { in_compute++; }
~in_computeGuard() { in_compute--; }
} in_computeGuard;

MStatus retValue = MS::kSuccess;

const bool isNormalContext = dataBlock.context().isNormal();
Expand Down Expand Up @@ -1193,6 +1206,11 @@ MStatus MayaUsdProxyShapeBase::computeOutStageData(MDataBlock& dataBlock)
return _OnLayerMutingChanged(notice);
});

_stageNoticeListener.SetStageEditTargetChangedCallback(
[this](const UsdNotice::StageEditTargetChanged& notice) {
return _OnStageEditTargetChanged(notice);
});

MayaUsdProxyStageSetNotice(*this).Send();
}

Expand Down Expand Up @@ -1528,6 +1546,8 @@ MStatus MayaUsdProxyShapeBase::postEvaluation(
// setGeometryDrawDirty, or no calls to setGeometryDrawDirty.
// MHWRender::MRenderer::setGeometryDrawDirty(thisMObject());

InComputeGuard inComputeGuard(*this);

if (context.isNormal() && evalType == PostEvaluationEnum::kEvaluatedDirectly) {
MDataBlock dataBlock = forceCache();
ProxyAccessor::syncCache(_usdAccessor, thisMObject(), dataBlock);
Expand Down Expand Up @@ -1874,6 +1894,42 @@ void MayaUsdProxyShapeBase::_OnLayerMutingChanged(const UsdNotice::LayerMutingCh
copyLayerMutingToAttribute(*stage, *this);
}

static void copyTargetLayerOnIdle(void* data)
{
MayaUsdProxyShapeBase* proxy = reinterpret_cast<MayaUsdProxyShapeBase*>(data);
if (!proxy)
return;

const auto stage = proxy->getUsdStage();
if (!stage)
return;

copyTargetLayerToAttribute(*stage, *proxy);
}

void MayaUsdProxyShapeBase::_OnStageEditTargetChanged(
const UsdNotice::StageEditTargetChanged& notice)
{
if (in_compute) {
MGlobal::executeTaskOnIdle(copyTargetLayerOnIdle, this);
return;
}

const auto stage = notice.GetStage();
if (!stage)
return;

// Note: copying the target layer into an attribute when the edit target
// changes can cause DG evaluation loops because the stage computation
// sets the edit target.
//
// Defer saving the edit target to be done later, on idle.
//
// One symptom of creating a compute loop is that the unit test named
// 'testMayaUsdProxyAccessor' fails because computation did not finish.
copyTargetLayerToAttribute(*stage, *this);
}

void MayaUsdProxyShapeBase::_OnStageObjectsChanged(const UsdNotice::ObjectsChanged& notice)
{
MProfilingScope profilingScope(
Expand Down
1 change: 1 addition & 0 deletions lib/mayaUsd/nodes/proxyShapeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ class MayaUsdProxyShapeBase
void _OnStageContentsChanged(const UsdNotice::StageContentsChanged& notice);
void _OnStageObjectsChanged(const UsdNotice::ObjectsChanged& notice);
void _OnLayerMutingChanged(const UsdNotice::LayerMutingChanged& notice);
void _OnStageEditTargetChanged(const UsdNotice::StageEditTargetChanged& notice);

UsdMayaStageNoticeListener _stageNoticeListener;

Expand Down
Loading

0 comments on commit be135b1

Please sign in to comment.