Creating an AABB is simple. But, if the 3d model has become rotated, how do you update the AABB to become accurate? Or is the AABB supposed to be in local space?
|
Axis Aligned Bounding Box means the box itself is always on the same orientation. To update the AABB you will need to recreate it each time the model rotates, and move it if the models positions changes. The box will change shape and size depending on the rotation and the model you use. If you want to have a rotating collision box than that matches up with the model, then that is completely different than an AABB, and you will need to look into the physics of your engine for that. Edit: If you want to update the AABB quickly, but with less accuracy, just pass the points of the original bounding box instead of the entire model. The bounding box won't be perfectly tight, but it is guaranteed to have the entire model inside of it. Here is an article describing how to achieve this. One thing I would like to add that is not in the article would be to create a few fully calculated bounding boxes at 10 rotations and when recalculating, use the bounding box that is closest to the current rotation, that should improve the tightness of the bounding box a lot without creating that much more overhead. |
|||||||||||||
|
|
From wikipedia:
If your model can be at any rotation, perhaps a bounding sphere is in fact a better bounding volume to be using? Bounding spheres are typically cheaper checks and many systems use several bounding volumes in preference order e.g. always check sphere, if that passes then check AABB, if that passes then ... |
|||
|
|