Jump to content

  • Log In with Google      Sign In   
  • Create Account


AABB format


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 ultramailman   Prime Members   -  Reputation: 1467

Like
0Likes
Like

Posted 17 April 2013 - 07:57 PM

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?

Sponsor:

#2 Hodgman   Moderators   -  Reputation: 24202

Like
4Likes
Like

Posted 17 April 2013 - 08:35 PM

It depends on the functions that are operating on them.
If you're using the first, but are computing 'x+width', then maybe you should be using the second.
If you're using the second, but are computing 'right-left', then maybe you should be using the first.

#3 0r0d   Members   -  Reputation: 797

Like
1Likes
Like

Posted 17 April 2013 - 10:19 PM

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.



#4 Khatharr   Crossbones+   -  Reputation: 2619

Like
0Likes
Like

Posted 17 April 2013 - 11:33 PM

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.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#5 ultramailman   Prime Members   -  Reputation: 1467

Like
0Likes
Like

Posted 18 April 2013 - 02:19 AM

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.

#6 Krohm   Crossbones+   -  Reputation: 2755

Like
0Likes
Like

Posted 19 April 2013 - 01:48 AM

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.

I hope this will help you in taking a decision.



#7 ultramailman   Prime Members   -  Reputation: 1467

Like
0Likes
Like

Posted 19 April 2013 - 02:13 AM

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.
I hope this will help you in taking a decision.


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, 19 April 2013 - 02:15 AM.


#8 Krohm   Crossbones+   -  Reputation: 2755

Like
0Likes
Like

Posted 19 April 2013 - 02:24 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS