diff options
author | Teravus Ovares | 2008-05-15 23:11:31 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-15 23:11:31 +0000 |
commit | afd5da6851f30945c86d8cd950879582fdf82a62 (patch) | |
tree | 64be548ff2e1a335b8d32d435f9ed6fad7497a9e | |
parent | fixed the key issue that caused appearance to go wonky (diff) | |
download | opensim-SC-afd5da6851f30945c86d8cd950879582fdf82a62.zip opensim-SC-afd5da6851f30945c86d8cd950879582fdf82a62.tar.gz opensim-SC-afd5da6851f30945c86d8cd950879582fdf82a62.tar.bz2 opensim-SC-afd5da6851f30945c86d8cd950879582fdf82a62.tar.xz |
* Adds various tweakable avatar control options to the OpenSim.ini.example.
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 64 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 47 | ||||
-rw-r--r-- | bin/OpenSim.ini.example | 35 |
3 files changed, 105 insertions, 41 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 606b13e..4165484 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -67,14 +67,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
67 | private PhysicsVector _acceleration; | 67 | private PhysicsVector _acceleration; |
68 | private PhysicsVector m_rotationalVelocity; | 68 | private PhysicsVector m_rotationalVelocity; |
69 | private float m_mass = 80f; | 69 | private float m_mass = 80f; |
70 | private float m_density = 60f; | 70 | public float m_density = 60f; |
71 | private bool m_pidControllerActive = true; | 71 | private bool m_pidControllerActive = true; |
72 | private float PID_D = 800.0f; | 72 | public float PID_D = 800.0f; |
73 | private float PID_P = 900.0f; | 73 | public float PID_P = 900.0f; |
74 | //private static float POSTURE_SERVO = 10000.0f; | 74 | //private static float POSTURE_SERVO = 10000.0f; |
75 | public static float CAPSULE_RADIUS = 0.37f; | 75 | public float CAPSULE_RADIUS = 0.37f; |
76 | public float CAPSULE_LENGTH = 2.140599f; | 76 | public float CAPSULE_LENGTH = 2.140599f; |
77 | private float m_tensor = 3800000f; | 77 | public float m_tensor = 3800000f; |
78 | public float heightFudgeFactor = 0.52f; | ||
79 | public float walkDivisor = 1.3f; | ||
80 | public float runDivisor = 0.8f; | ||
78 | private bool flying = false; | 81 | private bool flying = false; |
79 | private bool m_iscolliding = false; | 82 | private bool m_iscolliding = false; |
80 | private bool m_iscollidingGround = false; | 83 | private bool m_iscollidingGround = false; |
@@ -115,7 +118,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
115 | public int m_eventsubscription = 0; | 118 | public int m_eventsubscription = 0; |
116 | private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); | 119 | private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); |
117 | 120 | ||
118 | public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size) | 121 | 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) |
119 | { | 122 | { |
120 | ode = dode; | 123 | ode = dode; |
121 | _velocity = new PhysicsVector(); | 124 | _velocity = new PhysicsVector(); |
@@ -124,14 +127,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
124 | _acceleration = new PhysicsVector(); | 127 | _acceleration = new PhysicsVector(); |
125 | _parent_scene = parent_scene; | 128 | _parent_scene = parent_scene; |
126 | 129 | ||
127 | if (Environment.OSVersion.Platform == PlatformID.Unix) | 130 | PID_D = pid_d; |
128 | { | 131 | PID_P = pid_p; |
129 | m_tensor = 2000000f; | 132 | CAPSULE_RADIUS = capsule_radius; |
130 | } | 133 | m_tensor = tensor; |
131 | else | 134 | m_density = density; |
132 | { | 135 | heightFudgeFactor = height_fudge_factor; |
133 | m_tensor = 1300000f; | 136 | walkDivisor = walk_divisor; |
134 | } | 137 | runDivisor = rundivisor; |
138 | |||
135 | 139 | ||
136 | m_StandUpRotation = | 140 | m_StandUpRotation = |
137 | new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f, | 141 | 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 | |||
141 | { | 145 | { |
142 | m_colliderarr[i] = false; | 146 | m_colliderarr[i] = false; |
143 | } | 147 | } |
144 | CAPSULE_LENGTH = (size.Z - ((size.Z * 0.52f))); | 148 | CAPSULE_LENGTH = (size.Z - ((size.Z * height_fudge_factor))); |
145 | 149 | ||
146 | lock (OdeScene.OdeLock) | 150 | lock (OdeScene.OdeLock) |
147 | { | 151 | { |
@@ -391,7 +395,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
391 | float capsuleradius = CAPSULE_RADIUS; | 395 | float capsuleradius = CAPSULE_RADIUS; |
392 | //capsuleradius = 0.2f; | 396 | //capsuleradius = 0.2f; |
393 | 397 | ||
394 | CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.52f))); // subtract 43% of the size | 398 | CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z * heightFudgeFactor))); // subtract 43% of the size |
395 | //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); | 399 | //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); |
396 | d.BodyDestroy(Body); | 400 | d.BodyDestroy(Body); |
397 | 401 | ||
@@ -416,15 +420,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
416 | private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ, float tensor) | 420 | private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ, float tensor) |
417 | { | 421 | { |
418 | 422 | ||
419 | if (Environment.OSVersion.Platform == PlatformID.Unix) | ||
420 | { | ||
421 | m_tensor = 2000000f; | ||
422 | } | ||
423 | else | ||
424 | { | ||
425 | m_tensor = 550000f; | ||
426 | } | ||
427 | |||
428 | int dAMotorEuler = 1; | 423 | int dAMotorEuler = 1; |
429 | _parent_scene.waitForSpaceUnlock(_parent_scene.space); | 424 | _parent_scene.waitForSpaceUnlock(_parent_scene.space); |
430 | Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); | 425 | Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); |
@@ -662,17 +657,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
662 | 657 | ||
663 | // If the PID Controller isn't active then we set our force | 658 | // If the PID Controller isn't active then we set our force |
664 | // calculating base velocity to the current position | 659 | // calculating base velocity to the current position |
665 | if (Environment.OSVersion.Platform == PlatformID.Unix) | 660 | |
666 | { | ||
667 | PID_D = 3200.0f; | ||
668 | PID_P = 1400.0f; | ||
669 | } | ||
670 | else | ||
671 | { | ||
672 | PID_D = 2200.0f; | ||
673 | PID_P = 900.0f; | ||
674 | } | ||
675 | |||
676 | 661 | ||
677 | if (m_pidControllerActive == false) | 662 | if (m_pidControllerActive == false) |
678 | { | 663 | { |
@@ -686,11 +671,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
686 | 671 | ||
687 | if (!m_alwaysRun) | 672 | if (!m_alwaysRun) |
688 | { | 673 | { |
689 | movementdivisor = 1.3f; | 674 | movementdivisor = walkDivisor; |
690 | } | 675 | } |
691 | else | 676 | else |
692 | { | 677 | { |
693 | movementdivisor = 0.8f; | 678 | movementdivisor = runDivisor; |
694 | } | 679 | } |
695 | 680 | ||
696 | // if velocity is zero, use position control; otherwise, velocity control | 681 | // if velocity is zero, use position control; otherwise, velocity control |
@@ -830,11 +815,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
830 | _velocity.Y = (vec.Y); | 815 | _velocity.Y = (vec.Y); |
831 | 816 | ||
832 | _velocity.Z = (vec.Z); | 817 | _velocity.Z = (vec.Z); |
818 | |||
833 | if (_velocity.Z < -6 && !m_hackSentFall) | 819 | if (_velocity.Z < -6 && !m_hackSentFall) |
834 | { | 820 | { |
835 | // Collisionupdates will be used in the future, right now the're not being used. | ||
836 | m_hackSentFall = true; | 821 | m_hackSentFall = true; |
837 | //base.SendCollisionUpdate(new CollisionEventUpdate()); | ||
838 | m_pidControllerActive = false; | 822 | m_pidControllerActive = false; |
839 | } | 823 | } |
840 | else if (flying && !m_hackSentFly) | 824 | else if (flying && !m_hackSentFly) |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 873abc7..d795e45 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -166,6 +166,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
166 | private float mAvatarObjectContactBounce = 0.1f; | 166 | private float mAvatarObjectContactBounce = 0.1f; |
167 | 167 | ||
168 | 168 | ||
169 | private float avPIDD = 3200f; | ||
170 | private float avPIDP = 1400f; | ||
171 | private float avCapRadius = 0.37f; | ||
172 | private float avStandupTensor = 2000000f; | ||
173 | private float avDensity = 80f; | ||
174 | private float avHeightFudgeFactor = 0.52f; | ||
175 | private float avMovementDivisorWalk = 1.3f; | ||
176 | private float avMovementDivisorRun = 0.8f; | ||
177 | |||
178 | |||
169 | private float[] _heightmap; | 179 | private float[] _heightmap; |
170 | 180 | ||
171 | private float[] _watermap; | 181 | private float[] _watermap; |
@@ -271,6 +281,21 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
271 | { | 281 | { |
272 | mesher = meshmerizer; | 282 | mesher = meshmerizer; |
273 | m_config = config; | 283 | m_config = config; |
284 | // Defaults | ||
285 | |||
286 | if (Environment.OSVersion.Platform == PlatformID.Unix) | ||
287 | { | ||
288 | avPIDD = 3200.0f; | ||
289 | avPIDP = 1400.0f; | ||
290 | avStandupTensor = 2000000f; | ||
291 | } | ||
292 | else | ||
293 | { | ||
294 | avPIDD = 2200.0f; | ||
295 | avPIDP = 900.0f; | ||
296 | avStandupTensor = 550000f; | ||
297 | } | ||
298 | |||
274 | if (m_config != null) | 299 | if (m_config != null) |
275 | { | 300 | { |
276 | IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; | 301 | IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; |
@@ -306,6 +331,26 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
306 | ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f); | 331 | ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f); |
307 | m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10); | 332 | m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10); |
308 | 333 | ||
334 | avDensity = physicsconfig.GetFloat("av_density", 80f); | ||
335 | avHeightFudgeFactor = physicsconfig.GetFloat("av_height_fudge_factor", 0.52f); | ||
336 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f); | ||
337 | avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); | ||
338 | avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); | ||
339 | |||
340 | if (Environment.OSVersion.Platform == PlatformID.Unix) | ||
341 | { | ||
342 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 3200.0f); | ||
343 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 1400.0f); | ||
344 | avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_linux", 2000000f); | ||
345 | } | ||
346 | else | ||
347 | { | ||
348 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f); | ||
349 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); | ||
350 | avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f); | ||
351 | } | ||
352 | |||
353 | |||
309 | } | 354 | } |
310 | 355 | ||
311 | } | 356 | } |
@@ -1054,7 +1099,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1054 | pos.X = position.X; | 1099 | pos.X = position.X; |
1055 | pos.Y = position.Y; | 1100 | pos.Y = position.Y; |
1056 | pos.Z = position.Z; | 1101 | pos.Z = position.Z; |
1057 | OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode, size); | 1102 | OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, avHeightFudgeFactor, avMovementDivisorWalk, avMovementDivisorRun); |
1058 | _characters.Add(newAv); | 1103 | _characters.Add(newAv); |
1059 | return newAv; | 1104 | return newAv; |
1060 | } | 1105 | } |
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 72462c3..43bf251 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -207,6 +207,41 @@ m_avatarobjectcontact_bounce = 0.1 | |||
207 | objectcontact_friction = 250.0 | 207 | objectcontact_friction = 250.0 |
208 | objectcontact_bounce = 0.2 | 208 | objectcontact_bounce = 0.2 |
209 | 209 | ||
210 | ; # Avatar Control | ||
211 | |||
212 | ; PID Controller Settings. These affect the math that causes the avatar to reach the | ||
213 | |||
214 | av_pid_derivative_linux = 3200.0 | ||
215 | av_pid_proportional_linux = 1400.0 | ||
216 | |||
217 | av_pid_derivative_win = 2200.0 | ||
218 | av_pid_proportional_win = 900.0; | ||
219 | |||
220 | |||
221 | ;girth of the avatar. Adds radius to the height also | ||
222 | av_capsule_radius = 0.37 | ||
223 | |||
224 | ; Max force permissible to use to keep the avatar standing up straight | ||
225 | av_capsule_standup_tensor_win = 550000 | ||
226 | av_capsule_standup_tensor_linux = 2000000 | ||
227 | |||
228 | ; used to calculate mass of avatar. | ||
229 | ; float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH); | ||
230 | ; av_density * AVvolume; | ||
231 | |||
232 | av_density = 80 | ||
233 | |||
234 | ; use this value to cut 52% of the height the sim gives us | ||
235 | av_height_fudge_factor = 0.52 | ||
236 | |||
237 | ; Movement. Smaller is faster. | ||
238 | |||
239 | ; speed of movement with Always Run off | ||
240 | av_movement_divisor_walk = 1.3 | ||
241 | |||
242 | ; speed of movement with Always Run on | ||
243 | av_movement_divisor_run = 0.8 | ||
244 | |||
210 | 245 | ||
211 | [RemoteAdmin] | 246 | [RemoteAdmin] |
212 | enabled = false | 247 | enabled = false |