Help with Collision Detection..(i'm almost there)

Posts: 21
Joined: 2008.05
Post: #1
I've been working from different sources on the web and I'm almost there.

I have some animated models. I'm calculating the Bounding Sphere and AABB (for each frame) and storing it.

When I move an object I store it's old position, then...
- Do a Sphere collision test.
- If that hits... I rotate the AABB and then make a new AABB from the 8 corners (making a slightly bigger AABB). Then check if that hits.
- If so... put the object to the position it was just in...

This is workingish...problem is, I'm getting objects sort of locked in each others boxes. If I run into an object and then start rotating, my box can expand and we get locked in.

Also, we're not really exactly touching... Anyone have a suggestion on the next step?
- Should I be using some other sort of collision detection?
- Recalculate a new AABB?
- Am I doing something embarrassingly wrong.


Edit: Added screen shot below...
[Image: LHDjZ.png]
Quote this message in a reply
Posts: 1,560
Joined: 2003.10
Post: #2
(Jun 29, 2011 10:43 AM)carmine Wrote:  - If so... put the object to the position it was just in...

This may be the cause of your problems. For good collision response, you'll generally want to interpolate between the old and new positions to find the closest nonintersecting position and push your object back out only that far, update their velocities as appropriate, then subdivide your timeslice and run collision detection again on the remaining portion.

An example: A moving point is positioned at {0, 0} with a velocity of {4, 2}. There's a solid vertical wall at x=3. If the point moves a full step, it will intersect the wall. In the first 75% of the timeslice, the point does not intersect the wall, so you can interpolate its resulting position to {3, 1.5}. From there, assuming the wall has no friction or elasticity, the point's velocity would be changed to {0, 2}. You'd then process the remaining 25% of the timeslice with the new position and velocity (multiplied by the timeslice fraction), moving the point to {3, 2}.

I hope that's not too confusing. The above is only basic principle and would have to be modified for your particular situation, but maybe it'll at least give you something to go on.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Optimize the collision detection alaslipknot 1 2,669 May 12, 2013 08:02 PM
Last Post: SethWillits
  Collision detection tutorial ThemsAllTook 7 22,572 Nov 5, 2011 05:20 PM
Last Post: SethWillits
  Time Delta, collision detection mk12 19 15,447 Sep 8, 2010 06:40 PM
Last Post: AnotherJake
  Collision detection for pinball game johncmurphy 0 4,744 Sep 6, 2009 02:46 PM
Last Post: johncmurphy
  Phases of Collision Detection Ingemar 5 7,540 Aug 24, 2009 06:11 AM
Last Post: Skorche