From cdf9611080c433bd81f55b121661017a414b742f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 10 Mar 2019 18:13:03 +0100 Subject: [PATCH] Graphics/TileMap: Fix material index rendering --- ChangeLog.md | 1 + src/Nazara/Graphics/TileMap.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 0225f87aa..313c52f49 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -166,6 +166,7 @@ Nazara Engine: - Fixed SystemCursor_Move not showing up on Windows - Fixed Window movement constructor/assignation operator - Window::PushEvent is now public (useful for pushing external events ie. when using Qt or similar framework controlling window) +- Fixed TileMap not rendering the right materials if it had no tile using some materials in-between Nazara Development Kit: - Added ImageWidget (#139) diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp index 4ff59ec7b..4789f4a8b 100644 --- a/src/Nazara/Graphics/TileMap.cpp +++ b/src/Nazara/Graphics/TileMap.cpp @@ -27,14 +27,14 @@ namespace Nz { const VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(instanceData.data.data()); - std::size_t matCount = 0; std::size_t spriteCount = 0; - for (const Layer& layer : m_layers) + for (std::size_t layerIndex = 0; layerIndex < m_layers.size(); ++layerIndex) { + const auto& layer = m_layers[layerIndex]; if (layer.tiles.empty()) continue; - renderQueue->AddSprites(instanceData.renderOrder, GetMaterial(matCount++), &vertices[4 * spriteCount], layer.tiles.size(), scissorRect); + renderQueue->AddSprites(instanceData.renderOrder, GetMaterial(layerIndex), &vertices[4 * spriteCount], layer.tiles.size(), scissorRect); spriteCount += layer.tiles.size(); }