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

Tremblp/hydra 1413/isolate select keep lighting #243

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 10 additions & 2 deletions lib/flowViewport/sceneIndex/fvpIsolateSelectSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <pxr/imaging/hd/instancerTopologySchema.h>
#include <pxr/imaging/hd/geomSubsetSchema.h>
#include <pxr/imaging/hd/tokens.h>
#include <pxr/imaging/hd/lightSchema.h>

PXR_NAMESPACE_USING_DIRECTIVE

Expand Down Expand Up @@ -464,13 +465,20 @@ void IsolateSelectSceneIndex::_DirtyVisibilityRecursive(
// relevant for materials
auto prim = GetInputSceneIndex()->GetPrim(primPath);
if (prim.primType == HdPrimTypeTokens->material) {
return;
return;
}

// If the prim is a light, early out: setting its visibility to false means
// it won't contribute lighting to the scene, not what we want.
auto lightSchema = HdLightSchema::GetFromParent(prim.dataSource);
if (lightSchema.IsDefined()) {
return;
}

// GeomSubset visibility must not be set (see GetPrim()), so no need to
// dirty it.
if (isGeomSubset(prim)) {
return;
return;
}

TF_DEBUG(FVP_ISOLATE_SELECT_SCENE_INDEX)
Expand Down
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 @@ -91,6 +91,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
# HYDRA-1245.
if (MAYA_HAS_VIEW_SELECTED_OBJECT_API)
list(APPEND INTERACTIVE_TEST_SCRIPT_FILES
testIsolateSelectWithUsdLighting.py|skipOnPlatform:osx # HYDRA-1127 : refinedWire not working on OSX
cpp/testIsolateSelect.py
cpp/testIsolateSelectSwitchToVP2.py
cpp/testIsolateSelectMayaSelectionHighlighting.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.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As desired, the USD light is excluded from the isolate select set, but still contributes its lighting to the scene.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 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 maya.mel as mel
import fixturesUtils
import mayaUtils
import mtohUtils

def enableIsolateSelect(modelPanel):
# See comments in cpp/testIsolateSelect.py
cmds.setFocus(modelPanel)
mel.eval("enableIsolateSelect %s 1" % modelPanel)

def disableIsolateSelect(modelPanel):
cmds.setFocus(modelPanel)
mel.eval("enableIsolateSelect %s 0" % modelPanel)

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

IMAGE_DIFF_FAIL_THRESHOLD = 0.01
IMAGE_DIFF_FAIL_PERCENT = 0.2

def test_IsolateSelectWithUsdLighting(self):
mayaUtils.openTestScene(
"testIsolateSelectWithUsdLighting",
"mayaPlusUSDMeshesWithUSDLighting.ma")

# Bring the camera in closer.
self.setBasicCam(5)

cmds.refresh()

# Isolate select the USD sphere.
modelPanel = 'modelPanel4'
enableIsolateSelect(modelPanel)

cmds.select('|stage1|stageShape1,/pSphere1')
cmds.editor(modelPanel, edit=True, updateMainConnection=True)
cmds.isolateSelect(modelPanel, loadSelected=True)

cmds.refresh()

self.assertSnapshotClose("isolateSelectWithUsdLighting" + ".png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

# Disable the isolate selection.
disableIsolateSelect(modelPanel)

cmds.refresh()

if __name__ == '__main__':
fixturesUtils.runTests(globals())
Loading