Well I tried running through it with a debugger, but it still stops at the stepsimulation function. I can post all my code and see if maybe I'm doing something that is getting overlooked.
#include <iostream>
#include <irrlicht.h>
#include <btBulletDynamicsCommon.h>
#include <btBulletCollisionCommon.h>
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
static void CreateInitialScene();
static void CreateGround(const btVector3& TPosition, const vector3df& TScale, btScalar TMass);
static void CreateBox(const btVector3& TPosition, const vector3df& TScale, btScalar TMass);
static void CreateBall(const btVector3& TPosition, btScalar TRadius, btScalar TMass);
static void UpdatePhysics(f32 TDeltaTime);
static void UpdateGraphics(btRigidBody* TBodies);
static void ClearBodies();
static int GetRandInt(int TMax) { return rand() % TMax; }
static bool Done = false;
static btDiscreteDynamicsWorld* World;
IrrlichtDevice* Device;
IVideoDriver* Driver;
ISceneManager* Smgr;
IGUIEnvironment* Env;
IFileSystem* File;
ITimer* Timer;
ILogger* Log;
list <btRigidBody*> Bodies;
class MainEvent : public IEventReceiver {
public:
virtual bool OnEvent(const SEvent &TEvent) {
if (TEvent.EventType == EET_KEY_INPUT_EVENT && !TEvent.KeyInput.PressedDown) {
switch (TEvent.KeyInput.Key) {
case KEY_ESCAPE:
Done = true;
break;
case KEY_KEY_1:
CreateBox(btVector3(GetRandInt(10) - 5.0f, 7.0f, GetRandInt(10) - 5.0f), vector3df(GetRandInt(3) + 0.5f, GetRandInt(3) + 0.5f, GetRandInt(3) + 0.5f), 1.0f);
break;
case KEY_KEY_2:
CreateBall(btVector3(GetRandInt(10) - 5.0f, 7.0f, GetRandInt(10) - 5.0f), GetRandInt(5) / 5.0f + 0.2f, 1.0f);
break;
case KEY_KEY_X:
CreateInitialScene();
break;
default:
return false;
break;
}
return true;
}
return false;
}
};
int main(int argc, char* argv[])
{
MainEvent receiver;
Device = createDevice(EDT_OPENGL, dimension2d<u32>(1024, 720), 32, false, false, false, &receiver);
Env = Device->getGUIEnvironment();
Timer = Device->getTimer();
Smgr = Device->getSceneManager();
Driver = Device->getVideoDriver();
btDefaultCollisionConfiguration* collisionCong = new btDefaultCollisionConfiguration();
btBroadphaseInterface* broadphase = new bt32BitAxisSweep3(btVector3(-1000, -1000, -1000), btVector3(1000, 1000, 1000));
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionCong);
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver();
World = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionCong);
ICameraSceneNode* Cam = Smgr->addCameraSceneNode();
Cam->setPosition(vector3df(0.0f, 5.0f, -15.0f));
Cam->setTarget(vector3df(0, 0, 0));
Smgr->addLightSceneNode(0, vector3df(2, 5, -2), SColorf(4, 4, 4, 1));
CreateInitialScene();
f32 TimeStamp = Timer->getTime(), DeltaTime = 0;
while (!Done)
{
DeltaTime = Timer->getTime() - TimeStamp;
TimeStamp = Timer->getTime();
UpdatePhysics(DeltaTime);
Driver->beginScene(true, true, SColor(255, 20, 0, 0));
Smgr->drawAll();
Env->drawAll();
Driver->endScene();
Device->run();
}
ClearBodies();
delete World;
delete solver;
delete dispatcher;
delete broadphase;
delete collisionCong;
Device->drop();
return 0;
}
static void UpdatePhysics(f32 TDeltaTime)
{
World->stepSimulation(TDeltaTime * 0.001f, 60);
for (list<btRigidBody*>::Iterator it = Bodies.begin(); it != Bodies.end(); ++it)
{
UpdateGraphics(*it);
}
}
static void CreateInitialScene()
{
ClearBodies();
CreateBox(btVector3(0.0f, 0.0f, 0.0f), vector3df(10.0f, 0.5f, 10.0f), 0.0f);
}
static void CreateGround(const btVector3& TPosition, const vector3df& TScale, btScalar TMass)
{
}
static void CreateBox(const btVector3& TPosition, const vector3df& TScale, btScalar TMass)
{
ISceneNode* Node = Smgr->addCubeSceneNode(1.0f);
Node->setScale(TScale);
Node->setMaterialFlag(EMF_LIGHTING, 1);
Node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
btTransform Transform;
Transform.setIdentity();
Transform.setOrigin(TPosition);
btDefaultMotionState* Motion = new btDefaultMotionState(Transform);
btVector3 HalfExtents(TScale.X * 0.5f, TScale.Y * 0.5f, TScale.Z * 0.5f);
btCollisionShape* Shape = new btBoxShape(HalfExtents);
btVector3 LocalInertia;
Shape->calculateLocalInertia(TMass, LocalInertia);
btRigidBody* Body = new btRigidBody(TMass, Motion, Shape, LocalInertia);
Body->setUserPointer((void*)(Node));
World->addRigidBody(Body);
Bodies.push_back(Body);
}
static void CreateBall(const btVector3& TPosition, btScalar TRadius, btScalar TMass)
{
}
static void UpdateGraphics(btRigidBody* TBodies)
{
ISceneNode* Node = static_cast<ISceneNode*>(TBodies->getUserPointer());
btVector3 Point = TBodies->getCenterOfMassPosition();
Node->setPosition(vector3df((f32)Point[0], (f32)Point[1], (f32)Point[2]));
vector3df Euler;
const btQuaternion& TQuat = TBodies->getOrientation();
quaternion q(TQuat.getX(), TQuat.getY(), TQuat.getZ(), TQuat.getW());
q.toEuler(Euler);
Euler *= RADTODEG;
Node->setRotation(Euler);
}
static void ClearBodies()
{
for (list<btRigidBody *>::Iterator It = Bodies.begin(); It != Bodies.end(); ++It) {
btRigidBody *Object = *It;
// Delete irrlicht node
ISceneNode *Node = static_cast<ISceneNode *>(Object->getUserPointer());
Node->remove();
// Remove the object from the world
World->removeRigidBody(Object);
// Free memory
delete Object->getMotionState();
delete Object->getCollisionShape();
delete Object;
}
Bodies.clear();
}