Pane place direction fixed
This commit is contained in:
parent
d9bc17e9b6
commit
a691526693
@ -27,6 +27,7 @@ const float CROUCH_SHIFT_Y = -0.2f;
|
||||
|
||||
using glm::vec2;
|
||||
using glm::vec3;
|
||||
using std::string;
|
||||
|
||||
CameraControl::CameraControl(Player* player, const CameraSettings& settings)
|
||||
: player(player),
|
||||
@ -218,14 +219,28 @@ void PlayerController::updateInteraction(){
|
||||
int z = (int)iend.z;
|
||||
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;
|
||||
Block* def = contentIds->getBlockDef(player->choosenBlock);
|
||||
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;
|
||||
}
|
||||
} else if (name == "pane") {
|
||||
vec3 vec = camera->dir;
|
||||
if (abs(vec.x) > abs(vec.z)){
|
||||
if (vec.x > 0.0f) states = BLOCK_DIR_EAST;
|
||||
if (vec.x < 0.0f) states = BLOCK_DIR_WEST;
|
||||
}
|
||||
if (abs(vec.x) < abs(vec.z)){
|
||||
if (vec.z > 0.0f) states = BLOCK_DIR_SOUTH;
|
||||
if (vec.z < 0.0f) states = BLOCK_DIR_NORTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ void CoordSystem::transform(AABB& aabb) {
|
||||
aabb.b += fix2;
|
||||
}
|
||||
|
||||
const BlockRotProfile BlockRotProfile::PIPE {{
|
||||
const BlockRotProfile BlockRotProfile::PIPE {"pipe", {
|
||||
// Vertical
|
||||
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}, {0, 0, 0}},
|
||||
// X-Aligned
|
||||
@ -21,7 +21,7 @@ const BlockRotProfile BlockRotProfile::PIPE {{
|
||||
{{1, 0, 0}, {0, 0, 1}, {0, -1, 0}, {0, 0, -1}, {0, 1, 0}},
|
||||
}};
|
||||
|
||||
const BlockRotProfile BlockRotProfile::PANE {{
|
||||
const BlockRotProfile BlockRotProfile::PANE {"pane", {
|
||||
// North
|
||||
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}, {0, 0, 0}},
|
||||
// East
|
||||
|
||||
@ -29,6 +29,7 @@ struct CoordSystem {
|
||||
|
||||
struct BlockRotProfile {
|
||||
static const int MAX_COUNT = 16;
|
||||
std::string name;
|
||||
CoordSystem variants[MAX_COUNT];
|
||||
|
||||
/* Wood logs, pillars, pipes */
|
||||
|
||||
@ -7,6 +7,11 @@ 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;
|
||||
|
||||
// limited to 16 block orientations
|
||||
const int BLOCK_ROT_MASK = 0xF;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user