aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs130
1 files changed, 88 insertions, 42 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index eb20eb3..bef7aec 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -131,8 +131,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
131 m_type = Vehicle.TYPE_NONE; 131 m_type = Vehicle.TYPE_NONE;
132 } 132 }
133 133
134 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) 134 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue, float timestep)
135 { 135 {
136 DetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
136 switch (pParam) 137 switch (pParam)
137 { 138 {
138 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: 139 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY:
@@ -229,8 +230,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
229 } 230 }
230 }//end ProcessFloatVehicleParam 231 }//end ProcessFloatVehicleParam
231 232
232 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue) 233 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue, float timestep)
233 { 234 {
235 DetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
234 switch (pParam) 236 switch (pParam)
235 { 237 {
236 case Vehicle.ANGULAR_FRICTION_TIMESCALE: 238 case Vehicle.ANGULAR_FRICTION_TIMESCALE:
@@ -265,6 +267,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
265 267
266 internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) 268 internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue)
267 { 269 {
270 DetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
268 switch (pParam) 271 switch (pParam)
269 { 272 {
270 case Vehicle.REFERENCE_FRAME: 273 case Vehicle.REFERENCE_FRAME:
@@ -278,6 +281,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
278 281
279 internal void ProcessVehicleFlags(int pParam, bool remove) 282 internal void ProcessVehicleFlags(int pParam, bool remove)
280 { 283 {
284 DetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove);
281 if (remove) 285 if (remove)
282 { 286 {
283 if (pParam == -1) 287 if (pParam == -1)
@@ -434,6 +438,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
434 438
435 internal void ProcessTypeChange(Vehicle pType) 439 internal void ProcessTypeChange(Vehicle pType)
436 { 440 {
441 DetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType);
437 // Set Defaults For Type 442 // Set Defaults For Type
438 m_type = pType; 443 m_type = pType;
439 switch (pType) 444 switch (pType)
@@ -594,7 +599,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
594 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); 599 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
595 m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT); 600 m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT);
596 break; 601 break;
597
598 } 602 }
599 }//end SetDefaultsForType 603 }//end SetDefaultsForType
600 604
@@ -609,12 +613,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin
609 MoveLinear(pTimestep, pParentScene); 613 MoveLinear(pTimestep, pParentScene);
610 MoveAngular(pTimestep); 614 MoveAngular(pTimestep);
611 LimitRotation(pTimestep); 615 LimitRotation(pTimestep);
616 DetailLog("{0},step,pos={1},force={2},velocity={3},angvel={4}",
617 m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity);
612 }// end Step 618 }// end Step
613 619
614 private void MoveLinear(float pTimestep, BSScene _pParentScene) 620 private void MoveLinear(float pTimestep, BSScene _pParentScene)
615 { 621 {
616 if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) // requested m_linearMotorDirection is significant 622 if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) // requested m_linearMotorDirection is significant
617 { 623 {
624 Vector3 origDir = m_linearMotorDirection;
625 Vector3 origVel = m_lastLinearVelocityVector;
626
618 // add drive to body 627 // add drive to body
619 Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep); 628 Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep);
620 m_lastLinearVelocityVector += (addAmount*10); // lastLinearVelocityVector is the current body velocity vector? 629 m_lastLinearVelocityVector += (addAmount*10); // lastLinearVelocityVector is the current body velocity vector?
@@ -630,9 +639,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
630 639
631 // decay applied velocity 640 // decay applied velocity
632 Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep))); 641 Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep)));
633 //Console.WriteLine("decay: " + decayfraction);
634 m_linearMotorDirection -= m_linearMotorDirection * decayfraction * 0.5f; 642 m_linearMotorDirection -= m_linearMotorDirection * decayfraction * 0.5f;
635 //Console.WriteLine("actual: " + m_linearMotorDirection); 643
644 DetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}",
645 m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector);
636 } 646 }
637 else 647 else
638 { // requested is not significant 648 { // requested is not significant
@@ -643,63 +653,66 @@ namespace OpenSim.Region.Physics.BulletSPlugin
643 653
644 // convert requested object velocity to world-referenced vector 654 // convert requested object velocity to world-referenced vector
645 m_dir = m_lastLinearVelocityVector; 655 m_dir = m_lastLinearVelocityVector;
646 Quaternion rot = m_prim.Orientation; 656 m_dir *= m_prim.Orientation;
647 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object 657
648 m_dir *= rotq; // apply obj rotation to velocity vector 658 // Add the various forces into m_dir which will be our new direction vector (velocity)
649 659
650 // add Gravity andBuoyancy 660 // add Gravity and Buoyancy
651 // KF: So far I have found no good method to combine a script-requested 661 // KF: So far I have found no good method to combine a script-requested
652 // .Z velocity and gravity. Therefore only 0g will used script-requested 662 // .Z velocity and gravity. Therefore only 0g will used script-requested
653 // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only. 663 // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only.
654 Vector3 grav = Vector3.Zero; 664 Vector3 grav = Vector3.Zero;
655 // There is some gravity, make a gravity force vector 665 // There is some gravity, make a gravity force vector that is applied after object velocity.
656 // that is applied after object velocity.
657 float objMass = m_prim.Mass;
658 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; 666 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
659 grav.Z = _pParentScene.DefaultGravity.Z * objMass * (1f - m_VehicleBuoyancy); 667 grav.Z = _pParentScene.DefaultGravity.Z * m_prim.Mass * (1f - m_VehicleBuoyancy);
660 // Preserve the current Z velocity 668 // Preserve the current Z velocity
661 Vector3 vel_now = m_prim.Velocity; 669 Vector3 vel_now = m_prim.Velocity;
662 m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity 670 m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity
663 671
664 Vector3 pos = m_prim.Position; 672 Vector3 pos = m_prim.Position;
673 Vector3 posChange = pos;
665// Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f); 674// Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f);
666 Vector3 posChange = new Vector3();
667 posChange.X = pos.X - m_lastPositionVector.X;
668 posChange.Y = pos.Y - m_lastPositionVector.Y;
669 posChange.Z = pos.Z - m_lastPositionVector.Z;
670 double Zchange = Math.Abs(posChange.Z); 675 double Zchange = Math.Abs(posChange.Z);
671 if (m_BlockingEndPoint != Vector3.Zero) 676 if (m_BlockingEndPoint != Vector3.Zero)
672 { 677 {
678 bool changed = false;
673 if (pos.X >= (m_BlockingEndPoint.X - (float)1)) 679 if (pos.X >= (m_BlockingEndPoint.X - (float)1))
674 { 680 {
675 pos.X -= posChange.X + 1; 681 pos.X -= posChange.X + 1;
676 m_prim.Position = pos; 682 changed = true;
677 } 683 }
678 if (pos.Y >= (m_BlockingEndPoint.Y - (float)1)) 684 if (pos.Y >= (m_BlockingEndPoint.Y - (float)1))
679 { 685 {
680 pos.Y -= posChange.Y + 1; 686 pos.Y -= posChange.Y + 1;
681 m_prim.Position = pos; 687 changed = true;
682 } 688 }
683 if (pos.Z >= (m_BlockingEndPoint.Z - (float)1)) 689 if (pos.Z >= (m_BlockingEndPoint.Z - (float)1))
684 { 690 {
685 pos.Z -= posChange.Z + 1; 691 pos.Z -= posChange.Z + 1;
686 m_prim.Position = pos; 692 changed = true;
687 } 693 }
688 if (pos.X <= 0) 694 if (pos.X <= 0)
689 { 695 {
690 pos.X += posChange.X + 1; 696 pos.X += posChange.X + 1;
691 m_prim.Position = pos; 697 changed = true;
692 } 698 }
693 if (pos.Y <= 0) 699 if (pos.Y <= 0)
694 { 700 {
695 pos.Y += posChange.Y + 1; 701 pos.Y += posChange.Y + 1;
702 changed = true;
703 }
704 if (changed)
705 {
696 m_prim.Position = pos; 706 m_prim.Position = pos;
707 DetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}",
708 m_prim.LocalID, m_BlockingEndPoint, posChange, pos);
697 } 709 }
698 } 710 }
699 if (pos.Z < _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y)) 711 if (pos.Z < _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y))
700 { 712 {
701 pos.Z = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + 2; 713 pos.Z = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + 2;
702 m_prim.Position = pos; 714 m_prim.Position = pos;
715 DetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos);
703 } 716 }
704 717
705 // Check if hovering 718 // Check if hovering
@@ -746,6 +759,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
746 } 759 }
747 } 760 }
748 761
762 DetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight);
763
749// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped 764// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped
750// m_VhoverTimescale = 0f; // time to acheive height 765// m_VhoverTimescale = 0f; // time to acheive height
751// pTimestep is time since last frame,in secs 766// pTimestep is time since last frame,in secs
@@ -774,12 +789,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
774 { 789 {
775 grav.Z = (float)(grav.Z * 1.125); 790 grav.Z = (float)(grav.Z * 1.125);
776 } 791 }
777 float terraintemp = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y); 792 float terraintemp = _pParentScene.GetTerrainHeightAtXYZ(pos);
778 float postemp = (pos.Z - terraintemp); 793 float postemp = (pos.Z - terraintemp);
779 if (postemp > 2.5f) 794 if (postemp > 2.5f)
780 { 795 {
781 grav.Z = (float)(grav.Z * 1.037125); 796 grav.Z = (float)(grav.Z * 1.037125);
782 } 797 }
798 DetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav);
783 //End Experimental Values 799 //End Experimental Values
784 } 800 }
785 if ((m_flags & (VehicleFlag.NO_X)) != 0) 801 if ((m_flags & (VehicleFlag.NO_X)) != 0)
@@ -803,29 +819,35 @@ namespace OpenSim.Region.Physics.BulletSPlugin
803 m_prim.Force = grav; 819 m_prim.Force = grav;
804 820
805 821
806 // apply friction 822 // Apply friction
807 Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep); 823 Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
808 m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount; 824 m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
825
826 DetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}",
827 m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount);
828
809 } // end MoveLinear() 829 } // end MoveLinear()
810 830
811 private void MoveAngular(float pTimestep) 831 private void MoveAngular(float pTimestep)
812 { 832 {
813 /* 833 // m_angularMotorDirection // angular velocity requested by LSL motor
814 private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor 834 // m_angularMotorApply // application frame counter
815 private int m_angularMotorApply = 0; // application frame counter 835 // m_angularMotorVelocity // current angular motor velocity (ramps up and down)
816 private float m_angularMotorVelocity = 0; // current angular motor velocity (ramps up and down) 836 // m_angularMotorTimescale // motor angular velocity ramp up rate
817 private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate 837 // m_angularMotorDecayTimescale // motor angular velocity decay rate
818 private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate 838 // m_angularFrictionTimescale // body angular velocity decay rate
819 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate 839 // m_lastAngularVelocity // what was last applied to body
820 private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body
821 */
822 840
823 // Get what the body is doing, this includes 'external' influences 841 // Get what the body is doing, this includes 'external' influences
824 Vector3 angularVelocity = m_prim.RotationalVelocity; 842 Vector3 angularVelocity = m_prim.RotationalVelocity;
825 // Vector3 angularVelocity = Vector3.Zero;
826 843
827 if (m_angularMotorApply > 0) 844 if (m_angularMotorApply > 0)
828 { 845 {
846 // Rather than snapping the angular motor velocity from the old value to
847 // a newly set velocity, this routine steps the value from the previous
848 // value (m_angularMotorVelocity) to the requested value (m_angularMotorDirection).
849 // There are m_angularMotorApply steps.
850 Vector3 origAngularVelocity = m_angularMotorVelocity;
829 // ramp up to new value 851 // ramp up to new value
830 // current velocity += error / (time to get there / step interval) 852 // current velocity += error / (time to get there / step interval)
831 // requested speed - last motor speed 853 // requested speed - last motor speed
@@ -833,23 +855,21 @@ namespace OpenSim.Region.Physics.BulletSPlugin
833 m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); 855 m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep);
834 m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); 856 m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep);
835 857
858 DetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}",
859 m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity);
860
836 m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected 861 m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected
837 // velocity may still be acheived. 862 // velocity may still be acheived.
838 } 863 }
839 else 864 else
840 { 865 {
841 // no motor recently applied, keep the body velocity 866 // No motor recently applied, keep the body velocity
842 /* m_angularMotorVelocity.X = angularVelocity.X;
843 m_angularMotorVelocity.Y = angularVelocity.Y;
844 m_angularMotorVelocity.Z = angularVelocity.Z; */
845
846 // and decay the velocity 867 // and decay the velocity
847 m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep); 868 m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep);
848 } // end motor section 869 } // end motor section
849 870
850 // Vertical attractor section 871 // Vertical attractor section
851 Vector3 vertattr = Vector3.Zero; 872 Vector3 vertattr = Vector3.Zero;
852
853 if (m_verticalAttractionTimescale < 300) 873 if (m_verticalAttractionTimescale < 300)
854 { 874 {
855 float VAservo = 0.2f / (m_verticalAttractionTimescale * pTimestep); 875 float VAservo = 0.2f / (m_verticalAttractionTimescale * pTimestep);
@@ -871,7 +891,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
871 // Error is 0 (no error) to +/- 2 (max error) 891 // Error is 0 (no error) to +/- 2 (max error)
872 // scale it by VAservo 892 // scale it by VAservo
873 verterr = verterr * VAservo; 893 verterr = verterr * VAservo;
874//if (frcount == 0) Console.WriteLine("VAerr=" + verterr);
875 894
876 // As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so 895 // As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so
877 // Change Body angular velocity X based on Y, and Y based on X. Z is not changed. 896 // Change Body angular velocity X based on Y, and Y based on X. Z is not changed.
@@ -884,11 +903,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
884 vertattr.X += bounce * angularVelocity.X; 903 vertattr.X += bounce * angularVelocity.X;
885 vertattr.Y += bounce * angularVelocity.Y; 904 vertattr.Y += bounce * angularVelocity.Y;
886 905
906 DetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}",
907 m_prim.LocalID, verterr, bounce, vertattr);
908
887 } // else vertical attractor is off 909 } // else vertical attractor is off
888 910
889 // m_lastVertAttractor = vertattr; 911 // m_lastVertAttractor = vertattr;
890 912
891 // Bank section tba 913 // Bank section tba
914
892 // Deflection section tba 915 // Deflection section tba
893 916
894 // Sum velocities 917 // Sum velocities
@@ -898,11 +921,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
898 { 921 {
899 m_lastAngularVelocity.X = 0; 922 m_lastAngularVelocity.X = 0;
900 m_lastAngularVelocity.Y = 0; 923 m_lastAngularVelocity.Y = 0;
924 DetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
901 } 925 }
902 926
903 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 927 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
904 { 928 {
905 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. 929 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero.
930 DetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
906 } 931 }
907 932
908 // apply friction 933 // apply friction
@@ -912,10 +937,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
912 // Apply to the body 937 // Apply to the body
913 m_prim.RotationalVelocity = m_lastAngularVelocity; 938 m_prim.RotationalVelocity = m_lastAngularVelocity;
914 939
940 DetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity);
941 } //end MoveAngular
942
915 } //end MoveAngular 943 } //end MoveAngular
916 internal void LimitRotation(float timestep) 944 internal void LimitRotation(float timestep)
917 { 945 {
918 Quaternion rotq = m_prim.Orientation; // rotq = rotation of object 946 Quaternion rotq = m_prim.Orientation;
919 Quaternion m_rot = rotq; 947 Quaternion m_rot = rotq;
920 bool changed = false; 948 bool changed = false;
921 if (m_RollreferenceFrame != Quaternion.Identity) 949 if (m_RollreferenceFrame != Quaternion.Identity)
@@ -923,18 +951,22 @@ namespace OpenSim.Region.Physics.BulletSPlugin
923 if (rotq.X >= m_RollreferenceFrame.X) 951 if (rotq.X >= m_RollreferenceFrame.X)
924 { 952 {
925 m_rot.X = rotq.X - (m_RollreferenceFrame.X / 2); 953 m_rot.X = rotq.X - (m_RollreferenceFrame.X / 2);
954 changed = true;
926 } 955 }
927 if (rotq.Y >= m_RollreferenceFrame.Y) 956 if (rotq.Y >= m_RollreferenceFrame.Y)
928 { 957 {
929 m_rot.Y = rotq.Y - (m_RollreferenceFrame.Y / 2); 958 m_rot.Y = rotq.Y - (m_RollreferenceFrame.Y / 2);
959 changed = true;
930 } 960 }
931 if (rotq.X <= -m_RollreferenceFrame.X) 961 if (rotq.X <= -m_RollreferenceFrame.X)
932 { 962 {
933 m_rot.X = rotq.X + (m_RollreferenceFrame.X / 2); 963 m_rot.X = rotq.X + (m_RollreferenceFrame.X / 2);
964 changed = true;
934 } 965 }
935 if (rotq.Y <= -m_RollreferenceFrame.Y) 966 if (rotq.Y <= -m_RollreferenceFrame.Y)
936 { 967 {
937 m_rot.Y = rotq.Y + (m_RollreferenceFrame.Y / 2); 968 m_rot.Y = rotq.Y + (m_RollreferenceFrame.Y / 2);
969 changed = true;
938 } 970 }
939 changed = true; 971 changed = true;
940 } 972 }
@@ -944,8 +976,22 @@ namespace OpenSim.Region.Physics.BulletSPlugin
944 m_rot.Y = 0; 976 m_rot.Y = 0;
945 changed = true; 977 changed = true;
946 } 978 }
979 if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0)
980 {
981 m_rot.X = 0;
982 m_rot.Y = 0;
983 changed = true;
984 }
947 if (changed) 985 if (changed)
948 m_prim.Orientation = m_rot; 986 m_prim.Orientation = m_rot;
987
988 DetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot);
989 }
990
991 // Invoke the detailed logger and output something if it's enabled.
992 private void DetailLog(string msg, params Object[] args)
993 {
994 m_prim.Scene.VehicleLogging.Write(msg, args);
949 } 995 }
950 } 996 }
951} 997}