Skip to content

Commit

Permalink
Matching to Houdini build 18.5.29.
Browse files Browse the repository at this point in the history
  • Loading branch information
SideFX authored and Prisms User committed Nov 14, 2019
1 parent 8a86d10 commit 8a57cd0
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/houdini/lib/H_USD/HUSD/XUSD_Data.C
Original file line number Diff line number Diff line change
Expand Up @@ -1025,27 +1025,37 @@ XUSD_Data::addLayer(const XUSD_LayerAtPath &layer,
}
}

// Release the current write lock.
afterRelease();

// Tag the layer with our creator node, if it hasn't been set already.
// Then disallow further edits of the layer.
if (layer.isLayerAnonymous() &&
!HUSDgetCreatorNode(layer.myLayer, node_path))
HUSDsetCreatorNode(layer.myLayer, myDataLock->getLockedNodeId());
layer.myLayer->SetPermissionToEdit(false);

// The position argument is 0 for the strongest layer, -1 for the weakest.
// If the layer is meant to be editable, it must be the strongest layer.
// Adjust the position to reflect the fact that mySourceLayers is ordered
// weakest to strongest, so we must reverse the position argument.
// We figure this out before releasing the lock in case the active layer
// gets removed when we release the lock. We want the position to be
// relative to the list of layers including the active layer, otherwise
// the layer indices won't match up with what the users sees (which always
// includes an active layer).
if (add_layer_op == XUSD_ADD_LAYER_EDITABLE)
position = mySourceLayers.size();
else if (position >= 0 && position <= mySourceLayers.size())
position = mySourceLayers.size() - position;
else
position = 0;

// Release the current write lock.
afterRelease();

// Make sure the removal of the active layer didn't make the calculated
// position value invalid.
if (position > mySourceLayers.size())
position = mySourceLayers.size();

// Tag the layer with our creator node, if it hasn't been set already.
// Then disallow further edits of the layer.
if (layer.isLayerAnonymous() &&
!HUSDgetCreatorNode(layer.myLayer, node_path))
HUSDsetCreatorNode(layer.myLayer, myDataLock->getLockedNodeId());
layer.myLayer->SetPermissionToEdit(false);

// Add the sublayer to the stack. Then advance our active layer to point
// to this new layer (if we want to be allowed to edit it further), oro to
// one layer past this new sublayer. It is up to the caller to decide if it
Expand Down Expand Up @@ -1102,13 +1112,14 @@ XUSD_Data::removeLayer(const std::string &filepath)
// we have to flip the index value when deciding which stage
// sublayer to remove. Do this before releasing the lock in case
// the active layer gets removed, which does not affect the stage
// sublayers.
// sublayers. Note that we don't need to worry about placeholder
// layers, because they are always the strongest layers. And what
// we know is that we want to remove the i'th weakest layer. This
// can be safely assumed to be i spots from the end of the array
// of layers on the stage.
int stagesize = myStage->GetRootLayer()->GetNumSubLayerPaths();
int stageidx = stagesize - i - 1;

// Just verify that the source layers and stage sublayers match.
UT_ASSERT(mySourceLayers.size() == stagesize);

// Release the current write lock.
// Note that we don't need to add a layer to the write lock tag.
// We are either removing some non-current layer, in which case
Expand Down

0 comments on commit 8a57cd0

Please sign in to comment.