fixed that Collision::IntersectLine gets stuck in a loop forever. Closes #6

This commit is contained in:
oy 2010-08-16 04:09:21 +02:00 committed by GreYFoXGTi
parent 1cfa122521
commit 3d23f959b4

View file

@ -249,6 +249,7 @@ void ThroughOffset(vec2 Pos0, vec2 Pos1, int *Ox, int *Oy)
int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough)
{
float d = distance(Pos0, Pos1);
int End(d+1);
vec2 Last = Pos0;
int ix, iy; // Temporary position for checking collision
int dx, dy; // Offset for checking the "through" tile
@ -256,9 +257,9 @@ int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *p
{
ThroughOffset(Pos0, Pos1, &dx, &dy);
}
for(float f = 0; f < d; f++)
for(int i = 0; i < End; i++)
{
float a = f/d;
float a = i/d;
vec2 Pos = mix(Pos0, Pos1, a);
ix = round(Pos.x);
iy = round(Pos.y);