From eda0106d08fdfbbe7c038acd3f3981b7570ac3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Fri, 11 Oct 2019 18:10:12 +0200 Subject: [PATCH] Optimize horizontal depth --- raycastlib.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/raycastlib.h b/raycastlib.h index e3239d1..cfba3df 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -1092,7 +1092,8 @@ static inline int16_t _RCL_drawHorizontalColumn( if (doDepth) /*constant condition - compiler should optimize it out*/\ {\ depth += depthIncrement;\ - pixelInfo->depth = RCL_max(0,depth); /*TODO: optimize */\ + pixelInfo->depth = depth * (depth > 0); /* fast abs val */ \ + /* ^ int comparison is fast, it is not braching! (= test instr.) */\ }\ if (doCoords) /*constant condition - compiler should optimize it out*/\ {\