From c35057d1de803d4c425ca78580c4f38154262f66 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 4 Jan 2024 21:48:41 +0300 Subject: [PATCH] Rotation profiles limited to 8 --- src/files/WorldFiles.cpp | 2 +- src/voxels/Block.cpp | 10 +++++----- src/voxels/Block.h | 2 +- src/voxels/voxel.h | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/files/WorldFiles.cpp b/src/files/WorldFiles.cpp index 6c092a48..10ceb1ec 100644 --- a/src/files/WorldFiles.cpp +++ b/src/files/WorldFiles.cpp @@ -38,7 +38,7 @@ regfile::regfile(fs::path filename) : file(filename) { throw std::runtime_error("invalid region file magic number"); } version = header[8]; - if (version > REGION_FORMAT_VERSION) { + if (uint(version) > REGION_FORMAT_VERSION) { throw illegal_region_format( "region format "+std::to_string(version)+" is not supported"); } diff --git a/src/voxels/Block.cpp b/src/voxels/Block.cpp index 3b148d98..0b3491bd 100644 --- a/src/voxels/Block.cpp +++ b/src/voxels/Block.cpp @@ -23,13 +23,13 @@ void CoordSystem::transform(AABB& aabb) const { 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 { { 0, 0, 1 }, {-1, 0, 0 }, { 0, -1, 0 }}, // East - { { -1, 0, 0 }, { 0, 0,-1 }, { 0, -1, 0 }}, // South - { { 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 }}, // Down + { {-1, 0, 0 }, { 0, 0,-1 }, { 0, -1, 0 }}, // South + { { 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 }}, // Down }}; const BlockRotProfile BlockRotProfile::PANE {"pane", { diff --git a/src/voxels/Block.h b/src/voxels/Block.h index 98214be7..80b6d35c 100644 --- a/src/voxels/Block.h +++ b/src/voxels/Block.h @@ -47,7 +47,7 @@ struct CoordSystem { }; struct BlockRotProfile { - static const int MAX_COUNT = 16; + static const int MAX_COUNT = 8; std::string name; CoordSystem variants[MAX_COUNT]; diff --git a/src/voxels/voxel.h b/src/voxels/voxel.h index ded557f9..c94397b1 100644 --- a/src/voxels/voxel.h +++ b/src/voxels/voxel.h @@ -10,10 +10,10 @@ const int BLOCK_DIR_EAST = 0x3; const int BLOCK_DIR_UP = 0x4; const int BLOCK_DIR_DOWN = 0x5; -// limited to 16 block orientations -const int BLOCK_ROT_MASK = 0xF; -// limited to 16 block variants -const int BLOCK_VARIANT_MASK = 0xF0; +// limited to 8 block orientations +const int BLOCK_ROT_MASK = 0b0000'0111; +// limited to 32 block variants +const int BLOCK_VARIANT_MASK = 0b1111'1000; struct voxel { blockid_t id; @@ -24,7 +24,7 @@ struct voxel { } inline uint8_t variant() const { - return (states & BLOCK_VARIANT_MASK) >> 4; + return (states & BLOCK_VARIANT_MASK) >> 3; } };