diff options
author | Robert Adams | 2013-08-16 13:44:31 -0700 |
---|---|---|
committer | Robert Adams | 2013-09-11 09:11:58 -0700 |
commit | e1120cb74db9092cc0f9a7fc245d2f2ed6160b7a (patch) | |
tree | 033512ed6bb67408767671a7538000dafc205fb7 /OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | |
parent | BulletSim: update DLLs and SOs with Bullet svn version 2644 (no major fixes) ... (diff) | |
download | opensim-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/Physics/BulletSPlugin/BSLinksetConstraints.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | 145 |
1 files changed, 124 insertions, 21 deletions
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: |