Page MenuHome

Geometry Nodes: Bounding Box Node
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Feb 15 2021, 5:59 AM.
Tokens
"Love" token, awarded by damian."Love" token, awarded by Shimoon."Like" token, awarded by PratikPB2123."Burninate" token, awarded by helloidonthaveanyideaformyusername."Love" token, awarded by Apofis."Love" token, awarded by victorlouis."Love" token, awarded by lone_noel."Love" token, awarded by TimBrown."Love" token, awarded by someuser.

Details

Summary

This patch adds a simple node to output the min and max of an axis aligned
bounding box for the geometry, including instances. The initial use case
I'm thinking about is a "bounding box boolean" node group, but I'm sure
there are others that wouldn't take too much imagination to come up with.
It's easy to imagine using this as a building block of more complex setups.


Diff Detail

Repository
rB Blender
Branch
geometry-nodes-bounding-box-node (branched from master)
Build Status
Buildable 12890
Build 12890: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Feb 15 2021, 5:59 AM
Hans Goudey (HooglyBoogly) created this revision.
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
  • Merge branch 'master' into geometry-nodes-bounding-box-node
  • Cleanup
Hans Goudey (HooglyBoogly) retitled this revision from WIP: Geometry Nodes: Bounding Box Node to Geometry Nodes: Bounding Box Node.Feb 20 2021, 1:38 AM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc
57

I wasn't sure if this should go here or in the geometry set code. I think it's a bit more specialized, so I put it here, and we can always move it if it's helpful elsewhere.

Can this be extended to support bounding spheres as well? (centroid and radius)

Great idea!

Also, less importantly, it's nice for once to see a node that doesn't have a geometry output socket.

Actually, I feel like it would be nice and would totally make sense to actually output the bounding box as geometry. At least, from the name of the node I would expect that and usually that is what you need anyways.

Hans Goudey (HooglyBoogly) planned changes to this revision.Feb 23 2021, 6:45 AM

Actually, I feel like it would be nice and would totally make sense to actually output the bounding box as geometry. At least, from the name of the node I would expect that and usually that is what you need anyways.

Yes, good point. It can output both for when you need the vectors too. I think I'll wait until we have a node that creates a cube primitive then, so I can just reuse the code and scale it properly here.

Yes, good point. It can output both for when you need the vectors too. I think I'll wait until we have a node that creates a cube primitive then, so I can just reuse the code and scale it properly here.

That sounds good to me!

hm, it make sense to make Boundbox output as a part of 'Object/Collection Info' Node?

hm, it make sense to make Boundbox output as a part of 'Object/Collection Info' Node?

Separating this functionality into a dedicated node makes sense to allow any (generated) geometry input and not require an object.
And adding this functionality to the object info node next to the dedicated bounding box node would be unnecessary in my opinion as it is not core functionality and can just as easily be achieved with the dedicated node.

  • Add box mesh output, update for changes in master

hm, it make sense to make Boundbox output as a part of 'Object/Collection Info' Node?

Separating this functionality into a dedicated node makes sense to allow any (generated) geometry input and not require an object.
And adding this functionality to the object info node next to the dedicated bounding box node would be unnecessary in my opinion as it is not core functionality and can just as easily be achieved with the dedicated node.

hm, i think you are right, it make sense, :)

Jacques Lucke (JacquesLucke) requested changes to this revision.Apr 1 2021, 5:19 PM

I think the min and max output should be zero vectors if there are no points.

This revision now requires changes to proceed.Apr 1 2021, 5:19 PM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
  • Output 0 if there was no bounding box computed

For meshes it looks all good to me now!

Maybe a bit of a niche use-case but I tested it with points and volumes as well.
I'm not sure how it should work for volumes, but right now it doesn't at all. I think a node that is in the Geometry category should also work on all Geometry component types.
It should probably just make the bounding box around the grids regardless of the content.

For points I found an interesting behaviour for a negative radius. I think having the bounding box affected by point radius makes sense, but having it shrink with negative radii is a bit strange. I'm not sure why those are even a thing to be completely honest.
I feel like a radius should be capped at 0. But that behaviour has to be consistent with the rest of Blender.

Thanks! Yes, we have to decide if the radius attribute should be clamped! That can be a separate patch though, should be pretty simple. If not, the boundbox code for points can just use the absolute value of the radius.

Looking at the volume bounding box computation, it looks like it would require some refactoring to work in this situation, since the cache of the boundbox is stored at the object level right now.
I agree this node should support it, but I would probably want to talk to @Jacques Lucke (JacquesLucke) before adding that myself.

This revision is now accepted and ready to land.Apr 5 2021, 12:20 PM
This revision was automatically updated to reflect the committed changes.

A followup patch to support instanced volumes is here: D10906