From 3e50d8248f8896fea0fa1e511b0cb7d76cec2765 Mon Sep 17 00:00:00 2001 From: codereader Date: Sat, 4 Dec 2021 06:47:15 +0100 Subject: [PATCH] #5584: Respect bucket index when adjusting geometry indices --- radiantcore/rendersystem/backend/GeometryRenderer.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/radiantcore/rendersystem/backend/GeometryRenderer.h b/radiantcore/rendersystem/backend/GeometryRenderer.h index 608fcae557..44e4e7ddee 100644 --- a/radiantcore/rendersystem/backend/GeometryRenderer.h +++ b/radiantcore/rendersystem/backend/GeometryRenderer.h @@ -180,11 +180,16 @@ class GeometryRenderer : bucket.removeSurface(slotInfo.firstVertex, slotInfo.numVertices, slotInfo.firstIndex, slotInfo.numIndices); - // Adjust all offsets in other slots + // Adjust all offsets in other slots pointing to the same bucket for (auto& slot : _slots) { - if (slot.firstVertex > slotInfo.firstVertex) + if (slot.bucketIndex == slotInfo.bucketIndex && + slot.firstVertex > slotInfo.firstVertex && + slot.firstVertex != InvalidVertexIndex) { + assert(slot.firstVertex >= slotInfo.numVertices); + assert(slot.firstIndex >= slotInfo.numIndices); + slot.firstVertex -= slotInfo.numVertices; slot.firstIndex -= slotInfo.numIndices; }