diff options
author | Robert Adams | 2012-09-28 12:34:50 -0700 |
---|---|---|
committer | Robert Adams | 2012-09-28 12:34:50 -0700 |
commit | 76e9cc41bd612035850e105a6fe34f483aab25e7 (patch) | |
tree | c1880302adc9cdea27a18203de3c8dec44606bd6 /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |
parent | BulletSim: add separate runtime and taint-time linkset children lists to keep... (diff) | |
download | opensim-SC_OLD-76e9cc41bd612035850e105a6fe34f483aab25e7.zip opensim-SC_OLD-76e9cc41bd612035850e105a6fe34f483aab25e7.tar.gz opensim-SC_OLD-76e9cc41bd612035850e105a6fe34f483aab25e7.tar.bz2 opensim-SC_OLD-76e9cc41bd612035850e105a6fe34f483aab25e7.tar.xz |
BulletSim: remember to release the physical body and shape when a prim is destroyed. This fixes many problems with physical linksets.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 87ffe3e..a0e627e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -154,8 +154,9 @@ public sealed class BSPrim : BSPhysObject | |||
154 | PhysicsScene.TaintedObject("BSPrim.destroy", delegate() | 154 | PhysicsScene.TaintedObject("BSPrim.destroy", delegate() |
155 | { | 155 | { |
156 | DetailLog("{0},BSPrim.Destroy,taint,", LocalID); | 156 | DetailLog("{0},BSPrim.Destroy,taint,", LocalID); |
157 | // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. | 157 | // If there are physical body and shape, release my use of same. |
158 | BulletSimAPI.DestroyObject(PhysicsScene.WorldID, LocalID); | 158 | PhysicsScene.Shapes.DereferenceBody(BSBody, true, null); |
159 | PhysicsScene.Shapes.DereferenceShape(BSShape, true, null); | ||
159 | }); | 160 | }); |
160 | } | 161 | } |
161 | 162 | ||
@@ -251,9 +252,6 @@ public sealed class BSPrim : BSPhysObject | |||
251 | _rotationalVelocity = OMV.Vector3.Zero; | 252 | _rotationalVelocity = OMV.Vector3.Zero; |
252 | 253 | ||
253 | // Zero some other properties directly into the physics engine | 254 | // Zero some other properties directly into the physics engine |
254 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, OMV.Vector3.Zero); | ||
255 | BulletSimAPI.SetAngularVelocity2(BSBody.ptr, OMV.Vector3.Zero); | ||
256 | BulletSimAPI.SetInterpolationVelocity2(BSBody.ptr, OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
257 | BulletSimAPI.ClearForces2(BSBody.ptr); | 255 | BulletSimAPI.ClearForces2(BSBody.ptr); |
258 | } | 256 | } |
259 | 257 | ||
@@ -1108,9 +1106,8 @@ public sealed class BSPrim : BSPhysObject | |||
1108 | ShapeData shapeData; | 1106 | ShapeData shapeData; |
1109 | FillShapeInfo(out shapeData); | 1107 | FillShapeInfo(out shapeData); |
1110 | 1108 | ||
1111 | // Undo me from any possible linkset so, if body is rebuilt, the link will get restored. | 1109 | // If this prim is part of a linkset, we must remove and restore the physical |
1112 | // NOTE that the new linkset is not set. This saves the handle to the linkset | 1110 | // links of the body is rebuilt. |
1113 | // so we can add ourselves back when shape mangling is complete. | ||
1114 | bool needToRestoreLinkset = false; | 1111 | bool needToRestoreLinkset = false; |
1115 | 1112 | ||
1116 | // Create the correct physical representation for this type of object. | 1113 | // Create the correct physical representation for this type of object. |
@@ -1119,12 +1116,15 @@ public sealed class BSPrim : BSPhysObject | |||
1119 | null, delegate(BulletBody dBody) | 1116 | null, delegate(BulletBody dBody) |
1120 | { | 1117 | { |
1121 | // Called if the current prim body is about to be destroyed. | 1118 | // Called if the current prim body is about to be destroyed. |
1122 | // The problem is the constraints for Linksets which need to be updated for the new body. | 1119 | // Remove all the physical dependencies on the old body. |
1123 | needToRestoreLinkset = Linkset.RemoveBodyDependencies(this); | 1120 | needToRestoreLinkset = Linkset.RemoveBodyDependencies(this); |
1124 | }); | 1121 | }); |
1125 | 1122 | ||
1126 | if (needToRestoreLinkset) | 1123 | if (needToRestoreLinkset) |
1124 | { | ||
1125 | // If physical body dependencies were removed, restore them | ||
1127 | Linkset.RestoreBodyDependencies(this); | 1126 | Linkset.RestoreBodyDependencies(this); |
1127 | } | ||
1128 | 1128 | ||
1129 | // Make sure the properties are set on the new object | 1129 | // Make sure the properties are set on the new object |
1130 | UpdatePhysicalParameters(); | 1130 | UpdatePhysicalParameters(); |