From 46964b3848eb7471d2f0e2284ae389b4b53337c1 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 1 May 2018 06:48:05 +0000 Subject: [PATCH] Fix a crash on Doombringer duel5.bsp where one of the lights has more than 32768 triangles - this was using more than one shadowmesh and the sidetotals code was written incorrectly to assume there is a single shadowmesh per light - so now shadowmeshes are preallocated large enough for the entire model, to ensure there is only one. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12412 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rsurf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gl_rsurf.c b/gl_rsurf.c index cd4c08bb..3051aa0b 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -1383,7 +1383,12 @@ void R_Q1BSP_CompileShadowMap(entity_render_t *ent, vec3_t relativelightorigin, int i; if (!model->brush.shadowmesh) return; - r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap = Mod_ShadowMesh_Begin(r_main_mempool, 32768, 32768, NULL, NULL, NULL, false, false, true); + // FIXME: the sidetotals code incorrectly assumes that static_meshchain is + // a single mesh - to prevent that from crashing (sideoffsets, sidetotals + // exceeding the number of triangles in a single mesh) we have to make sure + // that we make only a single mesh - so over-estimate the size of the mesh + // to match the model. + r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap = Mod_ShadowMesh_Begin(r_main_mempool, model->surfmesh.num_vertices, model->surfmesh.num_triangles, NULL, NULL, NULL, false, false, true); R_Shadow_PrepareShadowSides(model->brush.shadowmesh->numtriangles); for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++) { -- 2.39.2