diff options
Diffstat (limited to 'servers/physics_2d')
-rw-r--r-- | servers/physics_2d/physics_2d_server_wrap_mt.cpp | 15 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_wrap_mt.h | 2 |
2 files changed, 5 insertions, 12 deletions
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index 7070902f77..76036930c6 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp @@ -40,7 +40,7 @@ void Physics2DServerWrapMT::thread_exit() { void Physics2DServerWrapMT::thread_step(real_t p_delta) { physics_2d_server->step(p_delta); - step_sem->post(); + step_sem.post(); } void Physics2DServerWrapMT::_thread_callback(void *_instance) { @@ -84,11 +84,11 @@ void Physics2DServerWrapMT::step(real_t p_step) { void Physics2DServerWrapMT::sync() { - if (step_sem) { + if (thread) { if (first_frame) first_frame = false; else - step_sem->wait(); //must not wait if a step was not issued + step_sem.wait(); //must not wait if a step was not issued } physics_2d_server->sync(); } @@ -107,11 +107,8 @@ void Physics2DServerWrapMT::init() { if (create_thread) { - step_sem = SemaphoreOld::create(); //OS::get_singleton()->release_rendering_thread(); - if (create_thread) { - thread = Thread::create(_thread_callback, this); - } + thread = Thread::create(_thread_callback, this); while (!step_thread_up) { OS::get_singleton()->delay_usec(1000); } @@ -146,9 +143,6 @@ void Physics2DServerWrapMT::finish() { space_free_cached_ids(); area_free_cached_ids(); body_free_cached_ids(); - - if (step_sem) - memdelete(step_sem); } Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool p_create_thread) : @@ -157,7 +151,6 @@ Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool physics_2d_server = p_contained; create_thread = p_create_thread; thread = NULL; - step_sem = NULL; step_pending = 0; step_thread_up = false; diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 0648b8651f..4d5e317c8c 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -58,7 +58,7 @@ class Physics2DServerWrapMT : public Physics2DServer { volatile bool step_thread_up; bool create_thread; - SemaphoreOld *step_sem; + Semaphore step_sem; int step_pending; void thread_step(real_t p_delta); void thread_flush(); |