Hi there!, this is the first time I'm writting in this forum. Thank you so much for your hard work!
I've readed lots of post and questions about the same question, but I still can't figure why I'm having this issue. A strange thing is that on Ubuntu it seems to work perfectly, but when I'm working on Windows 7 with a MSVC compiler sometimes it raises me this Assertion:
assertion failed (m_world-is locked() == false)
I've seen that this could be caused because bad deletion of bodies (inside a step, for example).
Here is my code: I've extended the library to use it as third party in my engine:
As you can see, in first place, I'm taking the step and, when it finishes, I destroy the elements who has been removed from my scene (stored at dirtyElements) and same for the joints. At last, I update graphical representation of bodies. Probably I'm not properely understanding something, but I can't figure why in Ubuntu it works perfectly and this Assertion only raises on Windows 🙁 Should I add a active waiting in my code somewhere else? Something like:
Any clue or tip please?
Thank you so much in advance and best regards 🙂
maije
I've readed lots of post and questions about the same question, but I still can't figure why I'm having this issue. A strange thing is that on Ubuntu it seems to work perfectly, but when I'm working on Windows 7 with a MSVC compiler sometimes it raises me this Assertion:
assertion failed (m_world-is locked() == false)
I've seen that this could be caused because bad deletion of bodies (inside a step, for example).
Here is my code: I've extended the library to use it as third party in my engine:
Code:
void PhysicWorld::step()
{
world->Step(timeStep / 1000.0f, velocityIterations, positionIterations);
// Clean widgets destroyed at collisions
if (dirtyElements.size() > 0)
{
for (auto it = dirtyElements.begin(); it != dirtyElements.end(); it++)
world->DestroyBody(*it);
dirtyElements.clear();
}
if (dirtyJoints.size() > 0)
{
for (auto it = dirtyJoints.begin(); it != dirtyJoints.end(); it++)
world->DestroyJoint(*it);
dirtyJoints.clear();
}
// Update widgets
for (b2Body *b = world->GetBodyList(); b; b = b->GetNext())
if (b->GetUserData()) ((PhysicWidget *) b->GetUserData())->updateGraphicComponent();
}
{
world->Step(timeStep / 1000.0f, velocityIterations, positionIterations);
// Clean widgets destroyed at collisions
if (dirtyElements.size() > 0)
{
for (auto it = dirtyElements.begin(); it != dirtyElements.end(); it++)
world->DestroyBody(*it);
dirtyElements.clear();
}
if (dirtyJoints.size() > 0)
{
for (auto it = dirtyJoints.begin(); it != dirtyJoints.end(); it++)
world->DestroyJoint(*it);
dirtyJoints.clear();
}
// Update widgets
for (b2Body *b = world->GetBodyList(); b; b = b->GetNext())
if (b->GetUserData()) ((PhysicWidget *) b->GetUserData())->updateGraphicComponent();
}
As you can see, in first place, I'm taking the step and, when it finishes, I destroy the elements who has been removed from my scene (stored at dirtyElements) and same for the joints. At last, I update graphical representation of bodies. Probably I'm not properely understanding something, but I can't figure why in Ubuntu it works perfectly and this Assertion only raises on Windows 🙁 Should I add a active waiting in my code somewhere else? Something like:
Code:
[...]
world->Step(timeStep / 1000.0f, velocityIterations, positionIterations);
while (world->IsLocked()) {}
// Clean widgets destroyed at collisions
if (dirtyElements.size() > 0)
[...]
world->Step(timeStep / 1000.0f, velocityIterations, positionIterations);
while (world->IsLocked()) {}
// Clean widgets destroyed at collisions
if (dirtyElements.size() > 0)
[...]
Any clue or tip please?
Thank you so much in advance and best regards 🙂
maije