Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
content_mapblock.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "nodedef.h"
8#include <IMeshManipulator.h>
9
10struct MeshMakeData;
11struct MeshCollector;
12
13struct LightPair {
16
17 LightPair() = default;
18 explicit LightPair(u16 value) : lightDay(value & 0xff), lightNight(value >> 8) {}
19 LightPair(u8 valueA, u8 valueB) : lightDay(valueA), lightNight(valueB) {}
20 LightPair(float valueA, float valueB) :
21 lightDay(core::clamp(core::round32(valueA), 0, 255)),
22 lightNight(core::clamp(core::round32(valueB), 0, 255)) {}
23 operator u16() const { return lightDay | lightNight << 8; }
24};
25
26struct LightInfo {
27 float light_day;
30
31 LightPair getPair(float sunlight_boost = 0.0) const
32 {
33 return LightPair(
34 (1 - sunlight_boost) * light_day
35 + sunlight_boost * light_boosted,
37 }
38};
39
40struct LightFrame {
41 f32 lightsDay[8];
43 bool sunlight[8];
44};
45
47{
48public:
50 scene::IMeshManipulator *mm);
51 void generate();
52 void renderSingle(content_t node, u8 param2 = 0x00);
53
54private:
57
58 const NodeDefManager *const nodedef;
59 scene::IMeshManipulator *const meshmanip;
60
62
63// current node
64 struct {
71 video::SColor color;
73 f32 scale;
75
76// lighting
78 LightInfo blendLight(const v3f &vertex_pos);
79 video::SColor blendLightColor(const v3f &vertex_pos);
80 video::SColor blendLightColor(const v3f &vertex_pos, const v3f &vertex_normal);
81
82 void useTile(int index = 0, u8 set_flags = MATERIAL_FLAG_CRACK_OVERLAY,
83 u8 reset_flags = 0, bool special = false);
84 void getTile(int index, TileSpec *tile);
85 void getTile(v3s16 direction, TileSpec *tile);
86 void getSpecialTile(int index, TileSpec *tile, bool apply_crack = false);
87
88// face drawing
89 void drawQuad(v3f *vertices, const v3s16 &normal = v3s16(0, 0, 0),
90 float vertical_tiling = 1.0);
91
92// cuboid drawing!
93 template <typename Fn>
94 void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount, const f32 *txc, u8 mask, Fn &&face_lighter);
95 void generateCuboidTextureCoords(aabb3f const &box, f32 *coords);
96 void drawAutoLightedCuboid(aabb3f box, f32 const *txc = nullptr, TileSpec *tiles = nullptr, int tile_count = 0, u8 mask = 0);
97 u8 getNodeBoxMask(aabb3f box, u8 solid_neighbors, u8 sametype_neighbors) const;
98
99// liquid-specific
119 bool smooth_liquids = false;
120
124 f32 getCornerLevel(int i, int k) const;
125 void drawLiquidSides();
126 void drawLiquidTop();
127 void drawLiquidBottom();
128
129// raillike-specific
130 // name of the group that enables connecting to raillike nodes of different kind
131 static const std::string raillike_groupname;
134 };
136 bool isSameRail(v3s16 dir);
137
138// plantlike-specific
148
149 void drawPlantlikeQuad(float rotation, float quad_offset = 0,
150 bool offset_top_only = false);
151 void drawPlantlike(bool is_rooted = false);
152
153// firelike-specific
154 void drawFirelikeQuad(float rotation, float opening_angle,
155 float offset_h, float offset_v = 0.0);
156
157// drawtypes
158 void drawSolidNode();
159 void drawLiquidNode();
160 void drawGlasslikeNode();
162 void drawAllfacesNode();
163 void drawTorchlikeNode();
164 void drawSignlikeNode();
165 void drawPlantlikeNode();
167 void drawFirelikeNode();
168 void drawFencelikeNode();
169 void drawRaillikeNode();
170 void drawNodeboxNode();
171 void drawMeshNode();
172
173// common
175 void drawNode();
176};
static v2f dir(const v2f &pos_dist)
Definition camera.cpp:191
Definition content_mapblock.h:47
void drawRaillikeNode()
Definition content_mapblock.cpp:1459
scene::IMeshManipulator *const meshmanip
Definition content_mapblock.h:59
void drawTorchlikeNode()
Definition content_mapblock.cpp:1002
void useTile(int index=0, u8 set_flags=MATERIAL_FLAG_CRACK_OVERLAY, u8 reset_flags=0, bool special=false)
Definition content_mapblock.cpp:74
void drawPlantlike(bool is_rooted=false)
Definition content_mapblock.cpp:1156
RaillikeData cur_rail
Definition content_mapblock.h:135
void errorUnknownDrawtype()
Definition content_mapblock.cpp:1712
void drawSignlikeNode()
Definition content_mapblock.cpp:1063
void getTile(int index, TileSpec *tile)
Definition content_mapblock.cpp:90
void generateCuboidTextureCoords(aabb3f const &box, f32 *coords)
Definition content_mapblock.cpp:304
const NodeDefManager *const nodedef
Definition content_mapblock.h:58
PlantlikeData cur_plant
Definition content_mapblock.h:147
void calculateCornerLevels()
Definition content_mapblock.cpp:601
LightPair light
Definition content_mapblock.h:69
void drawLiquidSides()
Definition content_mapblock.cpp:663
video::SColor blendLightColor(const v3f &vertex_pos)
Definition content_mapblock.cpp:287
u8 getNodeBoxMask(aabb3f box, u8 solid_neighbors, u8 sametype_neighbors) const
Definition content_mapblock.cpp:487
void drawLiquidBottom()
Definition content_mapblock.cpp:790
MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output, scene::IMeshManipulator *mm)
Definition content_mapblock.cpp:63
f32 scale
Definition content_mapblock.h:73
void drawNodeboxNode()
Definition content_mapblock.cpp:1535
MapNode n
Definition content_mapblock.h:67
const v3s16 blockpos_nodes
Definition content_mapblock.h:61
void drawLiquidNode()
Definition content_mapblock.cpp:808
void drawAutoLightedCuboid(aabb3f box, f32 const *txc=nullptr, TileSpec *tiles=nullptr, int tile_count=0, u8 mask=0)
Definition content_mapblock.cpp:329
v3s16 p
Definition content_mapblock.h:65
void getLiquidNeighborhood()
Definition content_mapblock.cpp:561
video::SColor color
Definition content_mapblock.h:71
LightInfo blendLight(const v3f &vertex_pos)
Definition content_mapblock.cpp:260
void generate()
Definition content_mapblock.cpp:1753
f32 getCornerLevel(int i, int k) const
Definition content_mapblock.cpp:608
bool isSameRail(v3s16 dir)
Definition content_mapblock.cpp:1408
TileSpec tile
Definition content_mapblock.h:72
void drawFencelikeNode()
Definition content_mapblock.cpp:1331
void drawPlantlikeQuad(float rotation, float quad_offset=0, bool offset_top_only=false)
Definition content_mapblock.cpp:1100
void drawQuad(v3f *vertices, const v3s16 &normal=v3s16(0, 0, 0), float vertical_tiling=1.0)
Definition content_mapblock.cpp:120
MeshMakeData *const data
Definition content_mapblock.h:55
void drawMeshNode()
Definition content_mapblock.cpp:1643
static const std::string raillike_groupname
Definition content_mapblock.h:131
void getSpecialTile(int index, TileSpec *tile, bool apply_crack=false)
Definition content_mapblock.cpp:102
LightFrame frame
Definition content_mapblock.h:70
void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount, const f32 *txc, u8 mask, Fn &&face_lighter)
Definition content_mapblock.cpp:223
LiquidData cur_liquid
Definition content_mapblock.h:118
void getSmoothLightFrame()
Definition content_mapblock.cpp:241
void drawFirelikeQuad(float rotation, float opening_angle, float offset_h, float offset_v=0.0)
Definition content_mapblock.cpp:1264
bool smooth_liquids
Definition content_mapblock.h:119
void drawFirelikeNode()
Definition content_mapblock.cpp:1284
void renderSingle(content_t node, u8 param2=0x00)
Definition content_mapblock.cpp:1766
void drawSolidNode()
Definition content_mapblock.cpp:395
v3f origin
Definition content_mapblock.h:66
void drawLiquidTop()
Definition content_mapblock.cpp:710
struct MapblockMeshGenerator::@15 cur_node
void drawGlasslikeFramedNode()
Definition content_mapblock.cpp:860
void prepareLiquidNodeDrawing()
Definition content_mapblock.cpp:524
MeshCollector *const collector
Definition content_mapblock.h:56
void drawPlantlikeNode()
Definition content_mapblock.cpp:1242
void drawNode()
Definition content_mapblock.cpp:1718
void drawGlasslikeNode()
Definition content_mapblock.cpp:820
void drawAllfacesNode()
Definition content_mapblock.cpp:1524
void drawPlantlikeRootedNode()
Definition content_mapblock.cpp:1248
const ContentFeatures * f
Definition content_mapblock.h:68
This class is for getting the actual properties of nodes from their content ID.
Definition nodedef.h:540
core::aabbox3d< f32 > aabb3f
Definition irr_aabb3d.h:11
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
u16 content_t
Definition mapnode.h:22
PlantlikeStyle
Definition nodedef.h:234
Definition nodedef.h:294
Definition content_mapblock.h:40
f32 lightsDay[8]
Definition content_mapblock.h:41
bool sunlight[8]
Definition content_mapblock.h:43
f32 lightsNight[8]
Definition content_mapblock.h:42
Definition content_mapblock.h:26
LightPair getPair(float sunlight_boost=0.0) const
Definition content_mapblock.h:31
float light_day
Definition content_mapblock.h:27
float light_boosted
Definition content_mapblock.h:29
float light_night
Definition content_mapblock.h:28
Definition content_mapblock.h:13
LightPair(u8 valueA, u8 valueB)
Definition content_mapblock.h:19
LightPair()=default
LightPair(float valueA, float valueB)
Definition content_mapblock.h:20
LightPair(u16 value)
Definition content_mapblock.h:18
u8 lightDay
Definition content_mapblock.h:14
u8 lightNight
Definition content_mapblock.h:15
Definition mapnode.h:124
Definition content_mapblock.h:101
f32 level
Definition content_mapblock.h:102
bool top_is_same_liquid
Definition content_mapblock.h:105
bool is_same_liquid
Definition content_mapblock.h:104
content_t content
Definition content_mapblock.h:103
Definition content_mapblock.h:100
video::SColor color_top
Definition content_mapblock.h:114
TileSpec tile_top
Definition content_mapblock.h:111
content_t c_flowing
Definition content_mapblock.h:112
TileSpec tile
Definition content_mapblock.h:110
NeighborData neighbors[3][3]
Definition content_mapblock.h:115
f32 corner_levels[2][2]
Definition content_mapblock.h:116
bool draw_bottom
Definition content_mapblock.h:109
bool top_is_same_liquid
Definition content_mapblock.h:108
content_t c_source
Definition content_mapblock.h:113
Definition content_mapblock.h:139
PlantlikeStyle draw_style
Definition content_mapblock.h:140
float rotate_degree
Definition content_mapblock.h:142
int face_num
Definition content_mapblock.h:144
bool random_offset_Y
Definition content_mapblock.h:143
float plant_height
Definition content_mapblock.h:145
v3f offset
Definition content_mapblock.h:141
Definition content_mapblock.h:132
int raillike_group
Definition content_mapblock.h:133
Definition collector.h:24
Definition mapblock_mesh.h:30
Definition tile.h:139
#define MATERIAL_FLAG_CRACK_OVERLAY
Definition tile.h:34