Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
item_visuals_manager.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 <string>
8#include <thread>
9#include <unordered_map>
10#include <vector>
11
12struct AnimationInfo;
13class Client;
14struct ItemStack;
15struct ItemMesh;
16namespace video { class ITexture; class SColor; }
17typedef std::vector<video::SColor> Palette; // copied from src/client/texturesource.h
18
19// Caches data needed to draw an itemstack
20
22{
25
27 void clear();
28
29 // Get item inventory texture
30 video::ITexture* getInventoryTexture(const ItemStack &item, Client *client) const;
31
32 // Get item inventory overlay texture
33 video::ITexture* getInventoryOverlayTexture(const ItemStack &item, Client *client) const;
34
35 // Get item inventory animation
36 // returns nullptr if it is not animated
38
39 // Get item inventory overlay animation
40 // returns nullptr if it is not animated
42
43 // Get item mesh
44 ItemMesh *getItemMesh(const ItemStack &item, Client *client) const;
45
46 // Get item palette
47 Palette* getPalette(const ItemStack &item, Client *client) const;
48
49 // Returns the base color of an item stack: the color of all
50 // tiles that do not define their own color.
51 video::SColor getItemstackColor(const ItemStack &stack, Client *client) const;
52
53private:
54 struct ItemVisuals;
55
56 // The id of the thread that is allowed to use irrlicht directly
57 std::thread::id m_main_thread;
58 // Cached textures and meshes
59 mutable std::unordered_map<std::string, std::unique_ptr<ItemVisuals>> m_cached_item_visuals;
60
62};
Definition client.h:106
std::vector< video::SColor > Palette
Definition item_visuals_manager.h:17
Definition activeobjectmgr.cpp:11
Definition clientmap.h:36
Definition tile.h:188
Definition wieldmesh.h:94
Definition inventory.h:21
Definition item_visuals_manager.cpp:15
Definition item_visuals_manager.h:22
AnimationInfo * getInventoryAnimation(const ItemStack &item, Client *client) const
Definition item_visuals_manager.cpp:141
ItemVisuals * createItemVisuals(const ItemStack &item, Client *client) const
Definition item_visuals_manager.cpp:39
video::ITexture * getInventoryOverlayTexture(const ItemStack &item, Client *client) const
Definition item_visuals_manager.cpp:124
ItemVisualsManager()
Definition item_visuals_manager.cpp:98
void clear()
Clears the cached visuals.
Definition item_visuals_manager.cpp:107
Palette * getPalette(const ItemStack &item, Client *client) const
Definition item_visuals_manager.cpp:161
std::unordered_map< std::string, std::unique_ptr< ItemVisuals > > m_cached_item_visuals
Definition item_visuals_manager.h:59
AnimationInfo * getInventoryOverlayAnimation(const ItemStack &item, Client *client) const
Definition item_visuals_manager.cpp:152
video::ITexture * getInventoryTexture(const ItemStack &item, Client *client) const
Definition item_visuals_manager.cpp:113
video::SColor getItemstackColor(const ItemStack &stack, Client *client) const
Definition item_visuals_manager.cpp:169
~ItemVisualsManager()
Definition item_visuals_manager.cpp:103
ItemMesh * getItemMesh(const ItemStack &item, Client *client) const
Definition item_visuals_manager.cpp:135
std::thread::id m_main_thread
Definition item_visuals_manager.h:57