Luanti 5.16.0-dev
Loading...
Searching...
No Matches
MapblockMeshGenerator Class Reference

#include <content_mapblock.h>

Collaboration diagram for MapblockMeshGenerator:

Classes

struct  LiquidData
struct  RaillikeData
struct  PlantlikeData

Public Member Functions

 MapblockMeshGenerator (MeshMakeData *input, MeshCollector *output)
void generate ()

Private Member Functions

void getSmoothLightFrame ()
LightInfo 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 (TileSpec *tile_ret, int index=0, u8 set_flags=0, u8 reset_flags=0, bool special=false)
void getTile (int index, TileSpec *tile_ret)
void getTile (v3s16 direction, TileSpec *tile_ret)
void getSpecialTile (int index, TileSpec *tile_ret, bool apply_crack=false)
void drawQuad (const TileSpec &tile, v3f *vertices, const v3s16 &normal=v3s16(0, 0, 0), float vertical_tiling=1.0)
template<typename Fn>
void drawCuboid (const aabb3f &box, const TileSpec *tiles, int tilecount, const f32 *txc, u8 mask, Fn &&face_lighter)
void drawAutoLightedCuboid (aabb3f box, const TileSpec &tile, f32 const *txc=nullptr, u8 mask=0)
void drawAutoLightedCuboid (aabb3f box, const TileSpec *tiles, int tile_count, f32 const *txc=nullptr, u8 mask=0)
u8 getNodeBoxMask (aabb3f box, u8 solid_neighbors, u8 sametype_neighbors) const
void prepareLiquidNodeDrawing ()
void getLiquidNeighborhood ()
void calculateCornerLevels ()
f32 getCornerLevel (int i, int k) const
void drawLiquidSides ()
void drawLiquidTop ()
void drawLiquidBottom ()
bool isSameRail (v3s16 dir)
void drawPlantlikeQuad (const TileSpec &tile, float rotation, float quad_offset=0, bool offset_top_only=false)
void drawPlantlike (const TileSpec &tile, bool is_rooted=false)
void drawFirelikeQuad (const TileSpec &tile, float rotation, float opening_angle, float offset_h, float offset_v=0.0)
void drawSolidNode ()
void drawLiquidNode ()
void drawGlasslikeNode ()
void drawGlasslikeFramedNode ()
void drawAllfacesNode ()
void drawTorchlikeNode ()
void drawSignlikeNode ()
void drawPlantlikeNode ()
void drawPlantlikeRootedNode ()
void drawFirelikeNode ()
void drawFencelikeNode ()
void drawRaillikeNode ()
void drawNodeboxNode ()
void drawMeshNode ()
void errorUnknownDrawtype ()
void drawNode ()

Static Private Member Functions

static void generateCuboidTextureCoords (aabb3f const &box, f32 *coords)

Private Attributes

MeshMakeData *const data
MeshCollector *const collector
const NodeDefManager *const nodedef
const v3s16 blockpos_nodes
struct { 
   v3s16   p 
   v3f   origin 
   MapNode   n 
   const ContentFeatures *   f 
   LightFrame   lframe 
   video::SColor   lcolor 
cur_node
LiquidData cur_liquid
RaillikeData cur_rail
PlantlikeData cur_plant

Static Private Attributes

static const std::string raillike_groupname = "connect_to_raillike"

Constructor & Destructor Documentation

◆ MapblockMeshGenerator()

MapblockMeshGenerator::MapblockMeshGenerator ( MeshMakeData * input,
MeshCollector * output )

Member Function Documentation

◆ blendLight()

LightInfo MapblockMeshGenerator::blendLight ( const v3f & vertex_pos)
private

References BS, cur_node, SMOOTH_LIGHTING_OVERSIZE, x, y, and z.

Referenced by blendLightColor(), blendLightColor(), and drawAutoLightedCuboid().

Here is the caller graph for this function:

◆ blendLightColor() [1/2]

video::SColor MapblockMeshGenerator::blendLightColor ( const v3f & vertex_pos)
private

References blendLight(), cur_node, encode_light(), and LightInfo::getPair().

Referenced by drawLiquidBottom(), drawLiquidSides(), drawLiquidTop(), drawMeshNode(), and drawQuad().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blendLightColor() [2/2]

video::SColor MapblockMeshGenerator::blendLightColor ( const v3f & vertex_pos,
const v3f & vertex_normal )
private

References applyFacesShading(), blendLight(), cur_node, encode_light(), LightInfo::getPair(), and MYMAX.

Here is the call graph for this function:

◆ calculateCornerLevels()

void MapblockMeshGenerator::calculateCornerLevels ( )
private

References cur_liquid, and getCornerLevel().

Referenced by drawLiquidNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawAllfacesNode()

void MapblockMeshGenerator::drawAllfacesNode ( )
private

References BS, data, drawAutoLightedCuboid(), getSmoothLightFrame(), and getTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawAutoLightedCuboid() [1/2]

void MapblockMeshGenerator::drawAutoLightedCuboid ( aabb3f box,
const TileSpec & tile,
f32 const * txc = nullptr,
u8 mask = 0 )
private

References drawAutoLightedCuboid().

Referenced by drawAllfacesNode(), drawAutoLightedCuboid(), drawFencelikeNode(), drawGlasslikeFramedNode(), and drawNodeboxNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawAutoLightedCuboid() [2/2]

void MapblockMeshGenerator::drawAutoLightedCuboid ( aabb3f box,
const TileSpec * tiles,
int tile_count,
f32 const * txc = nullptr,
u8 mask = 0 )
private

References applyFacesShading(), blendLight(), cur_node, data, Diag02, Diag13, drawCuboid(), encode_light(), LightInfo::getPair(), light_indices, lightDiff(), and MYMAX.

Here is the call graph for this function:

◆ drawCuboid()

template<typename Fn>
void MapblockMeshGenerator::drawCuboid ( const aabb3f & box,
const TileSpec * tiles,
int tilecount,
const f32 * txc,
u8 mask,
Fn && face_lighter )
private

References collector, cur_node, Diag13, MYMIN, quad_indices_02, quad_indices_13, and setupCuboidVertices().

Referenced by drawAutoLightedCuboid(), and drawSolidNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawFencelikeNode()

void MapblockMeshGenerator::drawFencelikeNode ( )
private

References blockpos_nodes, BS, cur_node, data, drawAutoLightedCuboid(), ContentFeatures::drawtype, MATERIAL_FLAG_CRACK, NDT_FENCELIKE, nodedef, R90, TileSpec::rotation, and useTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawFirelikeNode()

void MapblockMeshGenerator::drawFirelikeNode ( )
private

References blockpos_nodes, BS, CONTENT_AIR, CONTENT_IGNORE, cur_node, D6D_XN, D6D_XP, D6D_YN, D6D_YP, D6D_ZN, D6D_ZP, data, drawFirelikeQuad(), g_6dirs, MapNode::getContent(), and useTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawFirelikeQuad()

void MapblockMeshGenerator::drawFirelikeQuad ( const TileSpec & tile,
float rotation,
float opening_angle,
float offset_h,
float offset_v = 0.0 )
private

References BS, cur_node, and drawQuad().

Referenced by drawFirelikeNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawGlasslikeFramedNode()

void MapblockMeshGenerator::drawGlasslikeFramedNode ( )
private

References blockpos_nodes, BS, CPT2_GLASSLIKE_LIQUID_LEVEL, cur_node, D6D_XN, D6D_XP, D6D_YN, D6D_YP, D6D_ZN, D6D_ZP, data, dir(), drawAutoLightedCuboid(), drawQuad(), FRAMED_EDGE_COUNT, FRAMED_NEIGHBOR_COUNT, g_26dirs, g_6dirs, generateCuboidTextureCoords(), MapNode::getContent(), getSpecialTile(), and getTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawGlasslikeNode()

void MapblockMeshGenerator::drawGlasslikeNode ( )
private

References blockpos_nodes, BS, cur_node, D6D_XN, D6D_XP, D6D_YN, D6D_YP, D6D_ZN, D6D_ZP, data, dir(), drawQuad(), g_6dirs, MapNode::getContent(), and useTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawLiquidBottom()

void MapblockMeshGenerator::drawLiquidBottom ( )
private

References blendLightColor(), BS, collector, cur_liquid, cur_node, data, and quad_indices.

Referenced by drawLiquidNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawLiquidNode()

void MapblockMeshGenerator::drawLiquidNode ( )
private

References calculateCornerLevels(), cur_liquid, drawLiquidBottom(), drawLiquidSides(), drawLiquidTop(), getLiquidNeighborhood(), and prepareLiquidNodeDrawing().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawLiquidSides()

void MapblockMeshGenerator::drawLiquidSides ( )
private

References blendLightColor(), BS, collector, MapblockMeshGenerator::LiquidData::NeighborData::content, cur_liquid, cur_node, data, MapblockMeshGenerator::LiquidData::NeighborData::is_same_liquid, nodedef, quad_indices, and MapblockMeshGenerator::LiquidData::NeighborData::top_is_same_liquid.

Referenced by drawLiquidNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawLiquidTop()

void MapblockMeshGenerator::drawLiquidTop ( )
private

References blendLightColor(), blockpos_nodes, BS, collector, cur_liquid, cur_node, data, dir(), quad_indices, x, and z.

Referenced by drawLiquidNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawMeshNode()

void MapblockMeshGenerator::drawMeshNode ( )
private

References applyFacesShading(), blendLightColor(), cloneStaticMesh(), collector, CPT2_4DIR, CPT2_COLORED_4DIR, CPT2_COLORED_DEGROTATE, CPT2_COLORED_FACEDIR, CPT2_COLORED_WALLMOUNTED, CPT2_DEGROTATE, CPT2_FACEDIR, CPT2_WALLMOUNTED, cur_node, data, MYMIN, nodedef, recalculateBoundingBox(), rotateMeshBy6dFacedir(), rotateMeshXZby(), useTile(), wallmounted_to_facedir, and warningstream.

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawNode()

void MapblockMeshGenerator::drawNode ( )
private

References BS, cur_node, data, drawAllfacesNode(), drawFencelikeNode(), drawFirelikeNode(), drawGlasslikeFramedNode(), drawGlasslikeNode(), drawLiquidNode(), drawMeshNode(), drawNodeboxNode(), drawPlantlikeNode(), drawPlantlikeRootedNode(), drawRaillikeNode(), drawSignlikeNode(), drawSolidNode(), drawTorchlikeNode(), encode_light(), errorUnknownDrawtype(), getInteriorLight(), getSmoothLightFrame(), intToFloat(), NDT_AIRLIKE, NDT_ALLFACES, NDT_FENCELIKE, NDT_FIRELIKE, NDT_FLOWINGLIQUID, NDT_GLASSLIKE, NDT_GLASSLIKE_FRAMED, NDT_LIQUID, NDT_MESH, NDT_NODEBOX, NDT_NORMAL, NDT_PLANTLIKE, NDT_PLANTLIKE_ROOTED, NDT_RAILLIKE, NDT_SIGNLIKE, NDT_TORCHLIKE, and nodedef.

Referenced by generate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawNodeboxNode()

void MapblockMeshGenerator::drawNodeboxNode ( )
private

References blockpos_nodes, BS, CPT2_4DIR, CPT2_COLORED_4DIR, CPT2_COLORED_FACEDIR, CPT2_COLORED_WALLMOUNTED, CPT2_FACEDIR, CPT2_LEVELED, CPT2_WALLMOUNTED, cur_node, data, dir(), drawAutoLightedCuboid(), generateCuboidTextureCoords(), getNodeBoxMask(), getTile(), NDT_NORMAL, NODEBOX_CONNECTED, nodedef, MapNode::param0, and MapNode::param2.

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawPlantlike()

void MapblockMeshGenerator::drawPlantlike ( const TileSpec & tile,
bool is_rooted = false )
private

References BS, CPT2_COLORED_DEGROTATE, CPT2_DEGROTATE, CPT2_LEVELED, CPT2_MESHOPTIONS, cur_node, cur_plant, drawPlantlikeQuad(), DWM_XN, DWM_XP, DWM_YP, DWM_ZN, DWM_ZP, MO_BIT_RANDOM_OFFSET, MO_BIT_RANDOM_OFFSET_Y, MO_BIT_SCALE_SQRT2, MO_MASK_STYLE, PseudoRandom::next(), nodedef, PLANT_STYLE_CROSS, PLANT_STYLE_CROSS2, PLANT_STYLE_HASH, PLANT_STYLE_HASH2, and PLANT_STYLE_STAR.

Referenced by drawPlantlikeNode(), and drawPlantlikeRootedNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawPlantlikeNode()

void MapblockMeshGenerator::drawPlantlikeNode ( )
private

References drawPlantlike(), and useTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawPlantlikeQuad()

void MapblockMeshGenerator::drawPlantlikeQuad ( const TileSpec & tile,
float rotation,
float quad_offset = 0,
bool offset_top_only = false )
private

References BS, cur_node, cur_plant, drawQuad(), DWM_XN, DWM_XP, DWM_YN, DWM_YP, DWM_ZN, DWM_ZP, PseudoRandom::next(), and nodedef.

Referenced by drawPlantlike().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawPlantlikeRootedNode()

void MapblockMeshGenerator::drawPlantlikeRootedNode ( )
private

References blockpos_nodes, BS, cur_node, data, drawPlantlike(), drawSolidNode(), encode_light(), getInteriorLight(), getSmoothLightFrame(), nodedef, and useTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawQuad()

void MapblockMeshGenerator::drawQuad ( const TileSpec & tile,
v3f * vertices,
const v3s16 & normal = v3s16(0, 0, 0),
float vertical_tiling = 1.0 )
private

References applyFacesShading(), blendLightColor(), collector, cur_node, data, and quad_indices.

Referenced by drawFirelikeQuad(), drawGlasslikeFramedNode(), drawGlasslikeNode(), drawPlantlikeQuad(), drawRaillikeNode(), drawSignlikeNode(), and drawTorchlikeNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawRaillikeNode()

void MapblockMeshGenerator::drawRaillikeNode ( )
private

References BS, cur_node, cur_rail, dir(), drawQuad(), isSameRail(), MATERIAL_FLAG_BACKFACE_CULLING, raillike_groupname, and useTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawSignlikeNode()

void MapblockMeshGenerator::drawSignlikeNode ( )
private

References BS, cur_node, drawQuad(), DWM_S1, DWM_S2, DWM_XN, DWM_XP, DWM_YN, DWM_YP, DWM_ZN, DWM_ZP, MATERIAL_FLAG_BACKFACE_CULLING, nodedef, and useTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawSolidNode()

void MapblockMeshGenerator::drawSolidNode ( )
private

References applyFacesShading(), blockpos_nodes, BS, CONTENT_AIR, CONTENT_IGNORE, cur_node, data, Diag02, Diag13, drawCuboid(), encode_light(), MapNode::getContent(), getFaceLight(), getSmoothLightSolid(), getTile(), light_dirs, light_indices, lightDiff(), MATERIAL_FLAG_BACKFACE_CULLING, NDT_LIQUID, NDT_NORMAL, and nodedef.

Referenced by drawNode(), and drawPlantlikeRootedNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawTorchlikeNode()

void MapblockMeshGenerator::drawTorchlikeNode ( )
private

References BS, cur_node, drawQuad(), DWM_S1, DWM_S2, DWM_XN, DWM_XP, DWM_YN, DWM_YP, DWM_ZN, DWM_ZP, MATERIAL_FLAG_BACKFACE_CULLING, nodedef, and useTile().

Referenced by drawNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ errorUnknownDrawtype()

void MapblockMeshGenerator::errorUnknownDrawtype ( )
private

References cur_node, FATAL_ERROR, and infostream.

Referenced by drawNode().

Here is the caller graph for this function:

◆ generate()

void MapblockMeshGenerator::generate ( )

References blockpos_nodes, cur_node, data, drawNode(), nodedef, and ZoneScoped.

Referenced by createGenericNodeMesh(), and generateNodeMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateCuboidTextureCoords()

void MapblockMeshGenerator::generateCuboidTextureCoords ( aabb3f const & box,
f32 * coords )
staticprivate

References BS.

Referenced by drawGlasslikeFramedNode(), and drawNodeboxNode().

Here is the caller graph for this function:

◆ getCornerLevel()

f32 MapblockMeshGenerator::getCornerLevel ( int i,
int k ) const
private

References BS, MapblockMeshGenerator::LiquidData::NeighborData::content, CONTENT_AIR, cur_liquid, MapblockMeshGenerator::LiquidData::NeighborData::level, and MapblockMeshGenerator::LiquidData::NeighborData::top_is_same_liquid.

Referenced by calculateCornerLevels().

Here is the caller graph for this function:

◆ getLiquidNeighborhood()

void MapblockMeshGenerator::getLiquidNeighborhood ( )
private

References blockpos_nodes, MapblockMeshGenerator::LiquidData::NeighborData::content, CONTENT_IGNORE, cur_liquid, cur_node, data, MapNode::getContent(), MapblockMeshGenerator::LiquidData::NeighborData::is_same_liquid, MapblockMeshGenerator::LiquidData::NeighborData::level, LIQUID_LEVEL_MASK, LIQUID_LEVEL_MAX, nodedef, MapNode::param2, rangelim(), and MapblockMeshGenerator::LiquidData::NeighborData::top_is_same_liquid.

Referenced by drawLiquidNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNodeBoxMask()

u8 MapblockMeshGenerator::getNodeBoxMask ( aabb3f box,
u8 solid_neighbors,
u8 sametype_neighbors ) const
private

References ALPHAMODE_OPAQUE, BS, and cur_node.

Referenced by drawNodeboxNode().

Here is the caller graph for this function:

◆ getSmoothLightFrame()

void MapblockMeshGenerator::getSmoothLightFrame ( )
private

References blockpos_nodes, cur_node, data, getSmoothLightTransparent(), light_dirs, LightPair::lightDay, and LightPair::lightNight.

Referenced by drawAllfacesNode(), drawNode(), and drawPlantlikeRootedNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSpecialTile()

void MapblockMeshGenerator::getSpecialTile ( int index,
TileSpec * tile_ret,
bool apply_crack = false )
private

References TileLayer::color, cur_node, TileLayer::empty(), f, TileLayer::has_color, TileSpec::layers, MATERIAL_FLAG_CRACK, and TileLayer::material_flags.

Referenced by drawGlasslikeFramedNode(), prepareLiquidNodeDrawing(), and useTile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTile() [1/2]

void MapblockMeshGenerator::getTile ( int index,
TileSpec * tile_ret )
private

References cur_node, data, and getNodeTileN().

Referenced by drawAllfacesNode(), drawGlasslikeFramedNode(), drawNodeboxNode(), drawSolidNode(), and useTile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTile() [2/2]

void MapblockMeshGenerator::getTile ( v3s16 direction,
TileSpec * tile_ret )
private

References cur_node, data, and getNodeTile().

Here is the call graph for this function:

◆ isSameRail()

bool MapblockMeshGenerator::isSameRail ( v3s16 dir)
private

References blockpos_nodes, cur_node, cur_rail, data, dir(), ContentFeatures::drawtype, MapNode::getContent(), ContentFeatures::getGroup(), NDT_RAILLIKE, nodedef, and raillike_groupname.

Referenced by drawRaillikeNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepareLiquidNodeDrawing()

void MapblockMeshGenerator::prepareLiquidNodeDrawing ( )
private

References blockpos_nodes, cur_liquid, cur_node, data, encode_light(), MapNode::getContent(), getInteriorLight(), getSpecialTile(), and nodedef.

Referenced by drawLiquidNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ useTile()

void MapblockMeshGenerator::useTile ( TileSpec * tile_ret,
int index = 0,
u8 set_flags = 0,
u8 reset_flags = 0,
bool special = false )
private

References cur_node, data, getSpecialTile(), getTile(), and TileSpec::layers.

Referenced by drawFencelikeNode(), drawFirelikeNode(), drawGlasslikeNode(), drawMeshNode(), drawPlantlikeNode(), drawPlantlikeRootedNode(), drawRaillikeNode(), drawSignlikeNode(), and drawTorchlikeNode().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ blockpos_nodes

◆ collector

MeshCollector* const MapblockMeshGenerator::collector
private

◆ cur_liquid

◆ [struct]

◆ cur_plant

PlantlikeData MapblockMeshGenerator::cur_plant
private

Referenced by drawPlantlike(), and drawPlantlikeQuad().

◆ cur_rail

RaillikeData MapblockMeshGenerator::cur_rail
private

Referenced by drawRaillikeNode(), and isSameRail().

◆ data

◆ f

const ContentFeatures* MapblockMeshGenerator::f

Referenced by getSpecialTile().

◆ lcolor

video::SColor MapblockMeshGenerator::lcolor

◆ lframe

LightFrame MapblockMeshGenerator::lframe

◆ n

MapNode MapblockMeshGenerator::n

◆ nodedef

◆ origin

v3f MapblockMeshGenerator::origin

◆ p

v3s16 MapblockMeshGenerator::p

◆ raillike_groupname

const std::string MapblockMeshGenerator::raillike_groupname = "connect_to_raillike"
staticprivate

Referenced by drawRaillikeNode(), and isSameRail().


The documentation for this class was generated from the following files: