-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialise all layers on file load. #28
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,36 @@ static void preFileOpen(void*) | |
{ | ||
TF_DEBUG(ALUSDMAYA_EVENTS).Msg("preFileOpen\n"); | ||
} | ||
//---------------------------------------------------------------------------------------------------------------------- | ||
static void initialiseChildAndSublayers(nodes::Layer& layer, nodes::ProxyShape* proxy) | ||
{ | ||
// initialise self | ||
MPlug plug = layer.nameOnLoadPlug(); | ||
MString path = plug.asString(); | ||
if(path.length() && path.substring(0, 3) != "anon") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed we had this substring check before. Maybe we can do it better this time, try use SdfLayer::IsAnonymousLayerIdentifier to determine if it's anonymous |
||
{ | ||
SdfLayerHandle layerHdl = SdfLayer::FindOrOpen(path.asChar()); | ||
LAYER_HANDLE_CHECK(layerHdl); | ||
layer.setLayerAndClearAttribute(layerHdl); | ||
layer.init(proxy, layerHdl); | ||
} | ||
else | ||
{ | ||
layer.init(proxy, TfNullPtr); | ||
} | ||
|
||
// recursively call to initialise children/sublayers | ||
auto subLayers = layer.getSubLayers(); | ||
for(auto subLayer : subLayers) | ||
{ | ||
if(subLayer) initialiseChildAndSublayers(*subLayer, proxy); | ||
} | ||
auto childLayers = layer.getChildLayers(); | ||
for(auto childLayer : childLayers) | ||
{ | ||
if(childLayer) initialiseChildAndSublayers(*childLayer, proxy); | ||
} | ||
} | ||
//---------------------------------------------------------------------------------------------------------------------- | ||
static void postFileOpen(void*) | ||
{ | ||
|
@@ -86,29 +115,19 @@ static void postFileOpen(void*) | |
if(layer) | ||
{ | ||
layer->setLayerAndClearAttribute(stage->GetSessionLayer()); | ||
} | ||
} | ||
} | ||
} | ||
{ | ||
MItDependencyNodes iter(MFn::kPluginDependNode); | ||
for(; !iter.isDone(); iter.next()) | ||
{ | ||
fn.setObject(iter.item()); | ||
if(fn.typeId() == nodes::Layer::kTypeId) | ||
{ | ||
// now go and fix up each of the layer nodes in the scene | ||
nodes::Layer* layerPtr = (nodes::Layer*)fn.userNode(); | ||
MPlug plug = layerPtr->nameOnLoadPlug(); | ||
MString path = plug.asString(); | ||
if(path.length() && path.substring(0, 3) != "anon") | ||
{ | ||
SdfLayerHandle layer = SdfLayer::FindOrOpen(path.asChar()); | ||
LAYER_HANDLE_CHECK(layer); | ||
layerPtr->setLayerAndClearAttribute(layer); | ||
} | ||
else | ||
{ | ||
layer->init(proxy, stage->GetSessionLayer()); | ||
|
||
// initialise and fixup each child and sublayer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stick these sublayer and childlayer loops into a member function into Layer.h/cpp and call if from here |
||
auto subLayers = layer->getSubLayers(); | ||
for(auto subLayer : subLayers) | ||
{ | ||
if(subLayer) initialiseChildAndSublayers(*subLayer, proxy); | ||
} | ||
auto childLayers = layer->getChildLayers(); | ||
for(auto childLayer : childLayers) | ||
{ | ||
if(childLayer) initialiseChildAndSublayers(*childLayer, proxy); | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -126,6 +145,9 @@ static void postFileOpen(void*) | |
} | ||
} | ||
} | ||
// All layers should have been fixed up above. Do not fixup any | ||
// orphaned layers as they will not have access to the proxy node/stage | ||
// which makes them invalid. | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
@@ -180,4 +202,3 @@ void Global::onPluginUnload() | |
} // usdmaya | ||
} // al | ||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move initialiseChildAndSublayers function to be in Layer.h/cpp