Full vertical block rotation
This commit is contained in:
parent
8bc8eb14bd
commit
361a2eac67
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user