Page 1 of 1

Bouncy physics / Objects passing through world

Posted: Thu Oct 30, 2014 9:34 pm
by Silverlan
I've recently switched from PhysX to bullet (v2.82) and so far everthing's been fairly straight-forward and working great.

However, there is one issue where dynamic objects bounce 'into' static objects. I think this video shows fairly well what I mean:
http://youtu.be/KKN7wEWefAo

If you pause at 0:03, you can see the box passing into the floor for a split second, then it detangles itself. Sometimes it even passes through the floor entirely. This also happens with the player controller. (Capsule controller)

Now, I believe the reason for this is because my physics environment is very large and I'm dealing with high velocities.
The box is being pushed down using applyCentralForce before every simulation step with a force of (0,-600,0). (The time scale in the video has been slowed down to half the speed to show the 'bouncing' properly.). The AABB for the box in the video is (63.92,-576.08,-0.08),(104.08,-535.92,40.08).

I've had problems due to the scale of my world with PhysX as well, but PhysX allowed me to compensate.
Is there anything I can do about this in bullet, without having to shrink all of my physics objects?

Re: Bouncy physics / Objects passing through world

Posted: Fri Oct 31, 2014 2:10 am
by LEgregius
Have you tried to run with doubles? I had a very large world using PhysX years ago, and I had to use doubles in Bullet.

Re: Bouncy physics / Objects passing through world

Posted: Fri Oct 31, 2014 4:07 pm
by Silverlan
I just tried it, but there seems to be no difference:
http://youtu.be/D8nTOlCTkkQ

Here's my code for initializing the world:

Code: Select all

	m_btCollisionConfiguration = new btDefaultCollisionConfiguration();
	m_btDispatcher = new btCollisionDispatcher(m_btCollisionConfiguration);
	m_btOverlappingPairCache = new btDbvtBroadphase();
	m_btGhostPairCallback = new btGhostPairCallback;
	m_btOverlappingPairCache->getOverlappingPairCache()->setInternalGhostPairCallback(m_btGhostPairCallback);
	m_btSolver = new btSequentialImpulseConstraintSolver;

	m_btWorld = new btSoftRigidDynamicsWorld(m_btDispatcher,m_btOverlappingPairCache,m_btSolver,m_btCollisionConfiguration);
	m_btWorld->setGravity(btVector3(0.f,0.f,0.f));
Initializing the rigid body ('mass' is 1):

Code: Select all

			btConvexHullShape *shape = mesh->GetHullShape();

			btVector3 localInertia(0.f,0.f,0.f);
			shape->calculateLocalInertia(mass,localInertia);

			btTransform startTransform;
			startTransform.setIdentity();
			startTransform.setOrigin(origin);
			btScalar contactProcessingThreshold = BT_LARGE_FLOAT;
			btRigidBody *body = new btRigidBody(mass,NULL,shape,localInertia);
			body->setWorldTransform(startTransform);
			body->setContactProcessingThreshold(contactProcessingThreshold);
			int flags = body->getFlags();
			if(mass == 0.f)
				flags |= btCollisionObject::CF_STATIC_OBJECT;
			body->setCollisionFlags(flags);
			btSoftRigidDynamicsWorld *physEnv = game->GetPhysicsEnvironment();
			physEnv->addRigidBody(body);
The shape is a simple box.

Re: Bouncy physics / Objects passing through world

Posted: Mon Nov 03, 2014 12:39 am
by StabInTheDark
You need to build Bullet for double precision.

You will also need to scale to keep within Bullet scale.
http://www.bulletphysics.org/mediawiki- ... _The_World

Also too prevent tunneling
http://www.bulletphysics.org/mediawiki- ... n_Clamping

I have done these 3 steps with good results.