summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2014-04-05 09:55:21 -0300
committerreduz <reduzio@gmail.com>2014-04-05 09:55:21 -0300
commit35b84d2c85fd152bee05d7d5a05e20a5f602a285 (patch)
treecf112330aa05f9ca94904187d118c50bf9de6c08 /scene/2d
parent1278da71eade8a6a29bee1d5fa52470620923a62 (diff)
parentad9bf692838aa7a13f37ee90b9d6086a3dae2a5f (diff)
Merge pull request #203 from marynate/PR-fix-collisionshape2d-del-not-update
Fixed #173 #157 Update parent when deleting CollisionShape2D
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/collision_shape_2d.cpp9
-rw-r--r--scene/2d/collision_shape_2d.h2
2 files changed, 9 insertions, 2 deletions
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index 4ae9b37c21..f7e4c5faf0 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -39,6 +39,9 @@
void CollisionShape2D::_add_to_collision_object(Object *p_obj) {
+ if (unparenting)
+ return;
+
CollisionObject2D *co = p_obj->cast_to<CollisionObject2D>();
ERR_FAIL_COND(!co);
co->add_shape(shape,get_transform());
@@ -189,7 +192,10 @@ void CollisionShape2D::_notification(int p_what) {
rect=rect.grow(3);
} break;
-
+ case NOTIFICATION_UNPARENTED: {
+ unparenting = true;
+ _update_parent();
+ } break;
}
}
@@ -245,4 +251,5 @@ CollisionShape2D::CollisionShape2D() {
rect=Rect2(-Point2(10,10),Point2(20,20));
trigger=false;
+ unparenting = false;
}
diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h
index 2e2023f54d..a89af49a34 100644
--- a/scene/2d/collision_shape_2d.h
+++ b/scene/2d/collision_shape_2d.h
@@ -38,7 +38,7 @@ class CollisionShape2D : public Node2D {
Ref<Shape2D> shape;
Rect2 rect;
bool trigger;
-
+ bool unparenting;
void _shape_changed();
protected: