aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs53
1 files changed, 36 insertions, 17 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 7f94666..3afd52e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -70,6 +70,17 @@ 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
82 public LinksetImplementation LinksetImpl { get; protected set; }
83
73 public BSPrimLinkable LinksetRoot { get; protected set; } 84 public BSPrimLinkable LinksetRoot { get; protected set; }
74 85
75 protected BSScene m_physicsScene { get; private set; } 86 protected BSScene m_physicsScene { get; private set; }
@@ -78,7 +89,8 @@ public abstract class BSLinkset
78 public int LinksetID { get; private set; } 89 public int LinksetID { get; private set; }
79 90
80 // The children under the root in this linkset. 91 // The children under the root in this linkset.
81 protected HashSet<BSPrimLinkable> m_children; 92 // protected HashSet<BSPrimLinkable> m_children;
93 protected Dictionary<BSPrimLinkable, BSLinkInfo> m_children;
82 94
83 // We lock the diddling of linkset classes to prevent any badness. 95 // We lock the diddling of linkset classes to prevent any badness.
84 // This locks the modification of the instances of this class. Changes 96 // This locks the modification of the instances of this class. Changes
@@ -109,7 +121,7 @@ public abstract class BSLinkset
109 m_nextLinksetID = 1; 121 m_nextLinksetID = 1;
110 m_physicsScene = scene; 122 m_physicsScene = scene;
111 LinksetRoot = parent; 123 LinksetRoot = parent;
112 m_children = new HashSet<BSPrimLinkable>(); 124 m_children = new Dictionary<BSPrimLinkable, BSLinkInfo>();
113 LinksetMass = parent.RawMass; 125 LinksetMass = parent.RawMass;
114 Rebuilding = false; 126 Rebuilding = false;
115 127
@@ -170,17 +182,7 @@ public abstract class BSLinkset
170 bool ret = false; 182 bool ret = false;
171 lock (m_linksetActivityLock) 183 lock (m_linksetActivityLock)
172 { 184 {
173 ret = m_children.Contains(child); 185 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 } 186 }
185 return ret; 187 return ret;
186 } 188 }
@@ -194,7 +196,24 @@ public abstract class BSLinkset
194 lock (m_linksetActivityLock) 196 lock (m_linksetActivityLock)
195 { 197 {
196 action(LinksetRoot); 198 action(LinksetRoot);
197 foreach (BSPrimLinkable po in m_children) 199 foreach (BSPrimLinkable po in m_children.Keys)
200 {
201 if (action(po))
202 break;
203 }
204 }
205 return ret;
206 }
207
208 // Perform an action on each member of the linkset including root prim.
209 // Depends on the action on whether this should be done at taint time.
210 public delegate bool ForEachLinkInfoAction(BSLinkInfo obj);
211 public virtual bool ForEachLinkInfo(ForEachLinkInfoAction action)
212 {
213 bool ret = false;
214 lock (m_linksetActivityLock)
215 {
216 foreach (BSLinkInfo po in m_children.Values)
198 { 217 {
199 if (action(po)) 218 if (action(po))
200 break; 219 break;
@@ -364,7 +383,7 @@ public abstract class BSLinkset
364 { 383 {
365 lock (m_linksetActivityLock) 384 lock (m_linksetActivityLock)
366 { 385 {
367 foreach (BSPrimLinkable bp in m_children) 386 foreach (BSPrimLinkable bp in m_children.Keys)
368 { 387 {
369 mass += bp.RawMass; 388 mass += bp.RawMass;
370 } 389 }
@@ -382,7 +401,7 @@ public abstract class BSLinkset
382 com = LinksetRoot.Position * LinksetRoot.RawMass; 401 com = LinksetRoot.Position * LinksetRoot.RawMass;
383 float totalMass = LinksetRoot.RawMass; 402 float totalMass = LinksetRoot.RawMass;
384 403
385 foreach (BSPrimLinkable bp in m_children) 404 foreach (BSPrimLinkable bp in m_children.Keys)
386 { 405 {
387 com += bp.Position * bp.RawMass; 406 com += bp.Position * bp.RawMass;
388 totalMass += bp.RawMass; 407 totalMass += bp.RawMass;
@@ -401,7 +420,7 @@ public abstract class BSLinkset
401 { 420 {
402 com = LinksetRoot.Position; 421 com = LinksetRoot.Position;
403 422
404 foreach (BSPrimLinkable bp in m_children) 423 foreach (BSPrimLinkable bp in m_children.Keys)
405 { 424 {
406 com += bp.Position; 425 com += bp.Position;
407 } 426 }