aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules
diff options
context:
space:
mode:
authorUbitUmarov2019-01-31 17:25:18 +0000
committerUbitUmarov2019-01-31 17:25:18 +0000
commit9046e5cb9d5473fbd702eee5cb1403779c632ff6 (patch)
tree335e4b2897d14329cccdd8f1f921be29956de242 /OpenSim/Region/PhysicsModules
parentremove MRM module (minimodule). Its outdated and we have no maintainers. Than... (diff)
downloadopensim-SC-9046e5cb9d5473fbd702eee5cb1403779c632ff6.zip
opensim-SC-9046e5cb9d5473fbd702eee5cb1403779c632ff6.tar.gz
opensim-SC-9046e5cb9d5473fbd702eee5cb1403779c632ff6.tar.bz2
opensim-SC-9046e5cb9d5473fbd702eee5cb1403779c632ff6.tar.xz
ubode add position to pid control it stopped flying to prevent slow drifts
Diffstat (limited to 'OpenSim/Region/PhysicsModules')
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs56
1 files changed, 30 insertions, 26 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
index 5320912..7ad5e3d 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
@@ -1435,37 +1435,41 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1435 1435
1436 if(!m_freemove) 1436 if(!m_freemove)
1437 { 1437 {
1438
1439 // if velocity is zero, use position control; otherwise, velocity control 1438 // if velocity is zero, use position control; otherwise, velocity control
1440 if(tviszero && m_iscolliding && !m_flying) 1439 if(tviszero)
1441 { 1440 {
1442 // keep track of where we stopped. No more slippin' & slidin' 1441 if(m_iscolliding || m_flying)
1443 if(!_zeroFlag)
1444 { 1442 {
1445 _zeroFlag = true; 1443 // keep track of where we stopped. No more slippin' & slidin'
1446 _zeroPosition = localpos; 1444 if (!_zeroFlag)
1445 {
1446 _zeroFlag = true;
1447 _zeroPosition = localpos;
1448 }
1449 if(m_pidControllerActive)
1450 {
1451 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1452 // react to the physics scene by moving it's position.
1453 // Avatar to Avatar collisions
1454 // Prim to avatar collisions
1455
1456 vec.X = -vel.X * PID_D * 2f + (_zeroPosition.X - localpos.X) * (PID_P * 5);
1457 vec.Y = -vel.Y * PID_D * 2f + (_zeroPosition.Y - localpos.Y) * (PID_P * 5);
1458 if(vel.Z > 0)
1459 vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
1460 else
1461 vec.Z += (-vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P) * 0.2f;
1462 }
1447 } 1463 }
1448 if(m_pidControllerActive) 1464 else
1449 { 1465 {
1450 // We only want to deactivate the PID Controller if we think we want to have our surrogate 1466 _zeroFlag = false;
1451 // react to the physics scene by moving it's position. 1467 vec.X += (ctz.X - vel.X) * PID_D * 0.833f;
1452 // Avatar to Avatar collisions 1468 vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f;
1453 // Prim to avatar collisions 1469 // hack for breaking on fall
1454 1470 if (ctz.Z == -9999f)
1455 vec.X = -vel.X * PID_D * 2f + (_zeroPosition.X - localpos.X) * (PID_P * 5); 1471 vec.Z += -vel.Z * PID_D - m_parent_scene.gravityz * m_mass;
1456 vec.Y = -vel.Y * PID_D * 2f + (_zeroPosition.Y - localpos.Y) * (PID_P * 5);
1457 if(vel.Z > 0)
1458 vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
1459 else
1460 vec.Z += (-vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P) * 0.2f;
1461 /*
1462 if (flying)
1463 {
1464 vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
1465 }
1466 */
1467 } 1472 }
1468 //PidStatus = true;
1469 } 1473 }
1470 else 1474 else
1471 { 1475 {
@@ -1539,7 +1543,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1539 vec.X += (ctz.X - vel.X) * PID_D * 0.833f; 1543 vec.X += (ctz.X - vel.X) * PID_D * 0.833f;
1540 vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f; 1544 vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f;
1541 // hack for breaking on fall 1545 // hack for breaking on fall
1542 if(ctz.Z == -9999f) 1546 if (ctz.Z == -9999f)
1543 vec.Z += -vel.Z * PID_D - m_parent_scene.gravityz * m_mass; 1547 vec.Z += -vel.Z * PID_D - m_parent_scene.gravityz * m_mass;
1544 } 1548 }
1545 } 1549 }