aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorTeravus Ovares2007-12-15 05:08:08 +0000
committerTeravus Ovares2007-12-15 05:08:08 +0000
commit81828c9b145c1d5da36559c32559cf89d414287b (patch)
tree6b2849fbd264962d6c1ca28890300d49e941648f /OpenSim/Region/Physics/OdePlugin
parentGrid Inventory feature upgrade: renaming folders should now be correct, subfo... (diff)
downloadopensim-SC-81828c9b145c1d5da36559c32559cf89d414287b.zip
opensim-SC-81828c9b145c1d5da36559c32559cf89d414287b.tar.gz
opensim-SC-81828c9b145c1d5da36559c32559cf89d414287b.tar.bz2
opensim-SC-81828c9b145c1d5da36559c32559cf89d414287b.tar.xz
* Added an Avatar control tweak that disables the PID controller in certain circumstances.
* This allows collisions with other avatar and prim with a velocity greater then 0 to push avatar around.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs64
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs12
2 files changed, 55 insertions, 21 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 2e694b6..6f22ecf 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -46,6 +46,7 @@ namespace OpenSim.Region.Physics.OdePlugin
46 private PhysicsVector _target_velocity; 46 private PhysicsVector _target_velocity;
47 private PhysicsVector _acceleration; 47 private PhysicsVector _acceleration;
48 private PhysicsVector m_rotationalVelocity; 48 private PhysicsVector m_rotationalVelocity;
49 private bool m_pidControllerActive = true;
49 private static float PID_D = 3020.0f; 50 private static float PID_D = 3020.0f;
50 private static float PID_P = 7000.0f; 51 private static float PID_P = 7000.0f;
51 private static float POSTURE_SERVO = 10000.0f; 52 private static float POSTURE_SERVO = 10000.0f;
@@ -56,6 +57,8 @@ namespace OpenSim.Region.Physics.OdePlugin
56 private bool m_iscollidingGround = false; 57 private bool m_iscollidingGround = false;
57 private bool m_wascolliding = false; 58 private bool m_wascolliding = false;
58 private bool m_wascollidingGround = false; 59 private bool m_wascollidingGround = false;
60 private bool m_iscollidingObj = false;
61 private bool m_wascollidingObj = false;
59 private bool m_alwaysRun = false; 62 private bool m_alwaysRun = false;
60 private bool m_hackSentFall = false; 63 private bool m_hackSentFall = false;
61 private bool m_hackSentFly = false; 64 private bool m_hackSentFly = false;
@@ -165,10 +168,13 @@ namespace OpenSim.Region.Physics.OdePlugin
165 else 168 else
166 { 169 {
167 m_iscolliding = true; 170 m_iscolliding = true;
171
172
168 } 173 }
169 if (m_wascolliding != m_iscolliding) 174 if (m_wascolliding != m_iscolliding)
170 { 175 {
171 base.SendCollisionUpdate(new CollisionEventUpdate()); 176 base.SendCollisionUpdate(new CollisionEventUpdate());
177
172 } 178 }
173 m_wascolliding = m_iscolliding; 179 m_wascolliding = m_iscolliding;
174 } 180 }
@@ -222,8 +228,14 @@ namespace OpenSim.Region.Physics.OdePlugin
222 } 228 }
223 public override bool CollidingObj 229 public override bool CollidingObj
224 { 230 {
225 get { return false; } 231 get { return m_iscollidingObj; }
226 set { return; } 232 set {
233 m_iscollidingObj = value;
234 if (value)
235 m_pidControllerActive = false;
236 else
237 m_pidControllerActive = true;
238 }
227 } 239 }
228 240
229 public override PhysicsVector Position 241 public override PhysicsVector Position
@@ -248,6 +260,7 @@ namespace OpenSim.Region.Physics.OdePlugin
248 get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } 260 get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
249 set 261 set
250 { 262 {
263 m_pidControllerActive = true;
251 lock (OdeScene.OdeLock) 264 lock (OdeScene.OdeLock)
252 { 265 {
253 PhysicsVector SetSize = value; 266 PhysicsVector SetSize = value;
@@ -282,7 +295,9 @@ namespace OpenSim.Region.Physics.OdePlugin
282 public override PhysicsVector Velocity 295 public override PhysicsVector Velocity
283 { 296 {
284 get { return _velocity; } 297 get { return _velocity; }
285 set { _target_velocity = value; } 298 set {
299 m_pidControllerActive = true;
300 _target_velocity = value; }
286 } 301 }
287 302
288 public override bool Kinematic 303 public override bool Kinematic
@@ -304,12 +319,13 @@ namespace OpenSim.Region.Physics.OdePlugin
304 319
305 public void SetAcceleration(PhysicsVector accel) 320 public void SetAcceleration(PhysicsVector accel)
306 { 321 {
322 m_pidControllerActive = true;
307 _acceleration = accel; 323 _acceleration = accel;
308 } 324 }
309 325
310 public override void AddForce(PhysicsVector force) 326 public override void AddForce(PhysicsVector force)
311 { 327 {
312 328 m_pidControllerActive = true;
313 _target_velocity.X += force.X; 329 _target_velocity.X += force.X;
314 _target_velocity.Y += force.Y; 330 _target_velocity.Y += force.Y;
315 _target_velocity.Z += force.Z; 331 _target_velocity.Z += force.Z;
@@ -346,6 +362,12 @@ namespace OpenSim.Region.Physics.OdePlugin
346 public void Move(float timeStep) 362 public void Move(float timeStep)
347 { 363 {
348 // no lock; for now it's only called from within Simulate() 364 // no lock; for now it's only called from within Simulate()
365 if (m_pidControllerActive == false)
366 {
367 _zeroPosition = d.BodyGetPosition(Body);
368 }
369 //PidStatus = true;
370
349 PhysicsVector vec = new PhysicsVector(); 371 PhysicsVector vec = new PhysicsVector();
350 d.Vector3 vel = d.BodyGetLinearVel(Body); 372 d.Vector3 vel = d.BodyGetLinearVel(Body);
351 float movementdivisor = 1f; 373 float movementdivisor = 1f;
@@ -369,17 +391,21 @@ namespace OpenSim.Region.Physics.OdePlugin
369 _zeroFlag = true; 391 _zeroFlag = true;
370 _zeroPosition = d.BodyGetPosition(Body); 392 _zeroPosition = d.BodyGetPosition(Body);
371 } 393 }
372 d.Vector3 pos = d.BodyGetPosition(Body); 394 if (m_pidControllerActive)
373 vec.X = (_target_velocity.X - vel.X) * PID_D + (_zeroPosition.X - pos.X) * PID_P;
374 vec.Y = (_target_velocity.Y - vel.Y) * PID_D + (_zeroPosition.Y - pos.Y) * PID_P;
375 if (flying)
376 { 395 {
377 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100) + (_zeroPosition.Z - pos.Z) * PID_P; 396 d.Vector3 pos = d.BodyGetPosition(Body);
397 vec.X = (_target_velocity.X - vel.X) * PID_D + (_zeroPosition.X - pos.X) * PID_P;
398 vec.Y = (_target_velocity.Y - vel.Y) * PID_D + (_zeroPosition.Y - pos.Y) * PID_P;
399 if (flying)
400 {
401 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100) + (_zeroPosition.Z - pos.Z) * PID_P;
402 }
378 } 403 }
404 //PidStatus = true;
379 } 405 }
380 else 406 else
381 { 407 {
382 408 m_pidControllerActive = true;
383 _zeroFlag = false; 409 _zeroFlag = false;
384 if (m_iscolliding || flying) 410 if (m_iscolliding || flying)
385 { 411 {
@@ -455,14 +481,15 @@ namespace OpenSim.Region.Physics.OdePlugin
455 base.RequestPhysicsterseUpdate(); 481 base.RequestPhysicsterseUpdate();
456 string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); 482 string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
457 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); 483 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
458 if (primScenAvatarIn == "0") 484 //if (primScenAvatarIn == "0")
459 { 485 //{
460 MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); 486 //MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
461 } 487 //}
462 else 488 //else
463 { 489 //{
464 MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); 490 // MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
465 } 491 //}
492
466 } 493 }
467 } 494 }
468 else 495 else
@@ -477,6 +504,7 @@ namespace OpenSim.Region.Physics.OdePlugin
477 { 504 {
478 m_hackSentFall = true; 505 m_hackSentFall = true;
479 base.SendCollisionUpdate(new CollisionEventUpdate()); 506 base.SendCollisionUpdate(new CollisionEventUpdate());
507 m_pidControllerActive = false;
480 } 508 }
481 else if (flying && !m_hackSentFly) 509 else if (flying && !m_hackSentFly)
482 { 510 {
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index a765878..0cbd4d6 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -127,7 +127,7 @@ namespace OpenSim.Region.Physics.OdePlugin
127 contact.surface.bounce = 0.2f; 127 contact.surface.bounce = 0.2f;
128 128
129 TerrainContact.surface.mode |= d.ContactFlags.SoftERP; 129 TerrainContact.surface.mode |= d.ContactFlags.SoftERP;
130 TerrainContact.surface.mu = 250.0f; 130 TerrainContact.surface.mu = 550.0f;
131 TerrainContact.surface.bounce = 0.1f; 131 TerrainContact.surface.bounce = 0.1f;
132 TerrainContact.surface.soft_erp = 0.1025f; 132 TerrainContact.surface.soft_erp = 0.1025f;
133 133
@@ -255,7 +255,7 @@ namespace OpenSim.Region.Physics.OdePlugin
255 PhysicsActor p1; 255 PhysicsActor p1;
256 PhysicsActor p2; 256 PhysicsActor p2;
257 257
258 if (!actor_name_map.TryGetValue(g2, out p1)) 258 if (!actor_name_map.TryGetValue(g1, out p1))
259 { 259 {
260 p1 = PANull; 260 p1 = PANull;
261 } 261 }
@@ -267,16 +267,22 @@ namespace OpenSim.Region.Physics.OdePlugin
267 // We only need to test p2 for 'jump crouch purposes' 267 // We only need to test p2 for 'jump crouch purposes'
268 p2.IsColliding = true; 268 p2.IsColliding = true;
269 269
270
271
270 switch(p1.PhysicsActorType) { 272 switch(p1.PhysicsActorType) {
271 case (int)ActorTypes.Agent: 273 case (int)ActorTypes.Agent:
272 p2.CollidingObj = true; 274 p2.CollidingObj = true;
273 break; 275 break;
274 case (int)ActorTypes.Prim: 276 case (int)ActorTypes.Prim:
275 p2.CollidingObj = true; 277 if (p2.Velocity.X >0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0)
278 p2.CollidingObj = true;
276 break; 279 break;
277 case (int)ActorTypes.Unknown: 280 case (int)ActorTypes.Unknown:
278 p2.CollidingGround = true; 281 p2.CollidingGround = true;
279 break; 282 break;
283 default:
284 p2.CollidingGround = true;
285 break;
280 } 286 }
281 287
282 if (name1 == "Terrain" || name2 == "Terrain") 288 if (name1 == "Terrain" || name2 == "Terrain")