Luanti 5.17.0-dev
Loading...
Searching...
No Matches
node_visuals.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2025 cx384
4
5#pragma once
6
7#include <unordered_set>
8#include "nodedef.h" // CF_SPECIAL_COUNT
9#include "tile.h"
10
11class Client;
13namespace scene
14{
15 class IMeshManipulator;
16 struct SMesh;
17}
18
19// Stores client only data needed to draw nodes, like textures and meshes
20// Contained in ContentFeatures
21
23{
24 // 0 1 2 3 4 5
25 // up down right left back front
27 // Special tiles
29 u8 solidness = 2; // Used when choosing which face is drawn
30 u8 visual_solidness = 0; // When solidness=0, this tells how it looks like
31 bool backface_culling = true;
32 scene::SMesh *mesh_ptr = nullptr; // mesh in case of mesh node
33 video::SColor minimap_color;
34 std::vector<video::SColor> *palette = nullptr;
35
36 // alpha stays in ContentFeatures due to compatibility code that is necessary,
37 // because it was part of the node definition table in the past.
38
39 NodeVisuals() = default;
41
42 // Get color from palette or content features
43 video::SColor getColor(const ContentFeatures &f, u8 param2) const;
44
54 static void fillNodeVisuals(NodeDefManager *ndef, Client *client,
55 void *progress_callback_args);
56
58
59private:
60
61 // Functions needed for initialisation
63 std::unordered_set<std::string> &pool, const TextureSettings &tsettings);
64
65 // May override the alpha and drawtype of the content features
67 IShaderSource *shdsrc, Client *client, PreLoadedTextures *texture_pool,
68 const TextureSettings &tsettings);
69
70 void updateMesh(const std::string &mesh, float visual_scale, Client *client,
71 const TextureSettings &tsettings);
72 void collectMaterials(std::vector<u32> &leaves_materials);
73};
74
79{
80 switch (mode) {
81 case ALPHAMODE_BLEND:
85 case ALPHAMODE_CLIP:
86 default:
88 }
89}
Definition client.h:107
Definition shader.h:254
Definition texturesource.h:45
This class is for getting the actual properties of nodes from their content ID.
Definition nodedef.h:514
Definition nodedef.h:166
Definition activeobjectmgr.cpp:11
Definition camera.h:24
static MaterialType alpha_mode_to_material_type(AlphaMode mode)
get fitting material type for an alpha mode
Definition node_visuals.h:78
#define CF_SPECIAL_COUNT
Definition nodedef.h:291
AlphaMode
Definition nodedef.h:250
@ ALPHAMODE_CLIP
Definition nodedef.h:252
@ ALPHAMODE_OPAQUE
Definition nodedef.h:253
@ ALPHAMODE_BLEND
Definition nodedef.h:251
Definition nodedef.h:294
video::SColor getColor(const ContentFeatures &f, u8 param2) const
Definition node_visuals.cpp:553
u8 visual_solidness
Definition node_visuals.h:30
TileSpec special_tiles[CF_SPECIAL_COUNT]
Definition node_visuals.h:28
NodeVisuals()=default
static void fillNodeVisuals(NodeDefManager *ndef, Client *client, void *progress_callback_args)
Definition node_visuals.cpp:561
scene::SMesh * mesh_ptr
Definition node_visuals.h:32
video::SColor minimap_color
Definition node_visuals.h:33
bool backface_culling
Definition node_visuals.h:31
void updateTextures(ContentFeatures &f, ITextureSource *tsrc, IShaderSource *shdsrc, Client *client, PreLoadedTextures *texture_pool, const TextureSettings &tsettings)
Definition node_visuals.cpp:261
void preUpdateTextures(const ContentFeatures &f, ITextureSource *tsrc, std::unordered_set< std::string > &pool, const TextureSettings &tsettings)
Definition node_visuals.cpp:220
DISABLE_CLASS_COPY(NodeVisuals)
u8 solidness
Definition node_visuals.h:29
void updateMesh(const std::string &mesh, float visual_scale, Client *client, const TextureSettings &tsettings)
Definition node_visuals.cpp:491
void collectMaterials(std::vector< u32 > &leaves_materials)
Definition node_visuals.cpp:542
~NodeVisuals()
Definition node_visuals.cpp:206
std::vector< video::SColor > * palette
Definition node_visuals.h:34
TileSpec tiles[6]
Definition node_visuals.h:26
Definition node_visuals.cpp:38
Definition tile.h:233
MaterialType
Definition tile.h:12
@ TILE_MATERIAL_OPAQUE
Definition tile.h:19
@ TILE_MATERIAL_BASIC
Definition tile.h:13
@ TILE_MATERIAL_ALPHA
Definition tile.h:14