problem creating rigid body

HailStOrm03
Posts: 3
Joined: Fri Feb 26, 2010 10:55 am

problem creating rigid body

Post by HailStOrm03 »

Hi, I'm trying to create a simple rigid body and add it to the world. I looked at the function CreateRigidBody in DemoApplication and created a similar one, however when I call new btRigidBody gets called, it never initializes the shape.

Here's my code -

Code: Select all

void PhysicsManager::Init()
{
	m_broadphase = new btAxisSweep3(GameWorld::GetWorldMin(),GameWorld::GetWorldMax());
	m_collisionConfiguration = new btDefaultCollisionConfiguration();
	m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
	m_solver = new btSequentialImpulseConstraintSolver();
	m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);

	m_dynamicsWorld->setGravity(btVector3(0,-10,0));
}
//based off demo application
btRigidBody* PhysicsManager::CreateRigidBody(const btScalar mass, const btVector3& pos,btCollisionShape* shape)
{
	btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE));

	bool isDynamic = (mass != 0.f);

	btVector3 localInertia(0,0,0);
	if (isDynamic)
		shape->calculateLocalInertia(mass,localInertia);

	btDefaultMotionState* motionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),pos));

	btRigidBody::btRigidBodyConstructionInfo cInfo(mass,motionState,shape,localInertia);

        // shape = fine over here
	btRigidBody* body = new btRigidBody(cInfo);
      
body->btCollisionObject->m_broadPhaseHandle = 0 after construction
body->btCollisionObject->m_collisionShape = 0 after construction

Code: Select all

	//m_dynamicsWorld->getNumCollisionObjects() = 0 over here
  
	m_dynamicsWorld->addRigidBody(body);

	// m_dynamicsWorld->getNumCollisionObjects() also = 0 over here ?

	return body;
}
I've just started using bullet and this was the firs test I did; perhaps theres a linking problem. Please let me know if anyone knows what the problem could be. Thank you!
HailStOrm03
Posts: 3
Joined: Fri Feb 26, 2010 10:55 am

Re: problem creating rigid body

Post by HailStOrm03 »

OK, Well I confirmed that all my libraries etc are setup correct. I still cannot create a rigid body.

Everything seems fine until it reaches he btRigidBodyConstructor. Inside that everything becomes null.

Does anyone have an idea what could be causing this or experienced something like this before ?
HailStOrm03
Posts: 3
Joined: Fri Feb 26, 2010 10:55 am

Re: problem creating rigid body

Post by HailStOrm03 »

Well, it turns out I had the same error as this post -> http://bulletphysics.org/Bullet/phpBB3/ ... dio#p17104

I was using version 2.5, so had to add all the .cpp files.