Kinematic Controller help

binofet
Posts: 20
Joined: Fri Jun 15, 2007 5:03 pm

Kinematic Controller help

Post by binofet »

Hello all,

I am using a capped cylinder flagged as a kinematic object for character controllers. I place the capsule based on player input and collide the object with all near objects and gather the normals and penetration depths. I then sum the vectors up and move the object there.

This works perfectly for all collisions that _don't_ include acute angles. The movement is smooth and the collision is perfect, I just dont see how to resolve acute collision without looping through collision until its out. Here is an image that visually describes the problem.

Image

Fig. A shows a top view of capsule colliding with two objects that form a 90deg angle, summing those penetration normals * depth results in a vector that perfect resolves collision.

Fig. B shows a top view of capsule collising with two objects that form an acute angle, summing that penetration data does not resolve the collision.

Thanks for any help you guys can give!

Bino
ryanjuckett
Posts: 13
Joined: Tue Mar 11, 2008 9:04 am

Re: Kinematic Controller help

Post by ryanjuckett »

One solution to this problem is checking your desired motion with a swept capsule before actually changing your position. This will allow you to move up to the corner and stop right where penetration would start.

Many games will just do a move and resolve penetration method similar to what you describe and will then make their collision surfaces in a manner that avoid problem cases. Sometimes special collision is also placed down that is only collidable by player motion to assist in a smoother player control.

If you need a very dynamic environment where these problem cases cannot be avoided, I would look into using the swept shape method.
binofet
Posts: 20
Joined: Fri Jun 15, 2007 5:03 pm

Re: Kinematic Controller help

Post by binofet »

Thanks for the fast reply Ryan.

The swept shape method you describe sounds like the ticket. Is there a feature in Bullet to provide this or am I looking at creating a new shape type. If you could point me to an example, I'd be much obliged.

Thanks again,

Bino
ryanjuckett
Posts: 13
Joined: Tue Mar 11, 2008 9:04 am

Re: Kinematic Controller help

Post by ryanjuckett »

I'm not sure if there is a capsule sweep function in Bullet. I know they are intending on releasing a kinematic controller demo that would have one or atleast do some form of aproximation. Given that there will be something coming and that writing swept collision tests can be a non-trivial task, for the time being you could just do bisection along your motion to find a close enough solution using the basic capsule interest test.

You can also try project backwards along your line of motion to remove penetration instead of projecting along the normal of the intersecting wall (which is what it looks like you are doing). This should get you closer to your desired solution.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Kinematic Controller help

Post by Erwin Coumans »

Is there a feature in Bullet to provide this or am I looking at creating a new shape type
Yes, check out btCollisionWorld:

Code: Select all

	// convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback
	// This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback.
	void    convexSweepTest (const btConvexShape* castShape, const btTransform& from, const btTransform& to, ConvexResultCallback& resultCallback, short int collisionFilterMask=-1);
This query handles any convex shape, including translation and rotation. This is what we will use for our upcoming kinematic character controller. It probably needs to be augmented with some penetration depth calculation, in case the character starts off in a penetrating situation.

Hope this helps,
Erwin