Item Capsule Falls Through Ground When Stepped On

Esenthel
Posts: 3
Joined: Sun Jul 04, 2010 9:24 am

Item Capsule Falls Through Ground When Stepped On

Post by Esenthel »

Hi, I'm adding support in my engine (http://www.esenthel.com) for Bullet.

I've encountered an issue, when stepping on items, they sometimes fall through the ground.

Screen:
Image

Movie:
Issue at 00:26 seconds - http://www.esenthel.com/download/temp/b ... hrough.mp4

Details:
ground is a static BVH triangle mesh
item is dynamic capsule shape
character is also dynamic capsule shape (my custom implementation of character controller, to which I manually apply velocities)

Any ideas what I could do to make the item not fall through ground?

I've tried adjusting the Item Capsule Body:
getCollisionShape()->setMargin(..) values from 0, 0.00001, 0.001, 0.1, 0.5
setCcdSweptSphereRadius(..); values from 0, 0.00001, 0.001, 0.1, 0.5
setCcdMotionThreshold(0.00001f);

I've also tried commenting out the requirement for CCD that objects aren't in contact

Code: Select all

	virtual bool needsCollision(btBroadphaseProxy* proxy0) const
	{
		//don't collide with itself
		if (proxy0->m_clientObject == m_me)
			return false;

		///don't do CCD when the collision filters are not matching
		if (!ClosestConvexResultCallback::needsCollision(proxy0))
			return false;

		btCollisionObject* otherObj = (btCollisionObject*) proxy0->m_clientObject;

		//call needsResponse, see http://code.google.com/p/bullet/issues/detail?id=179
		/*if (m_dispatcher->needsResponse(m_me,otherObj))
		{
			///don't do CCD when there are already contact points (touching contact/penetration)
			btAlignedObjectArray<btPersistentManifold*> manifoldArray;
			btBroadphasePair* collisionPair = m_pairCache->findPair(m_me->getBroadphaseHandle(),proxy0);
			if (collisionPair)
			{
				if (collisionPair->m_algorithm)
				{
					manifoldArray.resize(0);
					collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);
					for (int j=0;j<manifoldArray.size();j++)
					{
						btPersistentManifold* manifold = manifoldArray[j];
						if (manifold->getNumContacts()>0)
							return false;
					}
				}
			}
		}*/
		return true;
	}
But none of the settings helped, and item still falls through ground occasionally.

Any advice what can I do?

Thanks
Norbo
Posts: 5
Joined: Tue Nov 06, 2007 8:52 am

Re: Item Capsule Falls Through Ground When Stepped On

Post by Norbo »

I'm not intimately familiar with Bullet, but that video shows what looks like common behavior when a light object gets squished by a heavy object (you can search about mass ratios for more information).

CCD can only do so much once things start getting squished. While I'm not sure about the available implementations in Bullet, most implementations do not guarantee that interpenetration is impossible (it's very hard and almost always results in other problems, like freezing).

You could try changing the masses of the involved bodies so that they're more similar (assuming that your character is indeed applying dynamic collision impulses). Some character controller implementations float over the ground and either do not apply any forces to what they're standing on, or apply a 'fake' manually calculated impulse that can be precisely controlled.

Sometimes, to avoid the problem entirely, small light props are set so they simply don't interact with things that would squish them.
jbiggs
Posts: 3
Joined: Mon Sep 14, 2009 6:12 pm

Re: Item Capsule Falls Through Ground When Stepped On

Post by jbiggs »

I have had pretty good luck dealing with object / terrain tunneling by dynamically shifting the ERP values of the btDiscreteDynamicsWorld solver (m_erp and m_erp2) at runtime.

Note that I am running Bullet 2.75.

Here are me experiences:

I find a tradeoff between my simulated vehicle's overall jitter vs. ability to reduce tunneling. In my case, when my vehicle (robot) is nearly still I set ERP low (e.g. ~ 0.1) which seems to settle down the body. When the vehicle is in motion I raise the ERP a bit (e.g. 0.6 to 1.0) based on speed to reduce the possibility of tunneling small objects into the terrain.

You may be able to set ERP and leave it there for simple body cases. I dynamically adjust because my robot is a compound object with a substantial number of joints.

jeff