You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The annotated source says "If the sweep isn’t actually moving anywhere, just do a static test. It’s faster and will give us a better result for that case."
and then the code goes on to show:
if delta.x == 0 and delta.y == 0
sweep.pos.x = box.pos.x
sweep.pos.y = box.pos.y
sweep.hit = this.intersectAABB(box)
if sweep.hit?
sweep.time = sweep.hit.time = 0
else
sweep.time = 1
Shouldn't sweep.pos.x = box.pos.x actually be sweep.pos.x = this.pos.x? If the object isn't moving, why would the position be the object you are colliding with?
(BTW, this has been a great resource! I've ported it more or less directly to a single C header file along with the tests: https://github.com/sponge/sdlgame/blob/master/src/sweep.h it mostly seems to be working besides a couple of weird edge cases that I'm not sure are my fault or are present in the original. I won't make any claims about how good my C is, though!)
The text was updated successfully, but these errors were encountered:
@sponge First, apologies for taking so long to respond!
The sweep in this case is representative of the movement of "box", not of "this". That is, it's intersecting the movement of "box" into a static "this", and the sweep object is capturing the result of that movement.
In the case of a movement where delta x and y are both zero, the sweep is starting at the box's start position and moving nowhere. The box is sitting where it started and not progressing at all, and the sweep time is just a boolean indicating whether it hit anything.
No worries, and I had forgotten about this issue myself! I did indeed have the concept of which box was which messed up, and forgot to close this here :)
The annotated source says "If the sweep isn’t actually moving anywhere, just do a static test. It’s faster and will give us a better result for that case."
and then the code goes on to show:
Shouldn't sweep.pos.x = box.pos.x actually be sweep.pos.x = this.pos.x? If the object isn't moving, why would the position be the object you are colliding with?
(BTW, this has been a great resource! I've ported it more or less directly to a single C header file along with the tests: https://github.com/sponge/sdlgame/blob/master/src/sweep.h it mostly seems to be working besides a couple of weird edge cases that I'm not sure are my fault or are present in the original. I won't make any claims about how good my C is, though!)
The text was updated successfully, but these errors were encountered: