Ok, so I have one static body to represent the walls in my game. I have box shaped fixtures to hold the data for these walls. There can potentially be thousands of separate walls in my game and I'm not sure how many Box2D can handle. The player can only collide with the ones close to him though so I thought of deleting the fixtures each frame and recreating the closest 20 or so to the player(actually first I thought of changing the fixture's shape's position but I'm not sure f I can do that). This seems good but I'm not sure how to iterate through the fixtures:
This of course destroys the fixture pointer that the loop is using(EDIT:So only one of my fixtures is getting destroyed then). This is more of a general newbie C++ question I guess but I'm sure someone could help 🙂 Also, I'm wondering if it's better to destroy/recreate the body each frame so I don't have to loop through all the fixtures to destroy them.
Code:
for (b2Fixture* f = collisionBody->GetFixtureList(); f; f = f->GetNext())
{
collisionBody->DestroyFixture(f);
}
{
collisionBody->DestroyFixture(f);
}
This of course destroys the fixture pointer that the loop is using(EDIT:So only one of my fixtures is getting destroyed then). This is more of a general newbie C++ question I guess but I'm sure someone could help 🙂 Also, I'm wondering if it's better to destroy/recreate the body each frame so I don't have to loop through all the fixtures to destroy them.