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