hard collisions vs. soft collisions

Started by
3 comments, last by Strewya 9 years, 11 months ago

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

Advertisement

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.

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

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

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.

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

This topic is closed to new replies.

Advertisement