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

@ -92,16 +92,19 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E->get());
if (!instance)
if (!instance) {
continue;
}
Ref<Mesh> m = instance->get_mesh();
if (m.is_null())
if (m.is_null()) {
continue;
}
Ref<Shape3D> shape = m->create_trimesh_shape();
if (shape.is_null())
if (shape.is_null()) {
continue;
}
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
@ -129,8 +132,9 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
}
Ref<Shape3D> shape = mesh->create_trimesh_shape();
if (shape.is_null())
if (shape.is_null()) {
return;
}
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
@ -219,8 +223,9 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
case MENU_OPTION_CREATE_NAVMESH: {
Ref<NavigationMesh> nmesh = memnew(NavigationMesh);
if (nmesh.is_null())
if (nmesh.is_null()) {
return;
}
nmesh->create_from_mesh(mesh);
NavigationRegion3D *nmi = memnew(NavigationRegion3D);
@ -284,10 +289,11 @@ struct MeshInstance3DEditorEdgeSort {
Vector2 b;
bool operator<(const MeshInstance3DEditorEdgeSort &p_b) const {
if (a == p_b.a)
if (a == p_b.a) {
return b < p_b.b;
else
} else {
return a < p_b.a;
}
}
MeshInstance3DEditorEdgeSort() {}
@ -309,8 +315,9 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) {
Set<MeshInstance3DEditorEdgeSort> edges;
uv_lines.clear();
for (int i = 0; i < mesh->get_surface_count(); i++) {
if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue;
}
Array a = mesh->surface_get_arrays(i);
Vector<Vector2> uv = a[p_layer == 0 ? Mesh::ARRAY_TEX_UV : Mesh::ARRAY_TEX_UV2];
@ -345,8 +352,9 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) {
edge.b = r[j + ((k + 1) % 3)];
}
if (edges.has(edge))
if (edges.has(edge)) {
continue;
}
uv_lines.push_back(edge.a);
uv_lines.push_back(edge.b);
@ -359,8 +367,9 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) {
}
void MeshInstance3DEditor::_debug_uv_draw() {
if (uv_lines.size() == 0)
if (uv_lines.size() == 0) {
return;
}
debug_uv->set_clip_contents(true);
debug_uv->draw_rect(Rect2(Vector2(), debug_uv->get_size()), Color(0.2, 0.2, 0.0));