diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-30 10:01:05 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-30 10:01:05 +0100 |
commit | a6da8899651a0d72dbaf87e8d7185d14bcd47112 (patch) | |
tree | 0d9089350edb7560ca375f830836522cc900547f /scene/2d | |
parent | 3c0daf06cf1b9b3c781d48362b223d50f7da9094 (diff) | |
parent | 5195f723b9c8265b2f6a8befaec84f7965117d90 (diff) |
Merge pull request #72302 from dalexeev/shape-stroke
Improve stroke drawing on 2D collision shapes
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/collision_polygon_2d.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 0e18f77b8a..3e4f729fda 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -131,15 +131,7 @@ void CollisionPolygon2D::_notification(int p_what) { break; } - int polygon_count = polygon.size(); - for (int i = 0; i < polygon_count; i++) { - Vector2 p = polygon[i]; - Vector2 n = polygon[(i + 1) % polygon_count]; - // draw line with width <= 1, so it does not scale with zoom and break pixel exact editing - draw_line(p, n, Color(0.9, 0.2, 0.0, 0.8), 1); - } - - if (polygon_count > 2) { + if (polygon.size() > 2) { #define DEBUG_DECOMPOSE #if defined(TOOLS_ENABLED) && defined(DEBUG_DECOMPOSE) Vector<Vector<Vector2>> decomp = _decompose_in_convex(); @@ -152,6 +144,11 @@ void CollisionPolygon2D::_notification(int p_what) { #else draw_colored_polygon(polygon, get_tree()->get_debug_collisions_color()); #endif + + const Color stroke_color = Color(0.9, 0.2, 0.0); + draw_polyline(polygon, stroke_color); + // Draw the last segment. + draw_line(polygon[polygon.size() - 1], polygon[0], stroke_color); } if (one_way_collision) { |