ubode add position to pid control it stopped flying to prevent slow drifts
parent
76b777b1fb
commit
9046e5cb9d
|
@ -1435,37 +1435,41 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
if(!m_freemove)
|
if(!m_freemove)
|
||||||
{
|
{
|
||||||
|
|
||||||
// if velocity is zero, use position control; otherwise, velocity control
|
// if velocity is zero, use position control; otherwise, velocity control
|
||||||
if(tviszero && m_iscolliding && !m_flying)
|
if(tviszero)
|
||||||
{
|
{
|
||||||
// keep track of where we stopped. No more slippin' & slidin'
|
if(m_iscolliding || m_flying)
|
||||||
if(!_zeroFlag)
|
|
||||||
{
|
{
|
||||||
_zeroFlag = true;
|
// keep track of where we stopped. No more slippin' & slidin'
|
||||||
_zeroPosition = localpos;
|
if (!_zeroFlag)
|
||||||
}
|
{
|
||||||
if(m_pidControllerActive)
|
_zeroFlag = true;
|
||||||
{
|
_zeroPosition = localpos;
|
||||||
// We only want to deactivate the PID Controller if we think we want to have our surrogate
|
}
|
||||||
// react to the physics scene by moving it's position.
|
if(m_pidControllerActive)
|
||||||
// Avatar to Avatar collisions
|
{
|
||||||
// Prim to avatar collisions
|
// We only want to deactivate the PID Controller if we think we want to have our surrogate
|
||||||
|
// react to the physics scene by moving it's position.
|
||||||
|
// Avatar to Avatar collisions
|
||||||
|
// Prim to avatar collisions
|
||||||
|
|
||||||
vec.X = -vel.X * PID_D * 2f + (_zeroPosition.X - localpos.X) * (PID_P * 5);
|
vec.X = -vel.X * PID_D * 2f + (_zeroPosition.X - localpos.X) * (PID_P * 5);
|
||||||
vec.Y = -vel.Y * PID_D * 2f + (_zeroPosition.Y - localpos.Y) * (PID_P * 5);
|
vec.Y = -vel.Y * PID_D * 2f + (_zeroPosition.Y - localpos.Y) * (PID_P * 5);
|
||||||
if(vel.Z > 0)
|
if(vel.Z > 0)
|
||||||
vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
|
vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
|
||||||
else
|
else
|
||||||
vec.Z += (-vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P) * 0.2f;
|
vec.Z += (-vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P) * 0.2f;
|
||||||
/*
|
}
|
||||||
if (flying)
|
}
|
||||||
{
|
else
|
||||||
vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
|
{
|
||||||
}
|
_zeroFlag = false;
|
||||||
*/
|
vec.X += (ctz.X - vel.X) * PID_D * 0.833f;
|
||||||
|
vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f;
|
||||||
|
// hack for breaking on fall
|
||||||
|
if (ctz.Z == -9999f)
|
||||||
|
vec.Z += -vel.Z * PID_D - m_parent_scene.gravityz * m_mass;
|
||||||
}
|
}
|
||||||
//PidStatus = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1539,7 +1543,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
vec.X += (ctz.X - vel.X) * PID_D * 0.833f;
|
vec.X += (ctz.X - vel.X) * PID_D * 0.833f;
|
||||||
vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f;
|
vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f;
|
||||||
// hack for breaking on fall
|
// hack for breaking on fall
|
||||||
if(ctz.Z == -9999f)
|
if (ctz.Z == -9999f)
|
||||||
vec.Z += -vel.Z * PID_D - m_parent_scene.gravityz * m_mass;
|
vec.Z += -vel.Z * PID_D - m_parent_scene.gravityz * m_mass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue