1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Style: Enforce braces around if blocks and loops

Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
Rémi Verschelde
2020-05-14 16:41:43 +02:00
parent 07bc4e2f96
commit 0ee0fa42e6
683 changed files with 22803 additions and 12225 deletions

View File

@@ -47,16 +47,18 @@ bool AbstractPolygon2DEditor::Vertex::valid() const {
}
bool AbstractPolygon2DEditor::_is_empty() const {
if (!_get_node())
if (!_get_node()) {
return true;
}
const int n = _get_polygon_count();
for (int i = 0; i < n; i++) {
Vector<Vector2> vertices = _get_polygon(i);
if (vertices.size() != 0)
if (vertices.size() != 0) {
return false;
}
}
return true;
@@ -185,8 +187,9 @@ void AbstractPolygon2DEditor::_wip_cancel() {
}
void AbstractPolygon2DEditor::_wip_close() {
if (!wip_active)
if (!wip_active) {
return;
}
if (_is_line()) {
_set_polygon(0, wip);
@@ -234,8 +237,9 @@ void AbstractPolygon2DEditor::disable_polygon_editing(bool p_disable, String p_r
}
bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (!_get_node() || !_polygon_editing_enabled)
if (!_get_node() || !_polygon_editing_enabled) {
return false;
}
Ref<InputEventMouseButton> mb = p_event;
@@ -248,8 +252,9 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
}
CanvasItemEditor::Tool tool = CanvasItemEditor::get_singleton()->get_current_tool();
if (tool != CanvasItemEditor::TOOL_SELECT)
if (tool != CanvasItemEditor::TOOL_SELECT) {
return false;
}
if (mb.is_valid()) {
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
@@ -260,8 +265,9 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) {
if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->is_pressed()) {
if (mb->get_control() || mb->get_shift() || mb->get_alt())
if (mb->get_control() || mb->get_shift() || mb->get_alt()) {
return false;
}
const PosVertex insert = closest_edge_point(gpoint);
@@ -464,8 +470,9 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
}
void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
if (!_get_node())
if (!_get_node()) {
return;
}
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
// All polygon points are sharp, so use the sharp handle icon
@@ -476,8 +483,9 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
const bool is_closed = !_is_line();
for (int j = -1; j < n_polygons; j++) {
if (wip_active && wip_destructive && j != -1)
if (wip_active && wip_destructive && j != -1) {
continue;
}
Vector<Vector2> points;
Vector2 offset;
@@ -486,8 +494,9 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
points = Variant(wip);
offset = Vector2(0, 0);
} else {
if (j == -1)
if (j == -1) {
continue;
}
points = _get_polygon(j);
offset = _get_offset(j);
}
@@ -519,10 +528,11 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
if (is_closed || i < n_points - 1) {
Vector2 p2;
if (j == edited_point.polygon &&
((wip_active && i == n_points - 1) || (((i + 1) % n_points) == edited_point.vertex)))
((wip_active && i == n_points - 1) || (((i + 1) % n_points) == edited_point.vertex))) {
p2 = edited_point.pos;
else
} else {
p2 = points[(i + 1) % n_points] + offset;
}
const Vector2 next_point = xform.xform(p2);
p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE));
@@ -554,17 +564,19 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
}
void AbstractPolygon2DEditor::edit(Node *p_polygon) {
if (!canvas_item_editor)
if (!canvas_item_editor) {
canvas_item_editor = CanvasItemEditor::get_singleton();
}
if (p_polygon) {
_set_node(p_polygon);
// Enable the pencil tool if the polygon is empty.
if (_is_empty())
if (_is_empty()) {
_menu_option(MODE_CREATE);
else
} else {
_menu_option(MODE_EDIT);
}
wip.clear();
wip_active = false;
@@ -596,12 +608,14 @@ void AbstractPolygon2DEditor::remove_point(const Vertex &p_vertex) {
_commit_action();
}
if (_is_empty())
if (_is_empty()) {
_menu_option(MODE_CREATE);
}
hover_point = Vertex();
if (selected_point == p_vertex)
if (selected_point == p_vertex) {
selected_point = Vertex();
}
}
AbstractPolygon2DEditor::Vertex AbstractPolygon2DEditor::get_active_point() const {
@@ -659,8 +673,9 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(c
Vector2 cp = Geometry::get_closest_point_to_segment_2d(p_pos, segment);
if (cp.distance_squared_to(segment[0]) < eps2 || cp.distance_squared_to(segment[1]) < eps2)
if (cp.distance_squared_to(segment[0]) < eps2 || cp.distance_squared_to(segment[1]) < eps2) {
continue; //not valid to reuse point
}
real_t d = cp.distance_to(p_pos);
if (d < closest_dist && d < grab_threshold) {