aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2013-08-16 13:44:31 -0700
committerRobert Adams2013-09-11 09:11:58 -0700
commite1120cb74db9092cc0f9a7fc245d2f2ed6160b7a (patch)
tree033512ed6bb67408767671a7538000dafc205fb7 /OpenSim/Region
parentBulletSim: update DLLs and SOs with Bullet svn version 2644 (no major fixes) ... (diff)
downloadopensim-SC-e1120cb74db9092cc0f9a7fc245d2f2ed6160b7a.zip
opensim-SC-e1120cb74db9092cc0f9a7fc245d2f2ed6160b7a.tar.gz
opensim-SC-e1120cb74db9092cc0f9a7fc245d2f2ed6160b7a.tar.bz2
opensim-SC-e1120cb74db9092cc0f9a7fc245d2f2ed6160b7a.tar.xz
BulletSim: add extended physics function physGetLinkType(linkNum). Add implementation of physChangeLinkParams() in BSLinksetConstraint.
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-xOpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs19
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs11
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs145
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs11
4 files changed, 163 insertions, 23 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
index e0f16d6..d035f7b 100755
--- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
@@ -64,6 +64,7 @@ public class ExtendedPhysics : INonSharedRegionModule
64 public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; 64 public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType";
65 public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; 65 public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed";
66 public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType"; 66 public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType";
67 public const string PhysFunctGetLinkType = "BulletSim.GetLinkType";
67 public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams"; 68 public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams";
68 69
69 // ============================================================= 70 // =============================================================
@@ -320,6 +321,24 @@ public class ExtendedPhysics : INonSharedRegionModule
320 return ret; 321 return ret;
321 } 322 }
322 323
324 // physGetLinkType(integer linkNum)
325 [ScriptInvocation]
326 public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode)
327 {
328 int ret = -1;
329 if (!Enabled) return ret;
330
331 PhysicsActor rootPhysActor;
332 PhysicsActor childPhysActor;
333
334 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
335 {
336 ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, childPhysActor));
337 }
338
339 return ret;
340 }
341
323 // physChangeLinkFixed(integer linkNum) 342 // physChangeLinkFixed(integer linkNum)
324 // Change the link between the root and the linkNum into a fixed, static physical connection. 343 // Change the link between the root and the linkNum into a fixed, static physical connection.
325 [ScriptInvocation] 344 [ScriptInvocation]
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 2058e3a..77f69a5 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -209,6 +209,17 @@ public abstract class BSLinkset
209 return ret; 209 return ret;
210 } 210 }
211 211
212 public bool TryGetLinkInfo(BSPrimLinkable child, out BSLinkInfo foundInfo)
213 {
214 bool ret = false;
215 BSLinkInfo found = null;
216 lock (m_linksetActivityLock)
217 {
218 ret = m_children.TryGetValue(child, out found);
219 }
220 foundInfo = found;
221 return ret;
222 }
212 // Perform an action on each member of the linkset including root prim. 223 // Perform an action on each member of the linkset including root prim.
213 // Depends on the action on whether this should be done at taint time. 224 // Depends on the action on whether this should be done at taint time.
214 public delegate bool ForEachLinkInfoAction(BSLinkInfo obj); 225 public delegate bool ForEachLinkInfoAction(BSLinkInfo obj);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index b72afc0..92df84e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -168,6 +168,8 @@ public sealed class BSLinksetConstraints : BSLinkset
168 LinksetImpl = LinksetImplementation.Constraint; 168 LinksetImpl = LinksetImplementation.Constraint;
169 } 169 }
170 170
171 private static string LogHeader = "[BULLETSIM LINKSET CONSTRAINT]";
172
171 // When physical properties are changed the linkset needs to recalculate 173 // When physical properties are changed the linkset needs to recalculate
172 // its internal properties. 174 // its internal properties.
173 // This is queued in the 'post taint' queue so the 175 // This is queued in the 'post taint' queue so the
@@ -511,7 +513,7 @@ public sealed class BSLinksetConstraints : BSLinkset
511 RemoveDependencies(child); 513 RemoveDependencies(child);
512 514
513 BSLinkInfo linkInfo = null; 515 BSLinkInfo linkInfo = null;
514 if (m_children.TryGetValue(child, out linkInfo)) 516 if (TryGetLinkInfo(child, out linkInfo))
515 { 517 {
516 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint; 518 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint;
517 if (linkInfoC != null) 519 if (linkInfoC != null)
@@ -529,28 +531,129 @@ public sealed class BSLinksetConstraints : BSLinkset
529 } 531 }
530 } 532 }
531 break; 533 break;
534 case ExtendedPhysics.PhysFunctGetLinkType:
535 if (pParams.Length > 0)
536 {
537 BSPrimLinkable child = pParams[0] as BSPrimLinkable;
538 if (child != null)
539 {
540 BSLinkInfo linkInfo = null;
541 if (TryGetLinkInfo(child, out linkInfo))
542 {
543 BSLinkInfoConstraint linkInfoC = linkInfo as BSLinkInfoConstraint;
544 if (linkInfoC != null)
545 {
546 ret = (object)(int)linkInfoC.constraintType;
547 }
548 }
549 }
550 }
551 break;
532 case ExtendedPhysics.PhysFunctChangeLinkParams: 552 case ExtendedPhysics.PhysFunctChangeLinkParams:
533 int setParam = 2; 553 // There should be two parameters: the childActor and a list of parameters to set
534 switch (setParam) 554 try
555 {
556 if (pParams.Length > 1)
557 {
558 BSPrimLinkable child = pParams[0] as BSPrimLinkable;
559 object[] setOps = (object[])pParams[1];
560 BSLinkInfo baseLinkInfo = null;
561 if (TryGetLinkInfo(child, out baseLinkInfo))
562 {
563 BSLinkInfoConstraint linkInfo = baseLinkInfo as BSLinkInfoConstraint;
564 if (linkInfo != null)
565 {
566 float valueFloat;
567 bool valueBool;
568 OMV.Vector3 valueVector;
569 OMV.Quaternion valueQuaternion;
570
571 int opIndex = 0;
572 while (opIndex < setOps.Length)
573 {
574 int thisOp = (int)setOps[opIndex];
575 switch (thisOp)
576 {
577 case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC:
578 valueVector = (OMV.Vector3)setOps[opIndex + 1];
579 linkInfo.frameInAloc = valueVector;
580 break;
581 case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT:
582 valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1];
583 linkInfo.frameInArot = valueQuaternion;
584 break;
585 case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC:
586 valueVector = (OMV.Vector3)setOps[opIndex + 1];
587 linkInfo.frameInBloc = valueVector;
588 break;
589 case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT:
590 valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1];
591 linkInfo.frameInBrot = valueQuaternion;
592 break;
593 case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW:
594 valueVector = (OMV.Vector3)setOps[opIndex + 1];
595 linkInfo.linearLimitLow = valueVector;
596 break;
597 case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH:
598 valueVector = (OMV.Vector3)setOps[opIndex + 1];
599 linkInfo.linearLimitHigh = valueVector;
600 break;
601 case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW:
602 valueVector = (OMV.Vector3)setOps[opIndex + 1];
603 linkInfo.angularLimitLow = valueVector;
604 break;
605 case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH:
606 valueVector = (OMV.Vector3)setOps[opIndex + 1];
607 linkInfo.angularLimitHigh = valueVector;
608 break;
609 case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET:
610 valueBool = (bool)setOps[opIndex + 1];
611 linkInfo.useFrameOffset = valueBool;
612 break;
613 case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR:
614 valueBool = (bool)setOps[opIndex + 1];
615 linkInfo.enableTransMotor = valueBool;
616 break;
617 case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL:
618 valueFloat = (float)setOps[opIndex + 1];
619 linkInfo.transMotorMaxVel = valueFloat;
620 break;
621 case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE:
622 valueFloat = (float)setOps[opIndex + 1];
623 linkInfo.transMotorMaxForce = valueFloat;
624 break;
625 case ExtendedPhysics.PHYS_PARAM_CFM:
626 valueFloat = (float)setOps[opIndex + 1];
627 linkInfo.cfm = valueFloat;
628 break;
629 case ExtendedPhysics.PHYS_PARAM_ERP:
630 valueFloat = (float)setOps[opIndex + 1];
631 linkInfo.erp = valueFloat;
632 break;
633 case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS:
634 valueFloat = (float)setOps[opIndex + 1];
635 linkInfo.solverIterations = valueFloat;
636 break;
637 case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING:
638 valueFloat = (float)setOps[opIndex + 1];
639 linkInfo.springDamping = valueFloat;
640 break;
641 case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS:
642 valueFloat = (float)setOps[opIndex + 1];
643 linkInfo.springStiffness = valueFloat;
644 break;
645 default:
646 break;
647 }
648 }
649 }
650 }
651 }
652 }
653 catch (Exception e)
535 { 654 {
536 case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: 655 // There are many ways to mess up the parameters. If not just right don't fail without some error.
537 case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: 656 m_physicsScene.Logger.WarnFormat("{0} bad parameters in physSetLinksetParams: {1}", LogHeader, e);
538 case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC:
539 case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT:
540 case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW:
541 case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH:
542 case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW:
543 case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH:
544 case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET:
545 case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR:
546 case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL:
547 case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE:
548 case ExtendedPhysics.PHYS_PARAM_CFM:
549 case ExtendedPhysics.PHYS_PARAM_ERP:
550 case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS:
551 case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING:
552 case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS:
553 break;
554 } 657 }
555 break; 658 break;
556 default: 659 default:
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
index 6136257..28ea8c0 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
@@ -317,14 +317,21 @@ public class BSPrimLinkable : BSPrimDisplaced
317 // Params: PhysActor linkedPrim, int typeCode 317 // Params: PhysActor linkedPrim, int typeCode
318 case ExtendedPhysics.PhysFunctChangeLinkType: 318 case ExtendedPhysics.PhysFunctChangeLinkType:
319 { 319 {
320 Linkset.Extension(pFunct, pParams); 320 ret = Linkset.Extension(pFunct, pParams);
321 break;
322 }
323 // physGetLinkType(linknum);
324 // Params: PhysActor linkedPrim
325 case ExtendedPhysics.PhysFunctGetLinkType:
326 {
327 ret = Linkset.Extension(pFunct, pParams);
321 break; 328 break;
322 } 329 }
323 // physChangeLinkParams(linknum, [code, value, code, value, ...]); 330 // physChangeLinkParams(linknum, [code, value, code, value, ...]);
324 // Params: PhysActor linkedPrim, object[] params 331 // Params: PhysActor linkedPrim, object[] params
325 case ExtendedPhysics.PhysFunctChangeLinkParams: 332 case ExtendedPhysics.PhysFunctChangeLinkParams:
326 { 333 {
327 Linkset.Extension(pFunct, pParams); 334 ret = Linkset.Extension(pFunct, pParams);
328 break; 335 break;
329 } 336 }
330 default: 337 default: