diff options
author | UbitUmarov | 2012-02-11 14:29:36 +0000 |
---|---|---|
committer | UbitUmarov | 2012-02-11 14:29:36 +0000 |
commit | 3f9c390b4d1e13057b11ef810f19fde7c6722fca (patch) | |
tree | e32eca7557b16f8475b89c2bab715815ad17f735 /OpenSim/Region/Physics | |
parent | a bit better vertical attractor and banking (diff) | |
download | opensim-SC_OLD-3f9c390b4d1e13057b11ef810f19fde7c6722fca.zip opensim-SC_OLD-3f9c390b4d1e13057b11ef810f19fde7c6722fca.tar.gz opensim-SC_OLD-3f9c390b4d1e13057b11ef810f19fde7c6722fca.tar.bz2 opensim-SC_OLD-3f9c390b4d1e13057b11ef810f19fde7c6722fca.tar.xz |
changes to vehicle banking
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs | 92 |
1 files changed, 23 insertions, 69 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs index 8999621..80218e7 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs | |||
@@ -38,6 +38,8 @@ | |||
38 | * settings use. | 38 | * settings use. |
39 | */ | 39 | */ |
40 | 40 | ||
41 | // Ubit 2012 | ||
42 | |||
41 | using System; | 43 | using System; |
42 | using System.Collections.Generic; | 44 | using System.Collections.Generic; |
43 | using System.Reflection; | 45 | using System.Reflection; |
@@ -57,24 +59,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
57 | get { return m_type; } | 59 | get { return m_type; } |
58 | } | 60 | } |
59 | 61 | ||
60 | // private OdeScene m_parentScene = null; | ||
61 | // private IntPtr m_aMotor = IntPtr.Zero; | ||
62 | |||
63 | |||
64 | private OdePrim rootPrim; | 62 | private OdePrim rootPrim; |
65 | private OdeScene _pParentScene; | 63 | private OdeScene _pParentScene; |
66 | 64 | ||
67 | |||
68 | |||
69 | |||
70 | private Vector3 refUpAxis = new Vector3(0, 0, 1); | ||
71 | private Vector3 refAtAxis = new Vector3(1, 0, 0); | ||
72 | |||
73 | |||
74 | // Vehicle properties | 65 | // Vehicle properties |
66 | private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier | ||
67 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; // what hell is this ? | ||
68 | |||
75 | private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind | 69 | private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind |
76 | 70 | ||
77 | private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier | ||
78 | private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings: | 71 | private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings: |
79 | // HOVER_TERRAIN_ONLY | 72 | // HOVER_TERRAIN_ONLY |
80 | // HOVER_GLOBAL_HEIGHT | 73 | // HOVER_GLOBAL_HEIGHT |
@@ -84,7 +77,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
84 | // LIMIT_MOTOR_UP | 77 | // LIMIT_MOTOR_UP |
85 | // LIMIT_ROLL_ONLY | 78 | // LIMIT_ROLL_ONLY |
86 | private Vector3 m_BlockingEndPoint = Vector3.Zero; // not sl | 79 | private Vector3 m_BlockingEndPoint = Vector3.Zero; // not sl |
87 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; | ||
88 | 80 | ||
89 | // Linear properties | 81 | // Linear properties |
90 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time | 82 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time |
@@ -116,7 +108,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
116 | private float m_VhoverHeight = 0f; | 108 | private float m_VhoverHeight = 0f; |
117 | private float m_VhoverEfficiency = 0f; | 109 | private float m_VhoverEfficiency = 0f; |
118 | private float m_VhoverTimescale = 1000f; | 110 | private float m_VhoverTimescale = 1000f; |
119 | private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height | ||
120 | private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. | 111 | private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. |
121 | // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) | 112 | // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) |
122 | // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. | 113 | // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. |
@@ -126,9 +117,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
126 | private float m_verticalAttractionEfficiency = 1.0f; // damped | 117 | private float m_verticalAttractionEfficiency = 1.0f; // damped |
127 | private float m_verticalAttractionTimescale = 1000f; // Timescale > 300 means no vert attractor. | 118 | private float m_verticalAttractionTimescale = 1000f; // Timescale > 300 means no vert attractor. |
128 | 119 | ||
129 | // special contact data for vehicles | ||
130 | public ContactData VehiculeContactData = new ContactData(0f, 0.1f); | ||
131 | |||
132 | // auxiliar | 120 | // auxiliar |
133 | private Vector3 m_dir = Vector3.Zero; // velocity applied to body | 121 | private Vector3 m_dir = Vector3.Zero; // velocity applied to body |
134 | 122 | ||
@@ -271,7 +259,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
271 | float timestep = _pParentScene.ODE_STEPSIZE; | 259 | float timestep = _pParentScene.ODE_STEPSIZE; |
272 | switch (pParam) | 260 | switch (pParam) |
273 | { | 261 | { |
274 | |||
275 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: | 262 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: |
276 | if (pValue.X < timestep) pValue.X = timestep; | 263 | if (pValue.X < timestep) pValue.X = timestep; |
277 | if (pValue.Y < timestep) pValue.Y = timestep; | 264 | if (pValue.Y < timestep) pValue.Y = timestep; |
@@ -575,7 +562,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
575 | return vec; | 562 | return vec; |
576 | } | 563 | } |
577 | 564 | ||
578 | |||
579 | public static void GetRollPitch(Quaternion rot, out float roll, out float pitch) | 565 | public static void GetRollPitch(Quaternion rot, out float roll, out float pitch) |
580 | { | 566 | { |
581 | // assuming rot is normalised | 567 | // assuming rot is normalised |
@@ -617,23 +603,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
617 | 603 | ||
618 | d.Vector3 dvtmp; | 604 | d.Vector3 dvtmp; |
619 | Vector3 tmpV; | 605 | Vector3 tmpV; |
606 | Vector3 curVel; // velocity in world | ||
607 | Vector3 curAngVel; // angular velocity in world | ||
608 | Vector3 force = Vector3.Zero; // actually linear aceleration until mult by mass in world frame | ||
609 | Vector3 torque = Vector3.Zero;// actually angular aceleration until mult by Inertia in vehicle frame | ||
610 | d.Vector3 dtorque = new d.Vector3(); | ||
611 | |||
620 | dvtmp = d.BodyGetLinearVel(Body); | 612 | dvtmp = d.BodyGetLinearVel(Body); |
621 | Vector3 curVel; | ||
622 | curVel.X = dvtmp.X; | 613 | curVel.X = dvtmp.X; |
623 | curVel.Y = dvtmp.Y; | 614 | curVel.Y = dvtmp.Y; |
624 | curVel.Z = dvtmp.Z; | 615 | curVel.Z = dvtmp.Z; |
625 | Vector3 curLocalVel = curVel * irotq; // current velocity in local | 616 | Vector3 curLocalVel = curVel * irotq; // current velocity in local |
626 | 617 | ||
627 | dvtmp = d.BodyGetAngularVel(Body); | 618 | dvtmp = d.BodyGetAngularVel(Body); |
628 | Vector3 curAngVel; | ||
629 | curAngVel.X = dvtmp.X; | 619 | curAngVel.X = dvtmp.X; |
630 | curAngVel.Y = dvtmp.Y; | 620 | curAngVel.Y = dvtmp.Y; |
631 | curAngVel.Z = dvtmp.Z; | 621 | curAngVel.Z = dvtmp.Z; |
632 | Vector3 curLocalAngVel = curAngVel * irotq; // current velocity in local | 622 | Vector3 curLocalAngVel = curAngVel * irotq; // current angular velocity in local |
633 | |||
634 | Vector3 force = Vector3.Zero; // actually linear aceleration until mult by mass in world frame | ||
635 | Vector3 torque = Vector3.Zero;// actually angular aceleration until mult by Inertia in object frame | ||
636 | d.Vector3 dtorque = new d.Vector3(); | ||
637 | 623 | ||
638 | // linear motor | 624 | // linear motor |
639 | if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000) | 625 | if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000) |
@@ -791,11 +777,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
791 | } | 777 | } |
792 | } | 778 | } |
793 | 779 | ||
794 | float r; | ||
795 | float p; | ||
796 | float y; | ||
797 | rotq.GetEulerAngles(out r, out p, out y); | ||
798 | |||
799 | // vertical atractor | 780 | // vertical atractor |
800 | if (m_verticalAttractionTimescale < 300) | 781 | if (m_verticalAttractionTimescale < 300) |
801 | { | 782 | { |
@@ -830,7 +811,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
830 | broll *= -((1 - m_bankingMix) + vfact); | 811 | broll *= -((1 - m_bankingMix) + vfact); |
831 | } | 812 | } |
832 | broll = (broll - curLocalAngVel.Z) / m_bankingTimescale; | 813 | broll = (broll - curLocalAngVel.Z) / m_bankingTimescale; |
833 | torque.Z += broll; | 814 | // torque.Z += broll; |
815 | |||
816 | // make z rot be in world Z not local as seems to be in sl | ||
817 | tmpV.X = 0; | ||
818 | tmpV.Y = 0; | ||
819 | tmpV.Z = broll; | ||
820 | tmpV *= irotq; | ||
821 | |||
822 | torque.X += tmpV.X; | ||
823 | torque.Y += tmpV.Y; | ||
824 | torque.Z += tmpV.Z; | ||
834 | } | 825 | } |
835 | } | 826 | } |
836 | 827 | ||
@@ -853,43 +844,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
853 | d.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque); | 844 | d.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque); |
854 | d.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame | 845 | d.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame |
855 | } | 846 | } |
856 | |||
857 | //end MoveAngular | ||
858 | |||
859 | // limit rotations | ||
860 | /* | ||
861 | bool changed = false; | ||
862 | |||
863 | if (m_RollreferenceFrame != Quaternion.Identity) | ||
864 | { | ||
865 | if (rotq.X >= m_RollreferenceFrame.X) | ||
866 | { | ||
867 | rot.X = rotq.X - (m_RollreferenceFrame.X / 2); | ||
868 | } | ||
869 | if (rotq.Y >= m_RollreferenceFrame.Y) | ||
870 | { | ||
871 | rot.Y = rotq.Y - (m_RollreferenceFrame.Y / 2); | ||
872 | } | ||
873 | if (rotq.X <= -m_RollreferenceFrame.X) | ||
874 | { | ||
875 | rot.X = rotq.X + (m_RollreferenceFrame.X / 2); | ||
876 | } | ||
877 | if (rotq.Y <= -m_RollreferenceFrame.Y) | ||
878 | { | ||
879 | rot.Y = rotq.Y + (m_RollreferenceFrame.Y / 2); | ||
880 | } | ||
881 | changed = true; | ||
882 | } | ||
883 | |||
884 | if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0) | ||
885 | { | ||
886 | rot.X = 0; | ||
887 | rot.Y = 0; | ||
888 | changed = true; | ||
889 | } | ||
890 | if (changed) | ||
891 | d.BodySetQuaternion(Body, ref rot); | ||
892 | */ | ||
893 | } | 847 | } |
894 | } | 848 | } |
895 | } | 849 | } |