diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-10-02 09:41:55 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-10-02 09:41:55 +0200 |
commit | 7b18a7143be13830f54fcfa8d49035f822e81eab (patch) | |
tree | 32abd86695948783ffe220f162e70e4fafc9efac /scene/3d | |
parent | 48afdfddb583c117ea3fff49d94b781b676b38e7 (diff) |
Better validate CollisionShape3D config. warning after #38743
Relates to #42479, though I don't think it would crash in the master version.
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/collision_shape_3d.cpp | 15 | ||||
-rw-r--r-- | scene/3d/navigation_region_3d.cpp | 4 |
2 files changed, 10 insertions, 9 deletions
diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index 6ff0ce6032..e1c691b89a 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -140,15 +140,14 @@ String CollisionShape3D::get_configuration_warning() const { warning += TTR("A shape must be provided for CollisionShape3D to function. Please create a shape resource for it."); } - if (Object::cast_to<RigidBody3D>(get_parent())) { - if (Object::cast_to<ConcavePolygonShape3D>(*shape)) { - if (Object::cast_to<RigidBody3D>(get_parent())->get_mode() != RigidBody3D::MODE_STATIC) { - if (!warning.empty()) { - warning += "\n\n"; - } - warning += TTR("ConcavePolygonShape3D doesn't support RigidBody3D in another mode than static."); - } + if (shape.is_valid() && + Object::cast_to<RigidBody3D>(get_parent()) && + Object::cast_to<ConcavePolygonShape3D>(*shape) && + Object::cast_to<RigidBody3D>(get_parent())->get_mode() != RigidBody3D::MODE_STATIC) { + if (!warning.empty()) { + warning += "\n\n"; } + warning += TTR("ConcavePolygonShape3D doesn't support RigidBody3D in another mode than static."); } return warning; diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index 71bc74f433..3d3467583d 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -197,10 +197,12 @@ String NavigationRegion3D::get_configuration_warning() const { } warning += TTR("A NavigationMesh resource must be set or created for this node to work."); } + const Node3D *c = this; while (c) { - if (Object::cast_to<Navigation3D>(c)) + if (Object::cast_to<Navigation3D>(c)) { return warning; + } c = Object::cast_to<Node3D>(c->get_parent()); } |