mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
fix custom block models
This commit is contained in:
parent
bbadaf7a19
commit
86b5f5d82b
2 changed files with 19 additions and 3 deletions
|
|
@ -11,6 +11,8 @@
|
|||
#include "maths/UVRegion.hpp"
|
||||
#include "voxels/Block.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets)
|
||||
: content(content) {
|
||||
auto indices = content->getIndices();
|
||||
|
|
@ -29,8 +31,22 @@ ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets)
|
|||
}
|
||||
}
|
||||
if (def->model == BlockModel::custom) {
|
||||
models[def->rt.id] =
|
||||
assets->require<model::Model>(def->modelName);
|
||||
auto model = assets->require<model::Model>(def->modelName);
|
||||
// temporary dirty fix tbh
|
||||
if (def->modelName.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
models[def->rt.id] = std::move(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue