Bullet collision failing with fast moving bodies

Post Reply
paokakis
Posts: 29
Joined: Mon Jan 04, 2021 10:31 am

Bullet collision failing with fast moving bodies

Post 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);
paokakis
Posts: 29
Joined: Mon Jan 04, 2021 10:31 am

Re: Bullet collision failing with fast moving bodies

Post 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);
Post Reply