From c3beb64961036cb6f86fc5a96612b6ef0e5117e5 Mon Sep 17 00:00:00 2001 From: rzulak Date: Mon, 27 Apr 2020 13:00:28 -0700 Subject: [PATCH 1/2] Fix object framing for sub-trees. --- lib/mayaUsd/ufe/UsdObject3d.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/mayaUsd/ufe/UsdObject3d.cpp b/lib/mayaUsd/ufe/UsdObject3d.cpp index e147aedaa9..41a180fad5 100644 --- a/lib/mayaUsd/ufe/UsdObject3d.cpp +++ b/lib/mayaUsd/ufe/UsdObject3d.cpp @@ -91,10 +91,9 @@ Ufe::BBox3d UsdObject3d::boundingBox() const // Would be nice to know if the object extents are animated or not, so // we can bypass time computation and simply use UsdTimeCode::Default() // as the time. - TfTokenVector purposes{UsdGeomTokens->default_}; - UsdGeomBBoxCache bboxCache(getTime(sceneItem()->path()), purposes); - auto bbox = bboxCache.ComputeLocalBound(fPrim); - auto range = bbox.GetRange(); + + auto bbox = UsdGeomImageable(fPrim).ComputeUntransformedBound(getTime(sceneItem()->path()), UsdGeomTokens->default_); + auto range = bbox.ComputeAlignedRange(); auto min = range.GetMin(); auto max = range.GetMax(); return Ufe::BBox3d(toVector3d(min), toVector3d(max)); From fbdadae5190c0c6e09c3a63343b4048875b748f3 Mon Sep 17 00:00:00 2001 From: rzulak Date: Thu, 30 Apr 2020 17:09:29 -0700 Subject: [PATCH 2/2] Add test --- test/lib/ufe/testObject3d.py | 21 ++++++++++++++++++++- test/lib/ufe/ufeTestUtils/testUtils.py | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/test/lib/ufe/testObject3d.py b/test/lib/ufe/testObject3d.py index 561027ec65..1a1c3ab3d8 100644 --- a/test/lib/ufe/testObject3d.py +++ b/test/lib/ufe/testObject3d.py @@ -18,7 +18,7 @@ from ufeTestUtils import mayaUtils from ufeTestUtils import usdUtils -from ufeTestUtils.testUtils import assertVectorAlmostEqual +from ufeTestUtils.testUtils import assertVectorAlmostEqual, assertVectorEqual import ufe @@ -100,6 +100,7 @@ def testBoundingBox(self): proxyShapePathSegment = mayaUtils.createUfePathSegment( proxyShapeMayaPath) + ####### # Create a UFE scene item from the sphere prim. spherePathSegment = usdUtils.createUfePathSegment('/parent/sphere') spherePath = ufe.Path([proxyShapePathSegment, spherePathSegment]) @@ -115,6 +116,24 @@ def testBoundingBox(self): assertVectorAlmostEqual(self, ufeBBox.min.vector, [-1]*3) assertVectorAlmostEqual(self, ufeBBox.max.vector, [1]*3) + ####### + # Create a UFE scene item from the parent Xform of the sphere prim. + parentPathSegment = usdUtils.createUfePathSegment('/parent') + parentPath = ufe.Path([proxyShapePathSegment, parentPathSegment]) + parentItem = ufe.Hierarchy.createItem(parentPath) + + # Get its Object3d interface. + parentObject3d = ufe.Object3d.object3d(parentItem) + + # Get its bounding box. + parentUFEBBox = parentObject3d.boundingBox() + + # Compare it to sphere's extents. + assertVectorEqual(self, ufeBBox.min.vector, parentUFEBBox.min.vector) + assertVectorEqual(self, ufeBBox.max.vector, parentUFEBBox.max.vector) + + + ####### # Remove the test file. os.remove(usdFilePath) diff --git a/test/lib/ufe/ufeTestUtils/testUtils.py b/test/lib/ufe/ufeTestUtils/testUtils.py index 0dbece9f57..2265a32c01 100644 --- a/test/lib/ufe/ufeTestUtils/testUtils.py +++ b/test/lib/ufe/ufeTestUtils/testUtils.py @@ -21,3 +21,7 @@ def assertVectorAlmostEqual(testCase, a, b, places=7): for va, vb in zip(a, b): testCase.assertAlmostEqual(va, vb, places) + +def assertVectorEqual(testCase, a, b): + for va, vb in zip(a, b): + testCase.assertEqual(va, vb)