diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 569d2e7..187951e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | |||
@@ -61,16 +61,7 @@ public abstract class BSLinkset | |||
61 | public int LinksetID { get; private set; } | 61 | public int LinksetID { get; private set; } |
62 | 62 | ||
63 | // The children under the root in this linkset. | 63 | // The children under the root in this linkset. |
64 | // There are two lists of children: the current children at runtime | ||
65 | // and the children at taint-time. For instance, if you delink a | ||
66 | // child from the linkset, the child is removed from m_children | ||
67 | // but the constraint won't be removed until taint time. | ||
68 | // Two lists lets this track the 'current' children and | ||
69 | // the physical 'taint' children separately. | ||
70 | // After taint processing and before the simulation step, these | ||
71 | // two lists must be the same. | ||
72 | protected HashSet<BSPhysObject> m_children; | 64 | protected HashSet<BSPhysObject> m_children; |
73 | protected HashSet<BSPhysObject> m_taintChildren; | ||
74 | 65 | ||
75 | // We lock the diddling of linkset classes to prevent any badness. | 66 | // We lock the diddling of linkset classes to prevent any badness. |
76 | // This locks the modification of the instances of this class. Changes | 67 | // This locks the modification of the instances of this class. Changes |
@@ -110,7 +101,6 @@ public abstract class BSLinkset | |||
110 | PhysicsScene = scene; | 101 | PhysicsScene = scene; |
111 | LinksetRoot = parent; | 102 | LinksetRoot = parent; |
112 | m_children = new HashSet<BSPhysObject>(); | 103 | m_children = new HashSet<BSPhysObject>(); |
113 | m_taintChildren = new HashSet<BSPhysObject>(); | ||
114 | m_mass = parent.MassRaw; | 104 | m_mass = parent.MassRaw; |
115 | } | 105 | } |
116 | 106 | ||
@@ -192,7 +182,7 @@ public abstract class BSLinkset | |||
192 | lock (m_linksetActivityLock) | 182 | lock (m_linksetActivityLock) |
193 | { | 183 | { |
194 | action(LinksetRoot); | 184 | action(LinksetRoot); |
195 | foreach (BSPhysObject po in m_taintChildren) | 185 | foreach (BSPhysObject po in m_children) |
196 | { | 186 | { |
197 | if (action(po)) | 187 | if (action(po)) |
198 | break; | 188 | break; |
@@ -201,9 +191,24 @@ public abstract class BSLinkset | |||
201 | return ret; | 191 | return ret; |
202 | } | 192 | } |
203 | 193 | ||
194 | // I am the root of a linkset and a new child is being added | ||
195 | // Called while LinkActivity is locked. | ||
196 | protected abstract void AddChildToLinkset(BSPhysObject child); | ||
197 | |||
198 | // Forcefully removing a child from a linkset. | ||
199 | // This is not being called by the child so we have to make sure the child doesn't think | ||
200 | // it's still connected to the linkset. | ||
201 | // Normal OpenSimulator operation will never do this because other SceneObjectPart information | ||
202 | // also has to be updated (like pointer to prim's parent). | ||
203 | protected abstract void RemoveChildFromOtherLinkset(BSPhysObject pchild); | ||
204 | |||
205 | // I am the root of a linkset and one of my children is being removed. | ||
206 | // Safe to call even if the child is not really in my linkset. | ||
207 | protected abstract void RemoveChildFromLinkset(BSPhysObject child); | ||
208 | |||
204 | // When physical properties are changed the linkset needs to recalculate | 209 | // When physical properties are changed the linkset needs to recalculate |
205 | // its internal properties. | 210 | // its internal properties. |
206 | // May be called at runtime or taint-time (just pass the appropriate flag). | 211 | // May be called at runtime or taint-time. |
207 | public abstract void Refresh(BSPhysObject requestor); | 212 | public abstract void Refresh(BSPhysObject requestor); |
208 | 213 | ||
209 | // The object is going dynamic (physical). Do any setup necessary | 214 | // The object is going dynamic (physical). Do any setup necessary |
@@ -238,8 +243,6 @@ public abstract class BSLinkset | |||
238 | public abstract void RestoreBodyDependencies(BSPrim child); | 243 | public abstract void RestoreBodyDependencies(BSPrim child); |
239 | 244 | ||
240 | // ================================================================ | 245 | // ================================================================ |
241 | // Below this point is internal magic | ||
242 | |||
243 | protected virtual float ComputeLinksetMass() | 246 | protected virtual float ComputeLinksetMass() |
244 | { | 247 | { |
245 | float mass = LinksetRoot.MassRaw; | 248 | float mass = LinksetRoot.MassRaw; |
@@ -264,7 +267,7 @@ public abstract class BSLinkset | |||
264 | com = LinksetRoot.Position * LinksetRoot.MassRaw; | 267 | com = LinksetRoot.Position * LinksetRoot.MassRaw; |
265 | float totalMass = LinksetRoot.MassRaw; | 268 | float totalMass = LinksetRoot.MassRaw; |
266 | 269 | ||
267 | foreach (BSPhysObject bp in m_taintChildren) | 270 | foreach (BSPhysObject bp in m_children) |
268 | { | 271 | { |
269 | com += bp.Position * bp.MassRaw; | 272 | com += bp.Position * bp.MassRaw; |
270 | totalMass += bp.MassRaw; | 273 | totalMass += bp.MassRaw; |
@@ -283,31 +286,16 @@ public abstract class BSLinkset | |||
283 | { | 286 | { |
284 | com = LinksetRoot.Position; | 287 | com = LinksetRoot.Position; |
285 | 288 | ||
286 | foreach (BSPhysObject bp in m_taintChildren) | 289 | foreach (BSPhysObject bp in m_children) |
287 | { | 290 | { |
288 | com += bp.Position * bp.MassRaw; | 291 | com += bp.Position * bp.MassRaw; |
289 | } | 292 | } |
290 | com /= (m_taintChildren.Count + 1); | 293 | com /= (m_children.Count + 1); |
291 | } | 294 | } |
292 | 295 | ||
293 | return com; | 296 | return com; |
294 | } | 297 | } |
295 | 298 | ||
296 | // I am the root of a linkset and a new child is being added | ||
297 | // Called while LinkActivity is locked. | ||
298 | protected abstract void AddChildToLinkset(BSPhysObject child); | ||
299 | |||
300 | // Forcefully removing a child from a linkset. | ||
301 | // This is not being called by the child so we have to make sure the child doesn't think | ||
302 | // it's still connected to the linkset. | ||
303 | // Normal OpenSimulator operation will never do this because other SceneObjectPart information | ||
304 | // also has to be updated (like pointer to prim's parent). | ||
305 | protected abstract void RemoveChildFromOtherLinkset(BSPhysObject pchild); | ||
306 | |||
307 | // I am the root of a linkset and one of my children is being removed. | ||
308 | // Safe to call even if the child is not really in my linkset. | ||
309 | protected abstract void RemoveChildFromLinkset(BSPhysObject child); | ||
310 | |||
311 | // Invoke the detailed logger and output something if it's enabled. | 299 | // Invoke the detailed logger and output something if it's enabled. |
312 | protected void DetailLog(string msg, params Object[] args) | 300 | protected void DetailLog(string msg, params Object[] args) |
313 | { | 301 | { |