From f99466681780e9654cd5e84d49a670a5d7b79441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Mon, 17 Sep 2018 10:54:22 +0200 Subject: [PATCH] Add inlines --- raycastlib.h | 8 ++++---- testSDL.c | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index 9db972a..0cdc3e1 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -420,7 +420,7 @@ Unit clamp(Unit value, Unit valueMin, Unit valueMax) return valueMin; } -Unit absVal(Unit value) +static inline Unit absVal(Unit value) { profileCall(absVal); @@ -428,7 +428,7 @@ Unit absVal(Unit value) } /// Like mod, but behaves differently for negative values. -Unit wrap(Unit value, Unit mod) +static inline Unit wrap(Unit value, Unit mod) { profileCall(wrap); @@ -436,7 +436,7 @@ Unit wrap(Unit value, Unit mod) } /// Performs division, rounding down, NOT towards zero. -Unit divRoundDown(Unit value, Unit divisor) +static inline Unit divRoundDown(Unit value, Unit divisor) { profileCall(divRoundDown); @@ -619,7 +619,7 @@ Unit len(Vector2D v) return dist(zero,v); } -int8_t pointIsLeftOfRay(Vector2D point, Ray ray) +static inline int8_t pointIsLeftOfRay(Vector2D point, Ray ray) { profileCall(pointIsLeftOfRay); diff --git a/testSDL.c b/testSDL.c index e27250b..3f44e69 100644 --- a/testSDL.c +++ b/testSDL.c @@ -20,6 +20,8 @@ #define HORIZONTAL_FOV (UNITS_PER_SQUARE / 5) #define VERTICAL_FOV UNITS_PER_SQUARE // redefine camera vertical FOV +#define PIXEL_FUNCTION pixelFunc + #include "raycastlib.h" #define LEVEL_X_RES 29 @@ -874,7 +876,7 @@ void pixelFunc(PixelInfo *pixel) uint8_t c; if (pixel->isWall) - c = sampleImage(textures[pixel->hit.type],pixel->hit.textureCoord,pixel->textureCoordY); + c = sampleImage(textures[pixel->hit.type],pixel->texCoords.x,pixel->texCoords.y); else c = pixel->isFloor ? 0b00010001 : 0b00001010; @@ -922,8 +924,7 @@ void draw() c.maxHits = 32; c.maxSteps = 32; - c.computeTextureCoords = 1; - render(camera,floorHeightAt,ceilingHeightAt,textureAt,pixelFunc,c); + render(camera,floorHeightAt,ceilingHeightAt,textureAt,c); Unit previousDepth;