-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
USD pick with kind support, with test.
- Loading branch information
Showing
13 changed files
with
209 additions
and
24 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
73 changes: 73 additions & 0 deletions
73
test/lib/mayaUsd/render/mayaToHydra/cpp/testUsdPickKind.py
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,73 @@ | ||
# 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 usdUtils | ||
|
||
import testUtils | ||
from testUtils import PluginLoaded | ||
|
||
class TestUsdPickKind(mtohUtils.MayaHydraBaseTestCase): | ||
# MayaHydraBaseTestCase.setUpClass requirement. | ||
_file = __file__ | ||
|
||
PICK_PATH = "|kindHierarchy|kindHierarchyShape,/RootAssembly/ParentGroup" | ||
|
||
def loadUsdScene(self): | ||
usdScenePath = testUtils.getTestScene('testUsdPickKind', 'kindHierarchy.usda') | ||
usdUtils.createStageFromFile(usdScenePath) | ||
|
||
def setUp(self): | ||
super(TestUsdPickKind, self).setUp() | ||
self.loadUsdScene() | ||
cmds.refresh() | ||
|
||
def test_pickKinds(self): | ||
with PluginLoaded('mayaHydraCppTests'): | ||
kinds = ["", "model", "group", "assembly", "component", "subcomponent"] | ||
selectedItems = [ | ||
# Kind is none: pick the most descendant prim. | ||
"/ChildAssembly/LeafModel/ImportantSubtree/Cube", | ||
# Kind is model: subcomponent is not part of the model kind | ||
# hierarchy, so we iterate up the parent hierarchy twice to | ||
# reach the component prim. | ||
"/ChildAssembly/LeafModel", | ||
# Kind is group: an assembly is a group, so ChildAssembly is | ||
# picked. | ||
"/ChildAssembly", | ||
# Kind is assembly. | ||
"/ChildAssembly", | ||
# Kind is component | ||
"/ChildAssembly/LeafModel", | ||
# Kind is subcomponent | ||
"/ChildAssembly/LeafModel/ImportantSubtree" | ||
] | ||
|
||
# Read the current USD selection kind. | ||
kindOptionVar = "mayaUsd_SelectionKind" | ||
previousKind = cmds.optionVar(q=kindOptionVar) | ||
|
||
for (kind, selectedItem) in zip(kinds, selectedItems): | ||
cmds.optionVar(sv=(kindOptionVar, kind)) | ||
cmds.mayaHydraCppTest( | ||
self.PICK_PATH + selectedItem, | ||
f="TestUsdPicking.pick") | ||
|
||
# Restore the USD selection kind back to its original value. | ||
cmds.optionVar(sv=(kindOptionVar, previousKind)) | ||
|
||
if __name__ == '__main__': | ||
fixturesUtils.runTests(globals()) |
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,35 @@ | ||
#usda 1.0 | ||
|
||
def Xform "RootAssembly" ( | ||
kind = "assembly" | ||
) | ||
{ | ||
def Xform "ParentGroup" ( | ||
kind = "group" | ||
) | ||
{ | ||
def Xform "ChildAssembly" ( | ||
kind = "assembly" | ||
) | ||
{ | ||
def Xform "LeafModel" ( | ||
kind = "component" | ||
) | ||
{ | ||
def Xform "ImportantSubtree" ( | ||
kind = "subcomponent" | ||
) | ||
{ | ||
def Mesh "Cube" | ||
{ | ||
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)] | ||
uniform token subdivisionScheme = "none" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.