Skip to content

Commit 3e01e4d

Browse files
committed
Added USD inherits / specializes test.
1 parent ea8c934 commit 3e01e4d

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed

test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
6060
testSceneModified.py
6161
testStageInstanceablePrimsSelHighlight.py|skipOnPlatform:osx # HYDRA-1315 : Wire not showing on OSX
6262
testIsolateSelectWithGeomSubset.py
63+
testUsdInheritsSpecializes.py
6364
cpp/testColorPreferences.py
6465
cpp/testCppFramework.py
6566
cpp/testDataProducerExample.py
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2025 Autodesk
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
import maya.cmds as cmds
17+
import fixturesUtils
18+
import mtohUtils
19+
import testUtils
20+
import usdUtils
21+
22+
class TestUsdInheritsSpecializes(mtohUtils.MayaHydraBaseTestCase):
23+
# MayaHydraBaseTestCase.setUpClass requirement.
24+
_file = __file__
25+
26+
_requiredPlugins = ['mayaHydraCppTests']
27+
28+
IMAGE_DIFF_FAIL_THRESHOLD = 0.1
29+
IMAGE_DIFF_FAIL_PERCENT = 2
30+
31+
def loadUsdScene(self, fileName):
32+
33+
# Move the camera in closer
34+
self.setBasicCam(5)
35+
36+
usdScenePath = testUtils.getTestScene('testUsdInheritsSpecializes', fileName)
37+
usdUtils.createStageFromFile(usdScenePath)
38+
39+
def test_Inherits(self):
40+
41+
self.loadUsdScene('cubeInherits.usda')
42+
43+
cmds.refresh()
44+
45+
self.assertSnapshotClose('inherits.png', self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)
46+
47+
def test_Specializes(self):
48+
49+
self.loadUsdScene('cubeSpecializes.usda')
50+
51+
cmds.refresh()
52+
53+
# Same snapshot as inherits.
54+
self.assertSnapshotClose('inherits.png', self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)
55+
56+
if __name__ == '__main__':
57+
fixturesUtils.runTests(globals())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#usda 1.0
2+
3+
class Xform "_class_BaseCube"
4+
{
5+
def Mesh "cube"
6+
{
7+
uniform bool doubleSided = 1
8+
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
9+
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
10+
int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4]
11+
point3f[] points = [(-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5)]
12+
color3f[] primvars:displayColor = [(1, 0, 0)]
13+
token visibility = "inherited"
14+
}
15+
}
16+
17+
def "CubeA" (
18+
inherits = </_class_BaseCube>
19+
)
20+
{}
21+
22+
def "CubeB" (
23+
inherits = </_class_BaseCube>
24+
)
25+
{
26+
double3 xformOp:translate = (2.0, 0, 0)
27+
uniform token[] xformOpOrder = ["xformOp:translate"]
28+
29+
over "cube"
30+
{
31+
color3f[] primvars:displayColor = [(0, 1, 0)]
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#usda 1.0
2+
(
3+
defaultPrim = "World"
4+
)
5+
6+
def Xform "World"
7+
{
8+
def Mesh "cubeBase"
9+
{
10+
uniform bool doubleSided = 1
11+
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
12+
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
13+
int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4]
14+
point3f[] points = [(-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5)]
15+
color3f[] primvars:displayColor = [(1, 0, 0)]
16+
token visibility = "inherited"
17+
}
18+
19+
def Mesh "specializedCube" (
20+
specializes = </World/cubeBase>
21+
)
22+
{
23+
double3 xformOp:translate = (2.0, 0, 0)
24+
uniform token[] xformOpOrder = ["xformOp:translate"]
25+
26+
color3f[] primvars:displayColor = [(0, 1, 0)]
27+
}
28+
}

0 commit comments

Comments
 (0)