1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Move client code out of ItemDefManager (#15967)

This commit is contained in:
cx384 2025-04-04 18:58:14 +02:00 committed by GitHub
parent a6d4cd7c15
commit 52b974184d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 195 additions and 163 deletions

View file

@ -13,6 +13,7 @@
#include "client/wieldmesh.h"
#include "client/texturesource.h"
#include "client/guiscalingfilter.h"
#include "client/item_visuals_manager.h"
struct MeshTimeInfo {
u64 time;
@ -43,6 +44,7 @@ void drawItemStack(
auto *idef = client->idef();
const ItemDefinition &def = item.getDefinition(idef);
ItemVisualsManager* item_visuals = client->getItemVisualsManager();
bool draw_overlay = false;
@ -58,7 +60,7 @@ void drawItemStack(
// Render as mesh if animated or no inventory image
if ((enable_animations && rotation_kind < IT_ROT_NONE) || inventory_image.empty()) {
imesh = idef->getWieldMesh(item, client);
imesh = item_visuals->getWieldMesh(item, client);
has_mesh = imesh && imesh->mesh;
}
if (has_mesh) {
@ -114,8 +116,7 @@ void drawItemStack(
driver->setTransform(video::ETS_WORLD, matrix);
driver->setViewPort(viewrect);
video::SColor basecolor =
client->idef()->getItemstackColor(item, client);
video::SColor basecolor = item_visuals->getItemstackColor(item, client);
const u32 mc = mesh->getMeshBufferCount();
if (mc > imesh->buffer_info.size())
@ -154,10 +155,10 @@ void drawItemStack(
draw_overlay = def.type == ITEM_NODE && inventory_image.empty();
} else { // Otherwise just draw as 2D
video::ITexture *texture = client->idef()->getInventoryTexture(item, client);
video::ITexture *texture = item_visuals->getInventoryTexture(item, client);
video::SColor color;
if (texture) {
color = client->idef()->getItemstackColor(item, client);
color = item_visuals->getItemstackColor(item, client);
} else {
color = video::SColor(255, 255, 255, 255);
ITextureSource *tsrc = client->getTextureSource();