summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Buring <ricardo.buring@gmail.com>2024-03-23 18:31:11 +0100
committerRicardo Buring <ricardo.buring@gmail.com>2024-03-23 18:51:39 +0100
commitb6f07a007a6cd661577f147491d7d0e95e81363c (patch)
tree990b04cc257ed02bd79243dd7cd017b42c5857ca
parentfe01776f05b1787b28b4a270d53037a3c25f4ca2 (diff)
downloadredot-engine-b6f07a007a6cd661577f147491d7d0e95e81363c.tar.gz
Fix concave CollisionPolygon2D debug drawing and docs
-rw-r--r--doc/classes/CollisionPolygon2D.xml2
-rw-r--r--scene/2d/physics/collision_polygon_2d.cpp19
2 files changed, 10 insertions, 11 deletions
diff --git a/doc/classes/CollisionPolygon2D.xml b/doc/classes/CollisionPolygon2D.xml
index 12f7024518..29535ffd64 100644
--- a/doc/classes/CollisionPolygon2D.xml
+++ b/doc/classes/CollisionPolygon2D.xml
@@ -4,7 +4,7 @@
A node that provides a polygon shape to a [CollisionObject2D] parent.
</brief_description>
<description>
- A node that provides a thickened polygon shape (a prism) to a [CollisionObject2D] parent and allows to edit it. The polygon can be concave or convex. This can give a detection shape to an [Area2D] or turn [PhysicsBody2D] into a solid object.
+ A node that provides a polygon shape to a [CollisionObject2D] parent and allows to edit it. The polygon can be concave or convex. This can give a detection shape to an [Area2D], turn [PhysicsBody2D] into a solid object, or give a hollow shape to a [StaticBody2D].
[b]Warning:[/b] A non-uniformly scaled [CollisionShape2D] will likely not behave as expected. Make sure to keep its scale the same on all axes and adjust its shape resource instead.
</description>
<tutorials>
diff --git a/scene/2d/physics/collision_polygon_2d.cpp b/scene/2d/physics/collision_polygon_2d.cpp
index 96ef346d23..72ee4d52c5 100644
--- a/scene/2d/physics/collision_polygon_2d.cpp
+++ b/scene/2d/physics/collision_polygon_2d.cpp
@@ -132,17 +132,16 @@ void CollisionPolygon2D::_notification(int p_what) {
}
if (polygon.size() > 2) {
-#define DEBUG_DECOMPOSE
-#if defined(TOOLS_ENABLED) && defined(DEBUG_DECOMPOSE)
- Vector<Vector<Vector2>> decomp = _decompose_in_convex();
-
- Color c(0.4, 0.9, 0.1);
- for (int i = 0; i < decomp.size(); i++) {
- c.set_hsv(Math::fmod(c.get_h() + 0.738, 1), c.get_s(), c.get_v(), 0.5);
- draw_colored_polygon(decomp[i], c);
+#ifdef TOOLS_ENABLED
+ if (build_mode == BUILD_SOLIDS) {
+ Vector<Vector<Vector2>> decomp = _decompose_in_convex();
+
+ Color c(0.4, 0.9, 0.1);
+ for (int i = 0; i < decomp.size(); i++) {
+ c.set_hsv(Math::fmod(c.get_h() + 0.738, 1), c.get_s(), c.get_v(), 0.5);
+ draw_colored_polygon(decomp[i], c);
+ }
}
-#else
- draw_colored_polygon(polygon, get_tree()->get_debug_collisions_color());
#endif
const Color stroke_color = Color(0.9, 0.2, 0.0);