fix NONE rotation profile

This commit is contained in:
MihailRis 2024-07-14 01:57:18 +03:00
parent ea765ffc0c
commit 638a0d9850
2 changed files with 40 additions and 34 deletions

View File

@ -49,6 +49,16 @@ void CoordSystem::transform(AABB& aabb) const {
aabb.b += fix; aabb.b += fix;
} }
const BlockRotProfile BlockRotProfile::NONE {"none", {
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, // North
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, // East
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, // South
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, // West
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, // Up
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, // Down
}};
const BlockRotProfile BlockRotProfile::PIPE {"pipe", { 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
@ -69,11 +79,9 @@ Block::Block(const std::string& name)
: name(name), : name(name),
caption(util::id_to_caption(name)), caption(util::id_to_caption(name)),
textureFaces {TEXTURE_NOTFOUND,TEXTURE_NOTFOUND,TEXTURE_NOTFOUND, textureFaces {TEXTURE_NOTFOUND,TEXTURE_NOTFOUND,TEXTURE_NOTFOUND,
TEXTURE_NOTFOUND,TEXTURE_NOTFOUND,TEXTURE_NOTFOUND}, TEXTURE_NOTFOUND,TEXTURE_NOTFOUND,TEXTURE_NOTFOUND}
rotations(BlockRotProfile::PIPE)
{} {}
Block::Block(std::string name, const std::string& texture) : name(std::move(name)), Block::Block(std::string name, const std::string& texture) : name(std::move(name)),
textureFaces{texture,texture,texture,texture,texture,texture}, textureFaces{texture,texture,texture,texture,texture,texture}
rotations(BlockRotProfile::PIPE)
{} {}

View File

@ -58,6 +58,9 @@ struct BlockRotProfile {
std::string name; std::string name;
CoordSystem variants[MAX_COUNT]; CoordSystem variants[MAX_COUNT];
/// @brief No rotation
static const BlockRotProfile NONE;
/// @brief Wood logs, pillars, pipes /// @brief Wood logs, pillars, pipes
static const BlockRotProfile PIPE; static const BlockRotProfile PIPE;
@ -160,7 +163,7 @@ public:
std::vector<AABB> hitboxes; std::vector<AABB> hitboxes;
/// @brief Set of available block rotations (coord-systems) /// @brief Set of available block rotations (coord-systems)
BlockRotProfile rotations; BlockRotProfile rotations = BlockRotProfile::NONE;
/// @brief Item will be picked on MMB click on the block /// @brief Item will be picked on MMB click on the block
std::string pickingItem = name+BLOCK_ITEM_SUFFIX; std::string pickingItem = name+BLOCK_ITEM_SUFFIX;
@ -207,12 +210,7 @@ public:
}; };
inline glm::ivec3 get_ground_direction(const Block* def, int rotation) { inline glm::ivec3 get_ground_direction(const Block* def, int rotation) {
const auto& profileName = def->rotations.name;
if (profileName == BlockRotProfile::PIPE_NAME) {
return -def->rotations.variants[rotation].axisY; return -def->rotations.variants[rotation].axisY;
} else {
return glm::ivec3(0, -1, 0);
}
} }
#endif // VOXELS_BLOCK_HPP_ #endif // VOXELS_BLOCK_HPP_