fix custom models instancing for different blocks

This commit is contained in:
MihailRis
2025-05-02 18:42:12 +03:00
parent edb12a32b0
commit 895855434f
2 changed files with 14 additions and 13 deletions
+9 -11
View File
@@ -37,17 +37,15 @@ void ContentGfxCache::refresh(const Block& def, const Atlas& atlas) {
}
if (def.model.type == BlockModelType::CUSTOM) {
auto model = assets.require<model::Model>(def.model.name);
// temporary dirty fix tbh
if (def.model.name.find(':') == std::string::npos) {
for (auto& mesh : model.meshes) {
size_t pos = mesh.texture.find(':');
if (pos == std::string::npos) {
continue;
}
if (auto region = atlas.getIf(mesh.texture.substr(pos+1))) {
for (auto& vertex : mesh.vertices) {
vertex.uv = region->apply(vertex.uv);
}
for (auto& mesh : model.meshes) {
size_t pos = mesh.texture.find(':');
if (pos == std::string::npos) {
continue;
}
if (auto region = atlas.getIf(mesh.texture.substr(pos+1))) {
for (auto& vertex : mesh.vertices) {
vertex.uv = region->apply(vertex.uv);
}
}
}