diff --git a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt index 8ebfb2224b..4b9d57845e 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt +++ b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt @@ -21,6 +21,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES testFlowViewportAPI.py testStageVariants.py testNurbsPrimitives.py + testCurveTools.py testPolygonPrimitives.py cpp/testColorPreferences.py cpp/testCppFramework.py diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_basic.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_basic.png new file mode 100644 index 0000000000..f1783255c8 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_basic.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_bezier.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_bezier.png new file mode 100644 index 0000000000..0bc9e23923 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_bezier.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_customKnots.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_customKnots.png new file mode 100644 index 0000000000..39a512d600 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_customKnots.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_degree1.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_degree1.png new file mode 100644 index 0000000000..f6bf6b05d9 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_degree1.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_degree2.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_degree2.png new file mode 100644 index 0000000000..a7549edc04 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_degree2.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_degree5.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_degree5.png new file mode 100644 index 0000000000..113f3a2550 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveControlVertices_degree5.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_basic.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_basic.png new file mode 100644 index 0000000000..ca746be93e Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_basic.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_bezier.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_bezier.png new file mode 100644 index 0000000000..b40c465d72 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_bezier.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_degree1.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_degree1.png new file mode 100644 index 0000000000..f6bf6b05d9 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_degree1.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_degree2.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_degree2.png new file mode 100644 index 0000000000..aefc7213d8 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_degree2.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_degree5.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_degree5.png new file mode 100644 index 0000000000..96cf61db19 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/curveEditPoints_degree5.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/threePointCircularArc_cubic.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/threePointCircularArc_cubic.png new file mode 100644 index 0000000000..06c0e7846c Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/threePointCircularArc_cubic.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/threePointCircularArc_fresh.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/threePointCircularArc_fresh.png new file mode 100644 index 0000000000..4c26de86a4 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/threePointCircularArc_fresh.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/threePointCircularArc_linear.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/threePointCircularArc_linear.png new file mode 100644 index 0000000000..e1760d980a Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/threePointCircularArc_linear.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_cubic.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_cubic.png new file mode 100644 index 0000000000..2be117ecdf Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_cubic.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_fresh.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_fresh.png new file mode 100644 index 0000000000..7fe14451bc Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_fresh.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_linear.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_linear.png new file mode 100644 index 0000000000..5f571305f4 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_linear.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_toggleArc.png b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_toggleArc.png new file mode 100644 index 0000000000..86a774513d Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/CurveToolsTest/twoPointCircularArc_toggleArc.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/testCurveTools.py b/test/lib/mayaUsd/render/mayaToHydra/testCurveTools.py new file mode 100644 index 0000000000..17e894ab64 --- /dev/null +++ b/test/lib/mayaUsd/render/mayaToHydra/testCurveTools.py @@ -0,0 +1,148 @@ +# 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 + +import platform + +class TestCurveTools(mtohUtils.MtohTestCase): + # MayaHydraBaseTestCase.setUpClass requirement. + _file = __file__ + + POINTS = [(0,-5,10), (-10, 0, 0), (0, 5, -10), (10, 0, 0), (0, -5, 5), (-5,0,0), (0,5,-5), (5, 0, 0), (0,0,0)] + CUSTOM_KNOTS = [0,1,2,3,4,5,6,7,8,9,10] + + @property + def imageDiffFailThreshold(self): + return 0.05 + + @property + def imageDiffFailPercent(self): + # HYDRA-837 : Wireframes seem to have a slightly different color on macOS. We'll increase the thresholds + # for that platform specifically for now, so we can still catch issues on other platforms. + if platform.system() == "Darwin": + return 2 + return 0.5 + + def compareSnapshot(self, referenceFilename, cameraDistance=15): + self.setBasicCam(cameraDistance) + cmds.refresh() + self.assertSnapshotClose(referenceFilename, self.imageDiffFailThreshold, self.imageDiffFailPercent) + + def setUp(self): + super(TestCurveTools, self).setUp() + self.setHdStormRenderer() + cmds.refresh() + + def createCircularArc(self, makeCircularArcNodeType): + arcNode = cmds.createNode(makeCircularArcNodeType) + curveNode = cmds.createNode("nurbsCurve") + cmds.connectAttr(arcNode + ".oc", curveNode + ".cr") + return arcNode + + def test_CurveControlVertices(self): + curve = cmds.curve(point=self.POINTS) + self.compareSnapshot("curveControlVertices_basic.png") + cmds.delete(curve) + + curve = cmds.curve(point=self.POINTS, knot=self.CUSTOM_KNOTS) + self.compareSnapshot("curveControlVertices_customKnots.png") + cmds.delete(curve) + + curve = cmds.curve(point=self.POINTS, degree=1) + self.compareSnapshot("curveControlVertices_degree1.png") + cmds.delete(curve) + + curve = cmds.curve(point=self.POINTS, degree=2) + self.compareSnapshot("curveControlVertices_degree2.png") + cmds.delete(curve) + + curve = cmds.curve(point=self.POINTS, degree=5) + self.compareSnapshot("curveControlVertices_degree5.png") + cmds.delete(curve) + + curve = cmds.curve(point=self.POINTS, bezier=True) + self.compareSnapshot("curveControlVertices_bezier.png") + cmds.delete(curve) + + def test_CurveEditPoints(self): + curve = cmds.curve(editPoint=self.POINTS) + self.compareSnapshot("curveEditPoints_basic.png") + cmds.delete(curve) + + curve = cmds.curve(editPoint=self.POINTS, degree=1) + self.compareSnapshot("curveEditPoints_degree1.png") + cmds.delete(curve) + + curve = cmds.curve(editPoint=self.POINTS, degree=2) + self.compareSnapshot("curveEditPoints_degree2.png") + cmds.delete(curve) + + curve = cmds.curve(editPoint=self.POINTS, degree=5) + self.compareSnapshot("curveEditPoints_degree5.png") + cmds.delete(curve) + + curve = cmds.curve(editPoint=self.POINTS, bezier=True) + self.compareSnapshot("curveEditPoints_bezier.png") + cmds.delete(curve) + + def test_TwoPointCircularArc(self): + arcNode = self.createCircularArc("makeTwoPointCircularArc") + self.compareSnapshot("twoPointCircularArc_fresh.png", 5) + + cmds.setAttr(arcNode + ".point1X", 0) + cmds.setAttr(arcNode + ".point1Y", 0) + cmds.setAttr(arcNode + ".point1Z", 5) + cmds.setAttr(arcNode + ".point2X", 5) + cmds.setAttr(arcNode + ".point2Y", 0) + cmds.setAttr(arcNode + ".point2Z", -5) + cmds.setAttr(arcNode + ".directionVectorX", -1) + cmds.setAttr(arcNode + ".directionVectorY", 0) + cmds.setAttr(arcNode + ".directionVectorZ", 0) + cmds.setAttr(arcNode + ".radius", 6) + cmds.setAttr(arcNode + ".toggleArc", False) + cmds.setAttr(arcNode + ".degree", 1) + cmds.setAttr(arcNode + ".sections", 4) + self.compareSnapshot("twoPointCircularArc_linear.png") + + cmds.setAttr(arcNode + ".toggleArc", True) + self.compareSnapshot("twoPointCircularArc_toggleArc.png") + + cmds.setAttr(arcNode + ".degree", 3) + self.compareSnapshot("twoPointCircularArc_cubic.png") + + def test_ThreePointCircularArc(self): + arcNode = self.createCircularArc("makeThreePointCircularArc") + self.compareSnapshot("threePointCircularArc_fresh.png", 5) + + cmds.setAttr(arcNode + ".point1X", -1) + cmds.setAttr(arcNode + ".point1Y", -1) + cmds.setAttr(arcNode + ".point1Z", 1) + cmds.setAttr(arcNode + ".point2X", 2) + cmds.setAttr(arcNode + ".point2Y", 2) + cmds.setAttr(arcNode + ".point2Z", -2) + cmds.setAttr(arcNode + ".point3X", 3) + cmds.setAttr(arcNode + ".point3Y", -3) + cmds.setAttr(arcNode + ".point3Z", 3) + cmds.setAttr(arcNode + ".degree", 1) + cmds.setAttr(arcNode + ".sections", 5) + self.compareSnapshot("threePointCircularArc_linear.png") + + cmds.setAttr(arcNode + ".degree", 3) + self.compareSnapshot("threePointCircularArc_cubic.png") + +if __name__ == '__main__': + fixturesUtils.runTests(globals())