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