Merge pull request #42495 from akien-mga/3.2-configuration-warnings-fixup
Better validate CollisionShape config. warning after #37226
This commit is contained in:
commit
ea7df14b18
2 changed files with 27 additions and 24 deletions
|
@ -181,27 +181,30 @@ bool CollisionShape2D::_edit_is_selected_on_click(const Point2 &p_point, double
|
|||
String CollisionShape2D::get_configuration_warning() const {
|
||||
|
||||
String warning = Node2D::get_configuration_warning();
|
||||
|
||||
if (!Object::cast_to<CollisionObject2D>(get_parent())) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("CollisionShape2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
|
||||
}
|
||||
|
||||
if (!shape.is_valid()) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("A shape must be provided for CollisionShape2D to function. Please create a shape resource for it!");
|
||||
} else {
|
||||
Ref<ConvexPolygonShape2D> convex = shape;
|
||||
Ref<ConcavePolygonShape2D> concave = shape;
|
||||
if (convex.is_valid() || concave.is_valid()) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("Polygon-based shapes are not meant be used nor edited directly through the CollisionShape2D node. Please use the CollisionPolygon2D node instead.");
|
||||
}
|
||||
}
|
||||
|
||||
Ref<ConvexPolygonShape2D> convex = shape;
|
||||
Ref<ConcavePolygonShape2D> concave = shape;
|
||||
if (convex.is_valid() || concave.is_valid()) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("Polygon-based shapes are not meant be used nor edited directly through the CollisionShape2D node. Please use the CollisionPolygon2D node instead.");
|
||||
}
|
||||
return warning;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
/*************************************************************************/
|
||||
|
||||
#include "collision_shape.h"
|
||||
|
||||
#include "scene/resources/box_shape.h"
|
||||
#include "scene/resources/capsule_shape.h"
|
||||
#include "scene/resources/concave_polygon_shape.h"
|
||||
|
@ -116,6 +117,7 @@ void CollisionShape::resource_changed(RES res) {
|
|||
String CollisionShape::get_configuration_warning() const {
|
||||
|
||||
String warning = Spatial::get_configuration_warning();
|
||||
|
||||
if (!Object::cast_to<CollisionObject>(get_parent())) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
|
@ -128,23 +130,21 @@ String CollisionShape::get_configuration_warning() const {
|
|||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it.");
|
||||
}
|
||||
|
||||
if (shape->is_class("PlaneShape")) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("Plane shapes don't work well and will be removed in future versions. Please don't use them.");
|
||||
}
|
||||
|
||||
if (Object::cast_to<RigidBody>(get_parent())) {
|
||||
if (Object::cast_to<ConcavePolygonShape>(*shape)) {
|
||||
if (Object::cast_to<RigidBody>(get_parent())->get_mode() != RigidBody::MODE_STATIC) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("ConcavePolygonShape doesn't support RigidBody in another mode than static.");
|
||||
} else {
|
||||
if (shape->is_class("PlaneShape")) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("Plane shapes don't work well and will be removed in future versions. Please don't use them.");
|
||||
}
|
||||
|
||||
if (Object::cast_to<RigidBody>(get_parent()) &&
|
||||
Object::cast_to<ConcavePolygonShape>(*shape) &&
|
||||
Object::cast_to<RigidBody>(get_parent())->get_mode() != RigidBody::MODE_STATIC) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
}
|
||||
warning += TTR("ConcavePolygonShape doesn't support RigidBody in another mode than static.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue