aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
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
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')
-rwxr-xr-xOpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs73
-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
5 files changed, 198 insertions, 14 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
index decb61a..278e9e7 100755
--- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
@@ -291,6 +291,10 @@ public class ExtendedPhysics : INonSharedRegionModule
291 return ret; 291 return ret;
292 } 292 }
293 293
294 // physChangeLinkFixed(integer linkNum)
295 // Change the link between the root and the linkNum into a fixed, static physical connection.
296 // This needs to change 'linkNum' into the physical object because lower level code has
297 // no access to the link numbers.
294 [ScriptInvocation] 298 [ScriptInvocation]
295 public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum) 299 public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum)
296 { 300 {
@@ -353,13 +357,76 @@ public class ExtendedPhysics : INonSharedRegionModule
353 [ScriptInvocation] 357 [ScriptInvocation]
354 public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum) 358 public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum)
355 { 359 {
356 return 0; 360 return -1;
357 } 361 }
358 362
359 [ScriptInvocation] 363 [ScriptInvocation]
360 public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum) 364 public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum,
365 Vector3 frameInAloc, Quaternion frameInArot,
366 Vector3 frameInBloc, Quaternion frameInBrot,
367 Vector3 linearLimitLow, Vector3 linearLimitHigh,
368 Vector3 angularLimitLow, Vector3 angularLimitHigh
369 )
361 { 370 {
362 return 0; 371 int ret = -1;
372 if (!Enabled) return ret;
373
374 // The part that is requesting the change.
375 SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID);
376
377 if (requestingPart != null)
378 {
379 // The type is is always on the root of a linkset.
380 SceneObjectGroup containingGroup = requestingPart.ParentGroup;
381 SceneObjectPart rootPart = containingGroup.RootPart;
382
383 if (rootPart != null)
384 {
385 Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor;
386 if (rootPhysActor != null)
387 {
388 SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
389 if (linkPart != null)
390 {
391 Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor;
392 if (linkPhysActor != null)
393 {
394 ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkSpring, linkNum, linkPhysActor,
395 frameInAloc, frameInArot,
396 frameInBloc, frameInBrot,
397 linearLimitLow, linearLimitHigh,
398 angularLimitLow, angularLimitHigh
399 );
400 }
401 else
402 {
403 m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
404 LogHeader, rootPart.Name, hostID, linkNum);
405 }
406 }
407 else
408 {
409 m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
410 LogHeader, rootPart.Name, hostID, linkNum);
411 }
412 }
413 else
414 {
415 m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}",
416 LogHeader, rootPart.Name, hostID);
417 }
418 }
419 else
420 {
421 m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}",
422 LogHeader, requestingPart.Name, hostID);
423 }
424 }
425 else
426 {
427 m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID);
428 }
429 return ret;
363 } 430 }
364 431
365 [ScriptInvocation] 432 [ScriptInvocation]
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: