aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs51
1 files changed, 34 insertions, 17 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 7f94666..9613fe0 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -70,6 +70,15 @@ public abstract class BSLinkset
70 return ret; 70 return ret;
71 } 71 }
72 72
73 public class BSLinkInfo
74 {
75 public BSPrimLinkable member;
76 public BSLinkInfo(BSPrimLinkable pMember)
77 {
78 member = pMember;
79 }
80 }
81
73 public BSPrimLinkable LinksetRoot { get; protected set; } 82 public BSPrimLinkable LinksetRoot { get; protected set; }
74 83
75 protected BSScene m_physicsScene { get; private set; } 84 protected BSScene m_physicsScene { get; private set; }
@@ -78,7 +87,8 @@ public abstract class BSLinkset
78 public int LinksetID { get; private set; } 87 public int LinksetID { get; private set; }
79 88
80 // The children under the root in this linkset. 89 // The children under the root in this linkset.
81 protected HashSet<BSPrimLinkable> m_children; 90 // protected HashSet<BSPrimLinkable> m_children;
91 protected Dictionary<BSPrimLinkable, BSLinkInfo> m_children;
82 92
83 // We lock the diddling of linkset classes to prevent any badness. 93 // We lock the diddling of linkset classes to prevent any badness.
84 // This locks the modification of the instances of this class. Changes 94 // This locks the modification of the instances of this class. Changes
@@ -109,7 +119,7 @@ public abstract class BSLinkset
109 m_nextLinksetID = 1; 119 m_nextLinksetID = 1;
110 m_physicsScene = scene; 120 m_physicsScene = scene;
111 LinksetRoot = parent; 121 LinksetRoot = parent;
112 m_children = new HashSet<BSPrimLinkable>(); 122 m_children = new Dictionary<BSPrimLinkable, BSLinkInfo>();
113 LinksetMass = parent.RawMass; 123 LinksetMass = parent.RawMass;
114 Rebuilding = false; 124 Rebuilding = false;
115 125
@@ -170,17 +180,7 @@ public abstract class BSLinkset
170 bool ret = false; 180 bool ret = false;
171 lock (m_linksetActivityLock) 181 lock (m_linksetActivityLock)
172 { 182 {
173 ret = m_children.Contains(child); 183 ret = m_children.ContainsKey(child);
174 /* Safer version but the above should work
175 foreach (BSPrimLinkable bp in m_children)
176 {
177 if (child.LocalID == bp.LocalID)
178 {
179 ret = true;
180 break;
181 }
182 }
183 */
184 } 184 }
185 return ret; 185 return ret;
186 } 186 }
@@ -194,7 +194,24 @@ public abstract class BSLinkset
194 lock (m_linksetActivityLock) 194 lock (m_linksetActivityLock)
195 { 195 {
196 action(LinksetRoot); 196 action(LinksetRoot);
197 foreach (BSPrimLinkable po in m_children) 197 foreach (BSPrimLinkable po in m_children.Keys)
198 {
199 if (action(po))
200 break;
201 }
202 }
203 return ret;
204 }
205
206 // Perform an action on each member of the linkset including root prim.
207 // Depends on the action on whether this should be done at taint time.
208 public delegate bool ForEachLinkInfoAction(BSLinkInfo obj);
209 public virtual bool ForEachLinkInfo(ForEachLinkInfoAction action)
210 {
211 bool ret = false;
212 lock (m_linksetActivityLock)
213 {
214 foreach (BSLinkInfo po in m_children.Values)
198 { 215 {
199 if (action(po)) 216 if (action(po))
200 break; 217 break;
@@ -364,7 +381,7 @@ public abstract class BSLinkset
364 { 381 {
365 lock (m_linksetActivityLock) 382 lock (m_linksetActivityLock)
366 { 383 {
367 foreach (BSPrimLinkable bp in m_children) 384 foreach (BSPrimLinkable bp in m_children.Keys)
368 { 385 {
369 mass += bp.RawMass; 386 mass += bp.RawMass;
370 } 387 }
@@ -382,7 +399,7 @@ public abstract class BSLinkset
382 com = LinksetRoot.Position * LinksetRoot.RawMass; 399 com = LinksetRoot.Position * LinksetRoot.RawMass;
383 float totalMass = LinksetRoot.RawMass; 400 float totalMass = LinksetRoot.RawMass;
384 401
385 foreach (BSPrimLinkable bp in m_children) 402 foreach (BSPrimLinkable bp in m_children.Keys)
386 { 403 {
387 com += bp.Position * bp.RawMass; 404 com += bp.Position * bp.RawMass;
388 totalMass += bp.RawMass; 405 totalMass += bp.RawMass;
@@ -401,7 +418,7 @@ public abstract class BSLinkset
401 { 418 {
402 com = LinksetRoot.Position; 419 com = LinksetRoot.Position;
403 420
404 foreach (BSPrimLinkable bp in m_children) 421 foreach (BSPrimLinkable bp in m_children.Keys)
405 { 422 {
406 com += bp.Position; 423 com += bp.Position;
407 } 424 }