diff options
author | Robert Adams | 2012-09-27 22:00:02 -0700 |
---|---|---|
committer | Robert Adams | 2012-09-27 22:02:13 -0700 |
commit | 6f89975526359b81c43c23d9a549660d12212c59 (patch) | |
tree | 7cf390516d8cc0422499dd891f9ceb48d6eb624f /OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |
parent | BulletSim: rename some constraint variables to be consistant with other name ... (diff) | |
download | opensim-SC-6f89975526359b81c43c23d9a549660d12212c59.zip opensim-SC-6f89975526359b81c43c23d9a549660d12212c59.tar.gz opensim-SC-6f89975526359b81c43c23d9a549660d12212c59.tar.bz2 opensim-SC-6f89975526359b81c43c23d9a549660d12212c59.tar.xz |
BulletSim: add separate runtime and taint-time linkset children lists to keep the creation of constraints separate from runtime.
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 2618971..648910a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -144,34 +144,37 @@ public class BSShapeCollection : IDisposable | |||
144 | 144 | ||
145 | // Release the usage of a body. | 145 | // Release the usage of a body. |
146 | // Called when releasing use of a BSBody. BSShape is handled separately. | 146 | // Called when releasing use of a BSBody. BSShape is handled separately. |
147 | public void DereferenceBody(BulletBody shape, bool inTaintTime, BodyDestructionCallback bodyCallback ) | 147 | public void DereferenceBody(BulletBody body, bool inTaintTime, BodyDestructionCallback bodyCallback ) |
148 | { | 148 | { |
149 | if (shape.ptr == IntPtr.Zero) | 149 | if (body.ptr == IntPtr.Zero) |
150 | return; | 150 | return; |
151 | 151 | ||
152 | lock (m_collectionActivityLock) | 152 | lock (m_collectionActivityLock) |
153 | { | 153 | { |
154 | BodyDesc bodyDesc; | 154 | BodyDesc bodyDesc; |
155 | if (Bodies.TryGetValue(shape.ID, out bodyDesc)) | 155 | if (Bodies.TryGetValue(body.ID, out bodyDesc)) |
156 | { | 156 | { |
157 | bodyDesc.referenceCount--; | 157 | bodyDesc.referenceCount--; |
158 | bodyDesc.lastReferenced = System.DateTime.Now; | 158 | bodyDesc.lastReferenced = System.DateTime.Now; |
159 | Bodies[shape.ID] = bodyDesc; | 159 | Bodies[body.ID] = bodyDesc; |
160 | DetailLog("{0},BSShapeCollection.DereferenceBody,ref={1}", shape.ID, bodyDesc.referenceCount); | 160 | DetailLog("{0},BSShapeCollection.DereferenceBody,ref={1}", body.ID, bodyDesc.referenceCount); |
161 | 161 | ||
162 | // If body is no longer being used, free it -- bodies are never shared. | 162 | // If body is no longer being used, free it -- bodies are never shared. |
163 | if (bodyDesc.referenceCount == 0) | 163 | if (bodyDesc.referenceCount == 0) |
164 | { | 164 | { |
165 | Bodies.Remove(shape.ID); | 165 | Bodies.Remove(body.ID); |
166 | BSScene.TaintCallback removeOperation = delegate() | 166 | BSScene.TaintCallback removeOperation = delegate() |
167 | { | 167 | { |
168 | DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody. ptr={1}", | 168 | DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody. ptr={1}", |
169 | shape.ID, shape.ptr.ToString("X")); | 169 | body.ID, body.ptr.ToString("X")); |
170 | // If the caller needs to know, pass the event up. | ||
171 | if (bodyCallback != null) bodyCallback(body); | ||
172 | |||
170 | // Zero any reference to the shape so it is not freed when the body is deleted. | 173 | // Zero any reference to the shape so it is not freed when the body is deleted. |
171 | BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, shape.ptr, IntPtr.Zero); | 174 | BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, body.ptr, IntPtr.Zero); |
172 | // It may have already been removed from the world in which case the next is a NOOP. | 175 | // It may have already been removed from the world in which case the next is a NOOP. |
173 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, shape.ptr); | 176 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, body.ptr); |
174 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, shape.ptr); | 177 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, body.ptr); |
175 | }; | 178 | }; |
176 | // If already in taint-time, do the operations now. Otherwise queue for later. | 179 | // If already in taint-time, do the operations now. Otherwise queue for later. |
177 | if (inTaintTime) | 180 | if (inTaintTime) |
@@ -182,7 +185,7 @@ public class BSShapeCollection : IDisposable | |||
182 | } | 185 | } |
183 | else | 186 | else |
184 | { | 187 | { |
185 | DetailLog("{0},BSShapeCollection.DereferenceBody,DID NOT FIND BODY", shape.ID, bodyDesc.referenceCount); | 188 | DetailLog("{0},BSShapeCollection.DereferenceBody,DID NOT FIND BODY", body.ID, bodyDesc.referenceCount); |
186 | } | 189 | } |
187 | } | 190 | } |
188 | } | 191 | } |