From f186330cf278a3cffc49de5d69786e1505e80ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Thu, 6 Sep 2018 10:15:23 +0200 Subject: [PATCH] Fix texture coords --- raycastlib.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index c90db01..18ab5f0 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -501,22 +501,26 @@ void castRayMultiHit(Ray ray, ArrayFunction arrayFunc, ArrayFunction typeFunc, if (no.y > 0) { h.direction = 0; - h.textureCoord = co.x; + h.textureCoord = constraints.computeTextureCoords ? + wrap(currentPos.x,UNITS_PER_SQUARE) : 0; } else if (no.x > 0) { h.direction = 1; - h.textureCoord = co.y; + h.textureCoord = constraints.computeTextureCoords ? + wrap(UNITS_PER_SQUARE - currentPos.y,UNITS_PER_SQUARE) : 0; } else if (no.y < 0) { h.direction = 2; - h.textureCoord = co.x; + h.textureCoord = constraints.computeTextureCoords ? + wrap(UNITS_PER_SQUARE - currentPos.x,UNITS_PER_SQUARE) : 0; } else { h.direction = 3; - h.textureCoord = co.y; + h.textureCoord = constraints.computeTextureCoords ? + wrap(currentPos.y,UNITS_PER_SQUARE) : 0; } hitResults[*hitResultsLen] = h;