ComputeLocalBound does not work the way it should?! Please help

Hello,

I have the following Structure:

PrimA - XForm (with rotation of 45 deg. on y-axis)
-PrimB - XForm (with translation of 0.5 on y-axis)
–Geometry - XForm (not transformation)
—Mesh - UsdMesh (a Box with size of 1 on all axis (-0.5 to 0.5)

Now I want the Boundingbox of PrimB in local space so I call ComputeLocalBound…

Perhaps I got something wrong, but the expected result should be -0.5 to 0.5 for X- and Z-axis and 0 to 1 on Y-axis.

But the result is:
min: {-0.70710678118654746, 0.0000000000000000, -0.70710678118654746}
max: {0.70710678118654746, 1.0000000000000000, 0.70710678118654746}

So the rotation from PrimA is still used. When removing the rotation on PrimA the result is as expected.

Can anybody explain why this happens and how I can get the bounds of a prim without the transformations from its parents?

Thank you very much for your help

I think you might want compute untranslated bound Universal Scene Description: UsdGeomImageable Class Reference

My understanding (might be incorrect) is that local bounds still includes all parent transforms minus any translations.

It might be useful though to have a flag on the compute local bounds to exclude any parent transforms at all or a different convenience method to get what you want. I think it would be a good request to file as an issue on the github repo (assuming my understanding is correct)

Thank you for your reply…

…I already tried ComputeUntranslatedBound. But that produces the exact same result (in this case) as ComputeLocalBound (wat is even stranger)

Hmm that is really odd. What USD version are you using? Would you be able to share a reproducible case?

The UsdGeomBBoxCache has logic in it that may seem unintuitive, but was based on Pixar pipeline experience getting sloppy bounds for years. In this case, what I think you maybe seeing is that all bboxes are placed (and importantly, combined, when computing aggregates) in an ancestor prim’s space. The space that we choose, if available is that of the closest containing “component” model, which gives us a tighter bound for the model as a whole, which is what we most often care about.

If there is no component model ancestor, it defaults to world space. If you fetch the raw range (rather than the alignedRange) from the BBox3d you get back, you’ll find the extent you’re expecting, whereas calling ComputeLocalBounds() and looking at range will still give transformed results.

Thank you for the reply, but I am not sure if I got you right…

Here is my code:
TfTokenVector tokens;

		tokens.push_back(TfToken("default"));

		UsdGeomBBoxCache bboxCache(UsdTimeCode::Default(), tokens);

		GfBBox3d nodeUntransformedBound = bboxCache.ComputeUntransformedBound(nodePrim.GetPrim());
		GfRange3d nodeUntransformedRange = nodeUntransformedBound.GetRange();

		GfVec3d nodeUntransformedRangeMin = nodeUntransformedRange.GetMin();
		GfVec3d nodeUntransformedRangeMax = nodeUntransformedRange.GetMax();

And this is the usd I use (nodePrim in the code above is /World/Root/LiveSessionRoot_0/LiveSessionRoot_0_0
):
BoundingTest.usda (5.8 KB)

And these are the results…

nodeUntransformedRangeMin:
{-0.70710678118654746, 0.0000000000000000, -0.70710678118654746}

nodeUntransformedRangeMax:
{0.70710678118654746, 1.0000000000000000, 0.70710678118654746}

Instead of 0.7xxx I would habe expected that this should be 0.5…

OK… when I set the kind-attribute of the node to “compoenet” I get the result I was expecting :slight_smile:

Thank you very very much for your support

Ah yes, apologies - in the “fall back to world space” case, the untransformed and transformed will be identical.