diff options
author | Dave Parks <davep@lindenlab.com> | 2010-10-07 15:37:07 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2010-10-07 15:37:07 -0500 |
commit | ca1f7828b236b9a692f04e390975e8fcda13d597 (patch) | |
tree | bc622e0b966c52f8f31069f0265bea5b54d8facc | |
parent | b70ccfe8e31cd253069a6e0ae0ec03e301d26578 (diff) |
Update convex decomp and physics shape display to include convex hulls for prims where appropriate.
-rw-r--r-- | indra/newview/llspatialpartition.cpp | 99 | ||||
-rw-r--r-- | install.xml | 4 |
2 files changed, 100 insertions, 3 deletions
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index b99829c3e4..68f3fdb1a0 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2907,12 +2907,109 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) gGL.popMatrix(); } } - else if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::USER_CONVEX) + else if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::USER_CONVEX || + type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::PRIM_CONVEX) { if (volume->isMesh()) { renderMeshBaseHull(volume, data_mask, color); } +#if 0 && LL_WINDOWS + else + { + LLVolumeParams volume_params = volume->getVolume()->getParams(); + S32 detail = get_physics_detail(volume_params, volume->getScale()); + LLVolume* phys_volume = LLPrimitive::sVolumeManager->refVolume(volume_params, detail); + + if (!phys_volume->mHullPoints) + { //build convex hull + std::vector<LLVector3> pos; + std::vector<U16> index; + + S32 index_offset = 0; + + for (S32 i = 0; i < phys_volume->getNumVolumeFaces(); ++i) + { + const LLVolumeFace& face = phys_volume->getVolumeFace(i); + if (index_offset + face.mNumVertices > 65535) + { + continue; + } + + for (S32 j = 0; j < face.mNumVertices; ++j) + { + pos.push_back(LLVector3(face.mPositions[j].getF32ptr())); + } + + for (S32 j = 0; j < face.mNumIndices; ++j) + { + index.push_back(face.mIndices[j]+index_offset); + } + + 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; + + LLConvexDecomposition::getInstance()->generateSingleHullMeshFromMesh( &mesh, &res ); + + //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; + + const F32* v = mesh.mVertexBase; + + for (S32 i = 0; i < res.mNumVertices; ++i) + { + F32* p = (F32*) ((U8*)v+i*mesh.mVertexStrideBytes); + phys_volume->mHullPoints[i].load3(p); + } + + 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]; + } + } + + if (phys_volume->mHullPoints) + { + //render hull + gGL.pushMatrix(); + glMultMatrixf((GLfloat*) volume->getRelativeXform().mMatrix); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + glColor3fv(color.mV); + LLVertexBuffer::unbind(); + glVertexPointer(3, GL_FLOAT, 16, phys_volume->mHullPoints); + glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices); + + glColor4fv(color.mV); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices); + gGL.popMatrix(); + } + + LLPrimitive::sVolumeManager->unrefVolume(phys_volume); + } +#endif //LL_WINDOWS } else if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::BOX) { diff --git a/install.xml b/install.xml index 84c4ac2aef..9ec364950c 100644 --- a/install.xml +++ b/install.xml @@ -1058,9 +1058,9 @@ anguage Infrstructure (CLI) international standard</string> <key>windows</key> <map> <key>md5sum</key> - <string>f661b5f34b5483d993e6032309723725</string> + <string>7c7526e45f8d0281bf4c0981911463ef</string> <key>url</key> - <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.2-windows-20100929.tar.bz2</uri> + <uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.3-windows-20101006.tar.bz2</uri> </map> <key>linux</key> <map> |