summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-01-12 13:48:17 +0100
committerGitHub <noreply@github.com>2018-01-12 13:48:17 +0100
commitbab9759645d29686c480d9bd0e6b1c50e4f541ef (patch)
tree2284d1d6fe5dfc7a763d0323fb99ae8c8565c28a /scene/3d
parent3a05d974e0fb925869fe0fdfdbde9da8ee6a2757 (diff)
parentaefedb73fcba789207db4da0d27214eecaf0f078 (diff)
Merge pull request #15606 from RandomShaper/fix-inherited-coll-shapes
Update collision shapes data on tree entered
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/collision_polygon.cpp20
-rw-r--r--scene/3d/collision_polygon.h2
-rw-r--r--scene/3d/collision_shape.cpp17
-rw-r--r--scene/3d/collision_shape.h2
4 files changed, 34 insertions, 7 deletions
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp
index ef1b33a4e2..3a77360bc2 100644
--- a/scene/3d/collision_polygon.cpp
+++ b/scene/3d/collision_polygon.cpp
@@ -73,6 +73,14 @@ void CollisionPolygon::_build_polygon() {
}
}
+void CollisionPolygon::_update_in_shape_owner(bool p_xform_only) {
+
+ parent->shape_owner_set_transform(owner_id, get_transform());
+ if (p_xform_only)
+ return;
+ parent->shape_owner_set_disabled(owner_id, disabled);
+}
+
void CollisionPolygon::_notification(int p_what) {
switch (p_what) {
@@ -82,14 +90,20 @@ void CollisionPolygon::_notification(int p_what) {
if (parent) {
owner_id = parent->create_shape_owner(this);
_build_polygon();
- parent->shape_owner_set_transform(owner_id, get_transform());
- parent->shape_owner_set_disabled(owner_id, disabled);
+ _update_in_shape_owner();
}
} break;
+ case NOTIFICATION_ENTER_TREE: {
+
+ if (parent) {
+ _update_in_shape_owner();
+ }
+
+ } break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
if (parent) {
- parent->shape_owner_set_transform(owner_id, get_transform());
+ _update_in_shape_owner(true);
}
} break;
diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h
index 6643cfa044..971c67f1ad 100644
--- a/scene/3d/collision_polygon.h
+++ b/scene/3d/collision_polygon.h
@@ -51,6 +51,8 @@ protected:
void _build_polygon();
+ void _update_in_shape_owner(bool p_xform_only = false);
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp
index d6d49a197c..943f4158f7 100644
--- a/scene/3d/collision_shape.cpp
+++ b/scene/3d/collision_shape.cpp
@@ -64,6 +64,14 @@ void CollisionShape::make_convex_from_brothers() {
}
}
+void CollisionShape::_update_in_shape_owner(bool p_xform_only) {
+
+ parent->shape_owner_set_transform(owner_id, get_transform());
+ if (p_xform_only)
+ return;
+ parent->shape_owner_set_disabled(owner_id, disabled);
+}
+
void CollisionShape::_notification(int p_what) {
switch (p_what) {
@@ -75,19 +83,20 @@ void CollisionShape::_notification(int p_what) {
if (shape.is_valid()) {
parent->shape_owner_add_shape(owner_id, shape);
}
- parent->shape_owner_set_transform(owner_id, get_transform());
- parent->shape_owner_set_disabled(owner_id, disabled);
+ _update_in_shape_owner();
}
} break;
case NOTIFICATION_ENTER_TREE: {
+ if (parent) {
+ _update_in_shape_owner();
+ }
if (get_tree()->is_debugging_collisions_hint()) {
_create_debug_shape();
}
-
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
if (parent) {
- parent->shape_owner_set_transform(owner_id, get_transform());
+ _update_in_shape_owner(true);
}
} break;
case NOTIFICATION_UNPARENTED: {
diff --git a/scene/3d/collision_shape.h b/scene/3d/collision_shape.h
index 724a025165..c9c91a5824 100644
--- a/scene/3d/collision_shape.h
+++ b/scene/3d/collision_shape.h
@@ -51,6 +51,8 @@ class CollisionShape : public Spatial {
void _create_debug_shape();
+ void _update_in_shape_owner(bool p_xform_only = false);
+
protected:
void _notification(int p_what);
static void _bind_methods();