Skip to content

Commit

Permalink
Merge pull request #2701 from Autodesk/bailp/MAYA-125895/transfer-tcp…
Browse files Browse the repository at this point in the history
…s-when-unsharing-layer

MAYA-125895 Handle timecodes-per-second when flipping shared state
  • Loading branch information
seando-adsk authored Nov 3, 2022
2 parents 3ba5e2c + 72f824f commit 42854b3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/mayaUsd/nodes/proxyShapeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,13 @@ void reproduceSharedStageState(
unsharedRootLayer->SetFramesPerSecond(fps);
stage->SetFramesPerSecond(fps);
}

// Transfer the TCPS (timecodes-per-second) for the same reason as above.
if (sharedRootLayer->HasTimeCodesPerSecond()) {
const double tcps = sharedRootLayer->GetTimeCodesPerSecond();
unsharedRootLayer->SetTimeCodesPerSecond(tcps);
stage->SetTimeCodesPerSecond(tcps);
}
}

} // namespace
Expand Down
44 changes: 44 additions & 0 deletions test/lib/mayaUsd/nodes/testProxyShapeBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,50 @@ def testShareStagePreserveFPS(self):
self.assertEqual(stage.GetFramesPerSecond(), fps)
self.assertEqual(stage.GetRootLayer().framesPerSecond, fps)

def testShareStagePreserveTCPS(self):
'''
Verify share/unshare stage preserve the TCPS metadata of the stage.
'''
# create new stage
cmds.file(new=True, force=True)

# Open usdCylinder.ma scene in testSamples
mayaUtils.openCylinderScene()

# get the stage
proxyShapes = cmds.ls(type="mayaUsdProxyShapeBase", long=True)
proxyShapePath = proxyShapes[0]
stage = mayaUsd.lib.GetPrim(proxyShapePath).GetStage()
stage.GetRootLayer().identifier

# Set an unusual TCPS on the stage.
tcps = 35.0
stage.SetTimeCodesPerSecond(tcps)
stage.GetRootLayer().timeCodesPerSecond = tcps

# Check that the stage TCPS is 35.
self.assertEqual(stage.GetTimeCodesPerSecond(), tcps)
self.assertEqual(stage.GetRootLayer().timeCodesPerSecond, tcps)

# Unshare the stage
cmds.setAttr('{}.{}'.format(proxyShapePath,"shareStage"), False)
stage = mayaUsd.lib.GetPrim(proxyShapePath).GetStage()
rootLayer = stage.GetRootLayer()

# Check that the stage is now unshared and the TCPS is still 35.
self.assertFalse(cmds.getAttr('{}.{}'.format(proxyShapePath,"shareStage")))
self.assertEqual(stage.GetTimeCodesPerSecond(), tcps)
self.assertEqual(stage.GetRootLayer().timeCodesPerSecond, tcps)

# Re-share the stage
cmds.setAttr('{}.{}'.format(proxyShapePath,"shareStage"), True)
stage = mayaUsd.lib.GetPrim(proxyShapePath).GetStage()

# Check that the stage is now shared again and the TCPS is the same.
self.assertTrue(cmds.getAttr('{}.{}'.format(proxyShapePath,"shareStage")))
self.assertEqual(stage.GetTimeCodesPerSecond(), tcps)
self.assertEqual(stage.GetRootLayer().timeCodesPerSecond, tcps)

def testShareStagePreserveSession(self):
'''
Verify share/unshare stage preserves the data in the session layer
Expand Down

0 comments on commit 42854b3

Please sign in to comment.