diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 0af8e13..f17e513 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -602,8 +602,8 @@ public sealed class BSShapeCollection : IDisposable | |||
602 | if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == BSPhysicsShapeType.SHAPE_MESH) | 602 | if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == BSPhysicsShapeType.SHAPE_MESH) |
603 | return false; | 603 | return false; |
604 | 604 | ||
605 | if (DDetail) DetailLog("{0},BSShapeCollection.GetReferenceToMesh,create,oldKey={1},newKey={2}", | 605 | if (DDetail) DetailLog("{0},BSShapeCollection.GetReferenceToMesh,create,oldKey={1},newKey={2},size={3},lod={4}", |
606 | prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newMeshKey.ToString("X")); | 606 | prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newMeshKey.ToString("X"), prim.Size, lod); |
607 | 607 | ||
608 | // Since we're recreating new, get rid of the reference to the previous shape | 608 | // Since we're recreating new, get rid of the reference to the previous shape |
609 | DereferenceShape(prim.PhysShape, shapeCallback); | 609 | DereferenceShape(prim.PhysShape, shapeCallback); |
@@ -631,50 +631,50 @@ public sealed class BSShapeCollection : IDisposable | |||
631 | } | 631 | } |
632 | else | 632 | else |
633 | { | 633 | { |
634 | IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, true, false); | 634 | IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, |
635 | false, // say it is not physical so a bounding box is not built | ||
636 | false // do not cache the mesh and do not use previously built versions | ||
637 | ); | ||
635 | 638 | ||
636 | if (meshData != null) | 639 | if (meshData != null) |
637 | { | 640 | { |
638 | int[] indices = meshData.getIndexListAsInt(); | ||
639 | List<OMV.Vector3> vertices = meshData.getVertexList(); | ||
640 | |||
641 | float[] verticesAsFloats = new float[vertices.Count * 3]; | ||
642 | int vi = 0; | ||
643 | foreach (OMV.Vector3 vv in vertices) | ||
644 | { | ||
645 | verticesAsFloats[vi++] = vv.X; | ||
646 | verticesAsFloats[vi++] = vv.Y; | ||
647 | verticesAsFloats[vi++] = vv.Z; | ||
648 | } | ||
649 | 641 | ||
650 | // DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,key={1},lod={2},size={3},indices={4},vertices={5}", | 642 | int[] indices = meshData.getIndexListAsInt(); |
651 | // BSScene.DetailLogZero, newMeshKey.ToString("X"), lod, size, indices.Length, vertices.Count); | 643 | // int realIndicesIndex = indices.Length; |
652 | 644 | float[] verticesAsFloats = meshData.getVertexListAsFloat(); | |
653 | /* | 645 | |
654 | // DEBUG DEBUG | 646 | // Remove degenerate triangles. These are triangles with two of the vertices |
655 | for (int ii = 0; ii < indices.Length; ii += 3) | 647 | // are the same. This is complicated by the problem that vertices are not |
648 | // made unique in sculpties so we have to compare the values in the vertex. | ||
649 | int realIndicesIndex = 0; | ||
650 | for (int tri = 0; tri < indices.Length; tri += 3) | ||
656 | { | 651 | { |
657 | DetailLog("{0,3}: {1,3},{2,3},{3,3}: <{4,10},{5,10},{6,10}>, <{7,10},{8,10},{9,10}>, <{10,10},{11,10},{12,10}>", | 652 | int v1 = indices[tri + 0] * 3; |
658 | ii / 3, | 653 | int v2 = indices[tri + 1] * 3; |
659 | indices[ii + 0], | 654 | int v3 = indices[tri + 2] * 3; |
660 | indices[ii + 1], | 655 | if (!( ( verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0] |
661 | indices[ii + 2], | 656 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1] |
662 | verticesAsFloats[indices[ii+0] + 0], | 657 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2] ) |
663 | verticesAsFloats[indices[ii+0] + 1], | 658 | || ( verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0] |
664 | verticesAsFloats[indices[ii+0] + 2], | 659 | && verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1] |
665 | verticesAsFloats[indices[ii+1] + 0], | 660 | && verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2] ) |
666 | verticesAsFloats[indices[ii+1] + 1], | 661 | || ( verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0] |
667 | verticesAsFloats[indices[ii+1] + 2], | 662 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1] |
668 | verticesAsFloats[indices[ii+2] + 0], | 663 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2] ) ) |
669 | verticesAsFloats[indices[ii+2] + 1], | 664 | ) |
670 | verticesAsFloats[indices[ii+2] + 2] | 665 | { |
671 | ); | 666 | // None of the vertices of the triangles are the same. This is a good triangle; |
667 | indices[realIndicesIndex + 0] = indices[tri + 0]; | ||
668 | indices[realIndicesIndex + 1] = indices[tri + 1]; | ||
669 | indices[realIndicesIndex + 2] = indices[tri + 2]; | ||
670 | realIndicesIndex += 3; | ||
671 | } | ||
672 | } | 672 | } |
673 | // END DEBUG DEBUG | 673 | DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", |
674 | */ | 674 | BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3); |
675 | 675 | ||
676 | newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, | 676 | newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, |
677 | indices.GetLength(0), indices, vertices.Count, verticesAsFloats); | 677 | realIndicesIndex, indices, verticesAsFloats.Length/3, verticesAsFloats); |
678 | } | 678 | } |
679 | } | 679 | } |
680 | newShape.shapeKey = newMeshKey; | 680 | newShape.shapeKey = newMeshKey; |
@@ -853,6 +853,11 @@ public sealed class BSShapeCollection : IDisposable | |||
853 | { | 853 | { |
854 | // level of detail based on size and type of the object | 854 | // level of detail based on size and type of the object |
855 | float lod = BSParam.MeshLOD; | 855 | float lod = BSParam.MeshLOD; |
856 | |||
857 | // prims with curvy internal cuts need higher lod | ||
858 | if (pbs.HollowShape == HollowShape.Circle) | ||
859 | lod = BSParam.MeshCircularLOD; | ||
860 | |||
856 | if (pbs.SculptEntry) | 861 | if (pbs.SculptEntry) |
857 | lod = BSParam.SculptLOD; | 862 | lod = BSParam.SculptLOD; |
858 | 863 | ||