Block rotation profiles

This commit is contained in:
MihailRis 2023-12-04 09:38:55 +03:00
parent 9ded9b63f8
commit 8bc8eb14bd
6 changed files with 53 additions and 16 deletions

View file

@ -1,10 +1,19 @@
#include "Block.h"
BlockRotProfile BlockRotProfile::PIPE {{
// Vertical
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}},
// X-Aligned
{{0, -1, 0}, {1, 0, 0}, {0, 0, 1}, {0, 1, 0}},
// Z-Aligned
{{1, 0, 0}, {0, 0, 1}, {0, -1, 0}, {0, 0, -1}},
}};
Block::Block(std::string name)
: name(name),
textureFaces {"notfound","notfound","notfound",
"notfound","notfound","notfound",} {
rotations = BlockRotProfile::PIPE;
}
Block::Block(std::string name, std::string texture) : name(name),

View file

@ -2,6 +2,7 @@
#define VOXELS_BLOCK_H_
#include <string>
#include <glm/glm.hpp>
#include "../maths/aabb.h"
#include "../typedefs.h"
@ -15,6 +16,23 @@
#define BLOCK_AABB_GRID 16
struct CoordSystem {
glm::ivec3 axisX;
glm::ivec3 axisY;
glm::ivec3 axisZ;
// Grid 3d position fix offset (for negative vectors)
glm::ivec3 fix;
};
struct BlockRotProfile {
CoordSystem variants[16];
/* Wood logs, pillars, pipes
3 orientations supported
*/
static BlockRotProfile PIPE;
};
enum class BlockModel {
none, // invisible
block, // default shape
@ -38,6 +56,7 @@ public:
bool breakable = true;
bool rotatable = false;
AABB hitbox;
BlockRotProfile rotations;
struct {
blockid_t id;

View file

@ -4,8 +4,11 @@
#include "../typedefs.h"
#define BLOCK_DIR_X 0x1
#define BLOCK_DIR_Y 0x2
#define BLOCK_DIR_Z 0x3
#define BLOCK_DIR_Y 0x0
#define BLOCK_DIR_Z 0x2
// limited to 16 block orientations
#define BLOCK_ROT_MASK 0xF
struct voxel {
blockid_t id;