* btKinematicCharacterController problems, again. *

Enlight
Posts: 8
Joined: Tue May 05, 2009 8:35 pm

* btKinematicCharacterController problems, again. *

Post by Enlight »

I've been working on my own implementation of btKinematicCharacterController for 2 months now. I resolved almost all problems but there is one problem that is driving me crazy. First of all, the scene in which I'm working on is composed of:

- One btHeightfieldTerrainShape.
- One btPairCachingGhostObject with a btCapsuleShape as the "character".
- Many btBvhTriangleMeshShape or btConvexHullShape-

In certain conditions, convexSweepTest fails randomly with btBvhTriangleMeshShape / btConvexHullShape objects, that is: hits perfectly in one position but fails completely at the next millimeter. The result is the well known jittering or even tunneling. This problem happends specially with large objects (20 meter wall with only 2 faces for example) and when the player is VERY close to these objects. Thats why I implemented a skin width (additional to the shape's margin) to keep objects separated from each other.

But even with an additional space, convexSweepTest failed, the *only* solution that worked fine was increasing the object margin, but increasing the margin to half a meter (.5f) so the convexSweep always work with large objects, produced some undesired side effects on smaller ones. With .5f of shape margin, collision with smaller objects begin to fail and produce jittering AGAIN.

I'm tired now of playing with margin and skins widths, and trying to find a balance between them. When I manage to stabilize the collision of certain type of objects its begin to fail on other ones.

Did anyone managed to implement a STABLE Kinematic Character Controller ?

And to bullet developers, why is convexSweepTest failing in certain conditions ? I really want to improve the kinematic character controller but I cannot find the problem and why MARGIN makes a BIG difference...? I'm sure that finding the "correct" value for the margin is *not* the solution to this problem.

And one more question, if convex sweep worked flawlessly, why do we need a "recoverFromPenetration()" in the first place ?

Thanks!
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: * btKinematicCharacterController problems, again. *

Post by ola »

I have found that when the distance between the two transforms in a convexSweepTest is too small, the test fails. It also fails when the two transforms are equal. I think it starts working at something around 0.1 units, but I haven't done any more accurate tests to figure it out.

It used to work for all distances earlier I think, but changed some versions ago, maybe it was ok in 2.65.
Enlight
Posts: 8
Joined: Tue May 05, 2009 8:35 pm

Re: * btKinematicCharacterController problems, again. *

Post by Enlight »

was it ok in 2.65 ? I really need to try that version. If it works and I found the problem I'll be glad to upload a patch to fix that in 2.74.

btw, I already tried to sweep objects always from a distance by doing something like this:

Code: Select all

start.setOrigin (m_currentPosition + (direction * -0.1f)); // start sweep from at least some distance (0.1 units backwards)
end.setOrigin (m_targetPosition);
collisionWorld->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
It is not very elegant but will always perform a sweep test with at least a minimal magnitude (0.1), probably away from the collision objects.

Anyway, it didn't work for me. :(