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)
This commit is contained in:
parent
e2b645e4d7
commit
6685256560
@ -169,8 +169,10 @@
|
|||||||
//
|
//
|
||||||
// VERSION HISTORY
|
// VERSION HISTORY
|
||||||
//
|
//
|
||||||
// 0.80 (2015-04-11) fix broken STBVOX_CONFIG_ROTATION_IN_LIGHTING refactoring;
|
// 0.80 (2015-04-11) fix broken STBVOX_CONFIG_ROTATION_IN_LIGHTING refactoring
|
||||||
// add STBVOX_CONFIG_VHEIGHT_IN_LIGHTING and other vheight fixes;
|
// 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")
|
// added documentation for vheight ("weird slopes")
|
||||||
// 0.79 (2015-04-01) fix the missing types from 0.78; fix string constants being const
|
// 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++
|
// 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
|
// then an additional 2-bit block rotation value is stored
|
||||||
// in this field as well.
|
// 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
|
// 'lighting' should still be 8 bits, as the macro will
|
||||||
// discard the bottom bits automatically. Similarly, if
|
// discard the bottom bits automatically. Similarly, if
|
||||||
// using STBVOX_CONFIG_VHEIGHT_IN_LIGHTING, encode with
|
// 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,
|
// (Rationale: rotation needs to be independent of blocktype,
|
||||||
// but is only 2 bits so doesn't want to be its own array.
|
// 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
|
// 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
|
// a parameter to STBVOX_MAKE_GEOMETRY) or you can store it in the
|
||||||
// "lighting" mesh variable if you defined STBVOX_CONFIG_VHEIGHT_IN_LIGHTING,
|
// "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
|
// 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,
|
// 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_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)
|
#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_EXT(lighting, rot) (((lighting)&~3)+(rot))
|
||||||
#define STBVOX_MAKE_LIGHTING(lighting, rot) (((lighting)&~3)+(rot))
|
|
||||||
#else
|
|
||||||
#define STBVOX_MAKE_LIGHTING(lighting) (lighting)
|
#define STBVOX_MAKE_LIGHTING(lighting) (lighting)
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef STBVOX_MAX_MESHES
|
#ifndef STBVOX_MAX_MESHES
|
||||||
#define STBVOX_MAX_MESHES 2 // opaque & transparent
|
#define STBVOX_MAX_MESHES 2 // opaque & transparent
|
||||||
|
@ -406,12 +406,12 @@ void convert_fastchunk_inplace(fast_chunk *fc)
|
|||||||
bright = (lt[o]&15)*12 + 15 + (sky[o]&15)*16;
|
bright = (lt[o]&15)*12 + 15 + (sky[o]&15)*16;
|
||||||
if (bright > 255) bright = 255;
|
if (bright > 255) bright = 255;
|
||||||
if (bright < 32) bright = 32;
|
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;
|
bright = (lt[o]>>4)*12 + 15 + (sky[o]>>4)*16;
|
||||||
if (bright > 255) bright = 255;
|
if (bright > 255) bright = 255;
|
||||||
if (bright < 32) bright = 32;
|
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 {
|
} else {
|
||||||
// @TODO: if blocktype is in between others, this breaks; need to find which side has two pointers, and use that
|
// @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;
|
bright = (lt[o]&15)*12 + 15 + (sky[o]&15)*16;
|
||||||
if (bright > 255) bright = 255;
|
if (bright > 255) bright = 255;
|
||||||
if (bright < 32) bright = 32;
|
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;
|
bright = (lt[o]>>4)*12 + 15 + (sky[o]>>4)*16;
|
||||||
if (bright > 255) bright = 255;
|
if (bright > 255) bright = 255;
|
||||||
if (bright < 32) bright = 32;
|
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);
|
memcpy(outb, rot, 4096);
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "stb.h"
|
#include "stb.h"
|
||||||
|
|
||||||
#define STBVOX_CONFIG_ROTATION_IN_LIGHTING
|
|
||||||
#include "stb_voxel_render.h"
|
#include "stb_voxel_render.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
Loading…
Reference in New Issue
Block a user