From fc72c3fdf5e155f13a86069fdcf1b26be9525d1e Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Fri, 18 Sep 2020 10:24:57 +0100 Subject: [PATCH] Remove the unnecessary sync() and the restrictions it imposes on 3D Physics. --- doc/classes/World.xml | 2 +- doc/classes/World2D.xml | 2 +- main/main.cpp | 1 - modules/bullet/bullet_physics_server.cpp | 3 --- modules/bullet/bullet_physics_server.h | 1 - servers/physics/physics_server_sw.cpp | 13 ++----------- servers/physics/physics_server_sw.h | 2 -- servers/physics_2d/physics_2d_server_sw.cpp | 2 -- servers/physics_server.h | 1 - 9 files changed, 4 insertions(+), 23 deletions(-) diff --git a/doc/classes/World.xml b/doc/classes/World.xml index 58ea063bd76..5685020b1c8 100644 --- a/doc/classes/World.xml +++ b/doc/classes/World.xml @@ -13,7 +13,7 @@ - Direct access to the world's physics 3D space state. Used for querying current and potential collisions. Must only be accessed from within [code]_physics_process(delta)[/code]. + Direct access to the world's physics 3D space state. Used for querying current and potential collisions. The World's [Environment]. diff --git a/doc/classes/World2D.xml b/doc/classes/World2D.xml index 8748e2926b0..5efd8b5bcec 100644 --- a/doc/classes/World2D.xml +++ b/doc/classes/World2D.xml @@ -16,7 +16,7 @@ The [RID] of this world's canvas resource. Used by the [VisualServer] for 2D drawing. - Direct access to the world's physics 2D space state. Used for querying current and potential collisions. Must only be accessed from the main thread within [code]_physics_process(delta)[/code]. + Direct access to the world's physics 2D space state. Used for querying current and potential collisions. When using multi-threaded physics, access is limited to [code]_physics_process(delta)[/code] in the main thread. The [RID] of this world's physics space resource. Used by the [Physics2DServer] for 2D physics, treating it as both a space and an area. diff --git a/main/main.cpp b/main/main.cpp index 551b5ccf5d9..24650899f58 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2075,7 +2075,6 @@ bool Main::iteration() { uint64_t physics_begin = OS::get_singleton()->get_ticks_usec(); - PhysicsServer::get_singleton()->sync(); PhysicsServer::get_singleton()->flush_queries(); Physics2DServer::get_singleton()->sync(); diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 6662e130c8d..4d9d05001f7 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -1568,9 +1568,6 @@ void BulletPhysicsServer::step(float p_deltaTime) { } } -void BulletPhysicsServer::sync() { -} - void BulletPhysicsServer::flush_queries() { } diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h index 4a3b4a2edc6..381c5191399 100644 --- a/modules/bullet/bullet_physics_server.h +++ b/modules/bullet/bullet_physics_server.h @@ -396,7 +396,6 @@ public: virtual void init(); virtual void step(float p_deltaTime); - virtual void sync(); virtual void flush_queries(); virtual void finish(); diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 7c950829ca4..bd6463d357c 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -196,7 +196,7 @@ PhysicsDirectSpaceState *PhysicsServerSW::space_get_direct_state(RID p_space) { SpaceSW *space = space_owner.get(p_space); ERR_FAIL_COND_V(!space, NULL); - ERR_FAIL_COND_V_MSG(!doing_sync || space->is_locked(), NULL, "Space state is inaccessible right now, wait for iteration or physics process notification."); + ERR_FAIL_COND_V_MSG(space->is_locked(), NULL, "Space state is inaccessible right now, wait for iteration or physics process notification."); return space->get_direct_state(); } @@ -979,7 +979,7 @@ PhysicsDirectBodyState *PhysicsServerSW::body_get_direct_state(RID p_body) { BodySW *body = body_owner.get(p_body); ERR_FAIL_COND_V(!body, NULL); - ERR_FAIL_COND_V_MSG(!doing_sync || body->get_space()->is_locked(), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification."); + ERR_FAIL_COND_V_MSG(body->get_space()->is_locked(), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification."); direct_state->body = body; return direct_state; @@ -1408,7 +1408,6 @@ void PhysicsServerSW::set_active(bool p_active) { void PhysicsServerSW::init() { - doing_sync = true; last_step = 0.001; iterations = 8; // 8? stepper = memnew(StepSW); @@ -1424,8 +1423,6 @@ void PhysicsServerSW::step(real_t p_step) { _update_shapes(); - doing_sync = false; - last_step = p_step; PhysicsDirectBodyStateSW::singleton->step = p_step; @@ -1442,10 +1439,6 @@ void PhysicsServerSW::step(real_t p_step) { #endif } -void PhysicsServerSW::sync(){ - -}; - void PhysicsServerSW::flush_queries() { #ifndef _3D_DISABLED @@ -1453,8 +1446,6 @@ void PhysicsServerSW::flush_queries() { if (!active) return; - doing_sync = true; - flushing_queries = true; uint64_t time_beg = OS::get_singleton()->get_ticks_usec(); diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h index 0b7b9fb145b..e6274c6282b 100644 --- a/servers/physics/physics_server_sw.h +++ b/servers/physics/physics_server_sw.h @@ -44,7 +44,6 @@ class PhysicsServerSW : public PhysicsServer { friend class PhysicsDirectSpaceStateSW; bool active; int iterations; - bool doing_sync; real_t last_step; int island_count; @@ -366,7 +365,6 @@ public: virtual void set_active(bool p_active); virtual void init(); virtual void step(real_t p_step); - virtual void sync(); virtual void flush_queries(); virtual void finish(); diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 809c5c40e06..3a3a2e46883 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -1331,8 +1331,6 @@ void Physics2DServerSW::step(real_t p_step) { _update_shapes(); - doing_sync = false; - last_step = p_step; Physics2DDirectBodyStateSW::singleton->step = p_step; island_count = 0; diff --git a/servers/physics_server.h b/servers/physics_server.h index 6a66763b2f3..b51638427f6 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -757,7 +757,6 @@ public: virtual void set_active(bool p_active) = 0; virtual void init() = 0; virtual void step(float p_step) = 0; - virtual void sync() = 0; virtual void flush_queries() = 0; virtual void finish() = 0;