Jump to content
  • Advertisement
terrysworkstations

Precision Problems with bouding sphere

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

I tried to make two spheres with bounding sphere to detect collision so they stop when they collide. But it seems that im having a precision issue. They stey stuck together because of small decimal keeping it stuck. Is there a way around this? Since they are in a 3d space, adding or subtracting a little off seems impossible and expensive. How can I solve these precision issues?

 

The code I used.

oldleftright = leftright, oldupdown = updown;

if(GetAsyncKeyState(VK_RIGHT))
    leftright += 0.0001;
if(GetAsyncKeyState(VK_LEFT))
    leftright -= 0.0001;
if(GetAsyncKeyState(VK_DOWN))
    updown -= 0.0001;
if(GetAsyncKeyState(VK_UP))
    updown += 0.0001;

collide = test.Intersect(test2);
if (collide)
{
    leftright = oldleftright;
    updown = oldupdown;
}
collide = false;

 

Share this post


Link to post
Share on other sites
Advertisement

  • 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!