1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Add wallmounted support for plantlike and plantlike_rooted nodes (#11379)

This commit is contained in:
Wuzzy 2021-07-15 19:19:59 +00:00 committed by GitHub
parent 68143ed8ec
commit f4d8cc0f0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 90 additions and 7 deletions

View file

@ -958,10 +958,38 @@ void MapblockMeshGenerator::drawPlantlikeQuad(float rotation, float quad_offset,
vertex.rotateXZBy(rotation + rotate_degree);
vertex += offset;
}
u8 wall = n.getWallMounted(nodedef);
if (wall != DWM_YN) {
for (v3f &vertex : vertices) {
switch (wall) {
case DWM_YP:
vertex.rotateYZBy(180);
vertex.rotateXZBy(180);
break;
case DWM_XP:
vertex.rotateXYBy(90);
break;
case DWM_XN:
vertex.rotateXYBy(-90);
vertex.rotateYZBy(180);
break;
case DWM_ZP:
vertex.rotateYZBy(-90);
vertex.rotateXYBy(90);
break;
case DWM_ZN:
vertex.rotateYZBy(90);
vertex.rotateXYBy(90);
break;
}
}
}
drawQuad(vertices, v3s16(0, 0, 0), plant_height);
}
void MapblockMeshGenerator::drawPlantlike()
void MapblockMeshGenerator::drawPlantlike(bool is_rooted)
{
draw_style = PLANT_STYLE_CROSS;
scale = BS / 2 * f->visual_scale;
@ -998,6 +1026,22 @@ void MapblockMeshGenerator::drawPlantlike()
break;
}
if (is_rooted) {
u8 wall = n.getWallMounted(nodedef);
switch (wall) {
case DWM_YP:
offset.Y += BS*2;
break;
case DWM_XN:
case DWM_XP:
case DWM_ZN:
case DWM_ZP:
offset.X += -BS;
offset.Y += BS;
break;
}
}
switch (draw_style) {
case PLANT_STYLE_CROSS:
drawPlantlikeQuad(46);
@ -1048,7 +1092,7 @@ void MapblockMeshGenerator::drawPlantlikeRootedNode()
MapNode ntop = data->m_vmanip.getNodeNoEx(blockpos_nodes + p);
light = LightPair(getInteriorLight(ntop, 1, nodedef));
}
drawPlantlike();
drawPlantlike(true);
p.Y--;
}

View file

@ -146,7 +146,7 @@ public:
void drawPlantlikeQuad(float rotation, float quad_offset = 0,
bool offset_top_only = false);
void drawPlantlike();
void drawPlantlike(bool is_rooted = false);
// firelike-specific
void drawFirelikeQuad(float rotation, float opening_angle,

View file

@ -161,7 +161,9 @@ u8 MapNode::getWallMounted(const NodeDefManager *nodemgr) const
if (f.param_type_2 == CPT2_WALLMOUNTED ||
f.param_type_2 == CPT2_COLORED_WALLMOUNTED) {
return getParam2() & 0x07;
} else if (f.drawtype == NDT_SIGNLIKE || f.drawtype == NDT_TORCHLIKE) {
} else if (f.drawtype == NDT_SIGNLIKE || f.drawtype == NDT_TORCHLIKE ||
f.drawtype == NDT_PLANTLIKE ||
f.drawtype == NDT_PLANTLIKE_ROOTED) {
return 1;
}
return 0;