Reputation: 7925
What is AABB? A king of preview-collision before the real collision detection (I mean, the accurate one)?
I displayed the debug shapes and set up b2DebugDraw.e_aabbBit
flag in order to see it in action. I put a simple box falling, and when the box hit the ground, the AABB frame is completely different.
Upvotes: 1
Views: 966
Reputation: 3123
I think the other respondent already addressed what an AABB is. This response adds to their answer by explaining why the AABB you've drawn could be bigger and of different shape.
The AABB that's being displayed here looks like an AABB calculated for a square that's been dropped onto the green surface. That would at least explain why the AABB is bigger and why the AABB isn't the same shape.
Here's why...
While an AABB can serve as a minimally enclosing axis-aligned bounding box for any shape, Box2D also uses AABBs that encompass some movement and some additional wiggle room for future movement.
Take void b2Fixture::CreateProxies(b2BroadPhase* broadPhase, const b2Transform& xf)
for example. Here Box2D calculates AABBs using the shape's ComputeAABB
method which basically just calculates the minimal enclosure. This method is called for every "child" shape when first creating a new fixture (where any shape may be composed of 1 or more sub-shapes that are called "child" shapes).
OTOH, take a look at void b2Fixture::Synchronize(b2BroadPhase* broadPhase, const b2Transform& transform1, const b2Transform& transform2)
. This method is invoked from calling the world step method which calls it for all bodies that may have moved. When it calculates AABBs, it:
void b2AABB::Combine(const b2AABB& aabb1, const b2AABB& aabb2)
), and finallybroadPhase->MoveProxy(proxy->proxyId, proxy->aabb, displacement)
which adds some predictive room to each AABB.So as to why specifically the AABB drawn could be bigger and of different shape: step 3 often results in an AABB enlarged to hold most of the entire sweep of the child shape, and step 4 results in an AABB that's further extended on all sides by b2_aabbExtension
and additionally extended in the direction of travel (by b2_aabbMultiplier * displacement
).
Hope this helps!
Upvotes: 2
Reputation: 1
Well, axis-aligned bounding box is a... simple box :) You didn't give me any fundamentals regarding your project though. Anyway, the bounding box is just a math box, that is able to describe any physical body in three dimensions.
Just try to wrap your body with many boxes and you'll find out that it's sufficient to cover all the physics. It is used in games heavily because of its simplicity. You may do the same things on sphere-models, but with more complicated shapes you get more complicated math, then you get more overload which is too much for current CPU (including gpu).
But totally, there is nothing to explaing, concerning you won't need some maths. It's a simple box that is used to compare collision with another AABB, including help of triangle "normals" and "matrix" transformations.
Upvotes: 0