A few weird results getting started

Shival
Posts: 1
Joined: Tue Nov 27, 2007 4:18 pm

A few weird results getting started

Post by Shival »

Hello,

I am currently evaluating bullet but am having a few issues from the start.

I'm making a terrain mesh and 30 spheres. I'm setting the spheres at random cords and letting them fall on the terrain and roll. Now the weird issues im having is this. 1. If i run with msvc debug mode at the start they all roll around fine; if I run the debug exe without msvc, they all just stay floating at their starting points. 2. Now when I am in msvc debug mode and I reset the spheres, half of them just stay at their starting locations and dont move again.

This could be anything from time stepping to unintialized variables, so im going to post basic code im doing.

Engine Init

Code: Select all

m_collisionConfiguration = new btDefaultCollisionConfiguration();
   m_dispatcher = new	btCollisionDispatcher(m_collisionConfiguration);

   #define maxProxies 8192
   btVector3 worldAabbMin(-10000,-10000,-10000);
   btVector3 worldAabbMax(10000,10000,10000);
   m_overlappingPairCache = new btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies);

   btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
   m_solver = sol;

   m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
   m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
   m_dynamicsWorld->setGravity(btVector3(0,-9.8,0));
Sphere Init

Code: Select all

   mColShape = new btSphereShape(btScalar(.5));
   
   btTransform startTransform;
   startTransform.setIdentity();
   startTransform.setOrigin(btVector3(0, 0, 0));

   btVector3 localInertia(0,0,0);
   float mass = 1.0f;
   mColShape->calculateLocalInertia(mass, localInertia);

   //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
   btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
   btRigidBody* body = new btRigidBody(mass, myMotionState, mColShape, localInertia);

   Bullet_Physics_Manager::GetInstance()->GetDynamicsWorld()->addRigidBody(body);

   myMotionState->m_graphicsWorldTrans = myMotionState->m_startWorldTrans;
   body->setWorldTransform(myMotionState->m_graphicsWorldTrans);
   body->setInterpolationWorldTransform(myMotionState->m_startWorldTrans);
   body->activate();
   mRigidBody = body;
Engine Update

Code: Select all

 if(m_dynamicsWorld)
   {
      m_dynamicsWorld->stepSimulation(1.0f/60.0f);
      m_dynamicsWorld->updateAabbs();
   }
Reset Spheres

Code: Select all

btRigidBody* actor = static_cast<Bullet_PrimitiveObject*>(primPhysObject)->GetRigidBody();
   actor->setLinearVelocity(btVector3(0,0,0));
   actor->setAngularVelocity(btVector3(0,0,0));
   btTransform transform ;
   transform.setIdentity();
   transform.setOrigin(btVector3(rand() % 10,rand() % 10, rand() % 10));
   actor->setWorldTransform(transform);
   actor->setGravity(btVector3(0,-9.8,0));
   actor->activate(true);
Pull Out sphere drawing data

Code: Select all


btRigidBody* actor = static_cast<Bullet_PrimitiveObject*>(primPhysObject)->GetRigidBody();
float m[16];
actor->getWorldTransform().getOpenGLMatrix(m);

I would appreciate any help! If anything needs more code / explanation, please respond. I'm most likely doing something wrong.