From b28789a685e861332d276ff997bd775248e16173 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 25 Nov 2019 19:35:34 -0800 Subject: din: don't include v3f.h in din.h This requires a forward declaration of v3f_t and changing din() to take a v3f_t *. The swab module needed updating to supply a pointer type and a v3f_t definition. This is being done so din.h users can have their own v3f implementations. I might consolidate all the duplicated vector code scattered throughout the libs and modules, but for now I'm carrying on with the original intention of having modules be largely self-contained. Though the introduction of libs like ray and din has certainly violated that a bit already. --- src/modules/swab/swab.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/modules') diff --git a/src/modules/swab/swab.c b/src/modules/swab/swab.c index e4c3670..2b80d95 100644 --- a/src/modules/swab/swab.c +++ b/src/modules/swab/swab.c @@ -14,6 +14,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -37,6 +38,10 @@ typedef struct color_t { float r,g,b; } color_t; +typedef struct v3f_t { + float x, y, z; +} v3f_t; + /* convert a color into a packed, 32-bit rgb pixel value (taken from libs/ray/ray_color.h) */ static inline uint32_t color_to_uint32(color_t color) { @@ -122,11 +127,11 @@ static void swab_render_fragment(void *context, unsigned cpu, fb_fragment_t *fra uint32_t pixel; float t; - t = din(ctxt->din, (v3f_t){ .x = (float)x * xscale * .5f, .y = (float)y * yscale * .5f, .z = -z2 }) * 33.f; + t = din(ctxt->din, &(v3f_t){ .x = (float)x * xscale * .5f, .y = (float)y * yscale * .5f, .z = -z2 }) * 33.f; - color.r = din(ctxt->din, (v3f_t){ .x = (float)x * xscale * .7f, .y = (float)y * yscale * .7f, .z = z1 }) * t; - color.g = din(ctxt->din, (v3f_t){ .x = (float)x * xscale * .93f, .y = (float)y * yscale * .93f, .z = -z1 }) * t; - color.b = din(ctxt->din, (v3f_t){ .x = (float)x * xscale * .81f, .y = (float)y * yscale * .81f, .z = z2 }) * t; + color.r = din(ctxt->din, &(v3f_t){ .x = (float)x * xscale * .7f, .y = (float)y * yscale * .7f, .z = z1 }) * t; + color.g = din(ctxt->din, &(v3f_t){ .x = (float)x * xscale * .93f, .y = (float)y * yscale * .93f, .z = -z1 }) * t; + color.b = din(ctxt->din, &(v3f_t){ .x = (float)x * xscale * .81f, .y = (float)y * yscale * .81f, .z = z2 }) * t; pixel = color_to_uint32(color); fb_fragment_put_pixel_unchecked(fragment, x, y, pixel); -- cgit v1.2.1