Rotation profiles limited to 8

This commit is contained in:
MihailRis 2024-01-04 21:48:41 +03:00
parent 6542bcbc6a
commit c35057d1de
4 changed files with 12 additions and 12 deletions

View File

@ -38,7 +38,7 @@ regfile::regfile(fs::path filename) : file(filename) {
throw std::runtime_error("invalid region file magic number"); throw std::runtime_error("invalid region file magic number");
} }
version = header[8]; version = header[8];
if (version > REGION_FORMAT_VERSION) { if (uint(version) > REGION_FORMAT_VERSION) {
throw illegal_region_format( throw illegal_region_format(
"region format "+std::to_string(version)+" is not supported"); "region format "+std::to_string(version)+" is not supported");
} }

View File

@ -23,13 +23,13 @@ void CoordSystem::transform(AABB& aabb) const {
aabb.b += fix; aabb.b += fix;
} }
const BlockRotProfile BlockRotProfile::PIPE {"pipe", {//TODO consexpr or init-time fix calculations const BlockRotProfile BlockRotProfile::PIPE {"pipe", {
{ { 1, 0, 0 }, { 0, 0, 1 }, { 0, -1, 0 }}, // North { { 1, 0, 0 }, { 0, 0, 1 }, { 0, -1, 0 }}, // North
{ { 0, 0, 1 }, {-1, 0, 0 }, { 0, -1, 0 }}, // East { { 0, 0, 1 }, {-1, 0, 0 }, { 0, -1, 0 }}, // East
{ { -1, 0, 0 }, { 0, 0,-1 }, { 0, -1, 0 }}, // South { {-1, 0, 0 }, { 0, 0,-1 }, { 0, -1, 0 }}, // South
{ { 0, 0, -1 }, { 1, 0, 0 }, { 0, -1, 0 }}, // West { { 0, 0,-1 }, { 1, 0, 0 }, { 0, -1, 0 }}, // West
{ { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }}, // Up { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }}, // Up
{ { 1, 0, 0 }, { 0,-1, 0 }, { 0, 0,-1 }}, // Down { { 1, 0, 0 }, { 0,-1, 0 }, { 0, 0,-1 }}, // Down
}}; }};
const BlockRotProfile BlockRotProfile::PANE {"pane", { const BlockRotProfile BlockRotProfile::PANE {"pane", {

View File

@ -47,7 +47,7 @@ struct CoordSystem {
}; };
struct BlockRotProfile { struct BlockRotProfile {
static const int MAX_COUNT = 16; static const int MAX_COUNT = 8;
std::string name; std::string name;
CoordSystem variants[MAX_COUNT]; CoordSystem variants[MAX_COUNT];

View File

@ -10,10 +10,10 @@ const int BLOCK_DIR_EAST = 0x3;
const int BLOCK_DIR_UP = 0x4; const int BLOCK_DIR_UP = 0x4;
const int BLOCK_DIR_DOWN = 0x5; const int BLOCK_DIR_DOWN = 0x5;
// limited to 16 block orientations // limited to 8 block orientations
const int BLOCK_ROT_MASK = 0xF; const int BLOCK_ROT_MASK = 0b0000'0111;
// limited to 16 block variants // limited to 32 block variants
const int BLOCK_VARIANT_MASK = 0xF0; const int BLOCK_VARIANT_MASK = 0b1111'1000;
struct voxel { struct voxel {
blockid_t id; blockid_t id;
@ -24,7 +24,7 @@ struct voxel {
} }
inline uint8_t variant() const { inline uint8_t variant() const {
return (states & BLOCK_VARIANT_MASK) >> 4; return (states & BLOCK_VARIANT_MASK) >> 3;
} }
}; };