From 668525656035c5ac64a29558375b8fedf4137a60 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Sat, 11 Apr 2015 01:05:55 -0700 Subject: [PATCH] change STBVOX_MAKE_LIGHTING to STBVOX_MAKE_LIGHTING_EXT so header file doesn't have to see the config variables (although this way is actually more bug prone since you can now use the wrong macro) --- stb_voxel_render.h | 17 ++++++++--------- tests/caveview/cave_mesher.c | 8 ++++---- tests/caveview/caveview.h | 1 - 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/stb_voxel_render.h b/stb_voxel_render.h index 45f9618..4087be2 100644 --- a/stb_voxel_render.h +++ b/stb_voxel_render.h @@ -169,8 +169,10 @@ // // VERSION HISTORY // -// 0.80 (2015-04-11) fix broken STBVOX_CONFIG_ROTATION_IN_LIGHTING refactoring; -// add STBVOX_CONFIG_VHEIGHT_IN_LIGHTING and other vheight fixes; +// 0.80 (2015-04-11) fix broken STBVOX_CONFIG_ROTATION_IN_LIGHTING refactoring +// change STBVOX_MAKE_LIGHTING to STBVOX_MAKE_LIGHTING_EXT so +// that header defs don't need to see config vars +// add STBVOX_CONFIG_VHEIGHT_IN_LIGHTING and other vheight fixes // added documentation for vheight ("weird slopes") // 0.79 (2015-04-01) fix the missing types from 0.78; fix string constants being const // 0.78 (2015-04-02) bad "#else", compile as C++ @@ -713,11 +715,11 @@ struct stbvox_input_description // then an additional 2-bit block rotation value is stored // in this field as well. // - // Encode with STBVOX_MAKE_LIGHTING(lighting,rot)--here + // Encode with STBVOX_MAKE_LIGHTING_EXT(lighting,rot)--here // 'lighting' should still be 8 bits, as the macro will // discard the bottom bits automatically. Similarly, if // using STBVOX_CONFIG_VHEIGHT_IN_LIGHTING, encode with - // STBVOX_MAKE_LIGHTING(lighting,vheight). + // STBVOX_MAKE_LIGHTING_EXT(lighting,vheight). // // (Rationale: rotation needs to be independent of blocktype, // but is only 2 bits so doesn't want to be its own array. @@ -1038,7 +1040,7 @@ enum // with the block. You can either use the "geometry" mesh variable (it's // a parameter to STBVOX_MAKE_GEOMETRY) or you can store it in the // "lighting" mesh variable if you defined STBVOX_CONFIG_VHEIGHT_IN_LIGHTING, -// using STBVOX_MAKE_LIGHTING(lighting,vheight). +// using STBVOX_MAKE_LIGHTING_EXT(lighting,vheight). // // Note that if you start with a 2D height map and generate vheight data from // it, you don't necessarily store only one value per (x,y) coordinate, @@ -1102,11 +1104,8 @@ enum #define STBVOX_MAKE_TEXLERP_VERT3(e,n,w,s,u) ((e)+(n)*8+(w)*64+(s)*512+(u)*4096) #define STBVOX_MAKE_TEXLERP_FACE3(e,n,w,s,u,d) ((e)+(n)*8+(w)*64+(s)*512+(u)*4096+(d)*16384) -#if defined(STBVOX_CONFIG_ROTATION_IN_LIGHTING) || defined(STBVOX_CONFIG_VHEIGHT_IN_LIGHTING) -#define STBVOX_MAKE_LIGHTING(lighting, rot) (((lighting)&~3)+(rot)) -#else +#define STBVOX_MAKE_LIGHTING_EXT(lighting, rot) (((lighting)&~3)+(rot)) #define STBVOX_MAKE_LIGHTING(lighting) (lighting) -#endif #ifndef STBVOX_MAX_MESHES #define STBVOX_MAX_MESHES 2 // opaque & transparent diff --git a/tests/caveview/cave_mesher.c b/tests/caveview/cave_mesher.c index c9d0710..52792c5 100644 --- a/tests/caveview/cave_mesher.c +++ b/tests/caveview/cave_mesher.c @@ -406,12 +406,12 @@ void convert_fastchunk_inplace(fast_chunk *fc) bright = (lt[o]&15)*12 + 15 + (sky[o]&15)*16; if (bright > 255) bright = 255; if (bright < 32) bright = 32; - outb[o*2+0] = STBVOX_MAKE_LIGHTING((unsigned char) bright, (rot[o*2+0]&3)); + outb[o*2+0] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+0]&3)); bright = (lt[o]>>4)*12 + 15 + (sky[o]>>4)*16; if (bright > 255) bright = 255; if (bright < 32) bright = 32; - outb[o*2+1] = STBVOX_MAKE_LIGHTING((unsigned char) bright, (rot[o*2+1]&3)); + outb[o*2+1] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+1]&3)); } } else { // @TODO: if blocktype is in between others, this breaks; need to find which side has two pointers, and use that @@ -426,12 +426,12 @@ void convert_fastchunk_inplace(fast_chunk *fc) bright = (lt[o]&15)*12 + 15 + (sky[o]&15)*16; if (bright > 255) bright = 255; if (bright < 32) bright = 32; - rot[o*2+0] = STBVOX_MAKE_LIGHTING((unsigned char) bright, (rot[o*2+0]&3)); + rot[o*2+0] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+0]&3)); bright = (lt[o]>>4)*12 + 15 + (sky[o]>>4)*16; if (bright > 255) bright = 255; if (bright < 32) bright = 32; - rot[o*2+1] = STBVOX_MAKE_LIGHTING((unsigned char) bright, (rot[o*2+1]&3)); + rot[o*2+1] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+1]&3)); } memcpy(outb, rot, 4096); diff --git a/tests/caveview/caveview.h b/tests/caveview/caveview.h index 96288e0..73a71da 100644 --- a/tests/caveview/caveview.h +++ b/tests/caveview/caveview.h @@ -3,7 +3,6 @@ #include "stb.h" -#define STBVOX_CONFIG_ROTATION_IN_LIGHTING #include "stb_voxel_render.h" typedef struct