minimize defines

This commit is contained in:
Ara
2023-12-04 22:50:00 +06:00
parent e0eacb51be
commit e45d85bc5a
17 changed files with 92 additions and 86 deletions
+7 -7
View File
@@ -7,14 +7,14 @@
#include "../maths/aabb.h"
#include "../typedefs.h"
#define FACE_MX 0
#define FACE_PX 1
#define FACE_MY 2
#define FACE_PY 3
#define FACE_MZ 4
#define FACE_PZ 5
const uint FACE_MX = 0;
const uint FACE_PX = 1;
const uint FACE_MY = 2;
const uint FACE_PY = 3;
const uint FACE_MZ = 4;
const uint FACE_PZ = 5;
#define BLOCK_AABB_GRID 16
const uint BLOCK_AABB_GRID = 16;
struct CoordSystem {
glm::ivec3 axisX;
+24 -19
View File
@@ -4,11 +4,13 @@
#include <stdlib.h>
#include "../constants.h"
#define CHUNK_MODIFIED 0x1
#define CHUNK_READY 0x2
#define CHUNK_LOADED 0x4
#define CHUNK_LIGHTED 0x8
#define CHUNK_UNSAVED 0x10
struct ChunkFlag{
static const int MODIFIED = 0x1;
static const int READY = 0x2;
static const int LOADED = 0x4;
static const int LIGHTED = 0x8;
static const int UNSAVED = 0x10;
};
#define CHUNK_DATA_LEN (CHUNK_VOL*2)
struct voxel;
@@ -19,10 +21,6 @@ struct RenderData {
size_t size;
};
#define BIT_ON(f,i) do{f|= i;} while(0)
#define BIT_OFF(f,i) do{f&=~(i);} while(0)
#define BITSET(f,i,s) if (s) BIT_ON(f,i); else BIT_OFF(f,i);
class Chunk {
public:
int x, z;
@@ -43,26 +41,33 @@ public:
Chunk* clone() const;
// flags getters/setters below
void SETFLAGS(int mask, bool value){
if (value)
flags |= mask;
else
flags &= ~(mask);
}
inline bool isUnsaved() const {return flags & CHUNK_UNSAVED;}
inline bool isUnsaved() const {return flags & ChunkFlag::UNSAVED;}
inline bool isModified() const {return flags & CHUNK_MODIFIED;}
inline bool isModified() const {return flags & ChunkFlag::MODIFIED;}
inline bool isLighted() const {return flags & CHUNK_LIGHTED;}
inline bool isLighted() const {return flags & ChunkFlag::LIGHTED;}
inline bool isLoaded() const {return flags & CHUNK_LOADED;}
inline bool isLoaded() const {return flags & ChunkFlag::LOADED;}
inline bool isReady() const {return flags & CHUNK_READY;}
inline bool isReady() const {return flags & ChunkFlag::READY;}
inline void setUnsaved(bool flag) {BITSET(flags, CHUNK_UNSAVED, flag);}
inline void setUnsaved(bool newState) {SETFLAGS(ChunkFlag::UNSAVED, newState);}
inline void setModified(bool flag) {BITSET(flags, CHUNK_MODIFIED, flag);}
inline void setModified(bool newState) {SETFLAGS(ChunkFlag::MODIFIED, newState);}
inline void setLoaded(bool flag) {BITSET(flags, CHUNK_LOADED, flag);}
inline void setLoaded(bool newState) {SETFLAGS(ChunkFlag::LOADED, newState);}
inline void setLighted(bool flag) {BITSET(flags, CHUNK_LIGHTED, flag);}
inline void setLighted(bool newState) {SETFLAGS(ChunkFlag::LIGHTED, newState);}
inline void setReady(bool flag) {BITSET(flags, CHUNK_READY, flag);}
inline void setReady(bool newState) {SETFLAGS(ChunkFlag::READY, newState);}
ubyte* encode() const;
bool decode(ubyte* data);
+1 -1
View File
@@ -16,7 +16,7 @@
#include "../maths/voxmaths.h"
#include "../core_defs.h"
#define SEA_LEVEL 55
const int SEA_LEVEL = 55;
class Map2D {
int x, z;