From 0ec6dfb1a1bfcbe70b40927fabca956782aa2a8c Mon Sep 17 00:00:00 2001 From: nlin Date: Wed, 8 Jul 2009 01:41:05 +0000 Subject: Experimental fix for tilted avatar capsule, Mantis #2905 Set av_capsule_tilted to false in opensim.ini. Default is true, so there is no change in avatar behavior (and no breaking of existing content which relies on the tilted capsule). This commit straightens up the avatar capsule so it behaves consistently (e.g. same collision behavior against prims regardless of which direction the avatar is coming from; ability to fit through narrow doorways). Please note this introduces other side effects which have not been fixed. In particular: * The avatar frequently falls through the terrain if it is not flat, though the avatar behaves pretty well on flat terrain. This requires investigation of the ode terrain collider. * The apparent foot position of the avatar with respect to the ground is changed. This requires investigation of the avatar height/capsule height. Please consider this as work in progress. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 33 +++++++++++++++++++----- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 3 +++ 2 files changed, 29 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index e5e7d07..b832e0a 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -519,7 +519,14 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodySetMass(Body, ref ShellMass); d.Matrix3 m_caprot; // 90 Stand up on the cap of the capped cyllinder - d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2)); + if (_parent_scene.IsAvCapsuleTilted) + { + d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2)); + } + else + { + d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2)); + } d.GeomSetRotation(Shell, ref m_caprot); @@ -542,12 +549,24 @@ namespace OpenSim.Region.Physics.OdePlugin d.JointSetAMotorAngle(Amotor, 2, 0); // These lowstops and high stops are effectively (no wiggle room) - d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); + if (_parent_scene.IsAvCapsuleTilted) + { + d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); + } + else + { + d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0); + d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0); + d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0); + } // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the // capped cyllinder will fall over diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 0f92358..889afb6 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -199,6 +199,8 @@ namespace OpenSim.Region.Physics.OdePlugin private float avPIDP = 1400f; private float avCapRadius = 0.37f; private float avStandupTensor = 2000000f; + private bool avCapsuleTilted = true; // true = old compatibility mode with leaning capsule; false = new corrected mode + public bool IsAvCapsuleTilted { get { return avCapsuleTilted; } set { avCapsuleTilted = value; } } private float avDensity = 80f; private float avHeightFudgeFactor = 0.52f; private float avMovementDivisorWalk = 1.3f; @@ -426,6 +428,7 @@ namespace OpenSim.Region.Physics.OdePlugin avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f); avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); + avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", true); geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); -- cgit v1.1