in the main Thread we create physics World, and update his in another Thread, to increase game performance using a multi-core processor.
Because the main Thread uses maximum 35% of my 4-core processor.
This is possible to do?
Has anyone done this?
I try, but have error with "locked" World:
Code: Select all
Box2D assertion failed: m_world->IsLocked() == false
Check the world:IsLocked() every time, when need do something with physics - it's not the best solution.
Update -------------------------------------------------------------------------------------------------------------------
Box2d API World have Step() function, which fully controlled world update.
I found this tutorials for pausing world:
http://box2d.org/forum/viewtopic.php?t=6049
http://www.iforce2d.net/b2dtut/worlds
Found multithreading C++ Box2d library: https://github.com/skitzoid/Box2D-MT
Maybe need update LOVE2d physics world API, adding step() function for manual update world?
Demo.
version 0.0.3
[FIX] error with "locked" World still be if press 'up' (body:setPosition())
version 0.0.2
Ok, physics work in Thread, but error with "locked" World still be if press 'up' (body:setPosition()), like s-ol say.
Thanks s-ol for help.