Code: Select all
class SphereTrigger : public Trigger
{
public:
btSphereShape* shape;
btMotionState* motionState;
btRigidBody* body;
SphereTrigger(const btDiscreteDynamicsWorld* world,
const cml::vector3f& pos,
const float& radius,
const ActorId& id)
{
shape = new btSphereShape(radius);
btScalar mass = 0.0f;
cml::matrix44f_c transform;
transform.identity();
//put pos into transform here
motionState = new ActorMotionState(transform);
btRigidBody::btRigidBodyConstructionInfo rbCI(mass, motionState, shape);
body = new btRigidBody(rbCI);
world->addRigidBody(body);//error is happening here!
body->setCollisionFlags(body->getCollisionFlags() | btRigidBody::CF_NO_CONTACT_RESPONSE);
body->setUserPointer((void*)&id);
}
virtual ~SphereTrigger()
{
if(shape)
delete shape;
if(motionState)
delete motionState;
if(body)
delete body;
}
};