Page 1 of 1

Bullet collision failing with fast moving bodies

Posted: Thu Dec 23, 2021 8:55 pm
by paokakis
Hello, I am creating a 3D space shooter game using OpenGL and Bullet physics. I have a problem with fast moving projectiles. I am simulating a laser particle using a capsule shape. The problem is that this body penetrates objects some times and even pass through them, possibly because it is moving too fast for the physics engine. What can I do about that? Here is how I create the world :

Code: Select all

	mpBroadphase = new btDbvtBroadphase();
	// Set up the collision configuration and dispatcher
	mpCollisionConfiguration = new btDefaultCollisionConfiguration();
	mpDispatcher = new btCollisionDispatcher(mpCollisionConfiguration);
	// The actual physics solver
	mpSolver = new btSequentialImpulseConstraintSolver;
	// The world.
	mpDynamicsWorld = new btDiscreteDynamicsWorld(mpDispatcher, mpBroadphase, mpSolver, mpCollisionConfiguration);

Re: Bullet collision failing with fast moving bodies

Posted: Fri Dec 24, 2021 9:38 am
by paokakis
I found it. You need to make the body do constant collision detection like this:

Code: Select all

body.setCcdMotionThreshold(0.015f);
body.setCcdSweptSphereRadius(0.01f);