From 3ef4c4fce92d828432c2776126c321272127512e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 15 Sep 2018 17:56:59 +0200 Subject: [PATCH] Optimize --- raycastlib.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index 9d65de8..6f0ed57 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -819,14 +819,20 @@ void castRaysMultiHit(Camera cam, ArrayFunction arrayFunc, Ray r; r.start = cam.position; + Unit currentDX = 0; + Unit currentDY = 0; + for (int16_t i = 0; i < cam.resolution.x; ++i) { - r.direction.x = dir1.x + (dX * i) / cam.resolution.x; - r.direction.y = dir1.y + (dY * i) / cam.resolution.x; + r.direction.x = dir1.x + currentDX / cam.resolution.x; + r.direction.y = dir1.y + currentDY / cam.resolution.x; castRayMultiHit(r,arrayFunc,typeFunction,hits,&hitCount,constraints); columnFunc(hits,hitCount,i,r); + + currentDX += dX; + currentDY += dY; } }