I've recently come across bullet after wanted to get some physics into a game I'm working on in Ogre (nx was a bit over the top), but I'm having no end of issues trying to get it set up.
I initially had some problems getting the collision shapes working consistently - every now and again, inspecting the collision object for it's shape would show me an invalid pointer, when the shape I passed into the constructor was perfectly valid. I have no idea why this happened. If I instantiated the shape object twice (as in shape=new btSphereShape(1);shape=new btSphereShape(1);), it seemed to work...it was quite bizarre.
So I thought I'd take a step back, remove Ogre from the mix, and started setting up the "Hello World" application - and now I'm having issues with heap corruption instantiating some object. Here's what I've done
1) Downloaded and extracted bullet-2.74 to my dev folder (d:/dev/bullet-2.74)
2) Opened up msvc/8/wksbullet.sln and compiled it in debugdll configuration (note: running the demos resulted in MSVCP80D.dll not being found. This didn't happen with the debug configuration)
3) Copied the lib files from out/debug_dll8/build/libbulletcollision, libbulletdynamics and libbulletmath, and put them in bullet-2.74/lib/Debug
4) In a new project, I set the header include directories to bullet-2.74/src, and lib directories to bullet-2.74/lib/Debug, and made sure those 3 libraries were in the 'additional dependencies' list
5) created a cpp with the following contents:
Code: Select all
#include <btBulletDynamicsCommon.h>
#include <iostream>
int main () {
// Build the broadphase
int maxProxies = 1024;
btVector3 worldAabbMin(-10000,-10000,-10000);
btVector3 worldAabbMax(10000,10000,10000);
btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
// Set up the collision configuration and dispatcher
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
// The actual physics solver
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
// The world.
btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
// Clean up behind ourselves like good little programmers
delete dynamicsWorld;
delete solver;
delete dispatcher;
delete collisionConfiguration;
delete broadphase;
std::cout << "Hello World!" << std::endl;
std::cin.get();
return 0;
}
Nope.
Code: Select all
Debug Error!
Program d:/dev/testbullet/testbullet/debug/TestBullet.exe
HEAP CORRUPTION DETECTED: after Normal block (#154) at 0x00521468.
CRT detected that the application wrote to memory after end of heap buffer.
Using a bunch of _crtCheckMemory() shows that the heap corruption is happening straight on the line that instantiates the dispatcher.
Any ideas? Am I doing something stupid? That's what I suspect...