* Adds various tweakable avatar control options to the OpenSim.ini.example.

0.6.0-stable
Teravus Ovares 2008-05-15 23:11:31 +00:00
parent 129e7e19c5
commit afd5da6851
3 changed files with 105 additions and 41 deletions

View File

@ -67,14 +67,17 @@ namespace OpenSim.Region.Physics.OdePlugin
private PhysicsVector _acceleration; private PhysicsVector _acceleration;
private PhysicsVector m_rotationalVelocity; private PhysicsVector m_rotationalVelocity;
private float m_mass = 80f; private float m_mass = 80f;
private float m_density = 60f; public float m_density = 60f;
private bool m_pidControllerActive = true; private bool m_pidControllerActive = true;
private float PID_D = 800.0f; public float PID_D = 800.0f;
private float PID_P = 900.0f; public float PID_P = 900.0f;
//private static float POSTURE_SERVO = 10000.0f; //private static float POSTURE_SERVO = 10000.0f;
public static float CAPSULE_RADIUS = 0.37f; public float CAPSULE_RADIUS = 0.37f;
public float CAPSULE_LENGTH = 2.140599f; public float CAPSULE_LENGTH = 2.140599f;
private float m_tensor = 3800000f; public float m_tensor = 3800000f;
public float heightFudgeFactor = 0.52f;
public float walkDivisor = 1.3f;
public float runDivisor = 0.8f;
private bool flying = false; private bool flying = false;
private bool m_iscolliding = false; private bool m_iscolliding = false;
private bool m_iscollidingGround = false; private bool m_iscollidingGround = false;
@ -115,7 +118,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public int m_eventsubscription = 0; public int m_eventsubscription = 0;
private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size) public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
{ {
ode = dode; ode = dode;
_velocity = new PhysicsVector(); _velocity = new PhysicsVector();
@ -124,14 +127,15 @@ namespace OpenSim.Region.Physics.OdePlugin
_acceleration = new PhysicsVector(); _acceleration = new PhysicsVector();
_parent_scene = parent_scene; _parent_scene = parent_scene;
if (Environment.OSVersion.Platform == PlatformID.Unix) PID_D = pid_d;
{ PID_P = pid_p;
m_tensor = 2000000f; CAPSULE_RADIUS = capsule_radius;
} m_tensor = tensor;
else m_density = density;
{ heightFudgeFactor = height_fudge_factor;
m_tensor = 1300000f; walkDivisor = walk_divisor;
} runDivisor = rundivisor;
m_StandUpRotation = m_StandUpRotation =
new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f, new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f,
@ -141,7 +145,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
m_colliderarr[i] = false; m_colliderarr[i] = false;
} }
CAPSULE_LENGTH = (size.Z - ((size.Z * 0.52f))); CAPSULE_LENGTH = (size.Z - ((size.Z * height_fudge_factor)));
lock (OdeScene.OdeLock) lock (OdeScene.OdeLock)
{ {
@ -391,7 +395,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float capsuleradius = CAPSULE_RADIUS; float capsuleradius = CAPSULE_RADIUS;
//capsuleradius = 0.2f; //capsuleradius = 0.2f;
CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.52f))); // subtract 43% of the size CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z * heightFudgeFactor))); // subtract 43% of the size
//m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
d.BodyDestroy(Body); d.BodyDestroy(Body);
@ -416,15 +420,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ, float tensor) private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ, float tensor)
{ {
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
m_tensor = 2000000f;
}
else
{
m_tensor = 550000f;
}
int dAMotorEuler = 1; int dAMotorEuler = 1;
_parent_scene.waitForSpaceUnlock(_parent_scene.space); _parent_scene.waitForSpaceUnlock(_parent_scene.space);
Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
@ -662,16 +657,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// If the PID Controller isn't active then we set our force // If the PID Controller isn't active then we set our force
// calculating base velocity to the current position // calculating base velocity to the current position
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
PID_D = 3200.0f;
PID_P = 1400.0f;
}
else
{
PID_D = 2200.0f;
PID_P = 900.0f;
}
if (m_pidControllerActive == false) if (m_pidControllerActive == false)
@ -686,11 +671,11 @@ namespace OpenSim.Region.Physics.OdePlugin
if (!m_alwaysRun) if (!m_alwaysRun)
{ {
movementdivisor = 1.3f; movementdivisor = walkDivisor;
} }
else else
{ {
movementdivisor = 0.8f; movementdivisor = runDivisor;
} }
// if velocity is zero, use position control; otherwise, velocity control // if velocity is zero, use position control; otherwise, velocity control
@ -830,11 +815,10 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity.Y = (vec.Y); _velocity.Y = (vec.Y);
_velocity.Z = (vec.Z); _velocity.Z = (vec.Z);
if (_velocity.Z < -6 && !m_hackSentFall) if (_velocity.Z < -6 && !m_hackSentFall)
{ {
// Collisionupdates will be used in the future, right now the're not being used.
m_hackSentFall = true; m_hackSentFall = true;
//base.SendCollisionUpdate(new CollisionEventUpdate());
m_pidControllerActive = false; m_pidControllerActive = false;
} }
else if (flying && !m_hackSentFly) else if (flying && !m_hackSentFly)

View File

@ -166,6 +166,16 @@ namespace OpenSim.Region.Physics.OdePlugin
private float mAvatarObjectContactBounce = 0.1f; private float mAvatarObjectContactBounce = 0.1f;
private float avPIDD = 3200f;
private float avPIDP = 1400f;
private float avCapRadius = 0.37f;
private float avStandupTensor = 2000000f;
private float avDensity = 80f;
private float avHeightFudgeFactor = 0.52f;
private float avMovementDivisorWalk = 1.3f;
private float avMovementDivisorRun = 0.8f;
private float[] _heightmap; private float[] _heightmap;
private float[] _watermap; private float[] _watermap;
@ -271,6 +281,21 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
mesher = meshmerizer; mesher = meshmerizer;
m_config = config; m_config = config;
// Defaults
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
avPIDD = 3200.0f;
avPIDP = 1400.0f;
avStandupTensor = 2000000f;
}
else
{
avPIDD = 2200.0f;
avPIDP = 900.0f;
avStandupTensor = 550000f;
}
if (m_config != null) if (m_config != null)
{ {
IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"];
@ -306,6 +331,26 @@ namespace OpenSim.Region.Physics.OdePlugin
ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f); ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f);
m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10); m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10);
avDensity = physicsconfig.GetFloat("av_density", 80f);
avHeightFudgeFactor = physicsconfig.GetFloat("av_height_fudge_factor", 0.52f);
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);
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 3200.0f);
avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 1400.0f);
avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_linux", 2000000f);
}
else
{
avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f);
avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f);
avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f);
}
} }
} }
@ -1054,7 +1099,7 @@ namespace OpenSim.Region.Physics.OdePlugin
pos.X = position.X; pos.X = position.X;
pos.Y = position.Y; pos.Y = position.Y;
pos.Z = position.Z; pos.Z = position.Z;
OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode, size); OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, avHeightFudgeFactor, avMovementDivisorWalk, avMovementDivisorRun);
_characters.Add(newAv); _characters.Add(newAv);
return newAv; return newAv;
} }

View File

@ -207,6 +207,41 @@ m_avatarobjectcontact_bounce = 0.1
objectcontact_friction = 250.0 objectcontact_friction = 250.0
objectcontact_bounce = 0.2 objectcontact_bounce = 0.2
; # Avatar Control
; PID Controller Settings. These affect the math that causes the avatar to reach the
av_pid_derivative_linux = 3200.0
av_pid_proportional_linux = 1400.0
av_pid_derivative_win = 2200.0
av_pid_proportional_win = 900.0;
;girth of the avatar. Adds radius to the height also
av_capsule_radius = 0.37
; Max force permissible to use to keep the avatar standing up straight
av_capsule_standup_tensor_win = 550000
av_capsule_standup_tensor_linux = 2000000
; used to calculate mass of avatar.
; float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH);
; av_density * AVvolume;
av_density = 80
; use this value to cut 52% of the height the sim gives us
av_height_fudge_factor = 0.52
; Movement. Smaller is faster.
; speed of movement with Always Run off
av_movement_divisor_walk = 1.3
; speed of movement with Always Run on
av_movement_divisor_run = 0.8
[RemoteAdmin] [RemoteAdmin]
enabled = false enabled = false