Here is my set up code. I'm stepping the simulation at 1/1000, and that's the only thing that is done after setup. As you can see, 'r', which is used for restitution is set at 0.1, and I've also applied heavy damping (0.9), but it's not solving the problem.
Code: Select all
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
btVoronoiSimplexSolver* simplex = new btVoronoiSimplexSolver();
btMinkowskiPenetrationDepthSolver* pdSolver = new btMinkowskiPenetrationDepthSolver();
btConvex2dConvex2dAlgorithm::CreateFunc* convexAlgo2d = new btConvex2dConvex2dAlgorithm::CreateFunc(simplex,pdSolver);
dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE,CONVEX_2D_SHAPE_PROXYTYPE,convexAlgo2d);
dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE,CONVEX_2D_SHAPE_PROXYTYPE,convexAlgo2d);
dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE,BOX_2D_SHAPE_PROXYTYPE,convexAlgo2d);
dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE,BOX_2D_SHAPE_PROXYTYPE,new btBox2dBox2dCollisionAlgorithm::CreateFunc());
broadphase = new btDbvtBroadphase();
solver = new btSequentialImpulseConstraintSolver();
world = new btDiscreteDynamicsWorld
(
dispatcher,
broadphase,
solver,
collisionConfiguration
);
world->setGravity(btVector3(0.0f, -0.981f, 0.0f));
float r = 0.1f;
btScalar mass = 1.0f;
btVector3 inertia(0.0f, 0.0f, 0.0f);
for (int i = 0; i < N_BODIES; ++i)
{
btConvexHullShape* hull = new btConvexHullShape();
hull->addPoint(btVector3(0.0f, 0.02f, 0.0f));
hull->addPoint(btVector3(-0.02f, -0.02f, 0.0f));
hull->addPoint(btVector3(0.02f, -0.02f, 0.0f));
hull->setMargin(0.001f);
hull->calculateLocalInertia(mass, inertia);
btConvex2dShape* shape = new btConvex2dShape(hull);
shape->setMargin(0.001f);
shape->calculateLocalInertia(mass, inertia);
body[i] = new btRigidBody(mass, 0, shape, inertia);
body[i]->setRestitution(r);
body[i]->setWorldTransform(btTransform(btQuaternion::getIdentity(), btVector3((rand() % 100)*0.01, 0.1f + 0.06 * i, 0.0f)));
body[i]->setDamping(0.9, 0.9);
body[i]->setActivationState(DISABLE_DEACTIVATION);
world->addRigidBody(body[i]);
}Thanks in advance.