Luanti 5.11.0-dev
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Loading...
Searching...
No Matches
MapblockMeshGenerator Class Reference

#include <content_mapblock.h>

+ Collaboration diagram for MapblockMeshGenerator:

Classes

struct  LiquidData
 
struct  PlantlikeData
 
struct  RaillikeData
 

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=MATERIAL_FLAG_CRACK_OVERLAY, 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 generateCuboidTextureCoords (aabb3f const &box, f32 *coords)
 
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 ()
 

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 MapblockMeshGenerator::LiquidData::corner_levels, 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(), getTile(), and MeshMakeData::m_smooth_lighting.

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(), generateCuboidTextureCoords(), LightInfo::getPair(), light_indices, lightDiff(), MeshMakeData::m_smooth_lighting, 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 MeshCollector::append(), collector, 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, NodeDefManager::get(), VoxelManipulator::getNodeNoEx(), TileSpec::layers, MeshMakeData::m_vmanip, 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(), VoxelManipulator::getNodeNoEx(), MeshMakeData::m_vmanip, 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, MapNode::getContent(), VoxelManipulator::getNodeNoEx(), getSpecialTile(), getTile(), and MeshMakeData::m_vmanip.

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(), VoxelManipulator::getNodeNoExNoEmerge(), MeshMakeData::m_vmanip, 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 MeshCollector::append(), blendLightColor(), BS, collector, MapblockMeshGenerator::LiquidData::color_top, cur_liquid, cur_node, data, MeshMakeData::m_smooth_lighting, quad_indices, and MapblockMeshGenerator::LiquidData::tile_top.

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, MapblockMeshGenerator::LiquidData::draw_bottom, drawLiquidBottom(), drawLiquidSides(), drawLiquidTop(), getLiquidNeighborhood(), prepareLiquidNodeDrawing(), and MapblockMeshGenerator::LiquidData::top_is_same_liquid.

Referenced by drawNode().

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

◆ drawLiquidSides()

void MapblockMeshGenerator::drawLiquidSides ( )
private

◆ drawLiquidTop()

void MapblockMeshGenerator::drawLiquidTop ( )
private

References MeshCollector::append(), blendLightColor(), blockpos_nodes, BS, collector, MapblockMeshGenerator::LiquidData::color_top, MapblockMeshGenerator::LiquidData::corner_levels, cur_liquid, cur_node, data, dir(), MapblockMeshGenerator::LiquidData::NeighborData::level, MeshMakeData::m_enable_water_reflections, MeshMakeData::m_smooth_lighting, MapblockMeshGenerator::LiquidData::neighbors, quad_indices, MapblockMeshGenerator::LiquidData::tile_top, 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 MeshCollector::append(), applyFacesShading(), blendLightColor(), cloneMesh(), collector, CPT2_4DIR, CPT2_COLORED_4DIR, CPT2_COLORED_DEGROTATE, CPT2_COLORED_FACEDIR, CPT2_COLORED_WALLMOUNTED, CPT2_DEGROTATE, CPT2_FACEDIR, CPT2_WALLMOUNTED, cur_node, data, MeshMakeData::m_smooth_lighting, 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

◆ 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(), ContentFeatures::drawtype, NodeDefManager::get(), MapNode::getNodeBoxes(), getNodeBoxMask(), VoxelManipulator::getNodeNoEx(), getTile(), MeshMakeData::m_vmanip, NDT_NORMAL, NODEBOX_CONNECTED, NodeDefManager::nodeboxConnects(), 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

◆ 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, MapblockMeshGenerator::PlantlikeData::face_num, PseudoRandom::next(), nodedef, MapblockMeshGenerator::PlantlikeData::offset, MapblockMeshGenerator::PlantlikeData::plant_height, MapblockMeshGenerator::PlantlikeData::random_offset_Y, MapblockMeshGenerator::PlantlikeData::rotate_degree, and MapblockMeshGenerator::PlantlikeData::scale.

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(), VoxelManipulator::getNodeNoEx(), getSmoothLightFrame(), MeshMakeData::m_smooth_lighting, MeshMakeData::m_vmanip, MATERIAL_FLAG_CRACK_OVERLAY, 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 MeshCollector::append(), applyFacesShading(), blendLightColor(), collector, cur_node, data, MeshMakeData::m_smooth_lighting, 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, MATERIAL_FLAG_CRACK_OVERLAY, MapblockMeshGenerator::RaillikeData::raillike_group, 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, MATERIAL_FLAG_CRACK_OVERLAY, 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(), generateCuboidTextureCoords(), NodeDefManager::get(), MapNode::getContent(), getFaceLight(), VoxelManipulator::getNodeNoEx(), getSmoothLightSolid(), getTile(), intToFloat(), TileSpec::layers, light_dirs, light_indices, lightDiff(), MeshMakeData::m_smooth_lighting, MeshMakeData::m_vmanip, MATERIAL_FLAG_BACKFACE_CULLING, MATERIAL_FLAG_TILEABLE_HORIZONTAL, MATERIAL_FLAG_TILEABLE_VERTICAL, 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, MATERIAL_FLAG_CRACK_OVERLAY, 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(), NodeDefManager::get(), VoxelManipulator::getNodeNoEx(), MeshMakeData::m_side_length, MeshMakeData::m_vmanip, nodedef, and ZoneScoped.

Referenced by MapBlockMesh::MapBlockMesh(), and createGenericNodeMesh().

+ 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 )
private

References BS.

Referenced by drawAutoLightedCuboid(), and drawSolidNode().

+ Here is the caller graph for this function:

◆ getCornerLevel()

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

◆ getLiquidNeighborhood()

void MapblockMeshGenerator::getLiquidNeighborhood ( )
private

◆ 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::has_color, TileSpec::layers, MATERIAL_FLAG_CRACK, TileLayer::material_flags, and TileLayer::texture_id.

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

+ 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, NodeDefManager::get(), MapNode::getContent(), ContentFeatures::getGroup(), VoxelManipulator::getNodeNoEx(), MeshMakeData::m_vmanip, NDT_RAILLIKE, nodedef, MapblockMeshGenerator::RaillikeData::raillike_group, 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

◆ useTile()

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

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

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

◆ 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: