From 03ed89102917b5cc44ff10b521809426cf303b47 Mon Sep 17 00:00:00 2001 From: vladislavbelov Date: Thu, 18 Feb 2021 21:09:41 +0000 Subject: [PATCH] Do not generate render data in case CDecal calculated wrong coordinates. Tested By: OptimusShepard, Stan Differential Revision: https://code.wildfiregames.com/D3578 This was SVN commit r24932. --- source/renderer/DecalRData.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/renderer/DecalRData.cpp b/source/renderer/DecalRData.cpp index eecbb58417..cf03687d3e 100644 --- a/source/renderer/DecalRData.cpp +++ b/source/renderer/DecalRData.cpp @@ -234,6 +234,15 @@ void CDecalRData::BuildVertexData() ssize_t i0, j0, i1, j1; m_Decal->CalcVertexExtents(i0, j0, i1, j1); + // Currently CalcVertexExtents might return empty rectangle, that means + // we can't render it. + if (i1 <= i0 && j1 <= j0) + { + // We have nothing to render. + m_VBDecals.Reset(); + m_VBDecalsIndices.Reset(); + return; + } CmpPtr cmpWaterManager(*m_Simulation, SYSTEM_ENTITY); @@ -300,8 +309,6 @@ void CDecalRData::BuildVertexData() } } - ENSURE(!indices.empty()); - // Construct vertex buffer. if (!m_VBDecalsIndices || m_VBDecalsIndices->m_Count != indices.size()) m_VBDecalsIndices = g_VBMan.AllocateChunk(sizeof(u16), indices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);