I am making my first post here, and it's nice to join a group of open source people.
The Bullet Physics library is very large, and in past projects I normally have simply written my own methods for applying movement, but the combination of everything into a single package provides an ideal solution. The only problem for me, personally, is that my use of bullet is intermediated by another, non-bullet library.
90% of the other library is bullet-independant, and whatever works with bullet, there are in-between methods. So I"ve had to struggle with learning everything and building my own methods to get use of bullet, and I've had most success so far, woo hoo!
But now I'm coming to a real tricky situation: the inbetween library has no support for bullet collision shapes beyond the box, cone, cylinder, convex hull and triangle mesh. None of these provided the solution I was looking for in the current task of my project, and so I did my own bullet research, and decided my collision shape requirement is the btCompoundShape class.
I've set up the object and given it the proper children objects (as follows), and think all requirements are satisfied. But I think something is still missing, because there are some strange behaviours. I've looked on the forum for introductory information on the btCompoundShape and there's too much for me to absorb, and I"ve looked on the doxygen info and tried to cover all the required elements.
Obviously there are a million things that can go wrong with physics setups, but I'm only looking for pointers and suggestions, and help if anyone happens to have experienced something like this.
The scenario:
I have a 3D object modelled in blender, plus two big collision boxes that represent the collision area, and I'm firing projectiles at the model.
The model and boxes are being exported from blender, and the two boxes are interpreted as independant btRigidBody objects.
The basic code I've written to build the btCompoundShape follows, with my project-specifics removed for clarity):
Code: Select all
softRigidDynamicsWorld->removeRigidBody(collisionBox1->_btRigidBody);
softRigidDynamicsWorld->removeRigidBody(collisionBox2->_btRigidBody);
btCompoundShape *_btCompoundShape = new btCompoundShape();
_btCompoundShape->addChildShape( collisionBox1->_btRigidBody->getWorldTransform(), collisionBox1->_btRigidBody->getCollisionShape() );
_btCompoundShape->addChildShape( collisionBox2->_btRigidBody->getWorldTransform(), collisionBox2->_btRigidBody->getCollisionShape() );
// assorted memory management lines...
collisionBox1->_btRigidBody->setCollisionShape( _btCompoundShape);
softRigidDynamicsWorld->addRigidBody( collisionBox1->_btRigidBody);The problem:
The model is stationary, and I am throwing a single projectile.
The projectile and collisionBoxes are all using box collision shapes.
Success: When the projectiles travel through the full volume of the collisionshape and miss the two boxes, nothing happens.
Success: When they hit collisionBox1, they lose their energy and the energy is transferred to the object, and it gets tossed in the same direction as the projectiles were travelling.
Success: Single projectile hits collisionBox1, it will lose its energy and the whole model gets tossed in the projectile direction.
Inconsistent: Single projectile hits collisionBox2, projectile will lose some of its energy and the whole model gets tossed in the projectile direction.
Failure: Projectile hits collisionBox2, projectile goes through collisionBox2 and a small amount of energy goes into the model and it moves back slowly. (not sure if it depends on where on the collisionBox2 the contact is made)
Failure: Projectile hits collisionBox2, projectile goes into collisionBox2, and then bounces back out the way it went in, and the model moves basically in the opposite direction the projectile was going. As if there was a second object the projectile hit, it bounced backward and hit the model from the other side.
I've also been using a bit of code to catch collisions between particular objects, and I'm confused by how a single object pair may have multiple manifold contact points if they're both boxes, but that's a separate issue.