Full vertical block rotation
This commit is contained in:
@@ -216,14 +216,12 @@ void PlayerController::updateInteraction(){
|
|||||||
uint8_t states = 0;
|
uint8_t states = 0;
|
||||||
|
|
||||||
if (contentIds->getBlockDef(player->choosenBlock)->rotatable){
|
if (contentIds->getBlockDef(player->choosenBlock)->rotatable){
|
||||||
if (abs(norm.x) > abs(norm.z)){
|
if (norm.x > 0) states = BLOCK_DIR_PX;
|
||||||
if (abs(norm.x) > abs(norm.y)) states = BLOCK_DIR_X;
|
else if (norm.x < 0) states = BLOCK_DIR_MX;
|
||||||
if (abs(norm.x) < abs(norm.y)) states = BLOCK_DIR_Y;
|
else if (norm.y > 0) states = BLOCK_DIR_PY;
|
||||||
}
|
else if (norm.y < 0) states = BLOCK_DIR_MY;
|
||||||
if (abs(norm.x) < abs(norm.z)){
|
else if (norm.z > 0) states = BLOCK_DIR_PZ;
|
||||||
if (abs(norm.z) > abs(norm.y)) states = BLOCK_DIR_Z;
|
else if (norm.z < 0) states = BLOCK_DIR_MZ;
|
||||||
if (abs(norm.z) < abs(norm.y)) states = BLOCK_DIR_Y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Block* block = contentIds->getBlockDef(vox->id);
|
Block* block = contentIds->getBlockDef(vox->id);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "Block.h"
|
#include "Block.h"
|
||||||
|
|
||||||
BlockRotProfile BlockRotProfile::PIPE {{
|
BlockRotProfile BlockRotProfile::PIPE {{
|
||||||
// Vertical
|
{ { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 0, 0, 0 } }, // BLOCK_DIR_PY
|
||||||
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}},
|
{ { 0,-1, 0 }, { 1, 0, 0 }, { 0, 0, 1 }, { 0, 1, 0 } }, // BLOCK_DIR_PX
|
||||||
// X-Aligned
|
{ { 1, 0, 0 }, { 0, 0, 1 }, { 0,-1, 0 }, { 0, 0,-1 } }, // BLOCK_DIR_PZ
|
||||||
{{0, -1, 0}, {1, 0, 0}, {0, 0, 1}, {0, 1, 0}},
|
{ { 0, 1, 0 }, {-1, 0, 0 }, { 0, 0, 1 }, { 1, 0, 0 } }, // BLOCK_DIR_MX
|
||||||
// Z-Aligned
|
{ {-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, 0, -1}},
|
{ { 1, 0, 0 }, { 0, 0,-1 }, { 0, 1, 0 }, { 0, 1, 0 } }, // BLOCK_DIR_MZ
|
||||||
}};
|
}};
|
||||||
|
|
||||||
Block::Block(std::string name)
|
Block::Block(std::string name)
|
||||||
|
|||||||
@@ -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);
|
int tree = generate_tree(&noise, &randomtree, heights, humidity, real_x, real_y, real_z, treesTile);
|
||||||
if (tree) {
|
if (tree) {
|
||||||
id = 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){
|
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)){
|
if ((height > SEA_LEVEL+1) && ((int)(height + 1) == real_y) && ((unsigned short)randomgrass.rand() > 65533)){
|
||||||
id = idWood;
|
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].id = id;
|
||||||
voxels[(y * CHUNK_D + z) * CHUNK_W + x].states = states;
|
voxels[(y * CHUNK_D + z) * CHUNK_W + x].states = states;
|
||||||
|
|||||||
+6
-3
@@ -3,9 +3,12 @@
|
|||||||
|
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
#define BLOCK_DIR_X 0x1
|
#define BLOCK_DIR_PX 0x1
|
||||||
#define BLOCK_DIR_Y 0x0
|
#define BLOCK_DIR_PY 0x0
|
||||||
#define BLOCK_DIR_Z 0x2
|
#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
|
// limited to 16 block orientations
|
||||||
#define BLOCK_ROT_MASK 0xF
|
#define BLOCK_ROT_MASK 0xF
|
||||||
|
|||||||
Reference in New Issue
Block a user