mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
feat: 'stairs' rotation profile
This commit is contained in:
parent
50aae8b98b
commit
9463917164
4 changed files with 33 additions and 1 deletions
|
|
@ -122,6 +122,8 @@ template<> void ContentUnitLoader<Block>::loadUnit(
|
|||
def.rotations = BlockRotProfile::PIPE;
|
||||
} else if (profile == BlockRotProfile::PANE_NAME) {
|
||||
def.rotations = BlockRotProfile::PANE;
|
||||
} else if (profile == BlockRotProfile::STAIRS_NAME) {
|
||||
def.rotations = BlockRotProfile::STAIRS;
|
||||
} else if (profile != "none") {
|
||||
logger.error() << "unknown rotation profile " << profile;
|
||||
def.rotatable = false;
|
||||
|
|
|
|||
|
|
@ -345,6 +345,16 @@ static int determine_rotation(
|
|||
if (camDir.z > 0.0f) return BLOCK_DIR_SOUTH;
|
||||
if (camDir.z < 0.0f) return BLOCK_DIR_NORTH;
|
||||
}
|
||||
} else if (name == "stairs") {
|
||||
int verticalBit = ((norm.y - camDir.y * 0.5f) < 0.0) ? 4 : 0;
|
||||
if (abs(camDir.x) > abs(camDir.z)) {
|
||||
if (camDir.x > 0.0f) return BLOCK_DIR_EAST | verticalBit;
|
||||
if (camDir.x < 0.0f) return BLOCK_DIR_WEST | verticalBit;
|
||||
}
|
||||
if (abs(camDir.x) < abs(camDir.z)) {
|
||||
if (camDir.z > 0.0f) return BLOCK_DIR_SOUTH | verticalBit;
|
||||
if (camDir.z < 0.0f) return BLOCK_DIR_NORTH | verticalBit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -421,7 +431,7 @@ void PlayerController::processRightClick(
|
|||
auto camera = player.fpCamera.get();
|
||||
|
||||
blockstate state {};
|
||||
state.rotation = determine_rotation(&def, selection.normal, camera->dir);
|
||||
state.rotation = determine_rotation(&def, selection.normal, camera->front);
|
||||
|
||||
if (!input.shift && target.rt.funcsset.oninteract) {
|
||||
if (scripting::on_block_interact(
|
||||
|
|
|
|||
|
|
@ -91,6 +91,22 @@ const BlockRotProfile BlockRotProfile::PANE {
|
|||
4
|
||||
};
|
||||
|
||||
const BlockRotProfile BlockRotProfile::STAIRS {
|
||||
"stairs",
|
||||
{
|
||||
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, // North
|
||||
{{0, 0, -1}, {0, 1, 0}, {1, 0, 0}}, // East
|
||||
{{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}}, // South
|
||||
{{0, 0, 1}, {0, 1, 0}, {-1, 0, 0}}, // West
|
||||
|
||||
{{-1, 0, 0}, {0, -1, 0}, {0, 0, 1}},
|
||||
{{0, 0, 1}, {0, -1, 0}, {1, 0, 0}},
|
||||
{{1, 0, 0}, {0, -1, 0}, {0, 0, -1}},
|
||||
{{0, 0, -1}, {0, -1, 0}, {-1, 0, 0}},
|
||||
},
|
||||
8
|
||||
};
|
||||
|
||||
Block::Block(const std::string& name)
|
||||
: name(name),
|
||||
caption(util::id_to_caption(name)),
|
||||
|
|
|
|||
|
|
@ -77,8 +77,12 @@ struct BlockRotProfile {
|
|||
/// @brief Doors, signs and other panes
|
||||
static const BlockRotProfile PANE;
|
||||
|
||||
/// @brief Stairs, stairs and stairs
|
||||
static const BlockRotProfile STAIRS;
|
||||
|
||||
static inline std::string PIPE_NAME = "pipe";
|
||||
static inline std::string PANE_NAME = "pane";
|
||||
static inline std::string STAIRS_NAME = "stairs";
|
||||
};
|
||||
|
||||
enum class BlockModelType {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue