فهرست منبع

Extend check for same space to all 2D/3D bodies/shapes

Pedro J. Estébanez 8 سال پیش
والد
کامیت
bc1d58c50d
2فایلهای تغییر یافته به همراه13 افزوده شده و 2 حذف شده
  1. 6 2
      servers/physics/physics_server_sw.cpp
  2. 7 0
      servers/physics_2d/physics_2d_server_sw.cpp

+ 6 - 2
servers/physics/physics_server_sw.cpp

@@ -222,12 +222,16 @@ void PhysicsServerSW::area_set_space(RID p_area, RID p_space) {
 
 
 	AreaSW *area = area_owner.get(p_area);
 	AreaSW *area = area_owner.get(p_area);
 	ERR_FAIL_COND(!area);
 	ERR_FAIL_COND(!area);
+
 	SpaceSW *space = NULL;
 	SpaceSW *space = NULL;
 	if (p_space.is_valid()) {
 	if (p_space.is_valid()) {
 		space = space_owner.get(p_space);
 		space = space_owner.get(p_space);
 		ERR_FAIL_COND(!space);
 		ERR_FAIL_COND(!space);
 	}
 	}
 
 
+	if (area->get_space() == space)
+		return; //pointless
+
 	area->set_space(space);
 	area->set_space(space);
 };
 };
 
 
@@ -471,15 +475,15 @@ void PhysicsServerSW::body_set_space(RID p_body, RID p_space) {
 
 
 	BodySW *body = body_owner.get(p_body);
 	BodySW *body = body_owner.get(p_body);
 	ERR_FAIL_COND(!body);
 	ERR_FAIL_COND(!body);
-	SpaceSW *space = NULL;
 
 
+	SpaceSW *space = NULL;
 	if (p_space.is_valid()) {
 	if (p_space.is_valid()) {
 		space = space_owner.get(p_space);
 		space = space_owner.get(p_space);
 		ERR_FAIL_COND(!space);
 		ERR_FAIL_COND(!space);
 	}
 	}
 
 
 	if (body->get_space() == space)
 	if (body->get_space() == space)
-		return; //pointles
+		return; //pointless
 
 
 	body->set_space(space);
 	body->set_space(space);
 };
 };

+ 7 - 0
servers/physics_2d/physics_2d_server_sw.cpp

@@ -286,12 +286,16 @@ void Physics2DServerSW::area_set_space(RID p_area, RID p_space) {
 
 
 	Area2DSW *area = area_owner.get(p_area);
 	Area2DSW *area = area_owner.get(p_area);
 	ERR_FAIL_COND(!area);
 	ERR_FAIL_COND(!area);
+
 	Space2DSW *space = NULL;
 	Space2DSW *space = NULL;
 	if (p_space.is_valid()) {
 	if (p_space.is_valid()) {
 		space = space_owner.get(p_space);
 		space = space_owner.get(p_space);
 		ERR_FAIL_COND(!space);
 		ERR_FAIL_COND(!space);
 	}
 	}
 
 
+	if (area->get_space() == space)
+		return; //pointless
+
 	area->set_space(space);
 	area->set_space(space);
 };
 };
 
 
@@ -533,6 +537,9 @@ void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
 		ERR_FAIL_COND(!space);
 		ERR_FAIL_COND(!space);
 	}
 	}
 
 
+	if (body->get_space() == space)
+		return; //pointless
+
 	body->set_space(space);
 	body->set_space(space);
 };
 };