diff --git a/src/logic/PlayerController.cpp b/src/logic/PlayerController.cpp index 5bca9899..0e1a5478 100644 --- a/src/logic/PlayerController.cpp +++ b/src/logic/PlayerController.cpp @@ -216,14 +216,12 @@ void PlayerController::updateInteraction(){ uint8_t states = 0; if (contentIds->getBlockDef(player->choosenBlock)->rotatable){ - if (abs(norm.x) > abs(norm.z)){ - if (abs(norm.x) > abs(norm.y)) states = BLOCK_DIR_X; - if (abs(norm.x) < abs(norm.y)) states = BLOCK_DIR_Y; - } - if (abs(norm.x) < abs(norm.z)){ - if (abs(norm.z) > abs(norm.y)) states = BLOCK_DIR_Z; - if (abs(norm.z) < abs(norm.y)) states = BLOCK_DIR_Y; - } + if (norm.x > 0) states = BLOCK_DIR_PX; + else if (norm.x < 0) states = BLOCK_DIR_MX; + else if (norm.y > 0) states = BLOCK_DIR_PY; + else if (norm.y < 0) states = BLOCK_DIR_MY; + else if (norm.z > 0) states = BLOCK_DIR_PZ; + else if (norm.z < 0) states = BLOCK_DIR_MZ; } Block* block = contentIds->getBlockDef(vox->id); diff --git a/src/voxels/Block.cpp b/src/voxels/Block.cpp index 41602a26..4f42d573 100644 --- a/src/voxels/Block.cpp +++ b/src/voxels/Block.cpp @@ -1,12 +1,12 @@ #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}}, + { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 0, 0, 0 } }, // BLOCK_DIR_PY + { { 0,-1, 0 }, { 1, 0, 0 }, { 0, 0, 1 }, { 0, 1, 0 } }, // BLOCK_DIR_PX + { { 1, 0, 0 }, { 0, 0, 1 }, { 0,-1, 0 }, { 0, 0,-1 } }, // BLOCK_DIR_PZ + { { 0, 1, 0 }, {-1, 0, 0 }, { 0, 0, 1 }, { 1, 0, 0 } }, // BLOCK_DIR_MX + { {-1, 0, 0 }, { 0,-1, 0 }, { 0, 0, 1 }, { 1, 1, 0 } }, // BLOCK_DIR_MY + { { 1, 0, 0 }, { 0, 0,-1 }, { 0, 1, 0 }, { 0, 1, 0 } }, // BLOCK_DIR_MZ }}; Block::Block(std::string name) diff --git a/src/voxels/WorldGenerator.cpp b/src/voxels/WorldGenerator.cpp index aabb2997..4374b3ac 100644 --- a/src/voxels/WorldGenerator.cpp +++ b/src/voxels/WorldGenerator.cpp @@ -206,7 +206,7 @@ void WorldGenerator::generate(voxel* voxels, int cx, int cz, int seed){ int tree = generate_tree(&noise, &randomtree, heights, humidity, real_x, real_y, real_z, treesTile); if (tree) { id = tree; - states = BLOCK_DIR_Y; + states = BLOCK_DIR_PY; } } if (((height - (1.5 - 0.2 * pow(height - 54, 4))) < real_y) && (real_y < height) && humidity.get(real_x, real_z) < 0.1){ @@ -224,7 +224,7 @@ void WorldGenerator::generate(voxel* voxels, int cx, int cz, int seed){ } if ((height > SEA_LEVEL+1) && ((int)(height + 1) == real_y) && ((unsigned short)randomgrass.rand() > 65533)){ id = idWood; - states = BLOCK_DIR_Y; + states = BLOCK_DIR_PY; } voxels[(y * CHUNK_D + z) * CHUNK_W + x].id = id; voxels[(y * CHUNK_D + z) * CHUNK_W + x].states = states; diff --git a/src/voxels/voxel.h b/src/voxels/voxel.h index 66026f8b..40e0083f 100644 --- a/src/voxels/voxel.h +++ b/src/voxels/voxel.h @@ -3,9 +3,12 @@ #include "../typedefs.h" -#define BLOCK_DIR_X 0x1 -#define BLOCK_DIR_Y 0x0 -#define BLOCK_DIR_Z 0x2 +#define BLOCK_DIR_PX 0x1 +#define BLOCK_DIR_PY 0x0 +#define BLOCK_DIR_PZ 0x2 +#define BLOCK_DIR_MX 0x3 +#define BLOCK_DIR_MY 0x4 +#define BLOCK_DIR_MZ 0x5 // limited to 16 block orientations #define BLOCK_ROT_MASK 0xF