Skip to content

Commit

Permalink
Merge pull request #203 from marynate/PR-fix-collisionshape2d-del-not…
Browse files Browse the repository at this point in the history
…-update

Fixed #173 #157 Update parent when deleting CollisionShape2D
  • Loading branch information
reduz committed Apr 5, 2014
2 parents 1278da7 + ad9bf69 commit 35b84d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion scene/2d/collision_shape_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -189,7 +192,10 @@ void CollisionShape2D::_notification(int p_what) {
rect=rect.grow(3);

} break;

case NOTIFICATION_UNPARENTED: {
unparenting = true;
_update_parent();
} break;
}

}
Expand Down Expand Up @@ -245,4 +251,5 @@ CollisionShape2D::CollisionShape2D() {
rect=Rect2(-Point2(10,10),Point2(20,20));

trigger=false;
unparenting = false;
}
2 changes: 1 addition & 1 deletion scene/2d/collision_shape_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CollisionShape2D : public Node2D {
Ref<Shape2D> shape;
Rect2 rect;
bool trigger;

bool unparenting;
void _shape_changed();
protected:

Expand Down

0 comments on commit 35b84d2

Please sign in to comment.