aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorRobert Adams2013-08-08 08:36:36 -0700
committerJustin Clark-Casey (justincc)2013-09-20 21:02:20 +0100
commit826f8ce79127040b787c9a87696c92a9cb558cdb (patch)
treed5fddf8d1c0da1d7d237a49247797c528c1e6cff /OpenSim/Region/Physics
parentBulletSim: Linkset.Refresh() calls internal ScheduleRebuild() to recreate the... (diff)
downloadopensim-SC_OLD-826f8ce79127040b787c9a87696c92a9cb558cdb.zip
opensim-SC_OLD-826f8ce79127040b787c9a87696c92a9cb558cdb.tar.gz
opensim-SC_OLD-826f8ce79127040b787c9a87696c92a9cb558cdb.tar.bz2
opensim-SC_OLD-826f8ce79127040b787c9a87696c92a9cb558cdb.tar.xz
BulletSim: add physChangeLinkSpring to change linkset link to be a spring constraint. Add implementation to create spring constraint. Send up property updates for linkset children at the end of flexible linkset links. The simulator probably doesn't do the right thing yet.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs24
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs102
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs9
4 files changed, 128 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
index b241059..9d8838b 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
@@ -43,7 +43,9 @@ public enum ConstraintType : int
43 SLIDER_CONSTRAINT_TYPE, 43 SLIDER_CONSTRAINT_TYPE,
44 CONTACT_CONSTRAINT_TYPE, 44 CONTACT_CONSTRAINT_TYPE,
45 D6_SPRING_CONSTRAINT_TYPE, 45 D6_SPRING_CONSTRAINT_TYPE,
46 MAX_CONSTRAINT_TYPE 46 MAX_CONSTRAINT_TYPE, // last type defined by Bullet
47 //
48 FIXED_CONSTRAINT_TYPE = 1234 // BulletSim constraint that is fixed and unmoving
47} 49}
48 50
49// =============================================================================== 51// ===============================================================================
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index d4b1c1e..2058e3a 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -79,6 +79,8 @@ public abstract class BSLinkset
79 } 79 }
80 public virtual void ResetLink() { } 80 public virtual void ResetLink() { }
81 public virtual void SetLinkParameters(BSConstraint constrain) { } 81 public virtual void SetLinkParameters(BSConstraint constrain) { }
82 // Returns 'true' if physical property updates from the child should be reported to the simulator
83 public virtual bool ShouldUpdateChildProperties() { return false; }
82 } 84 }
83 85
84 public LinksetImplementation LinksetImpl { get; protected set; } 86 public LinksetImplementation LinksetImpl { get; protected set; }
@@ -224,6 +226,21 @@ public abstract class BSLinkset
224 return ret; 226 return ret;
225 } 227 }
226 228
229 // Check the type of the link and return 'true' if the link is flexible and the
230 // updates from the child should be sent to the simulator so things change.
231 public virtual bool ShouldReportPropertyUpdates(BSPrimLinkable child)
232 {
233 bool ret = false;
234
235 BSLinkInfo linkInfo;
236 if (m_children.TryGetValue(child, out linkInfo))
237 {
238 ret = linkInfo.ShouldUpdateChildProperties();
239 }
240
241 return ret;
242 }
243
227 // Called after a simulation step to post a collision with this object. 244 // Called after a simulation step to post a collision with this object.
228 // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have 245 // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have
229 // anything to add for the collision and it should be passed through normal processing. 246 // anything to add for the collision and it should be passed through normal processing.
@@ -432,6 +449,13 @@ public abstract class BSLinkset
432 return com; 449 return com;
433 } 450 }
434 451
452 #region Extension
453 public virtual object Extension(string pFunct, params object[] pParams)
454 {
455 return null;
456 }
457 #endregion // Extension
458
435 // Invoke the detailed logger and output something if it's enabled. 459 // Invoke the detailed logger and output something if it's enabled.
436 protected void DetailLog(string msg, params Object[] args) 460 protected void DetailLog(string msg, params Object[] args)
437 { 461 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index db323c2..17fec9d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -60,8 +60,6 @@ public sealed class BSLinksetConstraints : BSLinkset
60 public float springDamping; 60 public float springDamping;
61 public float springStiffness; 61 public float springStiffness;
62 62
63
64
65 public BSLinkInfoConstraint(BSPrimLinkable pMember) 63 public BSLinkInfoConstraint(BSPrimLinkable pMember)
66 : base(pMember) 64 : base(pMember)
67 { 65 {
@@ -72,7 +70,8 @@ public sealed class BSLinksetConstraints : BSLinkset
72 // Set all the parameters for this constraint to a fixed, non-movable constraint. 70 // Set all the parameters for this constraint to a fixed, non-movable constraint.
73 public override void ResetLink() 71 public override void ResetLink()
74 { 72 {
75 constraintType = ConstraintType.D6_CONSTRAINT_TYPE; 73 // constraintType = ConstraintType.D6_CONSTRAINT_TYPE;
74 constraintType = ConstraintType.FIXED_CONSTRAINT_TYPE;
76 linearLimitLow = OMV.Vector3.Zero; 75 linearLimitLow = OMV.Vector3.Zero;
77 linearLimitHigh = OMV.Vector3.Zero; 76 linearLimitHigh = OMV.Vector3.Zero;
78 angularLimitLow = OMV.Vector3.Zero; 77 angularLimitLow = OMV.Vector3.Zero;
@@ -97,6 +96,7 @@ public sealed class BSLinksetConstraints : BSLinkset
97 { 96 {
98 switch (constraintType) 97 switch (constraintType)
99 { 98 {
99 case ConstraintType.FIXED_CONSTRAINT_TYPE:
100 case ConstraintType.D6_CONSTRAINT_TYPE: 100 case ConstraintType.D6_CONSTRAINT_TYPE:
101 BSConstraint6Dof constrain6dof = constrain as BSConstraint6Dof; 101 BSConstraint6Dof constrain6dof = constrain as BSConstraint6Dof;
102 if (constrain6dof != null) 102 if (constrain6dof != null)
@@ -145,6 +145,20 @@ public sealed class BSLinksetConstraints : BSLinkset
145 break; 145 break;
146 } 146 }
147 } 147 }
148
149 // Return 'true' if the property updates from the physics engine should be reported
150 // to the simulator.
151 // If the constraint is fixed, we don't need to report as the simulator and viewer will
152 // report the right things.
153 public override bool ShouldUpdateChildProperties()
154 {
155 bool ret = true;
156
157 if (constraintType == ConstraintType.FIXED_CONSTRAINT_TYPE)
158 ret = false;
159
160 return ret;
161 }
148 } 162 }
149 163
150 public BSLinksetConstraints(BSScene scene, BSPrimLinkable parent) : base(scene, parent) 164 public BSLinksetConstraints(BSScene scene, BSPrimLinkable parent) : base(scene, parent)
@@ -316,6 +330,7 @@ public sealed class BSLinksetConstraints : BSLinkset
316 330
317 switch (linkInfo.constraintType) 331 switch (linkInfo.constraintType)
318 { 332 {
333 case ConstraintType.FIXED_CONSTRAINT_TYPE:
319 case ConstraintType.D6_CONSTRAINT_TYPE: 334 case ConstraintType.D6_CONSTRAINT_TYPE:
320 // Relative position normalized to the root prim 335 // Relative position normalized to the root prim
321 // Essentually a vector pointing from center of rootPrim to center of li.member 336 // Essentually a vector pointing from center of rootPrim to center of li.member
@@ -466,5 +481,86 @@ public sealed class BSLinksetConstraints : BSLinkset
466 Rebuilding = false; 481 Rebuilding = false;
467 } 482 }
468 } 483 }
484
485 #region Extension
486 public override object Extension(string pFunct, params object[] pParams)
487 {
488 object ret = null;
489 switch (pFunct)
490 {
491 // pParams = (int linkNUm, PhysActor linkChild)
492 case BSScene.PhysFunctChangeLinkFixed:
493 if (pParams.Length > 1)
494 {
495 BSPrimLinkable child = pParams[1] as BSPrimLinkable;
496 if (child != null)
497 {
498 m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate()
499 {
500 // Pick up all the constraints currently created.
501 RemoveDependencies(child);
502
503 BSLinkInfo linkInfo = null;
504 if (m_children.TryGetValue(child, out linkInfo))
505 {
506 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint;
507 if (linkInfoC != null)
508 {
509 // Setting to fixed is easy. The reset state is the fixed link configuration.
510 linkInfoC.ResetLink();
511 ret = (object)true;
512 }
513 }
514 // Cause the whole linkset to be rebuilt in post-taint time.
515 Refresh(child);
516 });
517 }
518 }
519 break;
520 case BSScene.PhysFunctChangeLinkSpring:
521 if (pParams.Length > 11)
522 {
523 BSPrimLinkable child = pParams[1] as BSPrimLinkable;
524 if (child != null)
525 {
526 m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate()
527 {
528 // Pick up all the constraints currently created.
529 RemoveDependencies(child);
530
531 BSLinkInfo linkInfo = null;
532 if (m_children.TryGetValue(child, out linkInfo))
533 {
534 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint;
535 if (linkInfoC != null)
536 {
537 // Start with a reset link definition
538 linkInfoC.ResetLink();
539 linkInfoC.constraintType = ConstraintType.D6_SPRING_CONSTRAINT_TYPE;
540 linkInfoC.frameInAloc = (OMV.Vector3)pParams[2];
541 linkInfoC.frameInArot = (OMV.Quaternion)pParams[3];
542 linkInfoC.frameInBloc = (OMV.Vector3)pParams[4];
543 linkInfoC.frameInBrot = (OMV.Quaternion)pParams[5];
544 linkInfoC.linearLimitLow = (OMV.Vector3)pParams[6];
545 linkInfoC.linearLimitHigh = (OMV.Vector3)pParams[7];
546 linkInfoC.angularLimitLow = (OMV.Vector3)pParams[8];
547 linkInfoC.angularLimitHigh = (OMV.Vector3)pParams[9];
548 ret = (object)true;
549 }
550 }
551 // Cause the whole linkset to be rebuilt in post-taint time.
552 Refresh(child);
553 });
554 }
555 }
556 break;
557 default:
558 ret = base.Extension(pFunct, pParams);
559 break;
560 }
561 return ret;
562 }
563 #endregion // Extension
564
469} 565}
470} 566}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
index 77d8246..4c384a6 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
@@ -179,7 +179,7 @@ public class BSPrimLinkable : BSPrimDisplaced
179 // Do any filtering/modification needed for linksets. 179 // Do any filtering/modification needed for linksets.
180 public override void UpdateProperties(EntityProperties entprop) 180 public override void UpdateProperties(EntityProperties entprop)
181 { 181 {
182 if (Linkset.IsRoot(this)) 182 if (Linkset.IsRoot(this) || Linkset.ShouldReportPropertyUpdates(this))
183 { 183 {
184 // Properties are only updated for the roots of a linkset. 184 // Properties are only updated for the roots of a linkset.
185 // TODO: this will have to change when linksets are articulated. 185 // TODO: this will have to change when linksets are articulated.
@@ -316,12 +316,7 @@ public class BSPrimLinkable : BSPrimDisplaced
316 // Params: int linkNum, PhysActor linkedPrim 316 // Params: int linkNum, PhysActor linkedPrim
317 case BSScene.PhysFunctChangeLinkFixed: 317 case BSScene.PhysFunctChangeLinkFixed:
318 { 318 {
319 if (pParams.Length > 1) 319 Linkset.Extension(pFunct, pParams);
320 {
321 int linkNum = (int)pParams[0];
322 Manager.PhysicsActor linkActor = (Manager.PhysicsActor)pParams[1];
323 Linkset.Refresh(this);
324 }
325 break; 320 break;
326 } 321 }
327 default: 322 default: