Minetest  5.4.0
mapblock_mesh.cpp File Reference
#include "mapblock_mesh.h"
#include "client.h"
#include "mapblock.h"
#include "map.h"
#include "profiler.h"
#include "shader.h"
#include "mesh.h"
#include "minimap.h"
#include "content_mapblock.h"
#include "util/directiontables.h"
#include "client/meshgen/collector.h"
#include "client/renderingengine.h"
#include <array>
+ Include dependency graph for mapblock_mesh.cpp:

Classes

struct  FastFace
 

Functions

static u8 getInteriorLight (enum LightBank bank, MapNode n, s32 increment, const NodeDefManager *ndef)
 
u16 getInteriorLight (MapNode n, s32 increment, const NodeDefManager *ndef)
 
static u8 getFaceLight (enum LightBank bank, MapNode n, MapNode n2, v3s16 face_dir, const NodeDefManager *ndef)
 
u16 getFaceLight (MapNode n, MapNode n2, const v3s16 &face_dir, const NodeDefManager *ndef)
 
static u16 getSmoothLightCombined (const v3s16 &p, const std::array< v3s16, 8 > &dirs, MeshMakeData *data)
 
u16 getSmoothLightSolid (const v3s16 &p, const v3s16 &face_dir, const v3s16 &corner, MeshMakeData *data)
 
u16 getSmoothLightTransparent (const v3s16 &p, const v3s16 &corner, MeshMakeData *data)
 
void get_sunlight_color (video::SColorf *sunlight, u32 daynight_ratio)
 
void final_color_blend (video::SColor *result, u16 light, u32 daynight_ratio)
 
void final_color_blend (video::SColor *result, const video::SColor &data, const video::SColorf &dayLight)
 
static void getNodeVertexDirs (const v3s16 &dir, v3s16 *vertex_dirs)
 
static void getNodeTextureCoords (v3f base, const v3f &scale, const v3s16 &dir, float *u, float *v)
 
static void makeFastFace (const TileSpec &tile, u16 li0, u16 li1, u16 li2, u16 li3, const v3f &tp, const v3f &p, const v3s16 &dir, const v3f &scale, std::vector< FastFace > &dest)
 
static u8 face_contents (content_t m1, content_t m2, bool *equivalent, const NodeDefManager *ndef)
 
void getNodeTileN (MapNode mn, const v3s16 &p, u8 tileindex, MeshMakeData *data, TileSpec &tile)
 
void getNodeTile (MapNode mn, const v3s16 &p, const v3s16 &dir, MeshMakeData *data, TileSpec &tile)
 
static void getTileInfo (MeshMakeData *data, const v3s16 &p, const v3s16 &face_dir, bool &makes_face, v3s16 &p_corrected, v3s16 &face_dir_corrected, u16 *lights, u8 &waving, TileSpec &tile)
 
static void updateFastFaceRow (MeshMakeData *data, const v3s16 &&startpos, v3s16 translate_dir, const v3f &&translate_dir_f, const v3s16 &&face_dir, std::vector< FastFace > &dest)
 
static void updateAllFastFaceRows (MeshMakeData *data, std::vector< FastFace > &dest)
 
static void applyTileColor (PreMeshBuffer &pmb)
 
video::SColor encode_light (u16 light, u8 emissive_light)
 

Variables

static const v3s16 vertex_dirs_table []
 

Function Documentation

◆ applyTileColor()

static void applyTileColor ( PreMeshBuffer pmb)
static

References TileLayer::color, PreMeshBuffer::layer, and PreMeshBuffer::vertices.

Referenced by MapBlockMesh::MapBlockMesh().

+ Here is the caller graph for this function:

◆ encode_light()

video::SColor encode_light ( u16  light,
u8  emissive_light 
)

Encodes light of a node. The result is not the final color, but a half-baked vertex color. You have to multiply the resulting color with the node's color.

Parameters
lightthe first 8 bits are day light, the last 8 bits are night light
emissive_lightamount of light the surface emits, from 0 to LIGHT_SUN.

Referenced by MapblockMeshGenerator::blendLightColor(), MapblockMeshGenerator::drawCuboid(), MapblockMeshGenerator::drawGlasslikeFramedNode(), final_color_blend(), makeFastFace(), MapblockMeshGenerator::prepareLiquidNodeDrawing(), and MapblockMeshGenerator::useTile().

+ Here is the caller graph for this function:

◆ face_contents()

static u8 face_contents ( content_t  m1,
content_t  m2,
bool *  equivalent,
const NodeDefManager ndef 
)
static

References CONTENT_IGNORE, NodeDefManager::get(), ContentFeatures::isLiquid(), ContentFeatures::sameLiquid(), ContentFeatures::solidness, and ContentFeatures::visual_solidness.

Referenced by getTileInfo().

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

◆ final_color_blend() [1/2]

void final_color_blend ( video::SColor *  result,
const video::SColor &  data,
const video::SColorf &  dayLight 
)

Gives the final SColor shown on screen.

Parameters
resultoutput color
datathe half-baked vertex color
dayLightcolor of the sunlight

◆ final_color_blend() [2/2]

void final_color_blend ( video::SColor *  result,
u16  light,
u32  daynight_ratio 
)

Gives the final SColor shown on screen.

Parameters
resultoutput color
lightfirst 8 bits are day light, second 8 bits are night light

References encode_light(), and get_sunlight_color().

Referenced by MapBlockMesh::MapBlockMesh(), MapBlockMesh::animate(), ClientEnvironment::step(), and Game::updatePointedThing().

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

◆ get_sunlight_color()

void get_sunlight_color ( video::SColorf *  sunlight,
u32  daynight_ratio 
)

Returns the sunlight's color from the current day-night ratio.

Referenced by MapBlockMesh::MapBlockMesh(), MapBlockMesh::animate(), final_color_blend(), and GameGlobalShaderConstantSetter::onSetConstants().

+ Here is the caller graph for this function:

◆ getFaceLight() [1/2]

static u8 getFaceLight ( enum LightBank  bank,
MapNode  n,
MapNode  n2,
v3s16  face_dir,
const NodeDefManager ndef 
)
static

References decode_light(), NodeDefManager::get(), MapNode::getLight(), ContentFeatures::light_source, and MYMAX.

Referenced by getFaceLight(), and getTileInfo().

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

◆ getFaceLight() [2/2]

u16 getFaceLight ( MapNode  n,
MapNode  n2,
const v3s16 face_dir,
const NodeDefManager ndef 
)

References getFaceLight(), LIGHTBANK_DAY, and LIGHTBANK_NIGHT.

+ Here is the call graph for this function:

◆ getInteriorLight() [1/2]

static u8 getInteriorLight ( enum LightBank  bank,
MapNode  n,
s32  increment,
const NodeDefManager ndef 
)
static

References decode_light(), MapNode::getLight(), LIGHT_SUN, and rangelim.

Referenced by MapblockMeshGenerator::drawNode(), MapblockMeshGenerator::drawPlantlikeRootedNode(), getInteriorLight(), MapblockMeshGenerator::prepareLiquidNodeDrawing(), ClientEnvironment::step(), and Game::updatePointedThing().

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

◆ getInteriorLight() [2/2]

u16 getInteriorLight ( MapNode  n,
s32  increment,
const NodeDefManager ndef 
)

References getInteriorLight(), LIGHTBANK_DAY, and LIGHTBANK_NIGHT.

+ Here is the call graph for this function:

◆ getNodeTextureCoords()

static void getNodeTextureCoords ( v3f  base,
const v3f scale,
const v3s16 dir,
float *  u,
float *  v 
)
static

References dir().

Referenced by makeFastFace().

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

◆ getNodeTile()

void getNodeTile ( MapNode  mn,
const v3s16 p,
const v3s16 dir,
MeshMakeData data,
TileSpec tile 
)

References dir(), MapNode::getFaceDir(), getNodeTileN(), MeshMakeData::m_client, IGameDef::ndef(), p(), TileSpec::rotation, and TileSpec::world_aligned.

Referenced by MapblockMeshGenerator::getTile(), and getTileInfo().

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

◆ getNodeTileN()

void getNodeTileN ( MapNode  mn,
const v3s16 p,
u8  tileindex,
MeshMakeData data,
TileSpec tile 
)

References TileLayer::color, NodeDefManager::get(), MapNode::getColor(), TileLayer::has_color, TileSpec::layers, MeshMakeData::m_client, MeshMakeData::m_crack_pos_relative, MATERIAL_FLAG_CRACK, TileLayer::material_flags, IGameDef::ndef(), p(), TileLayer::texture_id, and ContentFeatures::tiles.

Referenced by getNodeTile(), and MapblockMeshGenerator::getTile().

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

◆ getNodeVertexDirs()

static void getNodeVertexDirs ( const v3s16 dir,
v3s16 vertex_dirs 
)
static

References dir(), idx, and vertex_dirs_table.

Referenced by getTileInfo(), and makeFastFace().

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

◆ getSmoothLightCombined()

static u16 getSmoothLightCombined ( const v3s16 p,
const std::array< v3s16, 8 > &  dirs,
MeshMakeData data 
)
static

References CONTENT_IGNORE, CPT_LIGHT, decode_light(), g_settings, NodeDefManager::get(), MapNode::getContent(), Settings::getFloat(), MapNode::getLightNoChecks(), VoxelManipulator::getNodeNoExNoEmerge(), ContentFeatures::light_propagates, ContentFeatures::light_source, LIGHT_SUN, LIGHTBANK_DAY, LIGHTBANK_NIGHT, MeshMakeData::m_client, MeshMakeData::m_vmanip, IGameDef::ndef(), p(), ContentFeatures::param_type, rangelim, and ContentFeatures::solidness.

Referenced by getSmoothLightTransparent().

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

◆ getSmoothLightSolid()

u16 getSmoothLightSolid ( const v3s16 p,
const v3s16 face_dir,
const v3s16 corner,
MeshMakeData data 
)

References getSmoothLightTransparent(), and p().

Referenced by getTileInfo().

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

◆ getSmoothLightTransparent()

u16 getSmoothLightTransparent ( const v3s16 p,
const v3s16 corner,
MeshMakeData data 
)

References getSmoothLightCombined(), and p().

Referenced by MapblockMeshGenerator::getSmoothLightFrame(), and getSmoothLightSolid().

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

◆ getTileInfo()

static void getTileInfo ( MeshMakeData data,
const v3s16 p,
const v3s16 face_dir,
bool &  makes_face,
v3s16 p_corrected,
v3s16 face_dir_corrected,
u16 *  lights,
u8 &  waving,
TileSpec tile 
)
static

References CONTENT_IGNORE, TileSpec::emissive_light, face_contents(), NodeDefManager::get(), MapNode::getContent(), getFaceLight(), VoxelManipulator::getNodeRefUnsafe(), VoxelManipulator::getNodeRefUnsafeCheckFlags(), getNodeTile(), getNodeVertexDirs(), getSmoothLightSolid(), TileSpec::layers, ContentFeatures::light_source, MeshMakeData::m_blockpos, MeshMakeData::m_client, MeshMakeData::m_smooth_lighting, MeshMakeData::m_vmanip, MAP_BLOCKSIZE, MATERIAL_FLAG_BACKFACE_CULLING, TileLayer::material_flags, IGameDef::ndef(), p(), and ContentFeatures::waving.

Referenced by updateFastFaceRow().

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

◆ makeFastFace()

static void makeFastFace ( const TileSpec tile,
u16  li0,
u16  li1,
u16  li2,
u16  li3,
const v3f tp,
const v3f p,
const v3s16 dir,
const v3f scale,
std::vector< FastFace > &  dest 
)
static

References applyFacesShading(), BS, dir(), TileSpec::emissive_light, encode_light(), getNodeTextureCoords(), getNodeVertexDirs(), p(), TileSpec::rotation, FastFace::tile, FastFace::vertex_0_2_connected, FastFace::vertices, and TileSpec::world_aligned.

Referenced by updateFastFaceRow().

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

◆ updateAllFastFaceRows()

static void updateAllFastFaceRows ( MeshMakeData data,
std::vector< FastFace > &  dest 
)
static

References MAP_BLOCKSIZE, and updateFastFaceRow().

Referenced by MapBlockMesh::MapBlockMesh().

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

◆ updateFastFaceRow()

static void updateFastFaceRow ( MeshMakeData data,
const v3s16 &&  startpos,
v3s16  translate_dir,
const v3f &&  translate_dir_f,
const v3s16 &&  face_dir,
std::vector< FastFace > &  dest 
)
static

References Profiler::avg(), g_profiler, g_settings, Settings::getBool(), getTileInfo(), TileSpec::isTileable(), makeFastFace(), MAP_BLOCKSIZE, and p().

Referenced by updateAllFastFaceRows().

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

Variable Documentation

◆ vertex_dirs_table

const v3s16 vertex_dirs_table[]
static
Initial value:
= {
v3s16( 1,-1, 1), v3s16( 1,-1,-1),
v3s16( 1, 1,-1), v3s16( 1, 1, 1),
v3s16( 1, 1,-1), v3s16(-1, 1,-1),
v3s16(-1, 1, 1), v3s16( 1, 1, 1),
v3s16(-1,-1, 1), v3s16( 1,-1, 1),
v3s16( 1, 1, 1), v3s16(-1, 1, 1),
v3s16(), v3s16(), v3s16(), v3s16(),
v3s16( 1,-1,-1), v3s16(-1,-1,-1),
v3s16(-1, 1,-1), v3s16( 1, 1,-1),
v3s16( 1,-1, 1), v3s16(-1,-1, 1),
v3s16(-1,-1,-1), v3s16( 1,-1,-1),
v3s16(-1,-1,-1), v3s16(-1,-1, 1),
v3s16(-1, 1, 1), v3s16(-1, 1,-1)
}
core::vector3d< s16 > v3s16
Definition: irr_v3d.h:28

Referenced by getNodeVertexDirs().