Skip to content

Commit

Permalink
Speed up Line2D._edit_get_rect()
Browse files Browse the repository at this point in the history
  • Loading branch information
arkology committed Jan 3, 2025
1 parent bdf625b commit 3fa775b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scene/2d/line_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ Rect2 Line2D::_edit_get_rect() const {
if (_points.size() == 0) {
return Rect2(0, 0, 0, 0);
}
Vector2 d = Vector2(_width, _width);
Rect2 bounding_rect = Rect2(_points[0] - d, 2 * d);
Vector2 min = _points[0];
Vector2 max = min;
for (int i = 1; i < _points.size(); i++) {
bounding_rect.expand_to(_points[i] - d);
bounding_rect.expand_to(_points[i] + d);
min = min.min(_points[i]);
max = max.max(_points[i]);
}
return bounding_rect;
return Rect2(min, max - min).grow(_width);
}

bool Line2D::_edit_use_rect() const {
Expand Down

0 comments on commit 3fa775b

Please sign in to comment.