fix upside down stair/slab placement

This commit is contained in:
darkrose 2013-11-17 18:18:31 +10:00
parent 656b8e53f5
commit aa649c6e03
3 changed files with 24 additions and 8 deletions

View File

@ -72,10 +72,10 @@ static void content_mapnode_nodebox_stairud(ContentFeatures *f)
f->addNodeBox(core::aabbox3d<f32>(
-0.5*BS,
-0.5*BS,
-0.5*BS,
0.,
0.5*BS,
0.,
0.
0.5*BS
));
}

View File

@ -44,8 +44,11 @@ static std::vector<aabb3f> transformNodeBox(MapNode &n,
{
std::vector<aabb3f> boxes;
int facedir = 0;
if (content_features(n).param2_type == CPT_FACEDIR_SIMPLE)
if (content_features(n).param2_type == CPT_FACEDIR_SIMPLE) {
facedir = n.param2&0x0F;
}else if (content_features(n).param_type == CPT_FACEDIR_SIMPLE) {
facedir = n.param1;
}
for(std::vector<aabb3f>::const_iterator
i = nodebox.begin();
i != nodebox.end(); i++)

View File

@ -3152,13 +3152,26 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
// Stairs and Slabs special functions
if (n.getContent() >= CONTENT_SLAB_STAIR_MIN && n.getContent() <= CONTENT_SLAB_STAIR_UD_MAX) {
MapNode abv = m_env.getMap().getNodeNoEx(p_over+p_dir);
// Make a cube is two slabs of the same type are stacked on each other
if (content_features(n).slab_cube_type != CONTENT_IGNORE && content_features(n).slab_cube_type == content_features(abv).slab_cube_type) {
// Flip it upside down if it's being placed on the roof
// or if placing against an upside down node
if (
p_dir.Y == 1
|| (
abv.getContent() >= CONTENT_SLAB_STAIR_UD_MIN
&& abv.getContent() <= CONTENT_SLAB_STAIR_UD_MAX
)
) {
n.setContent(n.getContent()|CONTENT_SLAB_STAIR_FLIP);
}
// Make a cube if two slabs of the same type are stacked on each other
if (
p_dir.X == 0
&& p_dir.Z == 0
&& content_features(n).slab_cube_type != CONTENT_IGNORE
&& content_features(n).slab_cube_type == content_features(abv).slab_cube_type
) {
n.setContent(content_features(n).slab_cube_type);
p_over += p_dir;
// Flip it upside down if it's being placed on the roof
}else if (p_dir.Y == 1) {
n.setContent(n.getContent()|CONTENT_SLAB_STAIR_FLIP);
}
}