We have a weird error... please help!!!

dwells254lb43
Posts: 10
Joined: Wed Jan 21, 2009 12:27 am

We have a weird error... please help!!!

Post by dwells254lb43 »

Hello everyone, me and a friend are working on a project for school atm and we are using the bullet library. We have been learning it now for about 3-4 weeks but we are stomped at a weird error that we are encountering. When we made our own little project, we just made a physics.h, a physics.cpp and a main and it worked fine. We then tried to add Direct X to the whole ordeal and things started messing up.. It is inside of this function however, it has nothing to do with Direct X.

void PhysicsWorld::CreateCollisionBox(BoxInfo& info)
{
// Creates a Box Object.

btCollisionShape* colShape = new btBoxShape(info.halfscale);
collisionShapes.push_back(colShape);

btTransform startTransform;
startTransform.setIdentity();

btScalar mass=info.mass;

//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);

btVector3 localInertia=info.localInertia;
if (isDynamic)
colShape->calculateLocalInertia(mass,localInertia);

startTransform.setOrigin(info.orgin);

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

rbInfo.m_friction=info.friction;
rbInfo.m_restitution=info.restitution;
rbInfo.m_linearDamping=info.linearDamping;
rbInfo.m_angularDamping=info.angularDamping;

btRigidBody* body = new btRigidBody(rbInfo);
dynamicsWorld->addRigidBody(body);

}

and here is the error::

Unhandled exception at 0x004a69bd in MovingObjects.exe: 0xC0000005: Access violation reading location 0x5b845c33.


MovingObjects is our program
error line:

in btcollisionworld.cpp line 100
collisionObject->getCollisionShape()->getAabb(trans,minAabb,maxAabb);



This is the same exact function we used when it wokred fine but now in the line where we pass data into rbInfo things are not getting updated.

Right here ::
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);

the colShape is passed as a box, and in our other function it is passed a sphere etc, (into rbInfo) however when we pass it through we debug and step into the function and the Info is not actually getting passed through but this data has the correct values before getting passed into rbInfo for example... for a sphere colShape has a value of 8 for sphere, but when we pass it into rbinfo it has a value of 8 but when we step into the function it shows it having a NULL value... :( .

I dont get why it worked earlier i actually have both programs.. the working one in console, and then the broken one where things are not getting updated with the Direct X. I just dont see how direct x will have any difference into this function when direct x is just graphics and this function is nothing but position values.
lickstab
Posts: 8
Joined: Wed Jan 14, 2009 6:00 pm

Re: We have a weird error... please help!!!

Post by lickstab »

hey, did you ever fix this?
i have the very same problem and no one could tell me what was wrong..
i get it even with the hello world example on a completely clean install.
works with 2.69 though.
Anubis9
Posts: 2
Joined: Tue Apr 14, 2009 10:09 pm

Re: We have a weird error... please help!!!

Post by Anubis9 »

Hello!
Sorry for double posting, but i guess it is better to write here as well, because someone who needs help, might find this topic and not the second one.


I've found the solution to this problem.
In order to make it work, just add "WIN32" (without quotes) to the Preprocessor Definitions in the Project Properties -> C/C++ -> Preprocessor.

Hope it helps! (It helped me at least).