btKinematicCharacterController slides down hills in 2.78.

LEgregius
Posts: 26
Joined: Tue Oct 14, 2008 1:34 am

btKinematicCharacterController slides down hills in 2.78.

Post by LEgregius »

btKinematicCharacterController character can't stand on a hill of any incline in 2.78. This was not an issue in 2.77. While there were not changes in the btKinematicCharacterController code aside from a one liner that is irrelevant, the sweep test seems to work a bit differently.

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.
LEgregius
Posts: 26
Joined: Tue Oct 14, 2008 1:34 am

Re: btKinematicCharacterController slides down hills in 2.78

Post by LEgregius »

The more I think about it, the more I think that the version where it moves the current position back up by the interpenetration amount is better because that would allow the volume to interpenetrate along the sides as well, giving the body some fuzz, but at the same time, if the body ends up interpenetrating something, it will end up pushing itself out in the next collision, which could cause some unintended results. I suppose it would also be worthwhile to change all of the other sweep tests in the code if this one ends up changed.

Either way, I would appreciate some feedback.
Zern
Posts: 4
Joined: Fri Jun 03, 2011 3:21 am

Re: btKinematicCharacterController slides down hills in 2.78

Post by Zern »

LEgregius,

I was just having this EXACT problem and was uploading a video to youtube (http://www.youtube.com/watch?v=TKNRGYrHqOQ - ironically) ... read over your post and it got me thinking,... I went back to the CharacterDemo and looked for anything that had to deal with the allowedCcdPenetration .. and found this sniplet that I didn't add in my "initPhysics" function (where you create the dispatcher, solver, broadphase, etc)

Code: Select all

m_pDynamicsWorld->getDispatchInfo().m_allowedCcdPenetration=0.0001f;
:) works like a charm now. I hope this helps you or anyone else having this issue.

-David
LEgregius
Posts: 26
Joined: Tue Oct 14, 2008 1:34 am

Re: btKinematicCharacterController slides down hills in 2.78

Post by LEgregius »

Yes, that works, but it's a bug that it slides down the hill regardless of whether you can fix it by modifying that variable. And it certainly should "work" with the default settings. That also affects everything else that uses the ccd sweeps, and I may not want to change the default for everything.