From 0c66c8b407574b4e8820cc01318cf2f7b6f1e139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sun, 6 Oct 2019 21:29:41 +0200 Subject: [PATCH] Improve point mapping --- raycastlib.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index 90651a7..f04017c 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -1649,9 +1649,10 @@ RCL_PixelInfo RCL_mapToScreen(RCL_Vector2D worldPosition, RCL_Unit height, cameraDir.x = cameraDir.y; cameraDir.y = -1 * tmp; - // decide whether the point is in the left or right part of screen + /* decide whether the point is in the left or right part of screen, using + dot product (non-normalized, as we only need to compare to 0) */ - if (RCL_vectorsAngleCos(toPoint,cameraDir) <= 0) + if ((toPoint.x * cameraDir.x + toPoint.y * cameraDir.y) <= 0) a *= -1; result.position.x =