Skip to content
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

MAYA-125895 Handle timecodes-per-second when flipping shared state #2701

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! :D

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