summaryrefslogtreecommitdiff
path: root/src/content_mapblock.h
diff options
context:
space:
mode:
authornumber Zero <silverunicorn2011@yandex.ru>2017-02-13 19:31:43 +0300
committerparamat <mat.gregory@virginmedia.com>2017-03-20 20:28:22 +0000
commitd4e0c0f9b818120286369b33b1bdb5eb6ece7a83 (patch)
tree3ed6ca31234a35f8f445a078a38b7977f759814b /src/content_mapblock.h
parente7246d3f0deed22f7d81e8988f656c594720d672 (diff)
downloadminetest-d4e0c0f9b818120286369b33b1bdb5eb6ece7a83.tar.gz
minetest-d4e0c0f9b818120286369b33b1bdb5eb6ece7a83.tar.bz2
minetest-d4e0c0f9b818120286369b33b1bdb5eb6ece7a83.zip
Content_mapblock.cpp: Refactor
Diffstat (limited to 'src/content_mapblock.h')
-rw-r--r--src/content_mapblock.h124
1 files changed, 121 insertions, 3 deletions
diff --git a/src/content_mapblock.h b/src/content_mapblock.h
index bb1e129da..c8425024f 100644
--- a/src/content_mapblock.h
+++ b/src/content_mapblock.h
@@ -19,11 +19,129 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef CONTENT_MAPBLOCK_HEADER
#define CONTENT_MAPBLOCK_HEADER
+#include "util/numeric.h"
+#include "nodedef.h"
+#include <IMeshManipulator.h>
struct MeshMakeData;
struct MeshCollector;
-void mapblock_mesh_generate_special(MeshMakeData *data,
- MeshCollector &collector);
-#endif
+struct LightFrame
+{
+ f32 lightsA[8];
+ f32 lightsB[8];
+};
+
+class MapblockMeshGenerator
+{
+public:
+ MeshMakeData *data;
+ MeshCollector *collector;
+
+ INodeDefManager *nodedef;
+ scene::ISceneManager *smgr;
+ scene::IMeshManipulator *meshmanip;
+
+// options
+ bool enable_mesh_cache;
+
+// current node
+ v3s16 blockpos_nodes;
+ v3s16 p;
+ v3f origin;
+ MapNode n;
+ const ContentFeatures *f;
+ u16 light;
+ LightFrame frame;
+ video::SColor color;
+ TileSpec tile;
+ float scale;
+
+// lighting
+ void getSmoothLightFrame();
+ u16 blendLight(const v3f &vertex_pos);
+ video::SColor blendLight(const v3f &vertex_pos, video::SColor tile_color);
+ video::SColor blendLight(const v3f &vertex_pos, const v3f &vertex_normal, video::SColor tile_color);
+
+ void useTile(int index, bool disable_backface_culling);
+ void useDefaultTile(bool set_color = true);
+ TileSpec getTile(const v3s16 &direction);
+
+// face drawing
+ void drawQuad(v3f *vertices, const v3s16 &normal = v3s16(0, 0, 0));
+
+// cuboid drawing!
+ void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount,
+ const u16 *lights , const f32 *txc);
+ void generateCuboidTextureCoords(aabb3f const &box, f32 *coords);
+ void drawAutoLightedCuboid(aabb3f box, const f32 *txc = NULL,
+ TileSpec *tiles = NULL, int tile_count = 0);
+
+// liquid-specific
+ bool top_is_same_liquid;
+ TileSpec tile_liquid;
+ TileSpec tile_liquid_top;
+ content_t c_flowing;
+ content_t c_source;
+ video::SColor color_liquid_top;
+ struct NeighborData {
+ f32 level;
+ content_t content;
+ bool is_same_liquid;
+ bool top_is_same_liquid;
+ };
+ NeighborData liquid_neighbors[3][3];
+ f32 corner_levels[2][2];
+ void prepareLiquidNodeDrawing(bool flowing);
+ void getLiquidNeighborhood(bool flowing);
+ void resetCornerLevels();
+ void calculateCornerLevels();
+ f32 getCornerLevel(int i, int k);
+ void drawLiquidSides(bool flowing);
+ void drawLiquidTop(bool flowing);
+
+// raillike-specific
+ // name of the group that enables connecting to raillike nodes of different kind
+ static const std::string raillike_groupname;
+ int raillike_group;
+ bool isSameRail(v3s16 dir);
+
+// plantlike-specific
+ PlantlikeStyle draw_style;
+ v3f offset;
+ int rotate_degree;
+ bool random_offset_Y;
+ int face_num;
+
+ void drawPlantlikeQuad(float rotation, float quad_offset = 0,
+ bool offset_top_only = false);
+
+// firelike-specific
+ void drawFirelikeQuad(float rotation, float opening_angle,
+ float offset_h, float offset_v = 0.0);
+
+// drawtypes
+ void drawLiquidNode(bool flowing);
+ void drawGlasslikeNode();
+ void drawGlasslikeFramedNode();
+ void drawAllfacesNode();
+ void drawTorchlikeNode();
+ void drawSignlikeNode();
+ void drawPlantlikeNode();
+ void drawFirelikeNode();
+ void drawFencelikeNode();
+ void drawRaillikeNode();
+ void drawNodeboxNode();
+ void drawMeshNode();
+
+// common
+ void errorUnknownDrawtype();
+ void drawNode();
+
+public:
+ MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output);
+ void generate();
+};
+
+#endif