Jump to content
  • Advertisement
Sign in to follow this  
vo1d

Sphere collision response problem

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

Hi, for sphere collision response i use this code: vec x_axis = p2->pos - p1->pos; x_axis.norm(); vec U1x = x_axis * (x_axis * p1->vel); vec U1y = p1->vel - U1x; vec U2x = x_axis * (x_axis * p2->vel); vec U2y = p2->vel - U2x; vec e1 = U1x * p1->mass; vec e2 = U2x * p2->mass; vec e3 = (U1x - U2x) * p2->mass; vec e4 = (U2x - U1x) * p1->mass; vec e12 = e1 + e2; float odm = 1.0f / (p1->mass + p2->mass); vec V1 = U1y + (e12 - e3) * odm; vec V2 = U2y + (e12 - e4) * odm; p1->vel = V1; p2->vel = V2; it works good, but there is one problem: sometimes when velocity is small first sphere connects to second 1) how to fix this problem? 2) maybe there are faster method to do it?

Share this post


Link to post
Share on other sites
Advertisement
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!