Better validate CollisionShape3D config. warning after #38743

Relates to #42479, though I don't think it would crash in the master version.
This commit is contained in:
Rémi Verschelde 2020-10-02 09:41:55 +02:00
parent 48afdfddb5
commit 7b18a7143b
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 12 additions and 10 deletions

View File

@ -313,8 +313,9 @@ String Light2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning(); String warning = Node2D::get_configuration_warning();
if (!texture.is_valid()) { if (!texture.is_valid()) {
if (!warning.empty()) if (!warning.empty()) {
warning += "\n\n"; warning += "\n\n";
}
warning += TTR("A texture with the shape of the light must be supplied to the \"Texture\" property."); warning += TTR("A texture with the shape of the light must be supplied to the \"Texture\" property.");
} }

View File

@ -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."); 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 (shape.is_valid() &&
if (Object::cast_to<ConcavePolygonShape3D>(*shape)) { Object::cast_to<RigidBody3D>(get_parent()) &&
if (Object::cast_to<RigidBody3D>(get_parent())->get_mode() != RigidBody3D::MODE_STATIC) { Object::cast_to<ConcavePolygonShape3D>(*shape) &&
if (!warning.empty()) { Object::cast_to<RigidBody3D>(get_parent())->get_mode() != RigidBody3D::MODE_STATIC) {
warning += "\n\n"; if (!warning.empty()) {
} warning += "\n\n";
warning += TTR("ConcavePolygonShape3D doesn't support RigidBody3D in another mode than static.");
}
} }
warning += TTR("ConcavePolygonShape3D doesn't support RigidBody3D in another mode than static.");
} }
return warning; return warning;

View File

@ -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."); warning += TTR("A NavigationMesh resource must be set or created for this node to work.");
} }
const Node3D *c = this; const Node3D *c = this;
while (c) { while (c) {
if (Object::cast_to<Navigation3D>(c)) if (Object::cast_to<Navigation3D>(c)) {
return warning; return warning;
}
c = Object::cast_to<Node3D>(c->get_parent()); c = Object::cast_to<Node3D>(c->get_parent());
} }