Skip to content

Added USD inherits / specializes test. #257

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

Merged
merged 4 commits into from
Mar 4, 2025
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
1 change: 1 addition & 0 deletions test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
testStageInstanceablePrimsSelHighlight.py|skipOnPlatform:osx # HYDRA-1315 : Wire not showing on OSX
testIsolateSelectWithGeomSubset.py
testMayaReference.py
testUsdInheritsSpecializes.py
cpp/testColorPreferences.py
cpp/testCppFramework.py
cpp/testDataProducerExample.py
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/testUsdInheritsSpecializes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2025 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import maya.cmds as cmds
import fixturesUtils
import mtohUtils
import testUtils
import usdUtils

class TestUsdInheritsSpecializes(mtohUtils.MayaHydraBaseTestCase):
# MayaHydraBaseTestCase.setUpClass requirement.
_file = __file__

_requiredPlugins = ['mayaHydraCppTests']

IMAGE_DIFF_FAIL_THRESHOLD = 0.1
IMAGE_DIFF_FAIL_PERCENT = 2

@property
def imageFileName(self):
# Same image snapshot for both inherits and specializes test.
return 'inherits.png'

def setUp(self):
super(TestUsdInheritsSpecializes, self).setUp()
self.modifyDefaultLightIntensityByUsdVersion()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I didn't get you were having this kind of problems... I did that function :-)


def loadUsdScene(self, fileName):

# Move the camera in closer
self.setBasicCam(5)

usdScenePath = testUtils.getTestScene('testUsdInheritsSpecializes', fileName)
usdUtils.createStageFromFile(usdScenePath)

def test_Inherits(self):

self.loadUsdScene('cubeInherits.usda')

cmds.refresh()

self.assertSnapshotClose(self.imageFileName, self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

def test_Specializes(self):

self.loadUsdScene('cubeSpecializes.usda')

cmds.refresh()

# Same snapshot as inherits.
self.assertSnapshotClose(self.imageFileName, self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

if __name__ == '__main__':
fixturesUtils.runTests(globals())
33 changes: 33 additions & 0 deletions test/testSamples/testUsdInheritsSpecializes/cubeInherits.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#usda 1.0

class Xform "_class_BaseCube"
{
def Mesh "cube"
{
uniform bool doubleSided = 1
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
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]
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)]
color3f[] primvars:displayColor = [(1, 0, 0)]
token visibility = "inherited"
}
}

def "CubeA" (
inherits = </_class_BaseCube>
)
{}

def "CubeB" (
inherits = </_class_BaseCube>
)
{
double3 xformOp:translate = (2.0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate"]

over "cube"
{
color3f[] primvars:displayColor = [(0, 1, 0)]
}
}
28 changes: 28 additions & 0 deletions test/testSamples/testUsdInheritsSpecializes/cubeSpecializes.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#usda 1.0
(
defaultPrim = "World"
)

def Xform "World"
{
def Mesh "cubeBase"
{
uniform bool doubleSided = 1
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
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]
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)]
color3f[] primvars:displayColor = [(1, 0, 0)]
token visibility = "inherited"
}

def Mesh "specializedCube" (
specializes = </World/cubeBase>
)
{
double3 xformOp:translate = (2.0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate"]

color3f[] primvars:displayColor = [(0, 1, 0)]
}
}