Search code examples
bulletphysics-enginebulletphysics

Character foot stuck to the floor using Bullet2.82


I'm using bullet 2.82 (double precision) with a fixed simulation time step of 1ms.

I use the following code to setup the world:

collision_config = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collision_config);

overlappingPairCache = new btDbvtBroadphase();

constraintSolver = new btSequentialImpulseConstraintSolver();

dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, overlappingPairCache, constraintSolver, collision_config);

dynamicsWorld->setGravity(btVector3(0, 0, -9.81));

btContactSolverInfo& solverInfo = dynamicsWorld->getSolverInfo();
solverInfo.m_numIterations = 2000;
solverInfo.m_globalCfm = 0.0;
solverInfo.m_erp = 0.2;
solverInfo.m_solverMode |= SOLVER_USE_2_FRICTION_DIRECTIONS;
solverInfo.m_sor = 1.3;
solverInfo.m_splitImpulse = 1;
solverInfo.m_splitImpulsePenetrationThreshold = -0.02;

For the character I use hinge constraints with angular motors.

Both floor and foot have a friction of 0.3.

This is a capture of my character trying to lift the left leg. The center of mass, is on the right leg, but the floor exerts a high force on the left foot (red arrow). You can actually see when the foot snaps free, right before it starts to fall.

I have no idea why this happens. Shouldn't friction only have an effect on movements on the xy-plane? So lifting the foot should always be possible, no matter how high the friction.

Trying to lift the left leg


Solution

  • I fixed the problem by using a primitive shape (btBoxShape) for the floor instead of using meshes for everything. Apparently mesh<->mesh collisions in bullet are a little bit fishy.