[irrBullet] Runtime crash when using IAttributes

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
RTCgee
Posts: 4
Joined: Wed Mar 12, 2014 3:54 pm

[irrBullet] Runtime crash when using IAttributes

Post by RTCgee »

I have the following code to process irrBullet collisions executed 60 times per second:

Code: Select all

void processCollisions(){
    for(unsigned int i=0; i < world->getNumManifolds(); i++){
        ICollisionCallbackInformation *info = world->getCollisionCallback(i);
        unsigned int numContacts = info->getPointer()->getNumContacts();
        for(unsigned int j=0; j < numContacts; j++)
        if(info->getContactPoint(j).getDistance()<1.5f && info->getContactPoint(j).getLifeTime() < 2.0f){
            io::IAttributes* body0 = info->getBody0()->getAttributes();
            io::IAttributes* body1 = info->getBody1()->getAttributes();
            core::stringc type0 = body0->existsAttribute("Type")? body0->getAttributeAsString("Type") :L"None",
                          type1 = body1->existsAttribute("Type")? body1->getAttributeAsString("Type") :L"None";
            /* Look at the types and call functions that fit */ }
        info->getPointer()->clearManifold();}}
World is my irrBullet world, the Type attribute, obviously, holds the type of the body.
The moment there is a collision, a runtime crash occurs.
With debugging I have found that this happens the moment body0->existsAttribute("Type") is called, but some more debugging showed that any function call on body0 and body1 result in a crash.
Although this is typical for a null-pointer, the pointers aren't 0x000000 and will be true when used as a bool.
I've already tried recompiling irrlicht and irrBullet without success.
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [irrBullet] Runtime crash when using IAttributes

Post by CuteAlien »

Maybe your getBody functions return uninitialized pointers?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
RTCgee
Posts: 4
Joined: Wed Mar 12, 2014 3:54 pm

Re: [irrBullet] Runtime crash when using IAttributes

Post by RTCgee »

CuteAlien wrote:Maybe your getBody functions return uninitialized pointers?
That would be a bug in irrBullet and I assume that when there is a collision there are 2 objects involved.
But an uninitialized pointer would explain why it acts like a nullpointer.
RTCgee
Posts: 4
Joined: Wed Mar 12, 2014 3:54 pm

Re: [irrBullet] Runtime crash when using IAttributes

Post by RTCgee »

I might have found the problem by looking at what the getBody function actually does, apperantly it uses the "userpointer" of the bullet body, but I used it myself too and have probably set it to a different value.
I'll see if it works after having changed the function.
Last edited by RTCgee on Mon Oct 20, 2014 12:48 pm, edited 1 time in total.
RTCgee
Posts: 4
Joined: Wed Mar 12, 2014 3:54 pm

Re: [irrBullet] Runtime crash when using IAttributes

Post by RTCgee »

Seems to work now.
As a note to irrBullet users:
don't try to change the userPointer of a bullet body, irrBullet will set it to a SCollisionObjectIdentification pointer with information about the ICollisionObject automatically.
Post Reply