Notifications
Clear all

[Closed] [SDK] GetWorldBoundBox fails for editable poly / editable mesh

Hi all! First post on the forums – looks like an awesome place!

I’m running into weird issue writing a Max plugin. I’m trying to get the bounding box & pivot information for objects in the scene. The pivot info is always fine, however the bounding box returns garbage info in some cases:

Standard Primitive: works fine
Converted to Editable Poly: doesn’t work
Converted to Editable Mesh: doesn’t work
Converted to Patch: works fine

This also happens when I import from an fbx: since it comes in as an Editable Mesh, I can’t get the bounding box.

Instead of the real bounding box, it always returns an ‘empty’ bounding box (center at 0,0,0, width = -infinity)

I’ve tried numerous things to get the data for editable polys / meshes: getting the object implementation as a TriObject, going through IMeshSelectData, etc. I always get the same, incorrect bounding box.


Is this expected? Is there something else I need to do, maybe with the modifier stack, to be able to get the bounding box?

Is this a really weird bug?

3 Replies

Alright, after at least half-a-day of researching this, I finally figured it out! It was simple trial and error, but eventually I found that if I cast the object to ITriObject or IPolyObject (depending on what it is), I get access to the underlying mesh, which has its own bounding box method:

(GeomObject as ITriObject).Mesh.GetBoundingBox(TM)

This returns the local space bounding box by default, but you can pass it:

TM = GeomObject.WorldSpaceObjectNode.GetObjectTM(0, null)

and that appears to return the correct world-space bounding box!

I still think it’s very strange that the object returns an empty bounding box, requiring you to go to the mesh and get its bounding box there. Since the IObject is a container for the IMesh, shouldn’t it return the mesh’s bounding box? Shouldn’t you always be able to get an object’s bounding box from IBaseObject without having to probe whether it’s an ITriObject or IPolyObject?

Is this a bug? Should I submit it to Autodesk?

GetWorldBoundBox is provided by objects and modifiers to let the system know where to update the screen when the user does something with an object (when you see the ghosting lines it’s because it’s not been calculated properly) If you want to get an objects bounding box use Object::GetDeformBBox

Thank you Klvnk! That does appear to be what I need – I will give it more testing!

It’s definitely a bit counter-intuitive that the “real” bounding box would be something called the deform box…