Merge pull request #42168 from madmiraal/fix-42108-3.2

[3.2]  Remove the unnecessary sync() and the restrictions it imposes on 3D Physics.
This commit is contained in:
Rémi Verschelde 2020-11-16 09:33:17 +01:00 committed by GitHub
commit fc5b106369
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 4 additions and 23 deletions

View file

@ -13,7 +13,7 @@
</methods> </methods>
<members> <members>
<member name="direct_space_state" type="PhysicsDirectSpaceState" setter="" getter="get_direct_space_state"> <member name="direct_space_state" type="PhysicsDirectSpaceState" setter="" getter="get_direct_space_state">
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.
</member> </member>
<member name="environment" type="Environment" setter="set_environment" getter="get_environment"> <member name="environment" type="Environment" setter="set_environment" getter="get_environment">
The World's [Environment]. The World's [Environment].

View file

@ -16,7 +16,7 @@
The [RID] of this world's canvas resource. Used by the [VisualServer] for 2D drawing. The [RID] of this world's canvas resource. Used by the [VisualServer] for 2D drawing.
</member> </member>
<member name="direct_space_state" type="Physics2DDirectSpaceState" setter="" getter="get_direct_space_state"> <member name="direct_space_state" type="Physics2DDirectSpaceState" setter="" getter="get_direct_space_state">
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.
</member> </member>
<member name="space" type="RID" setter="" getter="get_space"> <member name="space" type="RID" setter="" getter="get_space">
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. 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.

View file

@ -2079,7 +2079,6 @@ bool Main::iteration() {
uint64_t physics_begin = OS::get_singleton()->get_ticks_usec(); uint64_t physics_begin = OS::get_singleton()->get_ticks_usec();
PhysicsServer::get_singleton()->sync();
PhysicsServer::get_singleton()->flush_queries(); PhysicsServer::get_singleton()->flush_queries();
Physics2DServer::get_singleton()->sync(); Physics2DServer::get_singleton()->sync();

View file

@ -1568,9 +1568,6 @@ void BulletPhysicsServer::step(float p_deltaTime) {
} }
} }
void BulletPhysicsServer::sync() {
}
void BulletPhysicsServer::flush_queries() { void BulletPhysicsServer::flush_queries() {
} }

View file

@ -396,7 +396,6 @@ public:
virtual void init(); virtual void init();
virtual void step(float p_deltaTime); virtual void step(float p_deltaTime);
virtual void sync();
virtual void flush_queries(); virtual void flush_queries();
virtual void finish(); virtual void finish();

View file

@ -196,7 +196,7 @@ PhysicsDirectSpaceState *PhysicsServerSW::space_get_direct_state(RID p_space) {
SpaceSW *space = space_owner.get(p_space); SpaceSW *space = space_owner.get(p_space);
ERR_FAIL_COND_V(!space, NULL); 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(); 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); BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body, NULL); 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; direct_state->body = body;
return direct_state; return direct_state;
@ -1408,7 +1408,6 @@ void PhysicsServerSW::set_active(bool p_active) {
void PhysicsServerSW::init() { void PhysicsServerSW::init() {
doing_sync = true;
last_step = 0.001; last_step = 0.001;
iterations = 8; // 8? iterations = 8; // 8?
stepper = memnew(StepSW); stepper = memnew(StepSW);
@ -1424,8 +1423,6 @@ void PhysicsServerSW::step(real_t p_step) {
_update_shapes(); _update_shapes();
doing_sync = false;
last_step = p_step; last_step = p_step;
PhysicsDirectBodyStateSW::singleton->step = p_step; PhysicsDirectBodyStateSW::singleton->step = p_step;
@ -1442,10 +1439,6 @@ void PhysicsServerSW::step(real_t p_step) {
#endif #endif
} }
void PhysicsServerSW::sync(){
};
void PhysicsServerSW::flush_queries() { void PhysicsServerSW::flush_queries() {
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
@ -1453,8 +1446,6 @@ void PhysicsServerSW::flush_queries() {
if (!active) if (!active)
return; return;
doing_sync = true;
flushing_queries = true; flushing_queries = true;
uint64_t time_beg = OS::get_singleton()->get_ticks_usec(); uint64_t time_beg = OS::get_singleton()->get_ticks_usec();

View file

@ -44,7 +44,6 @@ class PhysicsServerSW : public PhysicsServer {
friend class PhysicsDirectSpaceStateSW; friend class PhysicsDirectSpaceStateSW;
bool active; bool active;
int iterations; int iterations;
bool doing_sync;
real_t last_step; real_t last_step;
int island_count; int island_count;
@ -366,7 +365,6 @@ public:
virtual void set_active(bool p_active); virtual void set_active(bool p_active);
virtual void init(); virtual void init();
virtual void step(real_t p_step); virtual void step(real_t p_step);
virtual void sync();
virtual void flush_queries(); virtual void flush_queries();
virtual void finish(); virtual void finish();

View file

@ -1332,8 +1332,6 @@ void Physics2DServerSW::step(real_t p_step) {
_update_shapes(); _update_shapes();
doing_sync = false;
last_step = p_step; last_step = p_step;
Physics2DDirectBodyStateSW::singleton->step = p_step; Physics2DDirectBodyStateSW::singleton->step = p_step;
island_count = 0; island_count = 0;

View file

@ -757,7 +757,6 @@ public:
virtual void set_active(bool p_active) = 0; virtual void set_active(bool p_active) = 0;
virtual void init() = 0; virtual void init() = 0;
virtual void step(float p_step) = 0; virtual void step(float p_step) = 0;
virtual void sync() = 0;
virtual void flush_queries() = 0; virtual void flush_queries() = 0;
virtual void finish() = 0; virtual void finish() = 0;