Issues with bullet 2.74 on VS2005

xwipeoutx
Posts: 9
Joined: Fri Mar 20, 2009 3:57 am

Issues with bullet 2.74 on VS2005

Post by xwipeoutx »

Hello,

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;
}
It's fairly simple, I thought it would "Just work".

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.
(This is during delete dynamicsWorld;)

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...
gabba
Posts: 9
Joined: Thu Mar 19, 2009 3:20 am

Re: Issues with bullet 2.74 on VS2005

Post by gabba »

xwipeoutx wrote:note: running the demos resulted in MSVCP80D.dll not being found. This didn't happen with the debug configuration
I can confirm this.
xwipeoutx wrote:Any ideas? Am I doing something stupid? That's what I suspect...
I created a new project using the same steps and the same code as you, and it compiles and runs fine. So the problem is not in the code.
I've never seen that error in my (short) programming life, but it looks as if something fundamental is messed up on your system. Have you at least made sure you have Visual Studio 2005 with SP1 installed? That service pack solved a lot of problems.
xwipeoutx
Posts: 9
Joined: Fri Mar 20, 2009 3:57 am

Re: Issues with bullet 2.74 on VS2005

Post by xwipeoutx »

Mm, thanks for the confirmation on that first thing :) At least that isn't me going crazy.

I definitely have SP1 installed, that can't be the problem. I'm going to try and get something going under linux and see how it goes there. If worse comes to worst, I'll wipe out all my dev tools (go crazy in add/remove programs) and reinstall that, and hope for the best...
xwipeoutx
Posts: 9
Joined: Fri Mar 20, 2009 3:57 am

Re: Issues with bullet 2.74 on VS2005

Post by xwipeoutx »

Bizarre.

So I got it compiling on linux without a hitch (except for my noobishness at linux, took me forever to link it properly :P), so I figured it must have been an issue with my system.

So, I uninstalled anything to do with microsoft development completely, even went into program files and local settings and cleared all that out too. I also deleted my source and binaries of bullet and recompiled it from scratch, and you know what? It was still broken. DARGH!

But I found I did have a working piece of code somewhere using btogre, and the only thing I noticed that could have been different is some #defines or something in Ogre

Code: Select all

#define WIN32
fixed it right up...it's working like a charm now.

So there you go. >_<

Is this documented anywhere?