aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs35
1 files changed, 16 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index 76860e4..57e74a3 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -162,11 +162,8 @@ public sealed class BSShapeCollection : IDisposable
162 // If the caller needs to know the old body is going away, pass the event up. 162 // If the caller needs to know the old body is going away, pass the event up.
163 if (bodyCallback != null) bodyCallback(body); 163 if (bodyCallback != null) bodyCallback(body);
164 164
165 if (PhysicsScene.PE.IsInWorld(PhysicsScene.World, body)) 165 // Removing an object not in the world is a NOOP
166 { 166 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
167 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
168 if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
169 }
170 167
171 // Zero any reference to the shape so it is not freed when the body is deleted. 168 // Zero any reference to the shape so it is not freed when the body is deleted.
172 PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, body, null); 169 PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, body, null);
@@ -615,7 +612,7 @@ public sealed class BSShapeCollection : IDisposable
615 612
616 newShape = CreatePhysicalMesh(prim, newMeshKey, prim.BaseShape, prim.Size, lod); 613 newShape = CreatePhysicalMesh(prim, newMeshKey, prim.BaseShape, prim.Size, lod);
617 // Take evasive action if the mesh was not constructed. 614 // Take evasive action if the mesh was not constructed.
618 newShape = VerifyMeshCreated(newShape, prim); 615 newShape = VerifyMeshCreated(PhysicsScene, newShape, prim);
619 616
620 ReferenceShape(newShape); 617 ReferenceShape(newShape);
621 618
@@ -724,7 +721,7 @@ public sealed class BSShapeCollection : IDisposable
724 721
725 newShape = CreatePhysicalHull(prim, newHullKey, prim.BaseShape, prim.Size, lod); 722 newShape = CreatePhysicalHull(prim, newHullKey, prim.BaseShape, prim.Size, lod);
726 // It might not have been created if we're waiting for an asset. 723 // It might not have been created if we're waiting for an asset.
727 newShape = VerifyMeshCreated(newShape, prim); 724 newShape = VerifyMeshCreated(PhysicsScene, newShape, prim);
728 725
729 ReferenceShape(newShape); 726 ReferenceShape(newShape);
730 727
@@ -928,7 +925,7 @@ public sealed class BSShapeCollection : IDisposable
928 925
929 // Create a hash of all the shape parameters to be used as a key 926 // Create a hash of all the shape parameters to be used as a key
930 // for this particular shape. 927 // for this particular shape.
931 private System.UInt64 ComputeShapeKey(OMV.Vector3 size, PrimitiveBaseShape pbs, out float retLod) 928 public static System.UInt64 ComputeShapeKey(OMV.Vector3 size, PrimitiveBaseShape pbs, out float retLod)
932 { 929 {
933 // level of detail based on size and type of the object 930 // level of detail based on size and type of the object
934 float lod = BSParam.MeshLOD; 931 float lod = BSParam.MeshLOD;
@@ -949,7 +946,7 @@ public sealed class BSShapeCollection : IDisposable
949 return pbs.GetMeshKey(size, lod); 946 return pbs.GetMeshKey(size, lod);
950 } 947 }
951 // For those who don't want the LOD 948 // For those who don't want the LOD
952 private System.UInt64 ComputeShapeKey(OMV.Vector3 size, PrimitiveBaseShape pbs) 949 public static System.UInt64 ComputeShapeKey(OMV.Vector3 size, PrimitiveBaseShape pbs)
953 { 950 {
954 float lod; 951 float lod;
955 return ComputeShapeKey(size, pbs, out lod); 952 return ComputeShapeKey(size, pbs, out lod);
@@ -962,7 +959,7 @@ public sealed class BSShapeCollection : IDisposable
962 // us to not loop forever. 959 // us to not loop forever.
963 // Called after creating a physical mesh or hull. If the physical shape was created, 960 // Called after creating a physical mesh or hull. If the physical shape was created,
964 // just return. 961 // just return.
965 private BulletShape VerifyMeshCreated(BulletShape newShape, BSPhysObject prim) 962 public static BulletShape VerifyMeshCreated(BSScene physicsScene, BulletShape newShape, BSPhysObject prim)
966 { 963 {
967 // If the shape was successfully created, nothing more to do 964 // If the shape was successfully created, nothing more to do
968 if (newShape.HasPhysicalShape) 965 if (newShape.HasPhysicalShape)
@@ -974,7 +971,7 @@ public sealed class BSShapeCollection : IDisposable
974 if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Fetched) 971 if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Fetched)
975 { 972 {
976 prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed; 973 prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed;
977 PhysicsScene.Logger.WarnFormat("{0} Fetched asset would not mesh. {1}, texture={2}", 974 physicsScene.Logger.WarnFormat("{0} Fetched asset would not mesh. {1}, texture={2}",
978 LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture); 975 LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture);
979 } 976 }
980 else 977 else
@@ -986,14 +983,14 @@ public sealed class BSShapeCollection : IDisposable
986 && prim.BaseShape.SculptTexture != OMV.UUID.Zero 983 && prim.BaseShape.SculptTexture != OMV.UUID.Zero
987 ) 984 )
988 { 985 {
989 DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset", prim.LocalID); 986 physicsScene.DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset", prim.LocalID);
990 // Multiple requestors will know we're waiting for this asset 987 // Multiple requestors will know we're waiting for this asset
991 prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Waiting; 988 prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Waiting;
992 989
993 BSPhysObject xprim = prim; 990 BSPhysObject xprim = prim;
994 Util.FireAndForget(delegate 991 Util.FireAndForget(delegate
995 { 992 {
996 RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod; 993 RequestAssetDelegate assetProvider = physicsScene.RequestAssetMethod;
997 if (assetProvider != null) 994 if (assetProvider != null)
998 { 995 {
999 BSPhysObject yprim = xprim; // probably not necessary, but, just in case. 996 BSPhysObject yprim = xprim; // probably not necessary, but, just in case.
@@ -1021,7 +1018,7 @@ public sealed class BSShapeCollection : IDisposable
1021 yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Fetched; 1018 yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Fetched;
1022 else 1019 else
1023 yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed; 1020 yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed;
1024 DetailLog("{0},BSShapeCollection,fetchAssetCallback,found={1},isSculpt={2},ids={3}", 1021 physicsScene.DetailLog("{0},BSShapeCollection,fetchAssetCallback,found={1},isSculpt={2},ids={3}",
1025 yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs ); 1022 yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs );
1026 1023
1027 }); 1024 });
@@ -1029,8 +1026,8 @@ public sealed class BSShapeCollection : IDisposable
1029 else 1026 else
1030 { 1027 {
1031 xprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed; 1028 xprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed;
1032 PhysicsScene.Logger.ErrorFormat("{0} Physical object requires asset but no asset provider. Name={1}", 1029 physicsScene.Logger.ErrorFormat("{0} Physical object requires asset but no asset provider. Name={1}",
1033 LogHeader, PhysicsScene.Name); 1030 LogHeader, physicsScene.Name);
1034 } 1031 }
1035 }); 1032 });
1036 } 1033 }
@@ -1038,15 +1035,15 @@ public sealed class BSShapeCollection : IDisposable
1038 { 1035 {
1039 if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Failed) 1036 if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Failed)
1040 { 1037 {
1041 PhysicsScene.Logger.WarnFormat("{0} Mesh failed to fetch asset. obj={1}, texture={2}", 1038 physicsScene.Logger.WarnFormat("{0} Mesh failed to fetch asset. obj={1}, texture={2}",
1042 LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture); 1039 LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture);
1043 } 1040 }
1044 } 1041 }
1045 } 1042 }
1046 1043
1047 // While we wait for the mesh defining asset to be loaded, stick in a simple box for the object. 1044 // While we wait for the mesh defining asset to be loaded, stick in a simple box for the object.
1048 BulletShape fillinShape = BuildPhysicalNativeShape(prim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); 1045 BulletShape fillinShape = physicsScene.Shapes.BuildPhysicalNativeShape(prim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX);
1049 DetailLog("{0},BSShapeCollection.VerifyMeshCreated,boxTempShape", prim.LocalID); 1046 physicsScene.DetailLog("{0},BSShapeCollection.VerifyMeshCreated,boxTempShape", prim.LocalID);
1050 1047
1051 return fillinShape; 1048 return fillinShape;
1052 } 1049 }