Objects penetration

mateas
Posts: 4
Joined: Sun Aug 11, 2013 10:24 pm

Objects penetration

Post by mateas »

Hi all,

I continue my work on a material structure simulation system as partialy mentioned in my previous post: http://www.bulletphysics.org/Bullet/php ... f=9&t=9334. Now I have a problem with strange penetration of particles defined with simple compound shapes based only on spheres representing particular atoms. To simplify everything sphere radius is automatically its mass and spheres positions around particle are positioned according to particle mass center. Unfortunately, when I simulate material structure I get particles penetrations (particular atoms from one particle penetrate atoms from other particles). I have tried to switch to multisphere shape but still no improvements. I was also trying to turn on CCD as I am applying various (random) impulses to particles to shuffle them in space, but either I do not understand CCD or it does not help in my case. I attach screen of a simple particle (2 identical atoms), effect of simulated shuffeling.

I initialize simulation with:

Code: Select all

// atoms radius is in range 0.08 - 0.2, therefore we have scaled gravity
world->setGravity(btVector3(0.0, 0.0, -0.981));
// for multithread solver
world->getSimulationIslandManager()->setSplitIslands(false);
// limit number of iterations
world->getSolverInfo().m_numIterations = 4;
// enable multithreading
world->getDispatchInfo().m_enableSPU = true;
// use CCD
world->getDispatchInfo().m_useContinuous = true;
// limit CCD penetration
world->getDispatchInfo().m_allowedCcdPenetration = 0.001;
Next I create collision shape with:

Code: Select all

// number of spheres (atoms) in shape (particle)
unsigned int s = ...
// create and initialize positions (according to mass center)
btVector3 * positions = new btVector3[s];
// ...
// create and initialize radiuses
btScalar * radiuses = new btScalar[s];
//...
// particle mass as sum of atoms radius
double mass = ...;
// collision shape
auto collisionShape = new btMultiSphereShape(positions, radiuses, s);
// fall inertia
auto fallInertia = btVector3(0,0,0);
collisionShape->calculateLocalInertia(mass,fallInertia);
// smaller margin because of atom sizes
collisionShape->setMargin(0.001);
In the end I set up CCD for this collision shape with:

Code: Select all

// radius of bounding sphere for the particle
double r = ...
// set up CCD
fallRigidBody->setCcdMotionThreshold(r / 2.0);	
fallRigidBody->setCcdSweptSphereRadius(r / 2.0);
What is interesting - if I use just atoms represented with SphereShapes, without any Compound Shapes, everything works fine, although I create and set up everything as shown.

If anybody could help me to prevent those penetrations I would be very grateful. If any additional information is needed just ask - I will provide anything You need:)

Thanks in advance,
Mateusz
You do not have the required permissions to view the files attached to this post.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Objects penetration

Post by Basroil »

You're probably going to need a far larger number of simulation ticks per second for objects that small. And have you tried using a equivalent force rather than impulse for the motion? Impulses and "forces" are applied differently, so you might have better luck. From the looks of it the particles are staying together as expected but getting pushed into each other; is there any exploding going on?
mateas
Posts: 4
Joined: Sun Aug 11, 2013 10:24 pm

Re: Objects penetration

Post by mateas »

Hi Basroil,

Thanks for the response. No, there is no explosion going on, although the way I apply the impulses might be treated like an explosion. I apply impulses to a subset of all particles like this:

Code: Select all

// create random number generator for impulses (marsene twisters)
boost::random::mt19937 rng;
// apply random impulse to a subset of particles - in the Z axis impulse is stronger
// this is the case when particles positioned at the bottom can "drill" up and oposite way
for(unsigned int i = 0; i < range; ++i){
	boost::random::uniform_real_distribution<double> objectXYImpulse( - 30.0 / objects[i]->getInvMass(), 30.0 / objects[i]->getInvMass());
	boost::random::uniform_real_distribution<double> objectZImpulse( - 100.0 / objects[i]->getInvMass(), 100.0 / objects[i]->getInvMass());
	objects[i]->applyCentralImpulse(btVector3(objectXYImpulse(rng), objectXYImpulse(rng), objectZImpulse(rng)));
}
I will try to increase the tick resolution and apply forces instead of impulses, but if You have any other ideas please share them:)

EDIT:
I have tried increasing ticks resolution, but still no progress and penetration happens. I have removed any modifications of world state at my side, leaving just the free fall with a gravity for all particles and I have still penetrations. Is there something about Compound shape and collisions that I should set up or take care?