Merge pull request #27602 from YeldhamDev/tileset_emptypoly_crash_fix

Fix crash when using the Tileset Editor when the given shape has no points
This commit is contained in:
Rémi Verschelde 2019-04-06 20:51:38 +02:00 committed by GitHub
commit f1dc158ebd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 12 deletions

View file

@ -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) {

View file

@ -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));
}

View file

@ -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();
}