Pārlūkot izejas kodu

Remove the unnecessary sync() and the restrictions it imposes on 3D Physics.

Marcel Admiraal 5 gadi atpakaļ
vecāks
revīzija
fc72c3fdf5

+ 1 - 1
doc/classes/World.xml

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

+ 1 - 1
doc/classes/World2D.xml

@@ -16,7 +16,7 @@
 			The [RID] of this world's canvas resource. Used by the [VisualServer] for 2D drawing.
 		</member>
 		<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 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.

+ 0 - 1
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();

+ 0 - 3
modules/bullet/bullet_physics_server.cpp

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

+ 0 - 1
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();
 

+ 2 - 11
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();

+ 0 - 2
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();
 

+ 0 - 2
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;

+ 0 - 1
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;