Jump to content
  • Advertisement
Sign in to follow this  

Sphere collision response problem

This topic is 5187 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
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!