diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-11-01 12:41:02 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-11-01 12:41:02 +1100 |
commit | 38910aeead73dc32dff7dee6736fba832aec3e20 (patch) | |
tree | 8dd7a5e02cd2c01a2adb02308cd134ca9849cd98 | |
parent | f09b54b7e9b578155d47c18acee9ff9fb12b8d15 (diff) |
Skip generating tile pieces if a color variant is invalid
-rw-r--r-- | source/rendering/StarTilePainter.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/rendering/StarTilePainter.cpp b/source/rendering/StarTilePainter.cpp index de49910..5655930 100644 --- a/source/rendering/StarTilePainter.cpp +++ b/source/rendering/StarTilePainter.cpp @@ -292,7 +292,9 @@ bool TilePainter::produceTerrainPrimitives(HashMap<QuadZLevel, List<RenderPrimit terrainLayer == TerrainLayer::Background ? TileLayer::Background : TileLayer::Foreground, false); for (auto const& piecePair : pieces) { TexturePtr texture = getPieceTexture(material, piecePair.first, materialHue, false); - RectF textureCoords = piecePair.first->variants.get(materialColorVariant).wrap(variance); + auto variant = piecePair.first->variants.ptr(materialColorVariant); + if (!variant) continue; + RectF textureCoords = variant->wrap(variance); RectF worldCoords = RectF::withSize(piecePair.second / TilePixels + Vec2F(pos), textureCoords.size() / TilePixels); quadList.emplace_back(std::in_place_type_t<RenderQuad>(), move(texture), worldCoords .min(), @@ -317,7 +319,9 @@ bool TilePainter::produceTerrainPrimitives(HashMap<QuadZLevel, List<RenderPrimit terrainLayer == TerrainLayer::Background ? TileLayer::Background : TileLayer::Foreground, true); for (auto const& piecePair : pieces) { auto texture = getPieceTexture(mod, piecePair.first, modHue, true); - auto& textureCoords = piecePair.first->variants.get(modColorVariant).wrap(variance); + auto variant = piecePair.first->variants.ptr(modColorVariant); + if (!variant) continue; + auto& textureCoords = variant->wrap(variance); RectF worldCoords = RectF::withSize(piecePair.second / TilePixels + Vec2F(pos), textureCoords.size() / TilePixels); quadList.emplace_back(std::in_place_type_t<RenderQuad>(), move(texture), worldCoords.min(), textureCoords.min(), |