OMV.Vector3 ComputeStairCorrection(float stepUp)
{
OMV.Vector3 ret = OMV.Vector3.Zero;
OMV.Vector3 displacement = OMV.Vector3.Zero;
if (stepUp > 0f)
{
// Found the stairs contact point. Push up a little to raise the character.
if (BSParam.AvatarStepForceFactor > 0f)
{
float upForce = stepUp * m_controllingPrim.Mass * BSParam.AvatarStepForceFactor;
ret = new OMV.Vector3(0f, 0f, upForce);
}
// Also move the avatar up for the new height
if (BSParam.AvatarStepUpCorrectionFactor > 0f)
{
// Move the avatar up related to the height of the collision
displacement = new OMV.Vector3(0f, 0f, stepUp * BSParam.AvatarStepUpCorrectionFactor);
m_controllingPrim.ForcePosition = m_controllingPrim.RawPosition + displacement;
} else
{
if (BSParam.AvatarStepUpCorrectionFactor < 0f)
{
// Move the avatar up about the specified step height
displacement = new OMV.Vector3(0f, 0f, BSParam.AvatarStepHeight);
m_controllingPrim.ForcePosition = m_controllingPrim.RawPosition + displacement;
}
}
m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs.ComputeStairCorrection,stepUp={1},isp={2},force={3}",
m_controllingPrim.LocalID, stepUp, displacement, ret);
}
return ret;
}
}