From d731420997fe7347f154e16905c526909addffcb Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 7 Jan 2012 23:07:37 +0000 Subject: [PATCH] Improve error handling git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10586 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/physics/triangle_mesh.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/physics/triangle_mesh.cpp b/src/physics/triangle_mesh.cpp index 914765243..d257867e3 100644 --- a/src/physics/triangle_mesh.cpp +++ b/src/physics/triangle_mesh.cpp @@ -101,10 +101,17 @@ void TriangleMesh::createCollisionShape(bool create_collision_object, const char fclose(f); btOptimizedBvh* bhv = btOptimizedBvh::deSerializeInPlace(bytes, pos, !IS_LITTLE_ENDIAN); - bhv_triangle_mesh = new btBvhTriangleMeshShape(&m_mesh, true /* useQuantizedAabbCompression */, - false /* buildBvh */); - bhv_triangle_mesh->setOptimizedBvh( bhv ); - + if (bhv == NULL) + { + fprintf(stderr, "[TriangleMesh] WARNING, failed to load serialized BHV"); + bhv_triangle_mesh = new btBvhTriangleMeshShape(&m_mesh, true /* useQuantizedAabbCompression */); + } + else + { + bhv_triangle_mesh = new btBvhTriangleMeshShape(&m_mesh, true /* useQuantizedAabbCompression */, + false /* buildBvh */); + bhv_triangle_mesh->setOptimizedBvh( bhv ); + } // Do *NOT* free the bytes, 'deSerializeInPlace' makes the btOptimizedBvh object // directly at this memory location //free(bytes);