Jump to content

  • Log In with Google      Sign In   
  • Create Account


hard collisions vs. soft collisions


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
4 replies to this topic

#1 too_many_stars   Members   -  Reputation: 209

Like
0Likes
Like

Posted 28 April 2014 - 10:41 AM

Hi guys,

 

In one of my many ventures into attempting to understand collision detections better, I came upon few posts that mentioned one should not do a hard collision, that is, move the object, detect if it collides, and then move it back so it's out of range. Rather, a programmer should try to predict the collision, and not let it happen in the first place.

 

Of course as a noob, I have been using the former method extensively as it's intuitive (and probably easier to code).

 

My question is, what's the advantage of using the predictive model? What does a game or a physical simulation care whether you adjust a position post collision vs. predictive modelling?

 

Thanks,

 

Mike



Sponsor:

#2 SeraphLance   Members   -  Reputation: 1316

Like
4Likes
Like

Posted 28 April 2014 - 10:57 AM

The biggest problem with that sort of collision detection is fast, small objects.  If two objects move through eachother in a single frame, reactive detection like that just doesn't work.  Even if they don't completely pass through one another, if they pass through the centers, your collision response will be reversed as well.



#3 cozzie   Members   -  Reputation: 1583

Like
1Likes
Like

Posted 28 April 2014 - 12:38 PM

To be honest, predictive doesn't sound that difficult compared to reactice (have to get into it myself though).

Idea:
- possiblePosition = currentPosition + requestedMovement
- check possiblePosition for collisions
- if no collisions newPosition = possiblePosition

#4 SeraphLance   Members   -  Reputation: 1316

Like
2Likes
Like

Posted 28 April 2014 - 12:51 PM

To be honest, predictive doesn't sound that difficult compared to reactice (have to get into it myself though).

Idea:
- possiblePosition = currentPosition + requestedMovement
- check possiblePosition for collisions
- if no collisions newPosition = possiblePosition

 

You need a bounding volume that encloses both the original position and the target position, or some other means of checking intermediate points.  Rendering and updating happens on a per-frame basis, but that doesn't mean the simulation is bound to frames.  Once the collision has "happened" on a frame, you've possibly lost information you need to cause a proper collision response.

 

A naive collision detection algorithm can also run into really bizarre cases where your objects almost super-impose on a frame, and reflection + an object slowing down causes them to still coincide on the next frame.  What do you do then?  Do you create a data structure to keep "already collided flags" on every object pair?  It just gets messy.


Edited by SeraphLance, 28 April 2014 - 12:53 PM.


#5 Strewya   Members   -  Reputation: 1355

Like
2Likes
Like

Posted 29 April 2014 - 01:29 AM

To be honest, predictive doesn't sound that difficult compared to reactice (have to get into it myself though).

Idea:
- possiblePosition = currentPosition + requestedMovement
- check possiblePosition for collisions
- if no collisions newPosition = possiblePosition

That's the same thing as reactive, you're just 'reacting' to a position before you set it, but aren't doing anything different.

Unless, ofcourse, your 'check collisions' line implied actual prediciton, in which case your idea is missing the key ingredient :)

As Seraph said, you'd need a bounding volume which is then tested against other objects for collision, if the collision is found then you continue to a more detailed test (since this can be just an AABB test).


devstropo.blogspot.com - Random stuff about my gamedev hobby





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