Fix initial collision pairs being cleared

This affected both 2D & 3D physics and was a regression introduced by my
physics mega-fix (#8999).
This commit is contained in:
Pedro J. Estébanez 2017-07-05 19:28:23 +02:00
parent f99481e0c2
commit a30dd8494c
2 changed files with 8 additions and 8 deletions

View File

@ -232,8 +232,6 @@ void PhysicsServerSW::area_set_space(RID p_area, RID p_space) {
if (area->get_space() == space) if (area->get_space() == space)
return; //pointless return; //pointless
area->set_space(space);
for (Set<ConstraintSW *>::Element *E = area->get_constraints().front(); E; E = E->next()) { for (Set<ConstraintSW *>::Element *E = area->get_constraints().front(); E; E = E->next()) {
RID self = E->get()->get_self(); RID self = E->get()->get_self();
if (!self.is_valid()) if (!self.is_valid())
@ -241,6 +239,8 @@ void PhysicsServerSW::area_set_space(RID p_area, RID p_space) {
free(self); free(self);
} }
area->clear_constraints(); area->clear_constraints();
area->set_space(space);
}; };
RID PhysicsServerSW::area_get_space(RID p_area) const { RID PhysicsServerSW::area_get_space(RID p_area) const {
@ -486,8 +486,6 @@ void PhysicsServerSW::body_set_space(RID p_body, RID p_space) {
if (body->get_space() == space) if (body->get_space() == space)
return; //pointless return; //pointless
body->set_space(space);
for (Map<ConstraintSW *, int>::Element *E = body->get_constraint_map().front(); E; E = E->next()) { for (Map<ConstraintSW *, int>::Element *E = body->get_constraint_map().front(); E; E = E->next()) {
RID self = E->key()->get_self(); RID self = E->key()->get_self();
if (!self.is_valid()) if (!self.is_valid())
@ -495,6 +493,8 @@ void PhysicsServerSW::body_set_space(RID p_body, RID p_space) {
free(self); free(self);
} }
body->clear_constraint_map(); body->clear_constraint_map();
body->set_space(space);
}; };
RID PhysicsServerSW::body_get_space(RID p_body) const { RID PhysicsServerSW::body_get_space(RID p_body) const {

View File

@ -296,8 +296,6 @@ void Physics2DServerSW::area_set_space(RID p_area, RID p_space) {
if (area->get_space() == space) if (area->get_space() == space)
return; //pointless return; //pointless
area->set_space(space);
for (Set<Constraint2DSW *>::Element *E = area->get_constraints().front(); E; E = E->next()) { for (Set<Constraint2DSW *>::Element *E = area->get_constraints().front(); E; E = E->next()) {
RID self = E->get()->get_self(); RID self = E->get()->get_self();
if (!self.is_valid()) if (!self.is_valid())
@ -305,6 +303,8 @@ void Physics2DServerSW::area_set_space(RID p_area, RID p_space) {
free(self); free(self);
} }
area->clear_constraints(); area->clear_constraints();
area->set_space(space);
}; };
RID Physics2DServerSW::area_get_space(RID p_area) const { RID Physics2DServerSW::area_get_space(RID p_area) const {
@ -540,8 +540,6 @@ void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
if (body->get_space() == space) if (body->get_space() == space)
return; //pointless return; //pointless
body->set_space(space);
for (Map<Constraint2DSW *, int>::Element *E = body->get_constraint_map().front(); E; E = E->next()) { for (Map<Constraint2DSW *, int>::Element *E = body->get_constraint_map().front(); E; E = E->next()) {
RID self = E->key()->get_self(); RID self = E->key()->get_self();
if (!self.is_valid()) if (!self.is_valid())
@ -549,6 +547,8 @@ void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
free(self); free(self);
} }
body->clear_constraint_map(); body->clear_constraint_map();
body->set_space(space);
}; };
RID Physics2DServerSW::body_get_space(RID p_body) const { RID Physics2DServerSW::body_get_space(RID p_body) const {