aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs42
1 files changed, 20 insertions, 22 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 7e784eb..005a758 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -36,11 +36,9 @@ public class BSLinkset
36{ 36{
37 private static string LogHeader = "[BULLETSIM LINKSET]"; 37 private static string LogHeader = "[BULLETSIM LINKSET]";
38 38
39 private BSPhysObject m_linksetRoot; 39 public BSPhysObject LinksetRoot { get; protected set; }
40 public BSPhysObject LinksetRoot { get { return m_linksetRoot; } }
41 40
42 private BSScene m_physicsScene; 41 public BSScene PhysicsScene { get; private set; }
43 public BSScene PhysicsScene { get { return m_physicsScene; } }
44 42
45 static int m_nextLinksetID = 1; 43 static int m_nextLinksetID = 1;
46 public int LinksetID { get; private set; } 44 public int LinksetID { get; private set; }
@@ -81,8 +79,8 @@ public class BSLinkset
81 // We create LOTS of linksets. 79 // We create LOTS of linksets.
82 if (m_nextLinksetID < 0) 80 if (m_nextLinksetID < 0)
83 m_nextLinksetID = 1; 81 m_nextLinksetID = 1;
84 m_physicsScene = scene; 82 PhysicsScene = scene;
85 m_linksetRoot = parent; 83 LinksetRoot = parent;
86 m_children = new List<BSPhysObject>(); 84 m_children = new List<BSPhysObject>();
87 m_mass = parent.MassRaw; 85 m_mass = parent.MassRaw;
88 } 86 }
@@ -131,7 +129,7 @@ public class BSLinkset
131 // Return 'true' if the passed object is the root object of this linkset 129 // Return 'true' if the passed object is the root object of this linkset
132 public bool IsRoot(BSPhysObject requestor) 130 public bool IsRoot(BSPhysObject requestor)
133 { 131 {
134 return (requestor.LocalID == m_linksetRoot.LocalID); 132 return (requestor.LocalID == LinksetRoot.LocalID);
135 } 133 }
136 134
137 public int NumberOfChildren { get { return m_children.Count; } } 135 public int NumberOfChildren { get { return m_children.Count; } }
@@ -159,7 +157,7 @@ public class BSLinkset
159 157
160 private float ComputeLinksetMass() 158 private float ComputeLinksetMass()
161 { 159 {
162 float mass = m_linksetRoot.MassRaw; 160 float mass = LinksetRoot.MassRaw;
163 foreach (BSPhysObject bp in m_children) 161 foreach (BSPhysObject bp in m_children)
164 { 162 {
165 mass += bp.MassRaw; 163 mass += bp.MassRaw;
@@ -169,8 +167,8 @@ public class BSLinkset
169 167
170 private OMV.Vector3 ComputeLinksetCenterOfMass() 168 private OMV.Vector3 ComputeLinksetCenterOfMass()
171 { 169 {
172 OMV.Vector3 com = m_linksetRoot.Position * m_linksetRoot.MassRaw; 170 OMV.Vector3 com = LinksetRoot.Position * LinksetRoot.MassRaw;
173 float totalMass = m_linksetRoot.MassRaw; 171 float totalMass = LinksetRoot.MassRaw;
174 172
175 lock (m_linksetActivityLock) 173 lock (m_linksetActivityLock)
176 { 174 {
@@ -188,7 +186,7 @@ public class BSLinkset
188 186
189 private OMV.Vector3 ComputeLinksetGeometricCenter() 187 private OMV.Vector3 ComputeLinksetGeometricCenter()
190 { 188 {
191 OMV.Vector3 com = m_linksetRoot.Position; 189 OMV.Vector3 com = LinksetRoot.Position;
192 190
193 lock (m_linksetActivityLock) 191 lock (m_linksetActivityLock)
194 { 192 {
@@ -256,7 +254,7 @@ public class BSLinkset
256 foreach (BSPhysObject child in m_children) 254 foreach (BSPhysObject child in m_children)
257 { 255 {
258 BSConstraint constrain; 256 BSConstraint constrain;
259 if (m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.BSBody, child.BSBody, out constrain)) 257 if (PhysicsScene.Constraints.TryGetConstraint(LinksetRoot.BSBody, child.BSBody, out constrain))
260 { 258 {
261 // DetailLog("{0},BSLinkset.RecomputeLinksetConstraintVariables,taint,child={1},mass={2},A={3},B={4}", 259 // DetailLog("{0},BSLinkset.RecomputeLinksetConstraintVariables,taint,child={1},mass={2},A={3},B={4}",
262 // LinksetRoot.LocalID, child.LocalID, linksetMass, constrain.Body1.ID, constrain.Body2.ID); 260 // LinksetRoot.LocalID, child.LocalID, linksetMass, constrain.Body1.ID, constrain.Body2.ID);
@@ -306,9 +304,9 @@ public class BSLinkset
306 304
307 BSPhysObject rootx = LinksetRoot; // capture the root as of now 305 BSPhysObject rootx = LinksetRoot; // capture the root as of now
308 BSPhysObject childx = child; 306 BSPhysObject childx = child;
309 m_physicsScene.TaintedObject("AddChildToLinkset", delegate() 307 PhysicsScene.TaintedObject("AddChildToLinkset", delegate()
310 { 308 {
311 DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID); 309 DetailLog("{0},AddChildToLinkset,taint,child={1}", LinksetRoot.LocalID, child.LocalID);
312 PhysicallyLinkAChildToRoot(rootx, childx); // build the physical binding between me and the child 310 PhysicallyLinkAChildToRoot(rootx, childx); // build the physical binding between me and the child
313 }); 311 });
314 } 312 }
@@ -322,7 +320,7 @@ public class BSLinkset
322 // has to be updated also (like pointer to prim's parent). 320 // has to be updated also (like pointer to prim's parent).
323 private void RemoveChildFromOtherLinkset(BSPhysObject pchild) 321 private void RemoveChildFromOtherLinkset(BSPhysObject pchild)
324 { 322 {
325 pchild.Linkset = new BSLinkset(m_physicsScene, pchild); 323 pchild.Linkset = new BSLinkset(PhysicsScene, pchild);
326 RemoveChildFromLinkset(pchild); 324 RemoveChildFromLinkset(pchild);
327 } 325 }
328 326
@@ -334,9 +332,9 @@ public class BSLinkset
334 { 332 {
335 BSPhysObject rootx = LinksetRoot; // capture the root as of now 333 BSPhysObject rootx = LinksetRoot; // capture the root as of now
336 BSPhysObject childx = child; 334 BSPhysObject childx = child;
337 m_physicsScene.TaintedObject("RemoveChildFromLinkset", delegate() 335 PhysicsScene.TaintedObject("RemoveChildFromLinkset", delegate()
338 { 336 {
339 DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID); 337 DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", LinksetRoot.LocalID, child.LocalID);
340 338
341 PhysicallyUnlinkAChildFromRoot(rootx, childx); 339 PhysicallyUnlinkAChildFromRoot(rootx, childx);
342 RecomputeLinksetConstraintVariables(); 340 RecomputeLinksetConstraintVariables();
@@ -370,7 +368,7 @@ public class BSLinkset
370 DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2},rLoc={3},cLoc={4},midLoc={5}", 368 DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2},rLoc={3},cLoc={4},midLoc={5}",
371 rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID, rootPrim.Position, childPrim.Position, midPoint); 369 rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID, rootPrim.Position, childPrim.Position, midPoint);
372 BS6DofConstraint constrain = new BS6DofConstraint( 370 BS6DofConstraint constrain = new BS6DofConstraint(
373 m_physicsScene.World, rootPrim.BSBody, childPrim.BSBody, 371 PhysicsScene.World, rootPrim.BSBody, childPrim.BSBody,
374 midPoint, 372 midPoint,
375 true, 373 true,
376 true 374 true
@@ -408,7 +406,7 @@ public class BSLinkset
408 // ================================================================================== 406 // ==================================================================================
409 */ 407 */
410 408
411 m_physicsScene.Constraints.AddConstraint(constrain); 409 PhysicsScene.Constraints.AddConstraint(constrain);
412 410
413 // zero linear and angular limits makes the objects unable to move in relation to each other 411 // zero linear and angular limits makes the objects unable to move in relation to each other
414 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 412 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
@@ -435,7 +433,7 @@ public class BSLinkset
435 DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); 433 DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID);
436 434
437 // Find the constraint for this link and get rid of it from the overall collection and from my list 435 // Find the constraint for this link and get rid of it from the overall collection and from my list
438 m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.BSBody, childPrim.BSBody); 436 PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.BSBody, childPrim.BSBody);
439 437
440 // Make the child refresh its location 438 // Make the child refresh its location
441 BulletSimAPI.PushUpdate2(childPrim.BSBody.Ptr); 439 BulletSimAPI.PushUpdate2(childPrim.BSBody.Ptr);
@@ -447,13 +445,13 @@ public class BSLinkset
447 { 445 {
448 DetailLog("{0},PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID); 446 DetailLog("{0},PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID);
449 447
450 m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.BSBody); 448 PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.BSBody);
451 } 449 }
452 450
453 // Invoke the detailed logger and output something if it's enabled. 451 // Invoke the detailed logger and output something if it's enabled.
454 private void DetailLog(string msg, params Object[] args) 452 private void DetailLog(string msg, params Object[] args)
455 { 453 {
456 m_physicsScene.PhysicsLogging.Write(msg, args); 454 PhysicsScene.PhysicsLogging.Write(msg, args);
457 } 455 }
458 456
459} 457}