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

HYDRA-780 : Image-based NURBS unit test #54

Merged
merged 19 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b9b5659
HYDRA-780 : Add image-based NURBS unit test
debloip-adsk Jan 31, 2024
debfd92
HYDRA-780 : Add image files and fix test
debloip-adsk Jan 31, 2024
cf3be32
HYDRA-780 : Cleanup compareSnapshot
debloip-adsk Jan 31, 2024
d82d259
HYDRA-780 : Remove need for PluginLoaded
debloip-adsk Jan 31, 2024
ed6339d
HYDRA-780 : Add comment on why specific NURBS were chosen
debloip-adsk Feb 1, 2024
7f80429
HYDRA-780 : Make each test have a new file by default
debloip-adsk Feb 1, 2024
9eb7e6e
HYDRA-780 : Adjust camera
debloip-adsk Feb 1, 2024
40411fc
Merge branch 'dev' into debloip/HYDRA-780/image-based-nurbs-tests
debloip-adsk Feb 1, 2024
f10b93e
HYDRA-780 : Adjust image diff threshold
debloip-adsk Feb 1, 2024
aa3ed1c
HYDRA-780 : Return makeNurbNodeName programmatically
debloip-adsk Feb 1, 2024
c567332
HYDRA-780 : Put stricter percent threshold
debloip-adsk Feb 1, 2024
99fd474
HYDRA-780 : Adjust image diff threshold
debloip-adsk Feb 2, 2024
f37797c
HYDRA-780 : Move camera closer for fresh prims
debloip-adsk Feb 2, 2024
3148c15
HYDRA-780 : Remove new file in mtohutils
debloip-adsk Feb 2, 2024
e67cefa
Create new scene before each test
debloip-adsk Feb 2, 2024
d3ffb20
HYDRA-780 : Add comment on ArubaTessellator
debloip-adsk Feb 2, 2024
8c7bc39
Merge branch 'dev' into debloip/HYDRA-780/image-based-nurbs-tests
debloip-adsk Feb 5, 2024
65aa6a4
HYDRA-780 : Refactor nurbsCreationCallable setup
debloip-adsk Feb 5, 2024
e70f367
HYDRA-780 : Move ArubaTessellator load code to common code
debloip-adsk Feb 5, 2024
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 @@ -18,6 +18,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
testFlowViewportAPI.py
testStageVariants.py
testArnoldLights.py
testNurbsPrimitives.py
cpp/testColorPreferences.py
cpp/testCppFramework.py
cpp/testMayaSceneFlattening.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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/testNurbsPrimitives.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Copyright 2024 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

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

IMAGE_DIFF_FAIL_THRESHOLD = 0.1
IMAGE_DIFF_FAIL_PERCENT = 0.75

def compareSnapshot(self, referenceFilename, cameraDistance=10):
self.setBasicCam(cameraDistance)
cmds.refresh()
self.assertSnapshotClose(referenceFilename, self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

def setupScene(self, nurbsCreationCallable):
self.setHdStormRenderer()
makeNurbNodeName = nurbsCreationCallable()[1]
cmds.refresh()
return makeNurbNodeName

# Torus attributes is a superset of sphere, cone, and cylinder attributes
def test_NurbsTorus(self):
makeNurbNodeName = self.setupScene(cmds.torus)
self.compareSnapshot("torus_fresh.png", 5)

cmds.setAttr(makeNurbNodeName + ".startSweep", 50)
cmds.setAttr(makeNurbNodeName + ".endSweep", 300)
cmds.setAttr(makeNurbNodeName + ".radius", 2)
cmds.setAttr(makeNurbNodeName + ".degree", 1)
cmds.setAttr(makeNurbNodeName + ".sections", 12)
cmds.setAttr(makeNurbNodeName + ".spans", 6)
cmds.setAttr(makeNurbNodeName + ".heightRatio", 0.8)
cmds.setAttr(makeNurbNodeName + ".minorSweep", 250)
self.compareSnapshot("torus_modified.png")

cmds.setAttr(makeNurbNodeName + ".useTolerance", True)
cmds.setAttr(makeNurbNodeName + ".tolerance", 0.05)
self.compareSnapshot("torus_tolerance.png")

# Cube attributes is a superset of plane attributes
def test_NurbsCube(self):
makeNurbNodeName = self.setupScene(cmds.nurbsCube)
self.compareSnapshot("cube_fresh.png", 5)

cmds.setAttr(makeNurbNodeName + ".degree", 1)
cmds.setAttr(makeNurbNodeName + ".patchesU", 2)
cmds.setAttr(makeNurbNodeName + ".patchesV", 3)
cmds.setAttr(makeNurbNodeName + ".width", 4)
cmds.setAttr(makeNurbNodeName + ".lengthRatio", 2)
cmds.setAttr(makeNurbNodeName + ".heightRatio", 3)
self.compareSnapshot("cube_modified.png")

def test_NurbsCircle(self):
makeNurbNodeName = self.setupScene(cmds.circle)
self.compareSnapshot("circle_fresh.png", 5)

cmds.setAttr(makeNurbNodeName + ".sweep", 180)
cmds.setAttr(makeNurbNodeName + ".radius", 2)
cmds.setAttr(makeNurbNodeName + ".degree", 1)
cmds.setAttr(makeNurbNodeName + ".sections", 12)
cmds.setAttr(makeNurbNodeName + ".normalX", 1)
cmds.setAttr(makeNurbNodeName + ".normalY", 2)
cmds.setAttr(makeNurbNodeName + ".normalZ", 3)
cmds.setAttr(makeNurbNodeName + ".centerX", 4)
cmds.setAttr(makeNurbNodeName + ".centerY", 5)
cmds.setAttr(makeNurbNodeName + ".centerZ", 6)
cmds.setAttr(makeNurbNodeName + ".firstPointX", 7)
cmds.setAttr(makeNurbNodeName + ".firstPointY", 8)
cmds.setAttr(makeNurbNodeName + ".firstPointZ", 9)
self.compareSnapshot("circle_modified.png")

cmds.setAttr(makeNurbNodeName + ".useTolerance", True)
cmds.setAttr(makeNurbNodeName + ".tolerance", 0.05)
self.compareSnapshot("circle_tolerance.png")

cmds.setAttr(makeNurbNodeName + ".fixCenter", False)
self.compareSnapshot("circle_unfixedCenter.png")

def test_NurbsSquare(self):
makeNurbNodeName = self.setupScene(cmds.nurbsSquare)
self.compareSnapshot("square_fresh.png", 5)

cmds.setAttr(makeNurbNodeName + ".sideLength1", 2)
cmds.setAttr(makeNurbNodeName + ".sideLength2", 3)
cmds.setAttr(makeNurbNodeName + ".spansPerSide", 4)
cmds.setAttr(makeNurbNodeName + ".degree", 1)
cmds.setAttr(makeNurbNodeName + ".normalX", 1)
cmds.setAttr(makeNurbNodeName + ".normalY", 2)
cmds.setAttr(makeNurbNodeName + ".normalZ", 3)
cmds.setAttr(makeNurbNodeName + ".centerX", 4)
cmds.setAttr(makeNurbNodeName + ".centerY", 5)
cmds.setAttr(makeNurbNodeName + ".centerZ", 6)
self.compareSnapshot("square_modified.png")

if __name__ == '__main__':
fixturesUtils.runTests(globals())
6 changes: 6 additions & 0 deletions test/testUtils/fixturesUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import sys
import unittest

# Plugins that are bundled and loaded by default in a Maya installation
DEFAULT_PLUGINS = ['ArubaTessellator']

def _setUpClass(modulePathName, pluginName, initializeStandalone):
'''
Common code for setUpClass() and readOnlySetUpClass()
Expand All @@ -31,6 +34,9 @@ def _setUpClass(modulePathName, pluginName, initializeStandalone):
import maya.cmds as cmds
cmds.loadPlugin(pluginName, quiet=True)

for defaultPlugin in DEFAULT_PLUGINS:
cmds.loadPlugin(defaultPlugin, quiet=True)

realPath = os.path.realpath(modulePathName)
return os.path.split(realPath)

Expand Down
6 changes: 6 additions & 0 deletions test/testUtils/mtohUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def setUpClass(cls):
"define `_file = __file__`")
fixturesUtils.readOnlySetUpClass(cls._file, 'mayaHydra',
initializeStandalone=False)

def setUp(self):
# Maya is not closed/reset between each test of a test suite,
# so open a new file before each test to minimize leftovers
# from previous tests.
cmds.file(new=True, force=True)

def setHdStormRenderer(self):
self.activeEditor = cmds.playblast(activeEditor=1)
Expand Down
Loading