From 691942dfbe845bc40524e22bcb6696dbc945a5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 15 Sep 2018 11:56:20 +0200 Subject: [PATCH] Roll texture coords --- raycastlib.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index 46489d2..9794424 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -46,12 +46,18 @@ #endif #ifndef USE_DIST_APPROX -#define USE_DIST_APPROX 0 /** What distance approximation to use: +#define USE_DIST_APPROX 0 /**< What distance approximation to use: 0: none (compute full Euclidean distance) 1: accurate approximation 2: octagonal approximation (LQ) */ #endif +#ifndef ROLL_TEXTURE_COORDS +#define ROLL_TEXTURE_COORDS 1 /**< Says whether rolling doors should also roll + the texture coordinates along (mostly + desired for doors). */ +#endif + #ifndef VERTICAL_FOV #define VERTICAL_FOV (UNITS_PER_SQUARE / 2) #endif @@ -1027,11 +1033,9 @@ void _columnFunctionSimple(HitResult *hits, uint16_t hitCount, uint16_t x, { // normal hit, check the door roll - Unit doorRoll = hit.doorRoll; - - int8_t unrolled = doorRoll >= 0 ? - doorRoll > hit.textureCoord : - hit.textureCoord > UNITS_PER_SQUARE + doorRoll; + int8_t unrolled = hit.doorRoll >= 0 ? + hit.doorRoll > hit.textureCoord : + hit.textureCoord > UNITS_PER_SQUARE + hit.doorRoll; if (unrolled) { @@ -1105,6 +1109,10 @@ void _columnFunctionSimple(HitResult *hits, uint16_t hitCount, uint16_t x, p.isFloor = 1; p.depth = dist; +#if ROLL_TEXTURE_COORDS == 1 + p.hit.textureCoord -= p.hit.doorRoll; +#endif + while (y < wallEnd) { p.position.y = y;