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?
Bouncy physics / Objects passing through world
-
- Posts: 27
- Joined: Thu Oct 30, 2014 9:15 pm
-
- Posts: 26
- Joined: Tue Oct 14, 2008 1:34 am
Re: Bouncy physics / Objects passing through world
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.
-
- Posts: 27
- Joined: Thu Oct 30, 2014 9:15 pm
Re: Bouncy physics / Objects passing through world
I just tried it, but there seems to be no difference:
http://youtu.be/D8nTOlCTkkQ
Here's my code for initializing the world:
Initializing the rigid body ('mass' is 1):
The shape is a simple box.
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));
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);
-
- Posts: 29
- Joined: Sat May 18, 2013 1:36 am
- Location: NY
Re: Bouncy physics / Objects passing through world
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.
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.