summaryrefslogtreecommitdiff
path: root/scene/3d/physics_body.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/physics_body.cpp')
-rw-r--r--scene/3d/physics_body.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 7d638d8737..25acd6deb0 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -258,6 +258,7 @@ void RigidBody::_body_enter_tree(ObjectID p_id) {
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
+ ERR_FAIL_COND(!contact_monitor);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(E->get().in_tree);
@@ -281,6 +282,7 @@ void RigidBody::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
+ ERR_FAIL_COND(!contact_monitor);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
@@ -306,6 +308,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
Object *obj = ObjectDB::get_instance(objid);
Node *node = Object::cast_to<Node>(obj);
+ ERR_FAIL_COND(!contact_monitor);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(objid);
ERR_FAIL_COND(!body_in && !E);
@@ -318,7 +321,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
E->get().in_tree = node && node->is_inside_tree();
if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
}
@@ -345,7 +348,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (in_tree)
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
}
@@ -719,6 +722,14 @@ void RigidBody::set_contact_monitor(bool p_enabled) {
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
//clean up mess
+ Object *obj = ObjectDB::get_instance(E->key());
+ Node *node = Object::cast_to<Node>(obj);
+
+ if (node) {
+
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
+ }
}
memdelete(contact_monitor);
@@ -772,7 +783,7 @@ String RigidBody::get_configuration_warning() const {
if (warning != String()) {
warning += "\n";
}
- warning += TTR("Size changes to RigidBody (in character or rigid modes) will be overriden by the physics engine when running.\nChange the size in children collision shapes instead.");
+ warning += TTR("Size changes to RigidBody (in character or rigid modes) will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.");
}
return warning;