Jump to content
  • Advertisement
Sign in to follow this  
too_many_stars

3D collision question

This topic is 571 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,

 

Right now I am reading 3D math primer by Fletcher Dunn and Ian Parberry and looking at their AABB3 class (around page 304).

 

The way they choose to represent their AABB3 class is with:

 

Vec3 min,

Vec3 max

 

Note there's no position

 

To move the verts of the  AABB around, they use a 4x3 matrix which means that the AABB resides exclusively in local space.

 

However, the collision tests for the AABB class such as

 

bool AABB3::intersectSphere(const Vec3& center, float radius)const    and

bool AABB3::intersectAABB(args...)

 

in the implemention detail all appear to be in local space.

 

Having come from the 2D realm, where I handled all collisions, including contact points, normals, penetration etc in world space, is it better in 3D to do all this in local space?

 

Perhaps I am missing something as well (it would not be the first time)

 

 

Thanks,

 

Mike

Edited by too_many_stars

Share this post


Link to post
Share on other sites
Advertisement

As long as the other sphere/AABB is in the local space of the first AABB there is no problem in the code.

 

Contact impulse/force handlers assume the contact points and normals are in the same space. Usually in world space.

 

Contact points and normals can be transformed to the local space of the shapes before performing position correction iteratively. Each iteration the positions and orientations of the bodies are corrected by some ammount. Of course after this the contact points and normals might have changed so in a next iteration we need to rebuild contact points and normals. However, re-run collision detection each iteration can become pretty expensive. So an efficient method, but not as accurate as the former, is to put contact points in the local space before iterating, and then transform the local contact points and normals using the transforms in the current iteration.

Edited by Irlan Robson

Share this post


Link to post
Share on other sites

Thanks Irlan,

 

That's what I suspected, that most of the work is done in world space. Porting over to 3D from 2D, I just want to make sure I understand the foundations before I get too far along and then have to change the entire collision system.

 

Mike

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!