irrBullet 0.1.8 - Bullet physics wrapper

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Barratator
Posts: 30
Joined: Fri Jan 08, 2010 3:30 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by Barratator »

Hello,
the allocation of the block is in rigidbody.cpp, line 44:

Code: Select all

 
motionState = new IMotionState(internalTransform);
 


Bastian
Rocko Bonaparte
Posts: 48
Joined: Tue Aug 31, 2010 6:27 am

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by Rocko Bonaparte »

[Update: Sure to form, I find the answer after posting--I think: AddToDeletionQueue. I'm seeing how well it works]

I am running leak checks on my code, and finding a slew of stuff with the physics engine. I am sure I am keeping stuff around I shouldn't, so that has to be knocked out before I can tell what may be internal to the Bullet or the wrapper. My problem is I am unsure stuff within my code I'm supposed to instruct to free, versus what I don't touch, and what I free indirectly be removing them from irrBullet.

Generally I'm just working with rigid bodies. So say my progression is something like this:

Code: Select all

 
                // Inside some header somewhere
                ISphereShape *physicsBounds;
                IRigidBody *physicsBody;
 
                // Inside actual source file
                physicsBounds = new ISphereShape(sceneNode, mass, false);            // sceneNode being an Irrlicht scene node
                physicsBounds->setUnscaledRadius(boundingCircleRadius);
                physicsBody = subsystems->physics->world->addRigidBody(physicsBounds);        // world is an irrBulletWorld
                physicsBody->getAttributes()->addBool("collide", true);
                physicsBody->setAngularFactor(0);
 
                // Fun time!  Rest of program is running...
 
                // Time to delete!  Now what?
                delete physicsBounds;              // Works fine
                subsystems->physics->world->removeCollisionObject(physicsBody);        // Segfaults!
                delete physicsBody;                                                                               // If I remove removeCollisionObject -- segfaults!
 
 
 
I assume I'm missing some removal call of some kind, and Bullet is still trying to work with the pointers. What else is there?
jaeg
Posts: 52
Joined: Thu Jun 28, 2007 11:20 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by jaeg »

I've been trying to integrate irrBullet into my game but I'm having trouble with adding some things. If I use a GImpact shape the bounding box will morph to accommodate the rotating player mesh but it doesn't rotate so it causes issues when colliding with walls and will force the player into a rotation perpendicular to the wall. If I use a sphere collision object I'm having issues with alligning the sphere with the playerNode or enemyNode. And if I use a convexHull it does not rotate when I apply forces on it.

How I've initialized the player. The player node is an animated mesh scene node:

Code: Select all

 
    playerShape = new IGImpactMeshShape(playerNode,playerNode->getMesh(), 10);
    playerBody = world->addRigidBody(playerShape);
    playerBody->setActivationState(EAS_DISABLE_DEACTIVATION);
    playerBody->setDamping(.8, .8);
    playerBody->setAngularFactor(vector3df(0.0f,1.0f,0.0f));
How I move the player is with these commands:
To move player forward or back I use a variation of this command:
playerBody->applyCentralForce(vector3df(0,0,-2000.0f), ERBTS_LOCAL);
And this to rotate the player:
playerBody->applyTorque(vector3df(0,3000.0f,0), ERBTS_LOCAL);

Idk if I'm providing enough information or not. I'm pretty much just hobbling this thing together.
Image

Uploaded with ImageShack.us

Also why does the player node and enemy nodes start out above the position they are placed?
Computer Science Major - Ball State University
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by cobra »

Rocko Bonaparte wrote: I am running leak checks on my code, and finding a slew of stuff with the physics engine...
Hi Rocko,

You are correct; you're making the memory leaks yourself.

Use this function to remove a collision object (both softbody and rigidbody):

Code: Select all

void irrBulletWorld::removeCollisionObject(ICollisionObject* const obj, bool deleteObject)
Never call delete on a pointer provided by irrBullet except the irrBulletWorld pointer.


@ jaeg:

Hi Jaeg,

The GImpact shape should not be a box, and the bounding box is only used in the broad-phase, not the narrow-phase, so it should not be causing any problems with the collision. Try using an IMeshSceneNode rather than an animated mesh scene node. And it seems that the vertices of the character models are all above 0 on the Y axis (or whatever up-axis is used in the modeling software), so naturally the box shape will be wrong. You will have to take the character meshes in the modeling software and center them on the up-axis.

- Josiah
Josiah Hartzell
Image
jaeg
Posts: 52
Joined: Thu Jun 28, 2007 11:20 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by jaeg »

Should the be half and half around the y axis then?
Computer Science Major - Ball State University
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by Virror »

This looks like a very good wrapper : D
But i keep getting linker errors when trying to link with my VS2010 project.
Have included the three folders that should be added, have included the "irrBullet.h" file and added the .lib file to the lib directory. What am i missing?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by serengeor »

Virror wrote:This looks like a very good wrapper : D
But i keep getting linker errors when trying to link with my VS2010 project.
Have included the three folders that should be added, have included the "irrBullet.h" file and added the .lib file to the lib directory. What am i missing?
We should now guess what linker errors you have and provide random solutions?
*Be more specific..

Anyways, my guess would be that you either don't link bullet/irrbullet libs or you're linking them in incorrect order.
Working on game: Marrbles (Currently stopped).
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by Virror »

Managed to mess up the Bullet linking when linking the irrBullet : p
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by Virror »

Ok, i cant get this to work : /
I need to link Bullet first, then irrBullet right?
Anyone can write step-by-step how to get it to work with VC2010?
I keep ketting linker fault and duplicaye include errors all the time depending on how i try to do it : /
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by mongoose7 »

Link against irrBullet first. Dependencies are resolved from left to right, so, if library A depends on library B, then A must appear in the link command before B.

Include errors are compile time. Put the headers for Bullet before the headers for irrBullet. You normally don't get duplicate includes because the include files are normally wrapped with exclusion code. You should post the exact errors, though.
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by Virror »

Hmm, should not irrBullet and Bullet have the same #ifndef names in the include files? Else they will be included twice?

Edit: By making sure Bullet and irrBullet share the same .h files i have managed to get them both to compile, but still get two linker errors:
btPolyhedralConvexShape.obj : error LNK2005: "public: virtual __thiscall btPolyhedralConvexShape::~btPolyhedralConvexShape(void)" (??1btPolyhedralConvexShape@@UAE@XZ) already defined in btConvexConcaveCollisionAlgorithm.obj
1>irrBullet.lib(softbody.obj) : error LNK2019: unresolved external symbol "public: void __thiscall btSoftBody::appendAnchor(int,class btRigidBody *,bool)" (?appendAnchor@btSoftBody@@QAEXHPAVbtRigidBody@@_N@Z) referenced in function "public: void __thiscall ISoftBody::appendAnchor(unsigned int,class IRigidBody * const,bool)" (?appendAnchor@ISoftBody@@QAEXIQAVIRigidBody@@_N@Z)
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by serengeor »

Virror wrote:Hmm, should not irrBullet and Bullet have the same #ifndef names in the include files? Else they will be included twice?

Edit: By making sure Bullet and irrBullet share the same .h files i have managed to get them both to compile..
The header guards should differ for every header, else you might have troubles with them.
Working on game: Marrbles (Currently stopped).
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by Virror »

Well, might be. But why cant they just use the same header files? Why do irrBullet need a separate set of the same headers that exists in the bullet catalog?
Removed all irrBullet Bullet headerfiles and removed the "Bullet/" from the cpp files, now it almost works, but getting one unresolved external:
btSoftBody::appendAnchor(int,class btRigidBody *,bool)

Checked the btSoftBody.cpp file and there is no function with those parameters, only with "(int node,btRigidBody* body, bool disableCollisionBetweenLinkedBodies,btScalar influence)"
Maybe they have changed that function in the latest release? Anyone have the latest bullet working?

Edit: I can now confirm that this has indeed been changed in bullet 2.78, so that version and newer cant be used : / Trying the 2.77 now instead : )
Last edited by Virror on Wed Oct 12, 2011 2:26 pm, edited 1 time in total.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by serengeor »

Virror wrote:Well, might be. But why cant they just use the same header files? Why do irrBullet need a separate set of the same headers that exists in the bullet catalog?
Might be because the user wouldn't need to look for that specific version it was built on, because new/old versions get incompatible :roll:
Working on game: Marrbles (Currently stopped).
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: irrBullet 0.1.71 - Bullet physics wrapper

Post by Virror »

Yeah ; )
But it works now with 2.77 though : )
Post Reply