Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: CircleShape Disappearing  (Read 1327 times)

0 Members and 1 Guest are viewing this topic.

drguildo

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
CircleShape Disappearing
« on: November 24, 2012, 10:36:23 pm »
I'm having trouble with CircleShapes I've define disappearing. I've uploaded my code to:

https://thunked.org/p/view/pub/3567icpoz

You use the Left and Right keys to rotate the line in the middle of the screen and the shapes follow the end of it. After the circles have converged on the line and doing this for a few seconds, the shapes disappear.

I have an ATI card and somebody on the IRC channel with an NVIDIA card also tested and was able to reproduce the problem. Can anybody explain why this is happening?

Thanks.

cf

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: CircleShape Disappearing
« Reply #1 on: November 24, 2012, 11:11:38 pm »
float xdiff = pos.x - v.x;
...
float newx = pos.x - (fabs(xdiff) * (1 / xdiff) * speed);
 
xdiff probably becomes zero when the circles converge, and newx subsequently explodes because of the division.
Why you don't get an exception I have no idea (assuming this is the problem).

Edit: Yes, this seems to be the case. Also, its seemingly common to not generate an exception on floating-point division by zero, but instead set it to a NaN-value. See this article and this FAQ for more information.

Finally, you could've probably found this out yourself with a little effort --- maybe printing the positions after each frame too see where they were. You'll usually get yelled at for simply posting a wall of code and expecting others to find the problem (or get no help), but I guess I was in a helping mood today. :P
« Last Edit: November 24, 2012, 11:35:50 pm by cf »

 

anything