fix: incorrect UV on custom model blocks

This commit is contained in:
MihailRis 2025-02-19 23:39:50 +03:00
parent 0ccfc2d3a0
commit 12105c2933
3 changed files with 4 additions and 7 deletions

View File

@ -13,6 +13,9 @@ util::TextureRegion util::get_texture_region(
} else { } else {
auto atlas = assets.get<Atlas>(name.substr(0, sep)); auto atlas = assets.get<Atlas>(name.substr(0, sep));
if (atlas) { if (atlas) {
if (sep == name.length() - 1) {
return {atlas->getTexture(), UVRegion(0,0,1,1)};
}
if (auto reg = atlas->getIf(name.substr(sep+1))) { if (auto reg = atlas->getIf(name.substr(sep+1))) {
return {atlas->getTexture(), *reg}; return {atlas->getTexture(), *reg};
} else if (!fallback.empty()){ } else if (!fallback.empty()){

View File

@ -269,12 +269,6 @@ void ContentLoader::loadBlock(
} else if (def.modelName.empty()) { } else if (def.modelName.empty()) {
throw std::runtime_error(name + ": no 'model-primitives' or 'model-name' found"); throw std::runtime_error(name + ": no 'model-primitives' or 'model-name' found");
} }
for (uint i = 0; i < 6; i++) {
std::string& texture = def.textureFaces[i];
if (texture == TEXTURE_NOTFOUND) {
texture = "";
}
}
} }
def.model = *model; def.model = *model;
} else if (!modelTypeName.empty()) { } else if (!modelTypeName.empty()) {

View File

@ -57,7 +57,7 @@ model::Model ModelsGenerator::fromCustom(
) { ) {
auto model = model::Model(); auto model = model::Model();
for (size_t i = 0; i < modelBoxes.size(); i++) { for (size_t i = 0; i < modelBoxes.size(); i++) {
auto& mesh = model.addMesh("blocks:" + modelTextures[i * 6]); auto& mesh = model.addMesh("blocks:");
mesh.lighting = lighting; mesh.lighting = lighting;
const UVRegion boxtexfaces[6] = { const UVRegion boxtexfaces[6] = {
get_region_for(modelTextures[i * 6 + 5], assets), get_region_for(modelTextures[i * 6 + 5], assets),