aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs52
1 files changed, 41 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index a9ae89d..be97c29 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -67,6 +67,7 @@ public sealed class BSLinksetConstraints : BSLinkset
67 { 67 {
68 constraint = null; 68 constraint = null;
69 ResetLink(); 69 ResetLink();
70 member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.creation", member.LocalID);
70 } 71 }
71 72
72 // Set all the parameters for this constraint to a fixed, non-movable constraint. 73 // Set all the parameters for this constraint to a fixed, non-movable constraint.
@@ -91,11 +92,13 @@ public sealed class BSLinksetConstraints : BSLinkset
91 frameInBrot = OMV.Quaternion.Identity; 92 frameInBrot = OMV.Quaternion.Identity;
92 springDamping = -1f; 93 springDamping = -1f;
93 springStiffness = -1f; 94 springStiffness = -1f;
95 member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID);
94 } 96 }
95 97
96 // Given a constraint, apply the current constraint parameters to same. 98 // Given a constraint, apply the current constraint parameters to same.
97 public override void SetLinkParameters(BSConstraint constrain) 99 public override void SetLinkParameters(BSConstraint constrain)
98 { 100 {
101 member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.SetLinkParameters,type={1}", member.LocalID, constraintType);
99 switch (constraintType) 102 switch (constraintType)
100 { 103 {
101 case ConstraintType.FIXED_CONSTRAINT_TYPE: 104 case ConstraintType.FIXED_CONSTRAINT_TYPE:
@@ -139,7 +142,7 @@ public sealed class BSLinksetConstraints : BSLinkset
139 if (springDamping != -1) 142 if (springDamping != -1)
140 constrainSpring.SetDamping(ii, springDamping); 143 constrainSpring.SetDamping(ii, springDamping);
141 if (springStiffness != -1) 144 if (springStiffness != -1)
142 constrainSpring.SetStiffness(ii, springStiffness); 145 constrainSpring.SetStiffness(ii, springStiffness);
143 } 146 }
144 } 147 }
145 break; 148 break;
@@ -155,7 +158,6 @@ public sealed class BSLinksetConstraints : BSLinkset
155 public override bool ShouldUpdateChildProperties() 158 public override bool ShouldUpdateChildProperties()
156 { 159 {
157 bool ret = true; 160 bool ret = true;
158
159 if (constraintType == ConstraintType.FIXED_CONSTRAINT_TYPE) 161 if (constraintType == ConstraintType.FIXED_CONSTRAINT_TYPE)
160 ret = false; 162 ret = false;
161 163
@@ -193,10 +195,16 @@ public sealed class BSLinksetConstraints : BSLinkset
193 { 195 {
194 // Queue to happen after all the other taint processing 196 // Queue to happen after all the other taint processing
195 m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() 197 m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate()
198 {
199 if (HasAnyChildren)
196 { 200 {
197 if (HasAnyChildren) 201 // Constraints that have not been changed are not rebuild but make sure
198 RecomputeLinksetConstraints(); 202 // the constraint of the requestor is rebuilt.
199 }); 203 PhysicallyUnlinkAChildFromRoot(LinksetRoot, requestor);
204 // Rebuild the linkset and all its constraints.
205 RecomputeLinksetConstraints();
206 }
207 });
200 } 208 }
201 } 209 }
202 210
@@ -415,13 +423,22 @@ public sealed class BSLinksetConstraints : BSLinkset
415 rootPrim.LocalID, rootPrim.PhysBody.AddrString, 423 rootPrim.LocalID, rootPrim.PhysBody.AddrString,
416 childPrim.LocalID, childPrim.PhysBody.AddrString); 424 childPrim.LocalID, childPrim.PhysBody.AddrString);
417 425
418 // Find the constraint for this link and get rid of it from the overall collection and from my list 426 // If asked to unlink root from root, just remove all the constraints
419 if (m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) 427 if (rootPrim == childPrim || childPrim == LinksetRoot)
420 { 428 {
421 // Make the child refresh its location 429 PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot);
422 m_physicsScene.PE.PushUpdate(childPrim.PhysBody);
423 ret = true; 430 ret = true;
424 } 431 }
432 else
433 {
434 // Find the constraint for this link and get rid of it from the overall collection and from my list
435 if (m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody))
436 {
437 // Make the child refresh its location
438 m_physicsScene.PE.PushUpdate(childPrim.PhysBody);
439 ret = true;
440 }
441 }
425 442
426 return ret; 443 return ret;
427 } 444 }
@@ -521,8 +538,6 @@ public sealed class BSLinksetConstraints : BSLinkset
521 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; 538 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint;
522 if (linkInfoC != null) 539 if (linkInfoC != null)
523 { 540 {
524 // Setting to fixed is easy. The reset state is the fixed link configuration.
525 linkInfoC.ResetLink();
526 linkInfoC.constraintType = (ConstraintType)requestedType; 541 linkInfoC.constraintType = (ConstraintType)requestedType;
527 ret = (object)true; 542 ret = (object)true;
528 DetailLog("{0},BSLinksetConstraint.ChangeLinkType,link={1},type={2}", 543 DetailLog("{0},BSLinksetConstraint.ChangeLinkType,link={1},type={2}",
@@ -589,6 +604,7 @@ public sealed class BSLinksetConstraints : BSLinkset
589 BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint; 604 BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint;
590 if (linkInfo != null) 605 if (linkInfo != null)
591 { 606 {
607 int valueInt;
592 float valueFloat; 608 float valueFloat;
593 bool valueBool; 609 bool valueBool;
594 OMV.Vector3 valueVector; 610 OMV.Vector3 valueVector;
@@ -602,6 +618,20 @@ public sealed class BSLinksetConstraints : BSLinkset
602 linkInfo.member.LocalID, thisOp, pParams[opIndex+1]); 618 linkInfo.member.LocalID, thisOp, pParams[opIndex+1]);
603 switch (thisOp) 619 switch (thisOp)
604 { 620 {
621 case ExtendedPhysics.PHYS_PARAM_LINK_TYPE:
622 valueInt = (int)pParams[opIndex + 1];
623 ConstraintType valueType = (ConstraintType)valueInt;
624 if (valueType == ConstraintType.FIXED_CONSTRAINT_TYPE
625 || valueType == ConstraintType.D6_CONSTRAINT_TYPE
626 || valueType == ConstraintType.D6_SPRING_CONSTRAINT_TYPE
627 || valueType == ConstraintType.HINGE_CONSTRAINT_TYPE
628 || valueType == ConstraintType.CONETWIST_CONSTRAINT_TYPE
629 || valueType == ConstraintType.SLIDER_CONSTRAINT_TYPE)
630 {
631 linkInfo.constraintType = valueType;
632 }
633 opIndex += 2;
634 break;
605 case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: 635 case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC:
606 valueVector = (OMV.Vector3)pParams[opIndex + 1]; 636 valueVector = (OMV.Vector3)pParams[opIndex + 1];
607 linkInfo.frameInAloc = valueVector; 637 linkInfo.frameInAloc = valueVector;