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
|
@ -181,19 +181,20 @@ 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()) {
|
||||
|
@ -202,6 +203,8 @@ String CollisionShape2D::get_configuration_warning() const {
|
|||
}
|
||||
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,8 +130,7 @@ 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.");
|
||||
}
|
||||
|
||||
} else {
|
||||
if (shape->is_class("PlaneShape")) {
|
||||
if (warning != String()) {
|
||||
warning += "\n\n";
|
||||
|
@ -137,16 +138,15 @@ String CollisionShape::get_configuration_warning() const {
|
|||
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 (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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return warning;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue