diff options
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 07e34ab..096b300 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -608,7 +608,7 @@ public sealed class BSShapeCollection : IDisposable | |||
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); |
610 | 610 | ||
611 | newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, prim.BaseShape, prim.Size, lod); | 611 | newShape = CreatePhysicalMesh(prim, newMeshKey, prim.BaseShape, prim.Size, lod); |
612 | // Take evasive action if the mesh was not constructed. | 612 | // Take evasive action if the mesh was not constructed. |
613 | newShape = VerifyMeshCreated(newShape, prim); | 613 | newShape = VerifyMeshCreated(newShape, prim); |
614 | 614 | ||
@@ -619,7 +619,7 @@ public sealed class BSShapeCollection : IDisposable | |||
619 | return true; // 'true' means a new shape has been added to this prim | 619 | return true; // 'true' means a new shape has been added to this prim |
620 | } | 620 | } |
621 | 621 | ||
622 | private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) | 622 | private BulletShape CreatePhysicalMesh(BSPhysObject prim, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) |
623 | { | 623 | { |
624 | BulletShape newShape = new BulletShape(); | 624 | BulletShape newShape = new BulletShape(); |
625 | 625 | ||
@@ -631,7 +631,7 @@ public sealed class BSShapeCollection : IDisposable | |||
631 | } | 631 | } |
632 | else | 632 | else |
633 | { | 633 | { |
634 | IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, | 634 | IMesh meshData = PhysicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, |
635 | true, | 635 | true, |
636 | false, // say it is not physical so a bounding box is not built | 636 | false, // say it is not physical so a bounding box is not built |
637 | false, // do not cache the mesh and do not use previously built versions | 637 | false, // do not cache the mesh and do not use previously built versions |
@@ -653,18 +653,20 @@ public sealed class BSShapeCollection : IDisposable | |||
653 | realIndicesIndex = 0; | 653 | realIndicesIndex = 0; |
654 | for (int tri = 0; tri < indices.Length; tri += 3) | 654 | for (int tri = 0; tri < indices.Length; tri += 3) |
655 | { | 655 | { |
656 | // Compute displacements into vertex array for each vertex of the triangle | ||
656 | int v1 = indices[tri + 0] * 3; | 657 | int v1 = indices[tri + 0] * 3; |
657 | int v2 = indices[tri + 1] * 3; | 658 | int v2 = indices[tri + 1] * 3; |
658 | int v3 = indices[tri + 2] * 3; | 659 | int v3 = indices[tri + 2] * 3; |
659 | if (!((verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0] | 660 | // Check to see if any two of the vertices are the same |
661 | if (!( ( verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0] | ||
660 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1] | 662 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1] |
661 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2]) | 663 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2]) |
662 | || (verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0] | 664 | || ( verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0] |
663 | && verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1] | 665 | && verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1] |
664 | && verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2]) | 666 | && verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2]) |
665 | || (verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0] | 667 | || ( verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0] |
666 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1] | 668 | && verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1] |
667 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2])) | 669 | && verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2]) ) |
668 | ) | 670 | ) |
669 | { | 671 | { |
670 | // None of the vertices of the triangles are the same. This is a good triangle; | 672 | // None of the vertices of the triangles are the same. This is a good triangle; |
@@ -678,8 +680,16 @@ public sealed class BSShapeCollection : IDisposable | |||
678 | DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", | 680 | DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", |
679 | BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3); | 681 | BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3); |
680 | 682 | ||
681 | newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, | 683 | if (realIndicesIndex != 0) |
682 | realIndicesIndex, indices, verticesAsFloats.Length/3, verticesAsFloats); | 684 | { |
685 | newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, | ||
686 | realIndicesIndex, indices, verticesAsFloats.Length / 3, verticesAsFloats); | ||
687 | } | ||
688 | else | ||
689 | { | ||
690 | PhysicsScene.Logger.ErrorFormat("{0} All mesh triangles degenerate. Prim {1} at {2} in {3}", | ||
691 | LogHeader, prim.PhysObjectName, prim.RawPosition, PhysicsScene.Name); | ||
692 | } | ||
683 | } | 693 | } |
684 | } | 694 | } |
685 | newShape.shapeKey = newMeshKey; | 695 | newShape.shapeKey = newMeshKey; |
@@ -897,9 +907,11 @@ public sealed class BSShapeCollection : IDisposable | |||
897 | // If this mesh has an underlying asset and we have not failed getting it before, fetch the asset | 907 | // If this mesh has an underlying asset and we have not failed getting it before, fetch the asset |
898 | if (prim.BaseShape.SculptEntry && !prim.LastAssetBuildFailed && prim.BaseShape.SculptTexture != OMV.UUID.Zero) | 908 | if (prim.BaseShape.SculptEntry && !prim.LastAssetBuildFailed && prim.BaseShape.SculptTexture != OMV.UUID.Zero) |
899 | { | 909 | { |
910 | DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset,lastFailed={1}", prim.LocalID, prim.LastAssetBuildFailed); | ||
911 | // This will prevent looping through this code as we keep trying to get the failed shape | ||
900 | prim.LastAssetBuildFailed = true; | 912 | prim.LastAssetBuildFailed = true; |
913 | |||
901 | BSPhysObject xprim = prim; | 914 | BSPhysObject xprim = prim; |
902 | DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset,lastFailed={1}", prim.LocalID, prim.LastAssetBuildFailed); | ||
903 | Util.FireAndForget(delegate | 915 | Util.FireAndForget(delegate |
904 | { | 916 | { |
905 | RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod; | 917 | RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod; |
@@ -910,7 +922,7 @@ public sealed class BSShapeCollection : IDisposable | |||
910 | { | 922 | { |
911 | bool assetFound = false; // DEBUG DEBUG | 923 | bool assetFound = false; // DEBUG DEBUG |
912 | string mismatchIDs = String.Empty; // DEBUG DEBUG | 924 | string mismatchIDs = String.Empty; // DEBUG DEBUG |
913 | if (yprim.BaseShape.SculptEntry) | 925 | if (asset != null && yprim.BaseShape.SculptEntry) |
914 | { | 926 | { |
915 | if (yprim.BaseShape.SculptTexture.ToString() == asset.ID) | 927 | if (yprim.BaseShape.SculptTexture.ToString() == asset.ID) |
916 | { | 928 | { |