feat: voxel fragment rotation applying to 'stairs' profile

This commit is contained in:
MihailRis 2025-04-30 21:56:04 +03:00
parent 3e2bf8a1d3
commit 12c7d4dfb4
2 changed files with 6 additions and 12 deletions

View File

@ -336,17 +336,8 @@ static int determine_rotation(
if (norm.y < 0.0f) return BLOCK_DIR_DOWN;
if (norm.z > 0.0f) return BLOCK_DIR_NORTH;
if (norm.z < 0.0f) return BLOCK_DIR_SOUTH;
} else if (name == "pane") {
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;
}
} else if (name == "stairs") {
int verticalBit = ((norm.y - camDir.y * 0.5f) < 0.0) ? 4 : 0;
} else if (name == "pane" || name == "stairs") {
int verticalBit = (name == "stairs" && (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;

View File

@ -209,10 +209,13 @@ std::unique_ptr<VoxelFragment> VoxelFragment::rotated(const Content& content) co
| ((voxel.state.segment & 0b100) >> 2);
auto& def = content.blocks.require(blockNames[voxel.id]);
if (def.rotations.name == BlockRotProfile::PANE_NAME ||
def.rotations.name == BlockRotProfile::PIPE_NAME){
def.rotations.name == BlockRotProfile::PIPE_NAME) {
if (voxel.state.rotation < 4) {
voxel.state.rotation = (voxel.state.rotation + 3) & 0b11;
}
} else if (def.rotations.name == BlockRotProfile::STAIRS_NAME) {
voxel.state.rotation = ((voxel.state.rotation + 3) & 0b11) |
(voxel.state.rotation & 0b100);
}
}
}