fix custom models instancing for different blocks
This commit is contained in:
@@ -37,8 +37,7 @@ void ContentGfxCache::refresh(const Block& def, const Atlas& atlas) {
|
|||||||
}
|
}
|
||||||
if (def.model.type == BlockModelType::CUSTOM) {
|
if (def.model.type == BlockModelType::CUSTOM) {
|
||||||
auto model = assets.require<model::Model>(def.model.name);
|
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) {
|
for (auto& mesh : model.meshes) {
|
||||||
size_t pos = mesh.texture.find(':');
|
size_t pos = mesh.texture.find(':');
|
||||||
if (pos == std::string::npos) {
|
if (pos == std::string::npos) {
|
||||||
@@ -50,7 +49,6 @@ void ContentGfxCache::refresh(const Block& def, const Atlas& atlas) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
models[def.rt.id] = std::move(model);
|
models[def.rt.id] = std::move(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,14 +62,17 @@ void ModelsGenerator::prepare(Content& content, Assets& assets) {
|
|||||||
);
|
);
|
||||||
def->model.name = def->name + ".model";
|
def->model.name = def->name + ".model";
|
||||||
} else {
|
} else {
|
||||||
auto model = assets.get<model::Model>(def->model.name);
|
auto srcModel = assets.get<model::Model>(def->model.name);
|
||||||
if (model) {
|
if (srcModel) {
|
||||||
|
auto model = std::make_unique<model::Model>(*srcModel);
|
||||||
for (auto& mesh : model->meshes) {
|
for (auto& mesh : model->meshes) {
|
||||||
if (mesh.texture.length() && mesh.texture[0] == '$') {
|
if (mesh.texture.length() && mesh.texture[0] == '$') {
|
||||||
int index = std::stoll(mesh.texture.substr(1));
|
int index = std::stoll(mesh.texture.substr(1));
|
||||||
mesh.texture = "blocks:" + def->textureFaces[index];
|
mesh.texture = "blocks:" + def->textureFaces[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
def->model.name = name + ".model";
|
||||||
|
assets.store(std::move(model), def->model.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user