Jump to content
  • Advertisement
Sign in to follow this  
Kurt-olsson

Recursive collision response

This topic is 2565 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

Ok, i am trying to get sliding to work. It is in 2D and i have 3 lines, both with different angles.

My plan is to:

1 Calculate sphere position against all lines with origin velocity.
2 Get the time of t for each lines, 1 = no collision and other collision = true
3 If no collision occur, just move the sphere
4 If a collision occur: Move sphere to the collision point - radius (push the circle out from the line)
5 Recalculate the velocity (calculate sliding plane and set sliding velocity as the new vector)
Repeat step 1 with new velocity and new position of sphere.


If number of reccursions go over lets say 3-4 then we probably is in a corner, just take away velocity and move back to last safe place.


I cant get this to work! i have tried thousands of different approaches and there is always some jittering in the corners.

Does anyone have good code / real or pseudo that does the collision routine recursive? Because i do it recursive i get "not responding" 1000 times and i have no more patience with this method.


Can´t you do something like check for collision and time against all lines and then create some list with all the lines that are intersecting and treat all these items one time for the sphere? adding sliding vectors together etc?

Share this post


Link to post
Share on other sites
Advertisement
Hi there,

When writing recursions, do you by any chance mean iterations?

I've had the same problem with a 2d line - circle collision physics simulation. In the first version I did as you do: if a circle collided with a line or another circle, I moved them apart (changed position directly) so there was no collision. Besides that, the simulation worked with impulses, which also made it jittery and unstable. I got rid of the jittering by changing the simulation, so that in stead of using direct position manipulation and impulses, I used forces to move the objects apart (circle - circle and circle - line). I simply applied a special form of damped spring. Then all jittering disappeared, and with just 4-8 iterations it runs very nicely.

I have a code sample, but it is messy and written in basic dialect. If you would like to look at it, I can post it here.

Cheers,
Mike


Ok, i am trying to get sliding to work. It is in 2D and i have 3 lines, both with different angles.

My plan is to:

1 Calculate sphere position against all lines with origin velocity.
2 Get the time of t for each lines, 1 = no collision and other collision = true
3 If no collision occur, just move the sphere
4 If a collision occur: Move sphere to the collision point - radius (push the circle out from the line)
5 Recalculate the velocity (calculate sliding plane and set sliding velocity as the new vector)
Repeat step 1 with new velocity and new position of sphere.


If number of reccursions go over lets say 3-4 then we probably is in a corner, just take away velocity and move back to last safe place.


I cant get this to work! i have tried thousands of different approaches and there is always some jittering in the corners.

Does anyone have good code / real or pseudo that does the collision routine recursive? Because i do it recursive i get "not responding" 1000 times and i have no more patience with this method.


Can´t you do something like check for collision and time against all lines and then create some list with all the lines that are intersecting and treat all these items one time for the sphere? adding sliding vectors together etc?

Share this post


Link to post
Share on other sites
yeah some samples would be nice.

the problem i have is so irritating, because i can make a sphere slide on ONE triangle-plane in 3D and 2d flawless with perfect sliding. But as soon as i involve multiple planes then the corners always have some bug. If obtuse corners are working then obtuse arent and oppisit.

i don´t understand why taking the collision closest to you and move the spere close to the intersection (but not too close) and then make new velocity according to sliding plane won´t work with multiple planes/lines?


there is something with my recursion/iterations that is not good. if i can get that part going i think the problem is solved.

Question: If you come in with velocity X and you have a hit at time t (lets say 0.8) with what speed do you calculate sliding plane?

v-= p.norm dot (v,p.norm);

Should i take the v-speed and multiply it by 0.8 or use the origin velocity? I dont think it maters, this just makes up how much sliding there will be?

Question? Should i update the sphere position between each iteration or just calculate the end-pos where i move the sphere one time?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!