http://code.google.com/p/bullet/issues/detail?id=90
if i replace the box shapes with this code below, (using triangles instead of box shapes) and i put it in Fracture mode. then fire off spheres at the triangles, the triangles break away naturally,
but when they fall to the two platforms i've set up, (for experimentation) one with mass one with no mass..
most of the Triangles pass right through the Box shape platforms like they were not there. what am i doing wrong in the code below?
(several of the extra settings (set away from default) are just experiments to see if i could improve on the triangle/platform dynamics)
see screen shot in file attachment...
(also many times the spheres will pass right through the triangles about 10% of the time)
Code: Select all
#define ARRAY_SIZE_X 10
#define ARRAY_SIZE_Y 10
#define ARRAY_SIZE_Z 3
#define SCALING 1.
#define START_POS_X -5
#define START_POS_Y 1
#define START_POS_Z 10
btBoxShape *theGround2 = new btBoxShape(btVector3(btScalar(18.),btScalar(1.),btScalar(10.)));
theGround2->setMargin(0.004f);
btCollisionShape* groundShape2 = theGround2;
m_collisionShapes.push_back(groundShape2);
{
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-3,10));
btScalar mass(0.0f);
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic) groundShape2->calculateLocalInertia(mass,localInertia);
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape2,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
m_dynamicsWorld->addRigidBody(body);
}
btBoxShape *theGround = new btBoxShape(btVector3(btScalar(15.),btScalar(1.),btScalar(7.)));
theGround->setMargin(0.04f);
btCollisionShape* groundShape = theGround;
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-1,10));
{
btScalar mass(3.5f);
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic) groundShape->calculateLocalInertia(mass,localInertia);
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
m_dynamicsWorld->addRigidBody(body);
}
{
btVector3 p1(-0.70f,-0.55f, 0);
btVector3 p2( 1.30f,-0.55f, 0);
btVector3 p3(-0.70f, 1.45f, 0);
btTriangleShape *theTriangle = new btTriangleShape(p1,p2,p3);
theTriangle->setMargin(0.04f);
btCollisionShape* colShape = theTriangle;
m_collisionShapes.push_back(colShape);
btTransform startTransform;
startTransform.setIdentity();
btScalar mass(0.1f);
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic) colShape->calculateLocalInertia(mass,localInertia);
float start_x = START_POS_X - ARRAY_SIZE_X/2;
float start_y = START_POS_Y;
float start_z = START_POS_Z - ARRAY_SIZE_Z/2;
for (int k=0;k<ARRAY_SIZE_Y;k++)
{
for (int i=0;i<ARRAY_SIZE_X;i++)
{
for(int j = 0;j<ARRAY_SIZE_Z;j++)
{
startTransform.setOrigin(SCALING*btVector3(
btScalar(2.0*i + start_x),
btScalar(2.0*k + start_y),
btScalar(2.0*j + start_z)));
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
btFractureBody* body = new btFractureBody(rbInfo, m_dynamicsWorld);
sFractureBodies.push_back(body);
btTransform tr;
tr.setIdentity();
btQuaternion orn(btVector3(1,0,0),45);
tr.setRotation(orn);
body->setWorldTransform(tr);
body->setActivationState(ISLAND_SLEEPING);
m_dynamicsWorld->addRigidBody(body);
body->setActivationState(ISLAND_SLEEPING);
}
}
}