mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 22:11:51 +00:00
Merge pull request #924 from Neveix/feat-block-ladder-rotation
Add block ladder rotation
This commit is contained in:
commit
021e00422b
7 changed files with 34 additions and 1 deletions
|
|
@ -69,6 +69,7 @@ Rotation profile (set of available block rotations and behaviour of placing bloc
|
||||||
- "pipe" - wood logs, pipes, pillars
|
- "pipe" - wood logs, pipes, pillars
|
||||||
- "pane" - panels, doors, signs
|
- "pane" - panels, doors, signs
|
||||||
- "stairs" - "pane" + flipped variants
|
- "stairs" - "pane" + flipped variants
|
||||||
|
- "ladder" - like a "pipe", but on horizontal surfaces it is installed like "pane"
|
||||||
|
|
||||||
### *particles*
|
### *particles*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@
|
||||||
- "pipe" - профиль "труба". Примеры блоков: бревно, труба, лампочка
|
- "pipe" - профиль "труба". Примеры блоков: бревно, труба, лампочка
|
||||||
- "pane" - профиль "панель". Примеры блоков: панель, дверь, табличка
|
- "pane" - профиль "панель". Примеры блоков: панель, дверь, табличка
|
||||||
- "stairs" - профиль "ступеньки" ("pane" + перевернутые варианты)
|
- "stairs" - профиль "ступеньки" ("pane" + перевернутые варианты)
|
||||||
|
- "ladder" - профиль "лестница" (как "pipe", но на горизонтальных поверхностях как "pane")
|
||||||
|
|
||||||
### Испускаемые частицы - *particles*
|
### Испускаемые частицы - *particles*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,8 @@ template<> void ContentUnitLoader<Block>::loadUnit(
|
||||||
def.rotations = BlockRotProfile::PANE;
|
def.rotations = BlockRotProfile::PANE;
|
||||||
} else if (profile == BlockRotProfile::STAIRS_NAME) {
|
} else if (profile == BlockRotProfile::STAIRS_NAME) {
|
||||||
def.rotations = BlockRotProfile::STAIRS;
|
def.rotations = BlockRotProfile::STAIRS;
|
||||||
|
} else if (profile == BlockRotProfile::LADDER_NAME) {
|
||||||
|
def.rotations = BlockRotProfile::LADDER;
|
||||||
} else if (profile != "none") {
|
} else if (profile != "none") {
|
||||||
logger.error() << "unknown rotation profile " << profile;
|
logger.error() << "unknown rotation profile " << profile;
|
||||||
def.rotatable = false;
|
def.rotatable = false;
|
||||||
|
|
|
||||||
|
|
@ -340,6 +340,19 @@ static int determine_rotation(
|
||||||
if (camDir.z > 0.0f) return BLOCK_DIR_SOUTH | verticalBit;
|
if (camDir.z > 0.0f) return BLOCK_DIR_SOUTH | verticalBit;
|
||||||
if (camDir.z < 0.0f) return BLOCK_DIR_NORTH | verticalBit;
|
if (camDir.z < 0.0f) return BLOCK_DIR_NORTH | verticalBit;
|
||||||
}
|
}
|
||||||
|
} else if (name == "ladder") {
|
||||||
|
if (norm.x < 0.0f) return BLOCK_DIR_EAST;
|
||||||
|
if (norm.x > 0.0f) return BLOCK_DIR_WEST;
|
||||||
|
if (norm.z > 0.0f) return BLOCK_DIR_NORTH;
|
||||||
|
if (norm.z < 0.0f) return BLOCK_DIR_SOUTH;
|
||||||
|
if (abs(camDir.x) > abs(camDir.z)) {
|
||||||
|
if (camDir.x > 0.0f) return BLOCK_DIR_EAST;
|
||||||
|
if (camDir.x < 0.0f) return BLOCK_DIR_WEST;
|
||||||
|
}
|
||||||
|
if (abs(camDir.x) < abs(camDir.z)) {
|
||||||
|
if (camDir.z > 0.0f) return BLOCK_DIR_SOUTH;
|
||||||
|
if (camDir.z < 0.0f) return BLOCK_DIR_NORTH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,17 @@ const BlockRotProfile BlockRotProfile::STAIRS {
|
||||||
8
|
8
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const BlockRotProfile BlockRotProfile::LADDER {
|
||||||
|
"ladder",
|
||||||
|
{
|
||||||
|
{{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
|
||||||
|
},
|
||||||
|
4
|
||||||
|
};
|
||||||
|
|
||||||
Block::Block(const std::string& name)
|
Block::Block(const std::string& name)
|
||||||
: name(name), caption(util::id_to_caption(name)) {
|
: name(name), caption(util::id_to_caption(name)) {
|
||||||
for (int i = 0; i < defaults.textureFaces.size(); i++) {
|
for (int i = 0; i < defaults.textureFaces.size(); i++) {
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,13 @@ struct BlockRotProfile {
|
||||||
/// @brief Stairs, stairs and stairs
|
/// @brief Stairs, stairs and stairs
|
||||||
static const BlockRotProfile STAIRS;
|
static const BlockRotProfile STAIRS;
|
||||||
|
|
||||||
|
/// @brief Ladders, wall signs, paintings
|
||||||
|
static const BlockRotProfile LADDER;
|
||||||
|
|
||||||
static inline std::string PIPE_NAME = "pipe";
|
static inline std::string PIPE_NAME = "pipe";
|
||||||
static inline std::string PANE_NAME = "pane";
|
static inline std::string PANE_NAME = "pane";
|
||||||
static inline std::string STAIRS_NAME = "stairs";
|
static inline std::string STAIRS_NAME = "stairs";
|
||||||
|
static inline std::string LADDER_NAME = "ladder";
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class BlockModelType {
|
enum class BlockModelType {
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,8 @@ std::unique_ptr<VoxelFragment> VoxelFragment::rotated(const Content& content) co
|
||||||
| ((voxel.state.segment & 0b100) >> 2);
|
| ((voxel.state.segment & 0b100) >> 2);
|
||||||
auto& def = content.blocks.require(blockNames[voxel.id]);
|
auto& def = content.blocks.require(blockNames[voxel.id]);
|
||||||
if (def.rotations.name == BlockRotProfile::PANE_NAME ||
|
if (def.rotations.name == BlockRotProfile::PANE_NAME ||
|
||||||
def.rotations.name == BlockRotProfile::PIPE_NAME) {
|
def.rotations.name == BlockRotProfile::PIPE_NAME ||
|
||||||
|
def.rotations.name == BlockRotProfile::LADDER_NAME) {
|
||||||
if (voxel.state.rotation < 4) {
|
if (voxel.state.rotation < 4) {
|
||||||
voxel.state.rotation = (voxel.state.rotation + 3) & 0b11;
|
voxel.state.rotation = (voxel.state.rotation + 3) & 0b11;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue