Luanti 5.11.0-dev
 
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, scene::IMeshManipulator *mm)
 
void generate ()
 
void renderSingle (content_t node, u8 param2=0x00)
 

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 (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)
 
void drawQuad (v3f *vertices, const v3s16 &normal=v3s16(0, 0, 0), float vertical_tiling=1.0)
 
template<typename Fn >
void drawCuboid (const aabb3f &box, TileSpec *tiles, int tilecount, const f32 *txc, u8 mask, Fn &&face_lighter)
 
void generateCuboidTextureCoords (aabb3f const &box, f32 *coords)
 
void drawAutoLightedCuboid (aabb3f box, f32 const *txc=nullptr, TileSpec *tiles=nullptr, int tile_count=0, 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 (float rotation, float quad_offset=0, bool offset_top_only=false)
 
void drawPlantlike (bool is_rooted=false)
 
void drawFirelikeQuad (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
 
scene::IMeshManipulator *const meshmanip
 
const v3s16 blockpos_nodes
 
struct { 
 
   v3s16   p 
 
   v3f   origin 
 
   MapNode   n 
 
   const ContentFeatures *   f 
 
   LightPair   light 
 
   LightFrame   frame 
 
   video::SColor   color 
 
   TileSpec   tile 
 
   f32   scale 
 
cur_node 
 
LiquidData cur_liquid
 
bool smooth_liquids = false
 
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,
scene::IMeshManipulator * mm )

Member Function Documentation

◆ blendLight()

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

References BS, cur_node, and SMOOTH_LIGHTING_OVERSIZE.

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 light.

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(), color, cur_node, encode_light(), light, 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()

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

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

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

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

◆ drawCuboid()

template<typename Fn >
void MapblockMeshGenerator::drawCuboid ( const aabb3f & box,
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 ( float rotation,
float opening_angle,
float offset_h,
float offset_v = 0.0 )
private

References BS, cur_node, drawQuad(), and scale.

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(), encode_light(), FRAMED_EDGE_COUNT, FRAMED_NEIGHBOR_COUNT, g_26dirs, g_6dirs, MapNode::getContent(), VoxelManipulator::getNodeNoEx(), getSpecialTile(), getTile(), MeshMakeData::m_smooth_lighting, 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_smooth_lighting, MapblockMeshGenerator::LiquidData::neighbors, quad_indices, smooth_liquids, and MapblockMeshGenerator::LiquidData::tile_top.

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(), 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, meshmanip, MYMIN, nodedef, recalculateBoundingBox(), rotateMeshBy6dFacedir(), rotateMeshXZby(), tile, 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(), TileLayer::isTransparent(), TileSpec::layers, MeshMakeData::m_vmanip, NDT_NORMAL, NODEBOX_CONNECTED, NodeDefManager::nodeboxConnects(), nodedef, MapNode::param0, MapNode::param2, and tile.

Referenced by drawNode().

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

◆ drawPlantlike()

void MapblockMeshGenerator::drawPlantlike ( 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 ( 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 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(), 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 ( 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, color, 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_vmanip, nodedef, MeshMakeData::side_length, and ZoneScoped.

Referenced by MapBlockMesh::MapBlockMesh().

+ 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, 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,
bool apply_crack = false )
private

References TileLayer::color, cur_node, TileLayer::has_color, TileSpec::layers, MATERIAL_FLAG_CRACK, TileLayer::material_flags, TileLayer::texture_id, and tile.

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

+ Here is the caller graph for this function:

◆ getTile() [1/2]

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

References cur_node, data, getNodeTileN(), and tile.

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

References cur_node, data, getNodeTile(), and tile.

+ 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

◆ renderSingle()

void MapblockMeshGenerator::renderSingle ( content_t node,
u8 param2 = 0x00 )

References cur_node, drawNode(), NodeDefManager::get(), and nodedef.

Referenced by createSpecialNodeMesh().

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

◆ useTile()

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

References cur_node, data, encode_light(), getSpecialTile(), getTile(), MeshMakeData::m_crack_pos_relative, and MeshMakeData::m_smooth_lighting.

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

◆ color

video::SColor MapblockMeshGenerator::color

◆ 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

◆ frame

LightFrame MapblockMeshGenerator::frame

◆ light

LightPair MapblockMeshGenerator::light

◆ meshmanip

scene::IMeshManipulator* const MapblockMeshGenerator::meshmanip
private

Referenced by drawMeshNode().

◆ 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().

◆ scale

f32 MapblockMeshGenerator::scale

◆ smooth_liquids

bool MapblockMeshGenerator::smooth_liquids = false
private

Referenced by drawLiquidTop().

◆ tile

TileSpec MapblockMeshGenerator::tile

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