Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Aug 15, 2012 4:18 am 
Offline

Joined: Fri Jun 15, 2012 7:11 am
Posts: 43
my clean up code:
Code:
         if(pRigidBody)
         {
            if(pColliderScene)
            {
               pColliderScene->getDynamicsWorld()->removeRigidBody(pRigidBody);
               pColliderScene = NULL;
            }            
            delete pRigidBody;
            pRigidBody = NULL;
         }
         // delete pCollisionShape; <--- do i need to delete shape?

do i need to remove the shape i use in pRigidBody->setShape(pCollisionShape); ?

and if those shape are compound of other shape do they get deleted by the compound shape or do i need to store pointer to everything and delete them meeself?
:oops:


Top
 Profile  
 
PostPosted: Wed Aug 15, 2012 2:18 pm 
Offline

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 317
Indeed you should delete all the btCollisionShapes you use.
Of course you might reuse the same shape multiple times (e.g. when you scale them through a btUniformScalingShape, or simply when multiple bodies share the same shape) and you must be careful not to delete shared shapes too early.

I use a class that I've made that collects the shapes for me. I've posted about it long time ago (http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=5768&hilit=btCollisionShapeGarbageCollector), (although the most up to date version can probably be found in the source code of this project: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=17&t=7159&hilit=HACD).

P.S. It's not "the state of the art", but I find it very useful for my programs.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group