diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 23:09:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-14 23:09:03 +0200 |
| commit | 00949f0c5fcc6a4f8382a4a97d5591fd9ec380f8 (patch) | |
| tree | 2b1c31f45add24085b64425ce440f577424c16a1 /scene/resources/convex_polygon_shape_2d.cpp | |
| parent | 5046f666a1181675b39f156c38346525dc1c444e (diff) | |
| parent | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (diff) | |
Merge pull request #38738 from akien-mga/cause-we-never-go-out-of-style
Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks
Diffstat (limited to 'scene/resources/convex_polygon_shape_2d.cpp')
| -rw-r--r-- | scene/resources/convex_polygon_shape_2d.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index 6b1ddec507..7df7c3ac72 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -35,12 +35,10 @@ #include "servers/rendering_server.h" bool ConvexPolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { - return Geometry::is_point_in_polygon(p_point, points); } void ConvexPolygonShape2D::_update_shape() { - Vector<Vector2> final_points = points; if (Geometry::is_polygon_clockwise(final_points)) { //needs to be counter clockwise final_points.invert(); @@ -50,26 +48,22 @@ void ConvexPolygonShape2D::_update_shape() { } void ConvexPolygonShape2D::set_point_cloud(const Vector<Vector2> &p_points) { - Vector<Point2> hull = Geometry::convex_hull_2d(p_points); ERR_FAIL_COND(hull.size() < 3); set_points(hull); } void ConvexPolygonShape2D::set_points(const Vector<Vector2> &p_points) { - points = p_points; _update_shape(); } Vector<Vector2> ConvexPolygonShape2D::get_points() const { - return points; } void ConvexPolygonShape2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_point_cloud", "point_cloud"), &ConvexPolygonShape2D::set_point_cloud); ClassDB::bind_method(D_METHOD("set_points", "points"), &ConvexPolygonShape2D::set_points); ClassDB::bind_method(D_METHOD("get_points"), &ConvexPolygonShape2D::get_points); @@ -78,20 +72,19 @@ void ConvexPolygonShape2D::_bind_methods() { } void ConvexPolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) { - Vector<Color> col; col.push_back(p_color); RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col); } Rect2 ConvexPolygonShape2D::get_rect() const { - Rect2 rect; for (int i = 0; i < points.size(); i++) { - if (i == 0) + if (i == 0) { rect.position = points[i]; - else + } else { rect.expand_to(points[i]); + } } return rect; |