-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate negative offset scale during composition
Cummulative negative layer offset scale on a composed layer doesn't make sense, as it reverses the direction of time, and can lead to incorrect and non-intuitive results specially with various spline evaluation behaviors and with time samples with soon to be implemented preValue support. Introduced PCP_ALLOW_NEGATIVE_LAYER_OFFSET_SCALE environment variable, which currently defaults to true, allowing the use of negative layer offset, however will issue a warning. A false value, will result in a coding error. (Internal change: 2357711)
- Loading branch information
1 parent
e104b33
commit fa8e2b2
Showing
5 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/pxrpythonsubst | ||
# | ||
# Copyright 2025 Pixar | ||
# | ||
# Licensed under the terms set forth in the LICENSE.txt file available at | ||
|
||
import unittest | ||
|
||
from pxr import Pcp, Sdf, Tf | ||
|
||
def _ComposeLayersWithNegativeOffsetScale(): | ||
refLayer = Sdf.Layer.CreateAnonymous("ref") | ||
refLayer.ImportFromString(''' | ||
#sdf 1.4.32 | ||
def "prim" { | ||
double attr.timeSamples = { | ||
0: 1.0, | ||
1: 2.0, | ||
} | ||
} | ||
'''.strip()) | ||
|
||
subLayer = Sdf.Layer.CreateAnonymous("sub") | ||
subLayer.ImportFromString(f''' | ||
#sdf 1.4.32 | ||
( | ||
subLayers = [ | ||
@{refLayer.identifier}@ (scale = -1) | ||
] | ||
) | ||
'''.strip()) | ||
|
||
rootLayer = Sdf.Layer.CreateAnonymous() | ||
rootLayer.ImportFromString(f''' | ||
#sdf 1.4.32 | ||
def "prim" ( | ||
references = @{subLayer.identifier}@</prim> (scale = -1) | ||
) | ||
{{ | ||
}} | ||
'''.strip()) | ||
|
||
pcpCache = Pcp.Cache(Pcp.LayerStackIdentifier(rootLayer)) | ||
_, errs = pcpCache.ComputePrimIndex("/prim") | ||
return errs | ||
|
||
class TestPcpNegativeLayerOffsetScale(unittest.TestCase): | ||
|
||
# Following will not result in a composition error | ||
@unittest.skipIf(not Tf.GetEnvSetting("PCP_ALLOW_NEGATIVE_LAYER_OFFSET_SCALE"), | ||
"Allow negative layer offset scale, no composition error") | ||
def test_NegativeLayerOffsetScaleAllowed(self): | ||
errs = _ComposeLayersWithNegativeOffsetScale() | ||
self.assertEqual(len(errs), 0) | ||
|
||
# Following will result in a composition error | ||
@unittest.skipIf(Tf.GetEnvSetting("PCP_ALLOW_NEGATIVE_LAYER_OFFSET_SCALE"), | ||
"Do not allow negative layer offset scale, composition error") | ||
def test_NegativeLayerOffsetScaleNotAllowed(self): | ||
errs = _ComposeLayersWithNegativeOffsetScale() | ||
self.assertEqual(len(errs), 2) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |