Luanti 5.10.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// options
65
66// current node
67 struct {
74 video::SColor color;
76 f32 scale;
78
79// lighting
81 LightInfo blendLight(const v3f &vertex_pos);
82 video::SColor blendLightColor(const v3f &vertex_pos);
83 video::SColor blendLightColor(const v3f &vertex_pos, const v3f &vertex_normal);
84
85 void useTile(int index = 0, u8 set_flags = MATERIAL_FLAG_CRACK_OVERLAY,
86 u8 reset_flags = 0, bool special = false);
87 void getTile(int index, TileSpec *tile);
88 void getTile(v3s16 direction, TileSpec *tile);
89 void getSpecialTile(int index, TileSpec *tile, bool apply_crack = false);
90
91// face drawing
92 void drawQuad(v3f *vertices, const v3s16 &normal = v3s16(0, 0, 0),
93 float vertical_tiling = 1.0);
94
95// cuboid drawing!
96 template <typename Fn>
97 void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount, const f32 *txc, u8 mask, Fn &&face_lighter);
98 void generateCuboidTextureCoords(aabb3f const &box, f32 *coords);
99 void drawAutoLightedCuboid(aabb3f box, f32 const *txc = nullptr, TileSpec *tiles = nullptr, int tile_count = 0, u8 mask = 0);
100 u8 getNodeBoxMask(aabb3f box, u8 solid_neighbors, u8 sametype_neighbors) const;
101
102// liquid-specific
122 bool smooth_liquids = false;
123
127 f32 getCornerLevel(int i, int k) const;
128 void drawLiquidSides();
129 void drawLiquidTop();
130 void drawLiquidBottom();
131
132// raillike-specific
133 // name of the group that enables connecting to raillike nodes of different kind
134 static const std::string raillike_groupname;
137 };
139 bool isSameRail(v3s16 dir);
140
141// plantlike-specific
151
152 void drawPlantlikeQuad(float rotation, float quad_offset = 0,
153 bool offset_top_only = false);
154 void drawPlantlike(bool is_rooted = false);
155
156// firelike-specific
157 void drawFirelikeQuad(float rotation, float opening_angle,
158 float offset_h, float offset_v = 0.0);
159
160// drawtypes
161 void drawSolidNode();
162 void drawLiquidNode();
163 void drawGlasslikeNode();
165 void drawAllfacesNode();
166 void drawTorchlikeNode();
167 void drawSignlikeNode();
168 void drawPlantlikeNode();
170 void drawFirelikeNode();
171 void drawFencelikeNode();
172 void drawRaillikeNode();
173 void drawNodeboxNode();
174 void drawMeshNode();
175
176// common
178 void drawNode();
179};
static v2f dir(const v2f &pos_dist)
Definition camera.cpp:191
Definition content_mapblock.h:47
void drawRaillikeNode()
Definition content_mapblock.cpp:1461
scene::IMeshManipulator *const meshmanip
Definition content_mapblock.h:59
void drawTorchlikeNode()
Definition content_mapblock.cpp:1004
void useTile(int index=0, u8 set_flags=MATERIAL_FLAG_CRACK_OVERLAY, u8 reset_flags=0, bool special=false)
Definition content_mapblock.cpp:76
void drawPlantlike(bool is_rooted=false)
Definition content_mapblock.cpp:1158
RaillikeData cur_rail
Definition content_mapblock.h:138
void errorUnknownDrawtype()
Definition content_mapblock.cpp:1718
void drawSignlikeNode()
Definition content_mapblock.cpp:1065
void getTile(int index, TileSpec *tile)
Definition content_mapblock.cpp:92
void generateCuboidTextureCoords(aabb3f const &box, f32 *coords)
Definition content_mapblock.cpp:306
const NodeDefManager *const nodedef
Definition content_mapblock.h:58
PlantlikeData cur_plant
Definition content_mapblock.h:150
void calculateCornerLevels()
Definition content_mapblock.cpp:603
LightPair light
Definition content_mapblock.h:72
void drawLiquidSides()
Definition content_mapblock.cpp:665
video::SColor blendLightColor(const v3f &vertex_pos)
Definition content_mapblock.cpp:289
u8 getNodeBoxMask(aabb3f box, u8 solid_neighbors, u8 sametype_neighbors) const
Definition content_mapblock.cpp:489
const bool enable_mesh_cache
Definition content_mapblock.h:64
void drawLiquidBottom()
Definition content_mapblock.cpp:792
MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output, scene::IMeshManipulator *mm)
Definition content_mapblock.cpp:63
f32 scale
Definition content_mapblock.h:76
void drawNodeboxNode()
Definition content_mapblock.cpp:1537
MapNode n
Definition content_mapblock.h:70
const v3s16 blockpos_nodes
Definition content_mapblock.h:61
void drawLiquidNode()
Definition content_mapblock.cpp:810
void drawAutoLightedCuboid(aabb3f box, f32 const *txc=nullptr, TileSpec *tiles=nullptr, int tile_count=0, u8 mask=0)
Definition content_mapblock.cpp:331
v3s16 p
Definition content_mapblock.h:68
void getLiquidNeighborhood()
Definition content_mapblock.cpp:563
video::SColor color
Definition content_mapblock.h:74
LightInfo blendLight(const v3f &vertex_pos)
Definition content_mapblock.cpp:262
void generate()
Definition content_mapblock.cpp:1759
f32 getCornerLevel(int i, int k) const
Definition content_mapblock.cpp:610
bool isSameRail(v3s16 dir)
Definition content_mapblock.cpp:1410
TileSpec tile
Definition content_mapblock.h:75
void drawFencelikeNode()
Definition content_mapblock.cpp:1333
void drawPlantlikeQuad(float rotation, float quad_offset=0, bool offset_top_only=false)
Definition content_mapblock.cpp:1102
void drawQuad(v3f *vertices, const v3s16 &normal=v3s16(0, 0, 0), float vertical_tiling=1.0)
Definition content_mapblock.cpp:122
MeshMakeData *const data
Definition content_mapblock.h:55
void drawMeshNode()
Definition content_mapblock.cpp:1645
static const std::string raillike_groupname
Definition content_mapblock.h:134
void getSpecialTile(int index, TileSpec *tile, bool apply_crack=false)
Definition content_mapblock.cpp:104
LightFrame frame
Definition content_mapblock.h:73
void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount, const f32 *txc, u8 mask, Fn &&face_lighter)
Definition content_mapblock.cpp:225
LiquidData cur_liquid
Definition content_mapblock.h:121
void getSmoothLightFrame()
Definition content_mapblock.cpp:243
void drawFirelikeQuad(float rotation, float opening_angle, float offset_h, float offset_v=0.0)
Definition content_mapblock.cpp:1266
bool smooth_liquids
Definition content_mapblock.h:122
void drawFirelikeNode()
Definition content_mapblock.cpp:1286
void renderSingle(content_t node, u8 param2=0x00)
Definition content_mapblock.cpp:1772
void drawSolidNode()
Definition content_mapblock.cpp:397
v3f origin
Definition content_mapblock.h:69
void drawLiquidTop()
Definition content_mapblock.cpp:712
struct MapblockMeshGenerator::@15 cur_node
void drawGlasslikeFramedNode()
Definition content_mapblock.cpp:862
void prepareLiquidNodeDrawing()
Definition content_mapblock.cpp:526
MeshCollector *const collector
Definition content_mapblock.h:56
void drawPlantlikeNode()
Definition content_mapblock.cpp:1244
void drawNode()
Definition content_mapblock.cpp:1724
void drawGlasslikeNode()
Definition content_mapblock.cpp:822
void drawAllfacesNode()
Definition content_mapblock.cpp:1526
void drawPlantlikeRootedNode()
Definition content_mapblock.cpp:1250
const ContentFeatures * f
Definition content_mapblock.h:71
This class is for getting the actual properties of nodes from their content ID.
Definition nodedef.h:541
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:235
Definition nodedef.h:295
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:104
f32 level
Definition content_mapblock.h:105
bool top_is_same_liquid
Definition content_mapblock.h:108
bool is_same_liquid
Definition content_mapblock.h:107
content_t content
Definition content_mapblock.h:106
Definition content_mapblock.h:103
video::SColor color_top
Definition content_mapblock.h:117
TileSpec tile_top
Definition content_mapblock.h:114
content_t c_flowing
Definition content_mapblock.h:115
TileSpec tile
Definition content_mapblock.h:113
NeighborData neighbors[3][3]
Definition content_mapblock.h:118
f32 corner_levels[2][2]
Definition content_mapblock.h:119
bool draw_bottom
Definition content_mapblock.h:112
bool top_is_same_liquid
Definition content_mapblock.h:111
content_t c_source
Definition content_mapblock.h:116
Definition content_mapblock.h:142
PlantlikeStyle draw_style
Definition content_mapblock.h:143
float rotate_degree
Definition content_mapblock.h:145
int face_num
Definition content_mapblock.h:147
bool random_offset_Y
Definition content_mapblock.h:146
float plant_height
Definition content_mapblock.h:148
v3f offset
Definition content_mapblock.h:144
Definition content_mapblock.h:135
int raillike_group
Definition content_mapblock.h:136
Definition collector.h:24
Definition mapblock_mesh.h:30
Definition tile.h:140
#define MATERIAL_FLAG_CRACK_OVERLAY
Definition tile.h:34