From f58e9035da059dc4b219c168f06f48d45d7c8bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Thu, 30 Aug 2018 14:22:13 +0200 Subject: [PATCH] Fix offset bug --- raycastlib.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index 3eae36f..55ffdac 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -225,10 +225,9 @@ void castRaySquare(Ray localRay, Vector2D *nextCellOffset, {\ nextCellOffset->c1 = n;\ collisionPointOffset->c1 = criticalLine.start.c1 - localRay.start.c1;\ - collisionPointOffset->c2 = clamp(\ - (collisionPointOffset->c1 * localRay.direction.c2) /\ - (localRay.direction.c1 == 0 ? 1 : localRay.direction.c1),\ - 0,UNITS_PER_SQUARE - 1);\ + collisionPointOffset->c2 = \ + (((int32_t) collisionPointOffset->c1) * localRay.direction.c2) /\ + ((localRay.direction.c1 == 0) ? 1 : localRay.direction.c1);\ } #define helper2(n1,n2,c)\