Trying to delete collision shape what am i doing wrong?!

Post Reply
johnsonalpha
Posts: 73
Joined: Fri May 01, 2015 8:23 pm

Trying to delete collision shape what am i doing wrong?!

Post by johnsonalpha »

im trying to figure out a way to store the collision shapes in a array and delete them at the end this is my code so far ive seen the demos but those methods dont work for me.


Code: Select all

// make a integer
int delcount = 0;


// pair creation
std::pair<btCollisionShape*,INode*> * pairDel;
pairDel = new std::pair<btCollisionShape*, INode*>[maxscene->NumChildren()];

// make a shape
groundShape = new btStaticPlaneShape(btVector3(0, 1, 0), 1);

// add that shape to pair
pairDel[delcount].first = groundShape;

delcount += 1;


// loop to delcount and delete the bt collision shapes that are stored in the pair
for ( int j=0; j<delcount; j++ )
{
    btCollisionShape* shape = pairDel[j].first;
    delete shape;
}
Waschmaschine
Posts: 10
Joined: Wed Apr 15, 2015 9:50 pm

Re: Trying to delete collision shape what am i doing wrong?!

Post by Waschmaschine »

The code works fine for me. But I think you are missing

Code: Select all

delete[] pairDel;
at the end. I would recommend to use something like an std::vector, so you can just iterate until the end and you do not have to track the elements (with delcount).
johnsonalpha
Posts: 73
Joined: Fri May 01, 2015 8:23 pm

Re: Trying to delete collision shape what am i doing wrong?!

Post by johnsonalpha »

Can you show me how to use a vector for it please? im really dumb!
Post Reply