Collision pentration.

vidjogamer
Posts: 13
Joined: Thu Apr 29, 2010 11:59 pm

Collision pentration.

Post by vidjogamer »

I have a sphere on a plane. When I press a button I make the sphere "jump". Upon landing it penetrates the plane.

From my understanding this is exactly what continuous collision detection aims to prevent.
So I added this code:

Code: Select all

m_dynamicsWorld->getDispatchInfo().m_useContinuous=true;
While it is less frequent, the penetration still occurs.
Am I doing CCD correctly?

Is there anything else I can do to help the problem?



On another note, I dont quite understand the difference between forces and impulses.
And if I want to lock all my motion to the x and y axes, what is the best way to achieve this?

Thanks so much for your help, bullet is a fantastic library.
vidjogamer
Posts: 13
Joined: Thu Apr 29, 2010 11:59 pm

Re: Collision pentration.

Post by vidjogamer »

Ok, I tried changing my motion threshold to .1. I played with it for a good minute and havent had any penetration. Will this cause any other side effects I should know about? How much slower is it? Thanks!

Code: Select all

rigidBody->setCcdMotionThreshold(0.1);
MaxDZ8
Posts: 149
Joined: Fri Jun 24, 2011 8:53 am

Re: Collision pentration.

Post by MaxDZ8 »

You must be having very low performance. Personally I have not observed much of a benefit by using CCD - I manually sweep everything that is over a threshold. Is the sphere kinematic? You might have to disable deactivation.
vidjogamer
Posts: 13
Joined: Thu Apr 29, 2010 11:59 pm

Re: Collision pentration.

Post by vidjogamer »

Do you think you could provide a code snippet?

Im running on a very good machine, with a barebones simulation (ground plane, 1 falling rigid body).
MaxDZ8
Posts: 149
Joined: Fri Jun 24, 2011 8:53 am

Re: Collision pentration.

Post by MaxDZ8 »

If memory serves, to disable deactivation you do

Code: Select all

body->setActivationState(DISABLE_DEACTIVATION);
on the kinematic object.
It seems that bullet mangles kinematic objects much like static objects and therefore builds an aggressive cache. This will prevent that from happening. In my experience (hull vs hulls, hull vs boxes) the cache would get updated only every few frames at best, I had a lot of encroaching before but it's now gone.
Take care of slip errors,

Code: Select all

body->setActivationState(0);
is a different thing and won't work.