mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 12:31:51 +00:00
AABB blocks rotation support (WIP part 1)
This commit is contained in:
parent
8bc8eb14bd
commit
0c764bcbd9
8 changed files with 120 additions and 90 deletions
|
|
@ -1,12 +1,24 @@
|
|||
#include "Block.h"
|
||||
|
||||
BlockRotProfile BlockRotProfile::PIPE {{
|
||||
using glm::vec3;
|
||||
|
||||
void CoordSystem::transform(AABB& aabb) {
|
||||
vec3 X(axisX);
|
||||
vec3 Y(axisY);
|
||||
vec3 Z(axisZ);
|
||||
aabb.a = X * aabb.a.x + Y * aabb.a.y + Z * aabb.a.z;
|
||||
aabb.b = X * aabb.b.x + Y * aabb.b.y + Z * aabb.b.z;
|
||||
aabb.a += fix2;
|
||||
aabb.b += fix2;
|
||||
}
|
||||
|
||||
const BlockRotProfile BlockRotProfile::PIPE {{
|
||||
// Vertical
|
||||
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}},
|
||||
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}, {0, 0, 0}},
|
||||
// X-Aligned
|
||||
{{0, -1, 0}, {1, 0, 0}, {0, 0, 1}, {0, 1, 0}},
|
||||
{{0, -1, 0}, {1, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 0}},
|
||||
// Z-Aligned
|
||||
{{1, 0, 0}, {0, 0, 1}, {0, -1, 0}, {0, 0, -1}},
|
||||
{{1, 0, 0}, {0, 0, 1}, {0, -1, 0}, {0, 0, -1}, {0, 1, 0}},
|
||||
}};
|
||||
|
||||
Block::Block(std::string name)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ struct CoordSystem {
|
|||
glm::ivec3 axisZ;
|
||||
// Grid 3d position fix offset (for negative vectors)
|
||||
glm::ivec3 fix;
|
||||
glm::ivec3 fix2;
|
||||
|
||||
void transform(AABB& aabb);
|
||||
};
|
||||
|
||||
struct BlockRotProfile {
|
||||
|
|
@ -30,7 +33,7 @@ struct BlockRotProfile {
|
|||
/* Wood logs, pillars, pipes
|
||||
3 orientations supported
|
||||
*/
|
||||
static BlockRotProfile PIPE;
|
||||
static const BlockRotProfile PIPE;
|
||||
};
|
||||
|
||||
enum class BlockModel {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue