From ff3c27ab20614039b9d879abae21f0c04b435302 Mon Sep 17 00:00:00 2001 From: smallmodel <15067410+smallmodel@users.noreply.github.com> Date: Sat, 8 Feb 2025 20:28:46 +0100 Subject: [PATCH] Fix assertion when the height is identical between vert0 and vert1 --- code/renderergl1/tr_terrain.c | 2 +- code/renderergl2/tr_terrain.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/renderergl1/tr_terrain.c b/code/renderergl1/tr_terrain.c index bcbab3da..10f73a15 100644 --- a/code/renderergl1/tr_terrain.c +++ b/code/renderergl1/tr_terrain.c @@ -144,7 +144,7 @@ static void R_InterpolateVert(terraTri_t *pTri, terrainVert_t *pVert) pMinHeight = (byte *)Q_min((uintptr_t)pVert0->pHgt, (uintptr_t)pVert1->pHgt); pMaxHeight = (byte *)Q_max((uintptr_t)pVert0->pHgt, (uintptr_t)pVert1->pHgt); pVert->pHgt = (byte *)(pMinHeight + ((pMaxHeight - pMinHeight) >> 1)); - assert(pVert->pHgt >= pMinHeight && pVert->pHgt < pMaxHeight); + assert(pVert->pHgt >= pMinHeight && pVert->pHgt < pMaxHeight || pMinHeight == pMaxHeight); // Calculate the average Z pVert->fHgtAvg = (float)(*pVert0->pHgt + *pVert1->pHgt); diff --git a/code/renderergl2/tr_terrain.c b/code/renderergl2/tr_terrain.c index 61fa1f2d..94c5fff2 100644 --- a/code/renderergl2/tr_terrain.c +++ b/code/renderergl2/tr_terrain.c @@ -141,7 +141,7 @@ static void R_InterpolateVert(terraTri_t *pTri, terrainVert_t *pVert) pMinHeight = (byte *)Q_min((uintptr_t)pVert0->pHgt, (uintptr_t)pVert1->pHgt); pMaxHeight = (byte *)Q_max((uintptr_t)pVert0->pHgt, (uintptr_t)pVert1->pHgt); pVert->pHgt = (byte *)(pMinHeight + ((pMaxHeight - pMinHeight) >> 1)); - assert(pVert->pHgt >= pMinHeight && pVert->pHgt < pMaxHeight); + assert(pVert->pHgt >= pMinHeight && pVert->pHgt < pMaxHeight || pMinHeight == pMaxHeight); // Calculate the average Z pVert->fHgtAvg = (float)(*pVert0->pHgt + *pVert1->pHgt);