Skip to content

Commit

Permalink
Merge pull request #1043 from marktucker/dev_fix_makevisible
Browse files Browse the repository at this point in the history
Fix a bug in UdsGeomImageable::MakeVisible

(Internal change: 2027610)
  • Loading branch information
pixar-oss committed Dec 4, 2019
2 parents 0f61343 + b588eda commit 6ae6939
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
12 changes: 12 additions & 0 deletions pxr/usd/usdGeom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pxr_test_scripts(
testenv/testUsdGeomConsts.py
testenv/testUsdGeomCurves.py
testenv/testUsdGeomExtentTransform.py
testenv/testUsdGeomImageable.py
testenv/testUsdGeomMesh.py
testenv/testUsdGeomMetrics.py
testenv/testUsdGeomMotionAPI.py
Expand Down Expand Up @@ -201,6 +202,10 @@ pxr_install_test_dir(
DEST testUsdGeomComputeAtTime
)

pxr_install_test_dir(
SRC testenv/testUsdGeomImageable
DEST testUsdGeomImageable)

pxr_register_test(testUsdGeomBasisCurves
PYTHON
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdGeomBasisCurves"
Expand Down Expand Up @@ -329,3 +334,10 @@ pxr_register_test(testUsdGeomComputeAtTime
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdGeomComputeAtTime"
EXPECTED_RETURN_CODE 0
)

pxr_register_test(testUsdGeomImageable
PYTHON
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdGeomImageable"
EXPECTED_RETURN_CODE 0
)

4 changes: 2 additions & 2 deletions pxr/usd/usdGeom/imageable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ _MakeVisible(const UsdPrim &prim, UsdTimeCode const &time,
if (UsdGeomImageable imageableParent = UsdGeomImageable(parent)) {

// Change visibility of parent to inherited if it is invisible.
if (*hasInvisibleAncestor ||
_SetInheritedIfInvisible(imageableParent, time)) {
if (_SetInheritedIfInvisible(imageableParent, time) ||
*hasInvisibleAncestor) {

*hasInvisibleAncestor = true;

Expand Down
41 changes: 41 additions & 0 deletions pxr/usd/usdGeom/testenv/testUsdGeomImageable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/pxrpythonsubst
#
# Copyright 2019 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.

from pxr import Usd, UsdGeom
import unittest

class TestUsdGeomImageable(unittest.TestCase):
def test_MakeVisible(self):
testFile = "AllInvisible.usda"
s = Usd.Stage.Open(testFile)
bar2 = UsdGeom.Imageable(s.GetPrimAtPath("/foo/bar2"))
thing1 = UsdGeom.Imageable(s.GetPrimAtPath("/foo/bar1/thing1"))
thing2 = UsdGeom.Imageable(s.GetPrimAtPath("/foo/bar1/thing2"))
thing1.MakeVisible()
self.assertEqual(bar2.ComputeVisibility(), UsdGeom.Tokens.invisible)
self.assertEqual(thing1.ComputeVisibility(), UsdGeom.Tokens.inherited)
self.assertEqual(thing2.ComputeVisibility(), UsdGeom.Tokens.invisible)

if __name__ == "__main__":
unittest.main()
31 changes: 31 additions & 0 deletions pxr/usd/usdGeom/testenv/testUsdGeomImageable/AllInvisible.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#usda 1.0
def Xform "foo"
{
token visibility = "invisible"

def Xform "bar1"
{
token visibility = "invisible"

def Sphere "thing1"
{
token visibility = "invisible"
}

def Sphere "thing2"
{
token visibility = "invisible"
}
}

def Xform "bar2"
{
token visibility = "invisible"

def Sphere "thing"
{
token visibility = "invisible"
}
}
}

0 comments on commit 6ae6939

Please sign in to comment.