aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2012-12-20 10:32:33 -0800
committerRobert Adams2012-12-20 10:32:33 -0800
commita5b2539cf92aac65c11a36d4eb41d04f1c55b042 (patch)
tree884b426e3f25879077c8d2e6eaa6f5c9ae3f4b4d /OpenSim/Region
parentBulletSim: angularMotorUp working again (seems a little slow as it takes long... (diff)
downloadopensim-SC_OLD-a5b2539cf92aac65c11a36d4eb41d04f1c55b042.zip
opensim-SC_OLD-a5b2539cf92aac65c11a36d4eb41d04f1c55b042.tar.gz
opensim-SC_OLD-a5b2539cf92aac65c11a36d4eb41d04f1c55b042.tar.bz2
opensim-SC_OLD-a5b2539cf92aac65c11a36d4eb41d04f1c55b042.tar.xz
BulletSim: replace use of funky nullable values for vehicle property update control (m_known* stuff). Bitmaps will be quicker to test and to clear.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs69
1 files changed, 43 insertions, 26 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 77ec76d..c3d75ea 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -602,21 +602,22 @@ namespace OpenSim.Region.Physics.BulletSPlugin
602 602
603 #region Known vehicle value functions 603 #region Known vehicle value functions
604 // Vehicle physical parameters that we buffer from constant getting and setting. 604 // Vehicle physical parameters that we buffer from constant getting and setting.
605 // The "m_known*" variables are initialized to 'null', fetched only if referenced 605 // The "m_known*" values are unknown until they are fetched and the m_knownHas flag is set.
606 // and stored back into the physics engine only if updated. 606 // Changing is remembered and the parameter is stored back into the physics engine only if updated.
607 // This does two things: 1) saves continuious calls into unmanaged code, and 607 // This does two things: 1) saves continuious calls into unmanaged code, and
608 // 2) signals when a physics property update must happen back to the simulator 608 // 2) signals when a physics property update must happen back to the simulator
609 // to update values modified for the vehicle. 609 // to update values modified for the vehicle.
610 private int m_knownChanged; 610 private int m_knownChanged;
611 private float? m_knownTerrainHeight; 611 private int m_knownHas;
612 private float? m_knownWaterLevel; 612 private float m_knownTerrainHeight;
613 private Vector3? m_knownPosition; 613 private float m_knownWaterLevel;
614 private Vector3? m_knownVelocity; 614 private Vector3 m_knownPosition;
615 private Vector3 m_knownVelocity;
615 private Vector3 m_knownForce; 616 private Vector3 m_knownForce;
616 private Quaternion? m_knownOrientation; 617 private Quaternion m_knownOrientation;
617 private Vector3? m_knownRotationalVelocity; 618 private Vector3 m_knownRotationalVelocity;
618 private Vector3 m_knownRotationalForce; 619 private Vector3 m_knownRotationalForce;
619 private Vector3? m_knownForwardVelocity; // vehicle relative forward speed 620 private Vector3 m_knownForwardVelocity; // vehicle relative forward speed
620 621
621 private const int m_knownChangedPosition = 1 << 0; 622 private const int m_knownChangedPosition = 1 << 0;
622 private const int m_knownChangedVelocity = 1 << 1; 623 private const int m_knownChangedVelocity = 1 << 1;
@@ -624,18 +625,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
624 private const int m_knownChangedOrientation = 1 << 3; 625 private const int m_knownChangedOrientation = 1 << 3;
625 private const int m_knownChangedRotationalVelocity = 1 << 4; 626 private const int m_knownChangedRotationalVelocity = 1 << 4;
626 private const int m_knownChangedRotationalForce = 1 << 5; 627 private const int m_knownChangedRotationalForce = 1 << 5;
628 private const int m_knownChangedTerrainHeight = 1 << 6;
629 private const int m_knownChangedWaterLevel = 1 << 7;
630 private const int m_knownChangedForwardVelocity = 1 << 7;
627 631
628 private void ForgetKnownVehicleProperties() 632 private void ForgetKnownVehicleProperties()
629 { 633 {
630 m_knownTerrainHeight = null; 634 m_knownHas = 0;
631 m_knownWaterLevel = null;
632 m_knownPosition = null;
633 m_knownVelocity = null;
634 m_knownForce = Vector3.Zero;
635 m_knownOrientation = null;
636 m_knownRotationalVelocity = null;
637 m_knownRotationalForce = Vector3.Zero;
638 m_knownForwardVelocity = null;
639 m_knownChanged = 0; 635 m_knownChanged = 0;
640 } 636 }
641 private void PushKnownChanged() 637 private void PushKnownChanged()
@@ -674,17 +670,23 @@ namespace OpenSim.Region.Physics.BulletSPlugin
674 // is used ot fetch the height only once for each vehicle simulation step. 670 // is used ot fetch the height only once for each vehicle simulation step.
675 private float GetTerrainHeight(Vector3 pos) 671 private float GetTerrainHeight(Vector3 pos)
676 { 672 {
677 if (m_knownTerrainHeight == null) 673 if ((m_knownHas & m_knownChangedTerrainHeight) == 0)
674 {
678 m_knownTerrainHeight = Prim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos); 675 m_knownTerrainHeight = Prim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos);
679 return (float)m_knownTerrainHeight; 676 m_knownHas |= m_knownChangedTerrainHeight;
677 }
678 return m_knownTerrainHeight;
680 } 679 }
681 680
682 // Since the computation of water level can be a little involved, this routine 681 // Since the computation of water level can be a little involved, this routine
683 // is used ot fetch the level only once for each vehicle simulation step. 682 // is used ot fetch the level only once for each vehicle simulation step.
684 private float GetWaterLevel(Vector3 pos) 683 private float GetWaterLevel(Vector3 pos)
685 { 684 {
686 if (m_knownWaterLevel == null) 685 if ((m_knownHas & m_knownChangedWaterLevel) == 0)
686 {
687 m_knownWaterLevel = Prim.PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(pos); 687 m_knownWaterLevel = Prim.PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(pos);
688 m_knownHas |= m_knownChangedWaterLevel;
689 }
688 return (float)m_knownWaterLevel; 690 return (float)m_knownWaterLevel;
689 } 691 }
690 692
@@ -692,8 +694,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
692 { 694 {
693 get 695 get
694 { 696 {
695 if (m_knownPosition == null) 697 if ((m_knownHas & m_knownChangedPosition) == 0)
698 {
696 m_knownPosition = Prim.ForcePosition; 699 m_knownPosition = Prim.ForcePosition;
700 m_knownHas |= m_knownChangedPosition;
701 }
697 return (Vector3)m_knownPosition; 702 return (Vector3)m_knownPosition;
698 } 703 }
699 set 704 set
@@ -707,8 +712,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
707 { 712 {
708 get 713 get
709 { 714 {
710 if (m_knownOrientation == null) 715 if ((m_knownHas & m_knownChangedOrientation) == 0)
716 {
711 m_knownOrientation = Prim.ForceOrientation; 717 m_knownOrientation = Prim.ForceOrientation;
718 m_knownHas |= m_knownChangedOrientation;
719 }
712 return (Quaternion)m_knownOrientation; 720 return (Quaternion)m_knownOrientation;
713 } 721 }
714 set 722 set
@@ -722,8 +730,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
722 { 730 {
723 get 731 get
724 { 732 {
725 if (m_knownVelocity == null) 733 if ((m_knownHas & m_knownChangedVelocity) == 0)
734 {
726 m_knownVelocity = Prim.ForceVelocity; 735 m_knownVelocity = Prim.ForceVelocity;
736 m_knownHas |= m_knownChangedVelocity;
737 }
727 return (Vector3)m_knownVelocity; 738 return (Vector3)m_knownVelocity;
728 } 739 }
729 set 740 set
@@ -743,8 +754,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
743 { 754 {
744 get 755 get
745 { 756 {
746 if (m_knownRotationalVelocity == null) 757 if ((m_knownHas & m_knownChangedRotationalVelocity) == 0)
758 {
747 m_knownRotationalVelocity = Prim.ForceRotationalVelocity; 759 m_knownRotationalVelocity = Prim.ForceRotationalVelocity;
760 m_knownHas |= m_knownChangedRotationalVelocity;
761 }
748 return (Vector3)m_knownRotationalVelocity; 762 return (Vector3)m_knownRotationalVelocity;
749 } 763 }
750 set 764 set
@@ -763,8 +777,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
763 { 777 {
764 get 778 get
765 { 779 {
766 if (m_knownForwardVelocity == null) 780 if ((m_knownHas & m_knownChangedForwardVelocity) == 0)
781 {
767 m_knownForwardVelocity = VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation)); 782 m_knownForwardVelocity = VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation));
783 m_knownHas |= m_knownChangedForwardVelocity;
784 }
768 return (Vector3)m_knownForwardVelocity; 785 return (Vector3)m_knownForwardVelocity;
769 } 786 }
770 } 787 }