Followers 0

# AABB format

## 7 posts in this topic

I've seen these two types of AABB:
struct aabb1{
int x, y;
int width, height;
}

struct aabb2{
int left;
int up;
int right;
int down;
}

I am used to the first type (it's what SDL uses), but recently I've encountered the second type, and the symmetry of it seems pretty attractive.

Which format for AABB is more commonly used?
0

##### Share on other sites

I've seen these two types of AABB:

struct aabb1{
int x, y;
int width, height;
}

struct aabb2{
int left;
int up;
int right;
int down;
}

I am used to the first type (it's what SDL uses), but recently I've encountered the second type, and the symmetry of it seems pretty attractive.

Which format for AABB is more commonly used?

Whichever is more appropriate to your needs.

1

##### Share on other sites
The first kind can be moved around more easily, the second kind skips a little extra math during collision detection.

You can more or less pick one and stick with it. Hodge hit it on the head, really.
0

##### Share on other sites
Oh, good point. They are kind of like the complement of the each other, and I just can't have the best of both worlds, eh.
0

##### Share on other sites

Maybe it will help you to know how Bullet deals with the problem.

The box itself only has "half-dimensions" and is always origin-centered. Somithing like

struct AABB {
int hwidth, hheight;
}; 

This box is used to create rigid bodies, which provide a transform. In line of concept, it's like

AABB box(2, 3);
int pos[2] = {52, 37};
CollisionBody *cb = NewCollisionBody(box, pos);


I'm omitting rotations to make this super-extra-easy to understand.

0

##### Share on other sites

Maybe it will help you to know how Bullet deals with the problem.
The box itself only has "half-dimensions" and is always origin-centered. Somithing like

struct AABB {
int hwidth, hheight;
}; 

This box is used to create rigid bodies, which provide a transform. In line of concept, it's like
AABB box(2, 3);
int pos[2] = {52, 37};
CollisionBody *cb = NewCollisionBody(box, pos);


I'm omitting rotations to make this super-extra-easy to understand.

Wow, another way to represent AABB. Thanks for sharing.

Is the AABB also separated into "position" and "description" inside the CollisionBody object, or are they only used as parameters for the object creation? Edited by ultramailman
0

##### Share on other sites

Bullet has two separated notions of Collision Shapes and Rigid Bodies (previously, Collision Objects).

While the CS itself is AABB, after using it for a rigid body, it is oriented.

The rigid body contains a pointer to the shape used to create it and a transform, besides other things such as mass and the current state. So, yes, I'd say the information is present and separated.

There are another few creation parameters which are not stored in the rigid body either, but I guess they're not relevant for the discussion.

0

## Create an account

Register a new account