1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +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

@@ -36,8 +36,9 @@
String Path3DGizmo::get_handle_name(int p_idx) const {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
if (c.is_null()) {
return "";
}
if (p_idx < c->get_point_count()) {
return TTR("Curve Point #") + itos(p_idx);
@@ -48,18 +49,20 @@ String Path3DGizmo::get_handle_name(int p_idx) const {
int idx = p_idx / 2;
int t = p_idx % 2;
String n = TTR("Curve Point #") + itos(idx);
if (t == 0)
if (t == 0) {
n += " In";
else
} else {
n += " Out";
}
return n;
}
Variant Path3DGizmo::get_handle_value(int p_idx) {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
if (c.is_null()) {
return Variant();
}
if (p_idx < c->get_point_count()) {
original = c->get_point_position(p_idx);
@@ -72,10 +75,11 @@ Variant Path3DGizmo::get_handle_value(int p_idx) {
int t = p_idx % 2;
Vector3 ofs;
if (t == 0)
if (t == 0) {
ofs = c->get_point_in(idx);
else
} else {
ofs = c->get_point_out(idx);
}
original = ofs + c->get_point_position(idx);
@@ -84,8 +88,9 @@ Variant Path3DGizmo::get_handle_value(int p_idx) {
void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
if (c.is_null()) {
return;
}
Transform gt = path->get_global_transform();
Transform gi = gt.affine_inverse();
@@ -138,20 +143,23 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin
if (t == 0) {
c->set_point_in(idx, local);
if (Path3DEditorPlugin::singleton->mirror_angle_enabled())
if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) {
c->set_point_out(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_out_length));
}
} else {
c->set_point_out(idx, local);
if (Path3DEditorPlugin::singleton->mirror_angle_enabled())
if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) {
c->set_point_in(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_in_length));
}
}
}
}
void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
if (c.is_null()) {
return;
}
UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
@@ -216,15 +224,17 @@ void Path3DGizmo::redraw() {
Ref<StandardMaterial3D> handles_material = gizmo_plugin->get_material("handles");
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
if (c.is_null()) {
return;
}
Vector<Vector3> v3a = c->tessellate();
//Vector<Vector3> v3a=c->get_baked_points();
int v3s = v3a.size();
if (v3s == 0)
if (v3s == 0) {
return;
}
Vector<Vector3> v3p;
const Vector3 *r = v3a.ptr();
@@ -280,11 +290,13 @@ Path3DGizmo::Path3DGizmo(Path3D *p_path) {
}
bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!path)
if (!path) {
return false;
}
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
if (c.is_null()) {
return false;
}
Transform gt = path->get_global_transform();
Transform it = gt.affine_inverse();
@@ -295,8 +307,9 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
if (mb.is_valid()) {
Point2 mbpos(mb->get_position().x, mb->get_position().y);
if (!mb->is_pressed())
if (!mb->is_pressed()) {
set_handle_clicked(false);
}
if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && (curve_create->is_pressed() || (curve_edit->is_pressed() && mb->get_control()))) {
//click into curve, break it down
@@ -310,14 +323,16 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
if (rc >= 2) {
const Vector3 *r = v3a.ptr();
if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist)
if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist) {
return false; //nope, existing
}
for (int i = 0; i < c->get_point_count() - 1; i++) {
//find the offset and point index of the place to break up
int j = idx;
if (p_camera->unproject_position(gt.xform(c->get_point_position(i + 1))).distance_to(mbpos) < click_dist)
if (p_camera->unproject_position(gt.xform(c->get_point_position(i + 1))).distance_to(mbpos) < click_dist) {
return false; //nope, existing
}
while (j < rc && c->get_point_position(i + 1) != r[j]) {
Vector3 from = r[j];
@@ -346,13 +361,15 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
}
j++;
}
if (idx == j)
if (idx == j) {
idx++; //force next
else
} else {
idx = j; //swap
}
if (j == rc)
if (j == rc) {
break;
}
}
}
@@ -368,10 +385,11 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
} else {
Vector3 org;
if (c->get_point_count() == 0)
if (c->get_point_count() == 0) {
org = path->get_transform().get_origin();
else
} else {
org = gt.xform(c->get_point_position(c->get_point_count() - 1));
}
Plane p(org, p_camera->get_transform().basis.get_axis(2));
Vector3 ray_from = p_camera->project_ray_origin(mbpos);
Vector3 ray_dir = p_camera->project_ray_normal(mbpos);
@@ -481,10 +499,12 @@ void Path3DEditorPlugin::_mode_changed(int p_idx) {
void Path3DEditorPlugin::_close_curve() {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
if (c.is_null()) {
return;
if (c->get_point_count() < 2)
}
if (c->get_point_count() < 2) {
return;
}
c->add_point(c->get_point_position(0), c->get_point_in(0), c->get_point_out(0));
}
@@ -596,8 +616,9 @@ Ref<EditorNode3DGizmo> Path3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
Ref<Path3DGizmo> ref;
Path3D *path = Object::cast_to<Path3D>(p_spatial);
if (path)
if (path) {
ref = Ref<Path3DGizmo>(memnew(Path3DGizmo(path)));
}
return ref;
}