From 8bddc84e627aa52f887f5d0b124d3687c034fc64 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 21 Jan 2023 16:01:30 +0100 Subject: [PATCH] Use Mem_MallocA() in Model_md5.cpp one step to making HD models (like https://www.moddb.com/mods/birdman-doom3/downloads/birdman-doom3-v11 ) work, but there's still other places in the code where the HD version of that model makes dhewm3 crash --- neo/renderer/Model_md5.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/neo/renderer/Model_md5.cpp b/neo/renderer/Model_md5.cpp index 59e8b314..30b91118 100644 --- a/neo/renderer/Model_md5.cpp +++ b/neo/renderer/Model_md5.cpp @@ -235,13 +235,16 @@ void idMD5Mesh::ParseMesh( idLexer &parser, int numJoints, const idJointMat *joi // build the information that will be common to all animations of this mesh: // silhouette edge connectivity and normal / tangent generation information // - idDrawVert *verts = (idDrawVert *) _alloca16( texCoords.Num() * sizeof( idDrawVert ) ); + bool onStack; + idDrawVert *verts = (idDrawVert*)Mem_MallocA( texCoords.Num()*sizeof(idDrawVert), onStack ); + for ( i = 0; i < texCoords.Num(); i++ ) { verts[i].Clear(); verts[i].st = texCoords[i]; } TransformVerts( verts, joints ); deformInfo = R_BuildDeformInfo( texCoords.Num(), verts, tris.Num(), tris.Ptr(), shader->UseUnsmoothedTangents() ); + Mem_FreeA( verts, onStack ); } /* @@ -352,12 +355,15 @@ idMD5Mesh::CalcBounds */ idBounds idMD5Mesh::CalcBounds( const idJointMat *entJoints ) { idBounds bounds; - idDrawVert *verts = (idDrawVert *) _alloca16( texCoords.Num() * sizeof( idDrawVert ) ); + bool onStack; + idDrawVert *verts = (idDrawVert*)Mem_MallocA( texCoords.Num()*sizeof(idDrawVert), onStack ); TransformVerts( verts, entJoints ); SIMDProcessor->MinMax( bounds[0], bounds[1], verts, texCoords.Num() ); + Mem_FreeA( verts, onStack ); + return bounds; }