diff options
Diffstat (limited to 'servers/physics_2d')
| -rw-r--r-- | servers/physics_2d/area_2d_sw.cpp | 4 | ||||
| -rw-r--r-- | servers/physics_2d/body_2d_sw.cpp | 2 | ||||
| -rw-r--r-- | servers/physics_2d/physics_2d_server_sw.cpp | 7 | ||||
| -rw-r--r-- | servers/physics_2d/physics_2d_server_wrap_mt.cpp | 17 | ||||
| -rw-r--r-- | servers/physics_2d/physics_2d_server_wrap_mt.h | 4 | ||||
| -rw-r--r-- | servers/physics_2d/shape_2d_sw.cpp | 28 | ||||
| -rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 2 |
7 files changed, 27 insertions, 37 deletions
diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp index c67d870b2a..45666d9d09 100644 --- a/servers/physics_2d/area_2d_sw.cpp +++ b/servers/physics_2d/area_2d_sw.cpp @@ -200,7 +200,7 @@ void Area2DSW::call_queries() { res[3] = E->key().body_shape; res[4] = E->key().area_shape; - Variant::CallError ce; + Callable::CallError ce; obj->call(monitor_callback_method, (const Variant **)resptr, 5, ce); } } @@ -232,7 +232,7 @@ void Area2DSW::call_queries() { res[3] = E->key().body_shape; res[4] = E->key().area_shape; - Variant::CallError ce; + Callable::CallError ce; obj->call(area_monitor_callback_method, (const Variant **)resptr, 5, ce); } } diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 4de52cacbd..863b422996 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -612,7 +612,7 @@ void Body2DSW::call_queries() { set_force_integration_callback(ObjectID(), StringName()); } else { - Variant::CallError ce; + Callable::CallError ce; if (fi_callback->callback_udata.get_type() != Variant::NIL) { obj->call(fi_callback->method, vp, 2, ce); diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index aa374aa6bc..baeb3f76b0 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -32,9 +32,9 @@ #include "broad_phase_2d_basic.h" #include "broad_phase_2d_hash_grid.h" #include "collision_solver_2d_sw.h" +#include "core/debugger/engine_debugger.h" #include "core/os/os.h" #include "core/project_settings.h" -#include "core/script_language.h" #define FLUSH_QUERY_CHECK(m_object) \ ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead."); @@ -1369,7 +1369,7 @@ void Physics2DServerSW::flush_queries() { flushing_queries = false; - if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_profiling()) { + if (EngineDebugger::is_profiling("servers")) { uint64_t total_time[Space2DSW::ELAPSED_TIME_MAX]; static const char *time_name[Space2DSW::ELAPSED_TIME_MAX] = { @@ -1400,7 +1400,8 @@ void Physics2DServerSW::flush_queries() { values.push_back("flush_queries"); values.push_back(USEC_TO_SEC(OS::get_singleton()->get_ticks_usec() - time_beg)); - ScriptDebugger::get_singleton()->add_profiling_frame_data("physics_2d", values); + values.push_front("physics_2d"); + EngineDebugger::profiler_add_frame_data("servers", values); } } diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index 291693de39..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,10 +151,8 @@ 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; - alloc_mutex = Mutex::create(); pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); @@ -177,6 +169,5 @@ Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool Physics2DServerWrapMT::~Physics2DServerWrapMT() { memdelete(physics_2d_server); - memdelete(alloc_mutex); //finish(); } diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 9a01344390..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(); @@ -67,7 +67,7 @@ class Physics2DServerWrapMT : public Physics2DServer { bool first_frame; - Mutex *alloc_mutex; + Mutex alloc_mutex; int pool_max_size; public: diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index 75c604f0fa..5fefb9595f 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -639,19 +639,19 @@ real_t ConvexPolygonShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 void ConvexPolygonShape2DSW::set_data(const Variant &p_data) { - ERR_FAIL_COND(p_data.get_type() != Variant::POOL_VECTOR2_ARRAY && p_data.get_type() != Variant::POOL_REAL_ARRAY); + ERR_FAIL_COND(p_data.get_type() != Variant::PACKED_VECTOR2_ARRAY && p_data.get_type() != Variant::PACKED_FLOAT32_ARRAY); if (points) memdelete_arr(points); points = NULL; point_count = 0; - if (p_data.get_type() == Variant::POOL_VECTOR2_ARRAY) { - PoolVector<Vector2> arr = p_data; + if (p_data.get_type() == Variant::PACKED_VECTOR2_ARRAY) { + Vector<Vector2> arr = p_data; ERR_FAIL_COND(arr.size() == 0); point_count = arr.size(); points = memnew_arr(Point, point_count); - PoolVector<Vector2>::Read r = arr.read(); + const Vector2 *r = arr.ptr(); for (int i = 0; i < point_count; i++) { points[i].pos = r[i]; @@ -665,12 +665,12 @@ void ConvexPolygonShape2DSW::set_data(const Variant &p_data) { } } else { - PoolVector<real_t> dvr = p_data; + Vector<real_t> dvr = p_data; point_count = dvr.size() / 4; ERR_FAIL_COND(point_count == 0); points = memnew_arr(Point, point_count); - PoolVector<real_t>::Read r = dvr.read(); + const real_t *r = dvr.ptr(); for (int i = 0; i < point_count; i++) { @@ -693,7 +693,7 @@ void ConvexPolygonShape2DSW::set_data(const Variant &p_data) { Variant ConvexPolygonShape2DSW::get_data() const { - PoolVector<Vector2> dvr; + Vector<Vector2> dvr; dvr.resize(point_count); @@ -899,13 +899,13 @@ int ConcavePolygonShape2DSW::_generate_bvh(BVH *p_bvh, int p_len, int p_depth) { void ConcavePolygonShape2DSW::set_data(const Variant &p_data) { - ERR_FAIL_COND(p_data.get_type() != Variant::POOL_VECTOR2_ARRAY && p_data.get_type() != Variant::POOL_REAL_ARRAY); + ERR_FAIL_COND(p_data.get_type() != Variant::PACKED_VECTOR2_ARRAY && p_data.get_type() != Variant::PACKED_FLOAT32_ARRAY); Rect2 aabb; - if (p_data.get_type() == Variant::POOL_VECTOR2_ARRAY) { + if (p_data.get_type() == Variant::PACKED_VECTOR2_ARRAY) { - PoolVector<Vector2> p2arr = p_data; + Vector<Vector2> p2arr = p_data; int len = p2arr.size(); ERR_FAIL_COND(len % 2); @@ -919,7 +919,7 @@ void ConcavePolygonShape2DSW::set_data(const Variant &p_data) { return; } - PoolVector<Vector2>::Read arr = p2arr.read(); + const Vector2 *arr = p2arr.ptr(); Map<Point2, int> pointmap; for (int i = 0; i < len; i += 2) { @@ -976,18 +976,16 @@ void ConcavePolygonShape2DSW::set_data(const Variant &p_data) { } Variant ConcavePolygonShape2DSW::get_data() const { - PoolVector<Vector2> rsegments; + Vector<Vector2> rsegments; int len = segments.size(); rsegments.resize(len * 2); - PoolVector<Vector2>::Write w = rsegments.write(); + Vector2 *w = rsegments.ptrw(); for (int i = 0; i < len; i++) { w[(i << 1) + 0] = points[segments[i].points[0]]; w[(i << 1) + 1] = points[segments[i].points[1]]; } - w.release(); - return rsegments; } diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 83bcae4607..2009cb823d 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -1346,7 +1346,7 @@ Space2DSW::Space2DSW() { body_linear_velocity_sleep_threshold = GLOBAL_DEF("physics/2d/sleep_threshold_linear", 2.0); body_angular_velocity_sleep_threshold = GLOBAL_DEF("physics/2d/sleep_threshold_angular", (8.0 / 180.0 * Math_PI)); body_time_to_sleep = GLOBAL_DEF("physics/2d/time_before_sleep", 0.5); - ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/time_before_sleep", PropertyInfo(Variant::REAL, "physics/2d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); + ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/time_before_sleep", PropertyInfo(Variant::FLOAT, "physics/2d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); broadphase = BroadPhase2DSW::create_func(); broadphase->set_pair_callback(_broadphase_pair, this); |