Merge pull request #38 from clasher113/main
Completed vertical block rotation (pipe)
This commit is contained in:
commit
fd11b55be7
@ -3,6 +3,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../typedefs.h"
|
||||
|
||||
class Texture;
|
||||
class Batch2D;
|
||||
|
||||
@ -224,14 +224,12 @@ void PlayerController::updateInteraction(){
|
||||
if (def->rotatable){
|
||||
const string& name = def->rotations.name;
|
||||
if (name == "pipe") {
|
||||
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.0f) states = BLOCK_DIR_WEST;
|
||||
else if (norm.x > 0.0f) states = BLOCK_DIR_EAST;
|
||||
else if (norm.y > 0.0f) states = BLOCK_DIR_UP;
|
||||
else if (norm.y < 0.0f) states = BLOCK_DIR_DOWN;
|
||||
else if (norm.z > 0.0f) states = BLOCK_DIR_NORTH;
|
||||
else if (norm.z < 0.0f) states = BLOCK_DIR_SOUTH;
|
||||
} else if (name == "pane") {
|
||||
vec3 vec = camera->dir;
|
||||
if (abs(vec.x) > abs(vec.z)){
|
||||
|
||||
@ -15,23 +15,19 @@ void CoordSystem::transform(AABB& aabb) {
|
||||
}
|
||||
|
||||
const BlockRotProfile BlockRotProfile::PIPE {"pipe", {
|
||||
// Vertical
|
||||
{{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}},
|
||||
// Z-Aligned
|
||||
{{1, 0, 0}, {0, 0, 1}, {0, -1, 0}, {0, 0, -1}, {0, 1, 0}},
|
||||
{ { 1, 0, 0 }, { 0, 0, 1 }, { 0,-1, 0 }, { 0, 0,-1 }, { 0, 1, 0 } }, // North
|
||||
{ { 0, 1, 0 }, {-1, 0, 0 }, { 0, 0, 1 }, { 1, 0, 0 }, { 1, 0, 0 } }, // East
|
||||
{ { 1, 0, 0 }, { 0, 0,-1 }, { 0, 1, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }, // South
|
||||
{ { 0,-1, 0 }, { 1, 0, 0 }, { 0, 0, 1 }, { 0, 1, 0 }, { 0, 1, 0 } }, // West
|
||||
{ { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }, // Up
|
||||
{ { 1, 0, 0 }, { 0,-1, 0 }, { 0, 0,-1 }, { 0, 1,-1 }, { 0, 1, 1 } }, // Down
|
||||
}};
|
||||
|
||||
const BlockRotProfile BlockRotProfile::PANE {"pane", {
|
||||
// North
|
||||
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}, {0, 0, 0}},
|
||||
// East
|
||||
{{0, 0, -1}, {0, 1, 0}, {1, 0, 0}, {1, 0, 0}, {0, 0, 1}},
|
||||
// South
|
||||
{{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}, {1, 0, -1}, {1, 0, 1}},
|
||||
// West
|
||||
{{0, 0, 1}, {0, 1, 0}, {-1, 0, 0}, {0, 0, -1}, {1, 0, 0}},
|
||||
{ { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }, // North
|
||||
{ { 0, 0,-1 }, { 0, 1, 0 }, { 1, 0, 0 }, { 1, 0, 0 }, { 0, 0, 1 } }, // East
|
||||
{ {-1, 0, 0 }, { 0, 1, 0 }, { 0, 0,-1 }, { 1, 0,-1 }, { 1, 0, 1 } }, // South
|
||||
{ { 0, 0, 1 }, { 0, 1, 0 }, {-1, 0, 0 }, { 0, 0,-1 }, { 1, 0, 0 } }, // West
|
||||
}};
|
||||
|
||||
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_UP;
|
||||
}
|
||||
}
|
||||
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_UP;
|
||||
}
|
||||
voxels[(y * CHUNK_D + z) * CHUNK_W + x].id = id;
|
||||
voxels[(y * CHUNK_D + z) * CHUNK_W + x].states = states;
|
||||
|
||||
@ -3,14 +3,12 @@
|
||||
|
||||
#include "../typedefs.h"
|
||||
|
||||
const int BLOCK_DIR_X = 0x1;
|
||||
const int BLOCK_DIR_Y = 0x0;
|
||||
const int BLOCK_DIR_Z = 0x2;
|
||||
|
||||
const int BLOCK_DIR_NORTH = 0x0;
|
||||
const int BLOCK_DIR_WEST = 0x1;
|
||||
const int BLOCK_DIR_SOUTH = 0x2;
|
||||
const int BLOCK_DIR_EAST = 0x3;
|
||||
const int BLOCK_DIR_UP = 0x4;
|
||||
const int BLOCK_DIR_DOWN = 0x5;
|
||||
|
||||
// limited to 16 block orientations
|
||||
const int BLOCK_ROT_MASK = 0xF;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user