aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs
diff options
context:
space:
mode:
authorTeravus Ovares2009-04-17 04:34:52 +0000
committerTeravus Ovares2009-04-17 04:34:52 +0000
commit0d00a767bc9d1d6aae20c31131cd2e4e6ed62418 (patch)
treee72b735905d97e3bcf114bf3ef9febfb587e8b17 /OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs
parent* minor: Eliminate redundant argument in PreloadUserCache (diff)
downloadopensim-SC-0d00a767bc9d1d6aae20c31131cd2e4e6ed62418.zip
opensim-SC-0d00a767bc9d1d6aae20c31131cd2e4e6ed62418.tar.gz
opensim-SC-0d00a767bc9d1d6aae20c31131cd2e4e6ed62418.tar.bz2
opensim-SC-0d00a767bc9d1d6aae20c31131cd2e4e6ed62418.tar.xz
* Commit a few fixes to the Vehicle settings
* Vertical Attractor servo
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs51
1 files changed, 49 insertions, 2 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs b/OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs
index c4c3044..3a99b48 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs
@@ -44,6 +44,11 @@ namespace OpenSim.Region.Physics.OdePlugin
44 get { return m_type; } 44 get { return m_type; }
45 } 45 }
46 46
47 public IntPtr Body
48 {
49 get { return m_body; }
50 }
51
47 private Vehicle m_type = Vehicle.TYPE_NONE; 52 private Vehicle m_type = Vehicle.TYPE_NONE;
48 private OdeScene m_parentScene = null; 53 private OdeScene m_parentScene = null;
49 private IntPtr m_body = IntPtr.Zero; 54 private IntPtr m_body = IntPtr.Zero;
@@ -75,6 +80,7 @@ namespace OpenSim.Region.Physics.OdePlugin
75 private float m_linearMotorTimescale = 0; 80 private float m_linearMotorTimescale = 0;
76 private float m_verticalAttractionEfficiency = 0; 81 private float m_verticalAttractionEfficiency = 0;
77 private float m_verticalAttractionTimescale = 0; 82 private float m_verticalAttractionTimescale = 0;
83 private Vector3 m_lastVector = Vector3.Zero;
78 private VehicleFlag m_flags = (VehicleFlag) 0; 84 private VehicleFlag m_flags = (VehicleFlag) 0;
79 85
80 86
@@ -222,8 +228,9 @@ namespace OpenSim.Region.Physics.OdePlugin
222 228
223 internal void Enable(IntPtr pBody, OdeScene pParentScene) 229 internal void Enable(IntPtr pBody, OdeScene pParentScene)
224 { 230 {
225 if (pBody == IntPtr.Zero || m_type == Vehicle.TYPE_NONE) 231 if (m_type == Vehicle.TYPE_NONE)
226 return; 232 return;
233
227 m_body = pBody; 234 m_body = pBody;
228 m_parentScene = pParentScene; 235 m_parentScene = pParentScene;
229 } 236 }
@@ -246,11 +253,13 @@ namespace OpenSim.Region.Physics.OdePlugin
246 { 253 {
247 if (m_body == IntPtr.Zero || m_type == Vehicle.TYPE_NONE) 254 if (m_body == IntPtr.Zero || m_type == Vehicle.TYPE_NONE)
248 return; 255 return;
249 256 VerticalAttractor(pTimestep);
257 LinearMotor(pTimestep);
250 } 258 }
251 259
252 private void SetDefaultsForType(Vehicle pType) 260 private void SetDefaultsForType(Vehicle pType)
253 { 261 {
262 m_type = pType;
254 switch (pType) 263 switch (pType)
255 { 264 {
256 case Vehicle.TYPE_SLED: 265 case Vehicle.TYPE_SLED:
@@ -388,5 +397,43 @@ namespace OpenSim.Region.Physics.OdePlugin
388 397
389 } 398 }
390 } 399 }
400
401 private void VerticalAttractor(float pTimestep)
402 {
403 // The purpose of this routine here is to quickly stabilize the Body while it's popped up in the air.
404 // The amotor needs a few seconds to stabilize so without it, the avatar shoots up sky high when you
405 // change appearance and when you enter the simulator
406 // After this routine is done, the amotor stabilizes much quicker
407 d.Mass objMass;
408 d.BodyGetMass(Body, out objMass);
409 //d.BodyGetS
410
411 d.Vector3 feet;
412 d.Vector3 head;
413 d.BodyGetRelPointPos(m_body, 0.0f, 0.0f, -1.0f, out feet);
414 d.BodyGetRelPointPos(m_body, 0.0f, 0.0f, 1.0f, out head);
415 float posture = head.Z - feet.Z;
416
417 // restoring force proportional to lack of posture:
418 float servo = (2.5f - posture) * (objMass.mass * m_verticalAttractionEfficiency / (m_verticalAttractionTimescale * pTimestep)) * objMass.mass;
419 d.BodyAddForceAtRelPos(m_body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f);
420 d.BodyAddForceAtRelPos(m_body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f);
421 //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
422 //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
423 }
424
425 private void LinearMotor(float pTimestep)
426 {
427
428 /*
429 float decayval = (m_linearMotorDecayTimescale * pTimestep);
430 m_linearMotorDirection *= decayval;
431 m_lastVector += m_linearMotorDirection
432
433
434 m_lin
435 m_lastVector
436 * */
437 }
391 } 438 }
392} 439}