-
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.
Each stage should only respond to its own stage invalidation notices. (…
- Loading branch information
Showing
5 changed files
with
103 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
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
46 changes: 46 additions & 0 deletions
46
test/lib/mayaUsd/render/mayaToHydra/cpp/testUsdStageInvalidate.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,46 @@ | ||
// 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 <maya/MGlobal.h> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
PXR_NAMESPACE_USING_DIRECTIVE | ||
|
||
TEST(TestUsdStageInvalidate, testAddStage) | ||
{ | ||
// Setup notifications accumulator for the first terminal scene index | ||
const SceneIndicesVector& sceneIndices = GetTerminalSceneIndices(); | ||
ASSERT_GT(sceneIndices.size(), 0u); | ||
auto siRoot = sceneIndices.front(); | ||
|
||
// Start accumulating notifications. | ||
SceneIndexNotificationsAccumulator notifsAccumulator(siRoot); | ||
|
||
// Add a stage with new layer. | ||
MGlobal::executePythonCommand("import mayaUsd_createStageWithNewLayer; mayaUsd_createStageWithNewLayer.createStageWithNewLayer()"); | ||
|
||
// Confirm the new stage is in the Hydra scene. | ||
auto prim = siRoot->GetPrim(SdfPath("/MayaUsdProxyShape_PluginNode/mayaUsdProxyShape1")); | ||
ASSERT_TRUE(prim.dataSource); | ||
|
||
// There should not have been any prim removed notifications, only prim | ||
// added and dirtied. | ||
ASSERT_EQ(notifsAccumulator.GetRemovedPrimEntries().size(), 0u); | ||
ASSERT_GT(notifsAccumulator.GetDirtiedPrimEntries().size(), 0u); | ||
ASSERT_GT(notifsAccumulator.GetAddedPrimEntries().size(), 0u); | ||
} |
43 changes: 43 additions & 0 deletions
43
test/lib/mayaUsd/render/mayaToHydra/cpp/testUsdStageInvalidate.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,43 @@ | ||
# 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 TestUsdStageInvalidate(mtohUtils.MayaHydraBaseTestCase): | ||
# MayaHydraBaseTestCase.setUpClass requirement. | ||
_file = __file__ | ||
|
||
# Base class setUp() defines HdStorm as the renderer. | ||
|
||
def setupScene(self): | ||
usdScenePath = testUtils.getTestScene('testUsdNativeInstances', 'instancedCubeHierarchies.usda') | ||
usdUtils.createStageFromFile(usdScenePath) | ||
# Clear the selection, otherwise we'll get selection highlighting | ||
# geometry prim removals for the current stage when we create and | ||
# switch the selection to the new stage in the C++ part of the test. | ||
cmds.select(clear=True) | ||
cmds.refresh() | ||
|
||
def test_addStage(self): | ||
self.setupScene() | ||
with PluginLoaded('mayaHydraCppTests'): | ||
cmds.mayaHydraCppTest(f="TestUsdStageInvalidate.testAddStage") | ||
|
||
if __name__ == '__main__': | ||
fixturesUtils.runTests(globals()) |