computer-graphics-bounding-volume-hierarchy icon indicating copy to clipboard operation
computer-graphics-bounding-volume-hierarchy copied to clipboard

AABB Tree Infinite Recursion

Open aiwen324 opened this issue 5 years ago • 1 comments

Hi, I encountered a problem that AABB tree includes all objects into its left node and the bounding box never shrinks (Since there is a large object on the midpoint along the longest axis). How should we handle this case? Here is some output (print msg). Maybe I misunderstand the initialization algorithm?

objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000

aiwen324 avatar Oct 05 '19 21:10 aiwen324

Remember that it's okay for sibling AABBs to overlap spatially. A big object that's in both halves of the AABB doesn't necessarily mean that every object must be in the same subtree. If you find this happening, consider making an alternative partitioning strategy in this special case.

abhimadan avatar Oct 05 '19 21:10 abhimadan