The sweep in stepDown looks like this.
Code: Select all
if (m_useGhostObjectSweepTest)
{
m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
} else
{
collisionWorld->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
}
It passes in the m_allowedCcdPenetration value, which defaults to 0.04.
What I believe is happening is that this sweep results the kinematic body interpenetrating the ground, which results in a collision detection the next frame, which then pushes the body out from the incline laterally, so that the next call to stepDown causes it to fall a bit more, etc.
if I either change the code to look like this:
Code: Select all
if (m_useGhostObjectSweepTest)
{
m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, 0.0);
} else
{
collisionWorld->convexSweepTest (m_convexShape, start, end, callback, 0.0);
}
or add
Code: Select all
m_currentPosition[m_upAxis] += collisionWorld->getDispatchInfo().m_allowedCcdPenetration;
to the bottom the function, i.e. moving it up to account for the penetration, body no longer slides down the hill.
I assume the first solution is preferred unless you have a better option on how to fix it.