51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef CONTENT_MAPBLOCK_HEADER
-#define CONTENT_MAPBLOCK_HEADER
-#include "util/numeric.h"
+#pragma once
+
#include "nodedef.h"
#include <IMeshManipulator.h>
struct MeshMakeData;
struct MeshCollector;
-struct LightFrame
-{
+struct LightPair {
+ u8 lightA;
+ u8 lightB;
+
+ LightPair() = default;
+ explicit LightPair(u16 value) : lightA(value & 0xff), lightB(value >> 8) {}
+ LightPair(u8 valueA, u8 valueB) : lightA(valueA), lightB(valueB) {}
+ LightPair(float valueA, float valueB) :
+ lightA(core::clamp(core::round32(valueA), 0, 255)),
+ lightB(core::clamp(core::round32(valueB), 0, 255)) {}
+ operator u16() const { return lightA | lightB << 8; }
+};
+
+struct LightFrame {
f32 lightsA[8];
f32 lightsB[8];
};
MeshMakeData *data;
MeshCollector *collector;
- INodeDefManager *nodedef;
- scene::ISceneManager *smgr;
+ const NodeDefManager *nodedef;
scene::IMeshManipulator *meshmanip;
// options
v3f origin;
MapNode n;
const ContentFeatures *f;
- u16 light;
+ LightPair light;
LightFrame frame;
video::SColor color;
TileSpec tile;
// 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);
+ LightPair blendLight(const v3f &vertex_pos);
+ video::SColor blendLightColor(const v3f &vertex_pos);
+ video::SColor blendLightColor(const v3f &vertex_pos, const v3f &vertex_normal);
- void useTile(int index, bool disable_backface_culling);
- void useDefaultTile(bool set_color = true);
- TileSpec getTile(const v3s16 &direction);
+ void useTile(int index = 0, u8 set_flags = MATERIAL_FLAG_CRACK_OVERLAY,
+ u8 reset_flags = 0, bool special = false);
+ void getTile(int index, TileSpec *tile);
+ void getTile(v3s16 direction, TileSpec *tile);
+ void getSpecialTile(int index, TileSpec *tile, bool apply_crack = false);
// face drawing
- void drawQuad(v3f *vertices, const v3s16 &normal = v3s16(0, 0, 0));
+ void drawQuad(v3f *vertices, const v3s16 &normal = v3s16(0, 0, 0),
+ float vertical_tiling = 1.0);
// cuboid drawing!
void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount,
- const u16 *lights , const f32 *txc);
+ const LightPair *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;
+ bool draw_liquid_bottom;
TileSpec tile_liquid;
TileSpec tile_liquid_top;
content_t c_flowing;
NeighborData liquid_neighbors[3][3];
f32 corner_levels[2][2];
- void prepareLiquidNodeDrawing(bool flowing);
- void getLiquidNeighborhood(bool flowing);
- void resetCornerLevels();
+ void prepareLiquidNodeDrawing();
+ void getLiquidNeighborhood();
void calculateCornerLevels();
f32 getCornerLevel(int i, int k);
- void drawLiquidSides(bool flowing);
- void drawLiquidTop(bool flowing);
+ void drawLiquidSides();
+ void drawLiquidTop();
+ void drawLiquidBottom();
// raillike-specific
// name of the group that enables connecting to raillike nodes of different kind
int rotate_degree;
bool random_offset_Y;
int face_num;
+ float plant_height;
void drawPlantlikeQuad(float rotation, float quad_offset = 0,
bool offset_top_only = false);
+ void drawPlantlike();
// firelike-specific
void drawFirelikeQuad(float rotation, float opening_angle,
float offset_h, float offset_v = 0.0);
// drawtypes
- void drawLiquidNode(bool flowing);
+ void drawLiquidNode();
void drawGlasslikeNode();
void drawGlasslikeFramedNode();
void drawAllfacesNode();
void drawTorchlikeNode();
void drawSignlikeNode();
void drawPlantlikeNode();
+ void drawPlantlikeRootedNode();
void drawFirelikeNode();
void drawFencelikeNode();
void drawRaillikeNode();
public:
MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output);
void generate();
+ void renderSingle(content_t node);
};
-
-#endif