|
@@ -222,12 +222,24 @@ 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
|
|
|
|
+
|
|
|
|
+ for (Set<ConstraintSW *>::Element *E = area->get_constraints().front(); E; E = E->next()) {
|
|
|
|
+ RID self = E->get()->get_self();
|
|
|
|
+ if (!self.is_valid())
|
|
|
|
+ continue;
|
|
|
|
+ free(self);
|
|
|
|
+ }
|
|
|
|
+ area->clear_constraints();
|
|
|
|
+
|
|
area->set_space(space);
|
|
area->set_space(space);
|
|
};
|
|
};
|
|
|
|
|
|
@@ -471,15 +483,23 @@ 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
|
|
|
|
+
|
|
|
|
+ while (body->get_constraint_map().size()) {
|
|
|
|
+ RID self = body->get_constraint_map().front()->key()->get_self();
|
|
|
|
+ if (!self.is_valid())
|
|
|
|
+ continue;
|
|
|
|
+ free(self);
|
|
|
|
+ }
|
|
|
|
+ body->clear_constraint_map();
|
|
|
|
|
|
body->set_space(space);
|
|
body->set_space(space);
|
|
};
|
|
};
|
|
@@ -1329,12 +1349,6 @@ void PhysicsServerSW::free(RID p_rid) {
|
|
body->remove_shape(0);
|
|
body->remove_shape(0);
|
|
}
|
|
}
|
|
|
|
|
|
- while (body->get_constraint_map().size()) {
|
|
|
|
- RID self = body->get_constraint_map().front()->key()->get_self();
|
|
|
|
- ERR_FAIL_COND(!self.is_valid());
|
|
|
|
- free(self);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
body_owner.free(p_rid);
|
|
body_owner.free(p_rid);
|
|
memdelete(body);
|
|
memdelete(body);
|
|
|
|
|