]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client/content_mapblock.cpp
Remove unused ITextSceneNode header (#11476)
[dragonfireclient.git] / src / client / content_mapblock.cpp
index e530f3d7f3f29b839ddf4eef4a395b7408036e42..bb2d6398f1015c855a19d07dc3f495fbcaeaafa2 100644 (file)
@@ -61,7 +61,7 @@ static constexpr u16 quad_indices[] = {0, 1, 2, 2, 3, 0};
 const std::string MapblockMeshGenerator::raillike_groupname = "connect_to_raillike";
 
 MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output,
-       irr::scene::IMeshManipulator *mm):
+       scene::IMeshManipulator *mm):
        data(input),
        collector(output),
        nodedef(data->m_client->ndef()),
@@ -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--;
 }