diff options
author | Dave Parks <davep@lindenlab.com> | 2010-12-17 14:58:39 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2010-12-17 14:58:39 -0600 |
commit | ac7fad4cd0beeee670be40fae1956e5f22a0f17d (patch) | |
tree | 5780a7d63e4a6c5031a8053c45eb50a502e1fd3a /indra | |
parent | 4056ab8fbf70a684aea64c8106c72f9e870ebe56 (diff) |
SH-558 Fix for crash in physics shape display.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llspatialpartition.cpp | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 6b77209867..cc54f21a7e 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3001,56 +3001,59 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) index_offset += face.mNumVertices; } - LLCDMeshData mesh; - mesh.mIndexBase = &index[0]; - mesh.mVertexBase = pos[0].mV; - mesh.mNumVertices = pos.size(); - mesh.mVertexStrideBytes = 12; - mesh.mIndexStrideBytes = 6; - mesh.mIndexType = LLCDMeshData::INT_16; - - mesh.mNumTriangles = index.size()/3; - - LLCDMeshData res; + if (!pos.empty() && !index.empty()) + { + LLCDMeshData mesh; + mesh.mIndexBase = &index[0]; + mesh.mVertexBase = pos[0].mV; + mesh.mNumVertices = pos.size(); + mesh.mVertexStrideBytes = 12; + mesh.mIndexStrideBytes = 6; + mesh.mIndexType = LLCDMeshData::INT_16; + + mesh.mNumTriangles = index.size()/3; + + LLCDMeshData res; - LLConvexDecomposition::getInstance()->generateSingleHullMeshFromMesh( &mesh, &res ); + LLConvexDecomposition::getInstance()->generateSingleHullMeshFromMesh( &mesh, &res ); - //copy res into phys_volume - phys_volume->mHullPoints = (LLVector4a*) malloc(sizeof(LLVector4a)*res.mNumVertices); - phys_volume->mNumHullPoints = res.mNumVertices; + //copy res into phys_volume + phys_volume->mHullPoints = (LLVector4a*) malloc(sizeof(LLVector4a)*res.mNumVertices); + phys_volume->mNumHullPoints = res.mNumVertices; - S32 idx_size = (res.mNumTriangles*3*2+0xF) & ~0xF; - phys_volume->mHullIndices = (U16*) malloc(idx_size); - phys_volume->mNumHullIndices = res.mNumTriangles*3; + S32 idx_size = (res.mNumTriangles*3*2+0xF) & ~0xF; + phys_volume->mHullIndices = (U16*) malloc(idx_size); + phys_volume->mNumHullIndices = res.mNumTriangles*3; - const F32* v = res.mVertexBase; + const F32* v = res.mVertexBase; - for (S32 i = 0; i < res.mNumVertices; ++i) - { - F32* p = (F32*) ((U8*)v+i*res.mVertexStrideBytes); - phys_volume->mHullPoints[i].load3(p); - } + for (S32 i = 0; i < res.mNumVertices; ++i) + { + F32* p = (F32*) ((U8*)v+i*res.mVertexStrideBytes); + phys_volume->mHullPoints[i].load3(p); + } - if (res.mIndexType == LLCDMeshData::INT_16) - { - for (S32 i = 0; i < res.mNumTriangles; ++i) + if (res.mIndexType == LLCDMeshData::INT_16) { - U16* idx = (U16*) (((U8*)res.mIndexBase)+i*res.mIndexStrideBytes); + for (S32 i = 0; i < res.mNumTriangles; ++i) + { + U16* idx = (U16*) (((U8*)res.mIndexBase)+i*res.mIndexStrideBytes); - phys_volume->mHullIndices[i*3+0] = idx[0]; - phys_volume->mHullIndices[i*3+1] = idx[1]; - phys_volume->mHullIndices[i*3+2] = idx[2]; + phys_volume->mHullIndices[i*3+0] = idx[0]; + phys_volume->mHullIndices[i*3+1] = idx[1]; + phys_volume->mHullIndices[i*3+2] = idx[2]; + } } - } - else - { - for (S32 i = 0; i < res.mNumTriangles; ++i) + else { - U32* idx = (U32*) (((U8*)res.mIndexBase)+i*res.mIndexStrideBytes); + for (S32 i = 0; i < res.mNumTriangles; ++i) + { + U32* idx = (U32*) (((U8*)res.mIndexBase)+i*res.mIndexStrideBytes); - phys_volume->mHullIndices[i*3+0] = (U16) idx[0]; - phys_volume->mHullIndices[i*3+1] = (U16) idx[1]; - phys_volume->mHullIndices[i*3+2] = (U16) idx[2]; + phys_volume->mHullIndices[i*3+0] = (U16) idx[0]; + phys_volume->mHullIndices[i*3+1] = (U16) idx[1]; + phys_volume->mHullIndices[i*3+2] = (U16) idx[2]; + } } } } |