-
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.
Merge remote-tracking branch 'origin/dev' into debloip/HYDRA-703/fix-…
…mesh-adapter-transform-update
- Loading branch information
Showing
5 changed files
with
173 additions
and
0 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
78 changes: 78 additions & 0 deletions
78
test/lib/mayaUsd/render/mayaToHydra/cpp/testUsdStageLayerMuting.cpp
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,78 @@ | ||
// Copyright 2023 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. | ||
// | ||
|
||
#include "testUtils.h" | ||
|
||
#include <pxr/base/gf/vec3d.h> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
PXR_NAMESPACE_USING_DIRECTIVE | ||
|
||
namespace { | ||
|
||
constexpr float kUnmutedExtent = 4.0f; | ||
|
||
FindPrimPredicate findCubePredicate = PrimNamePredicate("USDCube"); | ||
|
||
HdDataSourceLocator extentMinLocator = HdDataSourceLocator(TfToken("extent"), TfToken("min")); | ||
HdDataSourceLocator extentMaxLocator = HdDataSourceLocator(TfToken("extent"), TfToken("max")); | ||
|
||
} // namespace | ||
|
||
TEST(UsdStageLayerMuting, testSubLayerUnmuted) | ||
{ | ||
// Get the terminal scene index | ||
const auto& sceneIndices = GetTerminalSceneIndices(); | ||
ASSERT_GT(sceneIndices.size(), 0u); | ||
SceneIndexInspector inspector(sceneIndices.front()); | ||
|
||
// Find the cube prim | ||
PrimEntriesVector cubePrims = inspector.FindPrims(findCubePredicate); | ||
ASSERT_EQ(cubePrims.size(), 1u); | ||
HdSceneIndexPrim cubePrim = cubePrims.front().prim; | ||
|
||
// Retrieve the extent/min and extent/max data sources | ||
auto extentMinDataSource = HdTypedSampledDataSource<GfVec3d>::Cast( | ||
HdContainerDataSource::Get(cubePrim.dataSource, extentMinLocator)); | ||
ASSERT_TRUE(extentMinDataSource); | ||
auto extentMaxDataSource = HdTypedSampledDataSource<GfVec3d>::Cast( | ||
HdContainerDataSource::Get(cubePrim.dataSource, extentMaxLocator)); | ||
ASSERT_TRUE(extentMaxDataSource); | ||
|
||
// Ensure the extents have the correct values | ||
EXPECT_TRUE(GfIsClose( | ||
extentMinDataSource->GetTypedValue(0), -GfVec3d(kUnmutedExtent), DEFAULT_TOLERANCE)); | ||
EXPECT_TRUE(GfIsClose( | ||
extentMaxDataSource->GetTypedValue(0), GfVec3d(kUnmutedExtent), DEFAULT_TOLERANCE)); | ||
} | ||
|
||
TEST(UsdStageLayerMuting, testSubLayerMuted) | ||
{ | ||
// Get the terminal scene index | ||
const auto& sceneIndices = GetTerminalSceneIndices(); | ||
ASSERT_GT(sceneIndices.size(), 0u); | ||
SceneIndexInspector inspector(sceneIndices.front()); | ||
|
||
// Find the cube prim | ||
PrimEntriesVector cubePrims = inspector.FindPrims(findCubePredicate); | ||
ASSERT_EQ(cubePrims.size(), 1u); | ||
HdSceneIndexPrim cubePrim = cubePrims.front().prim; | ||
|
||
// Ensure there is no "extent" data source with the sublayer muted, | ||
// since the root layer did not define any special extents. | ||
auto extentDataSource = cubePrim.dataSource->Get(TfToken("extent")); | ||
EXPECT_FALSE(extentDataSource); | ||
} |
71 changes: 71 additions & 0 deletions
71
test/lib/mayaUsd/render/mayaToHydra/cpp/testUsdStageLayerMuting.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,71 @@ | ||
# Copyright 2023 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 unittest | ||
|
||
from testUtils import PluginLoaded | ||
|
||
class TestUsdStageLayerMuting(mtohUtils.MayaHydraBaseTestCase): | ||
# MayaHydraBaseTestCase.setUpClass requirement. | ||
_file = __file__ | ||
|
||
CUBE_PRIM_PATH = "/USDCube" | ||
SUB_LAYER_CUBE_SIZE = 8.0 | ||
|
||
def setSubLayerMuted(self, isMuted: bool): | ||
cmds.mayaUsdLayerEditor(self.subLayer.identifier, edit=True, muteLayer=(isMuted, self.usdProxyShapeUfePathString)) | ||
|
||
def setupUsdStage(self): | ||
import mayaUsd | ||
import mayaUsd_createStageWithNewLayer | ||
from pxr import UsdGeom, Sdf | ||
|
||
self.setHdStormRenderer() | ||
cmds.refresh() | ||
|
||
# Create a USD stage | ||
self.usdProxyShapeUfePathString = mayaUsd_createStageWithNewLayer.createStageWithNewLayer() | ||
stage = mayaUsd.lib.GetPrim(self.usdProxyShapeUfePathString).GetStage() | ||
|
||
# Define a cube prim in the stage (implicit surface) | ||
UsdGeom.Cube.Define(stage, self.CUBE_PRIM_PATH) | ||
|
||
# Add a sublayer to the stage | ||
rootLayer = stage.GetRootLayer() | ||
subLayerId = cmds.mayaUsdLayerEditor(rootLayer.identifier, edit=True, addAnonymous="testSubLayer")[0] | ||
self.subLayer = Sdf.Layer.Find(subLayerId) | ||
|
||
# Author an opinion on the sublayer | ||
stage.SetEditTarget(self.subLayer) | ||
cubePrim = stage.GetPrimAtPath(self.CUBE_PRIM_PATH) | ||
cubePrim.GetAttribute('size').Set(self.SUB_LAYER_CUBE_SIZE) | ||
|
||
cmds.refresh() | ||
|
||
@unittest.skipUnless(mtohUtils.checkForMayaUsdPlugin(), "Requires Maya USD Plugin.") | ||
def test_UsdStageLayerMuting(self): | ||
self.setupUsdStage() | ||
with PluginLoaded('mayaHydraCppTests'): | ||
cmds.mayaHydraCppTest(f="UsdStageLayerMuting.testSubLayerUnmuted") | ||
self.setSubLayerMuted(True) | ||
cmds.mayaHydraCppTest(f="UsdStageLayerMuting.testSubLayerMuted") | ||
self.setSubLayerMuted(False) | ||
cmds.mayaHydraCppTest(f="UsdStageLayerMuting.testSubLayerUnmuted") | ||
|
||
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