From ad40eb6450e049638369316762dff24f0a298a47 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 9 Feb 2014 22:12:44 +0100 Subject: [PATCH] Fix the bug that caused the shape exporter to crash --- code/nel/src/3d/mesh_multi_lod.cpp | 6 +++++- .../tools/3d/plugin_max/nel_export/nel_export_export.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/nel/src/3d/mesh_multi_lod.cpp b/code/nel/src/3d/mesh_multi_lod.cpp index 2ddf0d2e0..e26632f6e 100644 --- a/code/nel/src/3d/mesh_multi_lod.cpp +++ b/code/nel/src/3d/mesh_multi_lod.cpp @@ -791,17 +791,20 @@ void CMeshMultiLod::compileCoarseMeshes() { slotRef.CoarseTriangles.resize(slotRef.CoarseNumTris * 3); TCoarseMeshIndexType *dstPtr= &slotRef.CoarseTriangles[0]; + uint totalTris = 0; for(uint i=0;igetNbRdrPass(0);i++) { const CIndexBuffer &pb= meshGeom->getRdrPassPrimitiveBlock(0, i); CIndexBufferRead ibaRead; pb.lock (ibaRead); uint numTris= pb.getNumIndexes()/3; + totalTris += numTris; if (pb.getFormat() == CIndexBuffer::Indices16) { if (sizeof(TCoarseMeshIndexType) == sizeof(uint16)) { memcpy(dstPtr, (uint16 *) ibaRead.getPtr(), numTris*3*sizeof(uint16)); + dstPtr+= numTris*3; } else { @@ -820,6 +823,7 @@ void CMeshMultiLod::compileCoarseMeshes() if (sizeof(TCoarseMeshIndexType) == sizeof(uint32)) { memcpy(dstPtr, (uint32 *) ibaRead.getPtr(), numTris*3*sizeof(uint32)); + dstPtr+= numTris*3; } else { @@ -836,8 +840,8 @@ void CMeshMultiLod::compileCoarseMeshes() } } } - dstPtr+= numTris*3; } + nlassert(totalTris == slotRef.CoarseNumTris); } } } diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp index fbca1f037..46d88757b 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp @@ -142,7 +142,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) { bool tempBRet = bRet; bRet = false; - // delete pShape; // FIXME: there is a delete bug with CMeshMultiLod exported from max!!! + delete pShape; bRet = tempBRet; } catch (...)