Spatial hash bug is back...
Posted: Fri Sep 05, 2014 12:42 pm
Hi Scott. This bug seems to have disappeared for a *very* long time, and now its suddenly returned somehow, though I do have a bit more information about symptoms this time, and many things that I am certain are correct. I'm still using the same version of chipmunk that I was when this bug first occurred about a year ago.
So here's a video of the bug in action:
<iframe width="640" height="360" src="//www.youtube.com/embed/z3cpvsb8Ce8" frameborder="0" allowfullscreen></iframe>
EDIT: ok.... I can't seem to figure out how to post a video, so here's the raw link: https://www.youtube.com/watch?v=z3cpvsb8Ce8
What's happening is that the turret is waiting for the player to enter to enter one of 4 lines of fire (up, right, left or down). When he does, a ray is cast from the center of the turret to the players center. If there are any physics shapes in the way, the turret does not fire. In the first part of the video, this works correctly.
In the second part, after the edit, the turret is moved to where its y position is at 0, and so the ray is cast from y=0. The x coordinate seems to be irrelevant. When the start point of the segment query is on the y axis, tha'ts when it seems to fail. Interestingly, it seems that while casting a ray downward from y=0 fails, casting a ray up still succeeds.
Another thing to note is that the ray's direction is *not* straight, but rather pointed towards the player, so then the endpoint of the segment does not seem to matter as much. Maybe the quadrant it's in matters? I really don't know.
Again, with no other changes to the code at all, disabling the spatial hash makes everything work just fine, but the amount of segment queries that I'm doing becomes prohibitively expensive .
Here's a link to the old thread describing the problem, which contains an even older link to the original thread which brought it up.
So here's a video of the bug in action:
<iframe width="640" height="360" src="//www.youtube.com/embed/z3cpvsb8Ce8" frameborder="0" allowfullscreen></iframe>
EDIT: ok.... I can't seem to figure out how to post a video, so here's the raw link: https://www.youtube.com/watch?v=z3cpvsb8Ce8
What's happening is that the turret is waiting for the player to enter to enter one of 4 lines of fire (up, right, left or down). When he does, a ray is cast from the center of the turret to the players center. If there are any physics shapes in the way, the turret does not fire. In the first part of the video, this works correctly.
In the second part, after the edit, the turret is moved to where its y position is at 0, and so the ray is cast from y=0. The x coordinate seems to be irrelevant. When the start point of the segment query is on the y axis, tha'ts when it seems to fail. Interestingly, it seems that while casting a ray downward from y=0 fails, casting a ray up still succeeds.
Another thing to note is that the ray's direction is *not* straight, but rather pointed towards the player, so then the endpoint of the segment does not seem to matter as much. Maybe the quadrant it's in matters? I really don't know.
Again, with no other changes to the code at all, disabling the spatial hash makes everything work just fine, but the amount of segment queries that I'm doing becomes prohibitively expensive .
Here's a link to the old thread describing the problem, which contains an even older link to the original thread which brought it up.