fix Image for non-existing textures in atlas

This commit is contained in:
MihailRis
2024-06-30 22:25:31 +03:00
parent 2dffdf757c
commit 71c754b039
4 changed files with 22 additions and 9 deletions
+11 -8
View File
@@ -30,14 +30,17 @@ void Image::draw(const DrawContext* pctx, Assets* assets) {
} else {
auto atlasName = this->texture.substr(0, separator);
if (auto atlas = assets->get<Atlas>(atlasName)) {
texture = atlas->getTexture();
batch->texture(atlas->getTexture());
auto& region = atlas->get(this->texture.substr(separator+1));
batch->setRegion(region);
if (autoresize) {
setSize(glm::vec2(
texture->getWidth()*region.getWidth(),
texture->getHeight()*region.getHeight()));
if (auto region = atlas->getIf(this->texture.substr(separator+1))) {
texture = atlas->getTexture();
batch->texture(atlas->getTexture());
batch->setRegion(*region);
if (autoresize) {
setSize(glm::vec2(
texture->getWidth()*region->getWidth(),
texture->getHeight()*region->getHeight()));
}
} else {
batch->texture(nullptr);
}
}
}