From 9501900e1bd44b9aa2feb32b636c9bc9283a8363 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Silva Dias Date: Tue, 2 Apr 2019 11:45:18 -0300 Subject: [PATCH 1/2] Fix crash when using the Tileset Editor when the given shape has no points --- editor/plugins/tile_set_editor_plugin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 8fc080c8195..54e6e5b154e 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -2417,11 +2417,11 @@ void TileSetEditor::draw_polygon_shapes() { colors.push_back(c_bg); } } - if (polygon.size() == 0) + + if (polygon.size() < 3) continue; - if (polygon.size() > 2) { - workspace->draw_polygon(polygon, colors); - } + + workspace->draw_polygon(polygon, colors); if (coord == edited_shape_coord || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) { if (!creating_shape) { From c7cfe5330c5903f23f020633ebe433f1f485dd87 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Silva Dias Date: Tue, 2 Apr 2019 11:46:10 -0300 Subject: [PATCH 2/2] Make 'ConvexPolygonShape2D' start empty, so it's consistent with other shapes. --- scene/resources/convex_polygon_shape.cpp | 2 -- scene/resources/convex_polygon_shape_2d.cpp | 6 ------ 2 files changed, 8 deletions(-) diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp index 98d3460ed2e..5845e4be50e 100644 --- a/scene/resources/convex_polygon_shape.cpp +++ b/scene/resources/convex_polygon_shape.cpp @@ -83,6 +83,4 @@ void ConvexPolygonShape::_bind_methods() { ConvexPolygonShape::ConvexPolygonShape() : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON)) { - - //set_points(Vector3(1,1,1)); } diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index f275405de23..d424fb28144 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -99,10 +99,4 @@ Rect2 ConvexPolygonShape2D::get_rect() const { ConvexPolygonShape2D::ConvexPolygonShape2D() : Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) { - - int pcount = 3; - for (int i = 0; i < pcount; i++) - points.push_back(Vector2(Math::sin(i * Math_PI * 2 / pcount), -Math::cos(i * Math_PI * 2 / pcount)) * 10); - - _update_shape(); }