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

Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks

Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
This commit is contained in:
Rémi Verschelde
2020-05-14 13:23:58 +02:00
parent 710b34b702
commit 0be6d925dc
1552 changed files with 1 additions and 33876 deletions

View File

@@ -35,13 +35,11 @@
#include "scene/resources/curve.h"
String Path3DGizmo::get_handle_name(int p_idx) const {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
return "";
if (p_idx < c->get_point_count()) {
return TTR("Curve Point #") + itos(p_idx);
}
@@ -58,13 +56,11 @@ String Path3DGizmo::get_handle_name(int p_idx) const {
return n;
}
Variant Path3DGizmo::get_handle_value(int p_idx) {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
return Variant();
if (p_idx < c->get_point_count()) {
original = c->get_point_position(p_idx);
return original;
}
@@ -85,7 +81,6 @@ Variant Path3DGizmo::get_handle_value(int p_idx) {
return ofs;
}
void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
return;
@@ -97,13 +92,11 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin
// Setting curve point positions
if (p_idx < c->get_point_count()) {
Plane p(gt.xform(original), p_camera->get_transform().basis.get_axis(2));
Vector3 inters;
if (p.intersects_ray(ray_from, ray_dir, &inters)) {
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
float snap = Node3DEditor::get_singleton()->get_translate_snap();
inters.snap(Vector3(snap, snap, snap));
@@ -129,7 +122,6 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin
// Setting curve in/out positions
if (p.intersects_ray(ray_from, ray_dir, &inters)) {
if (!Path3DEditorPlugin::singleton->is_handle_clicked()) {
orig_in_length = c->get_point_in(idx).length();
orig_out_length = c->get_point_out(idx).length();
@@ -155,7 +147,6 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin
}
void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
return;
@@ -163,9 +154,7 @@ void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_canc
UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
if (p_idx < c->get_point_count()) {
if (p_cancel) {
c->set_point_position(p_idx, p_restore);
return;
}
@@ -218,7 +207,6 @@ void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_canc
}
void Path3DGizmo::redraw() {
clear();
Ref<StandardMaterial3D> path_material = gizmo_plugin->get_material("path_material", this);
@@ -240,7 +228,6 @@ void Path3DGizmo::redraw() {
// BUG: the following won't work when v3s, avoid drawing as a temporary workaround.
for (int i = 0; i < v3s - 1; i++) {
v3p.push_back(r[i]);
v3p.push_back(r[i + 1]);
//v3p.push_back(r[i]);
@@ -258,7 +245,6 @@ void Path3DGizmo::redraw() {
Vector<Vector3> sec_handles;
for (int i = 0; i < c->get_point_count(); i++) {
Vector3 p = c->get_point_position(i);
handles.push_back(p);
if (i > 0) {
@@ -287,13 +273,11 @@ void Path3DGizmo::redraw() {
}
Path3DGizmo::Path3DGizmo(Path3D *p_path) {
path = p_path;
set_spatial_node(p_path);
}
bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!path)
return false;
Ref<Curve3D> c = path->get_curve();
@@ -307,7 +291,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
Point2 mbpos(mb->get_position().x, mb->get_position().y);
if (!mb->is_pressed())
@@ -335,7 +318,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
return false; //nope, existing
while (j < rc && c->get_point_position(i + 1) != r[j]) {
Vector3 from = r[j];
Vector3 to = r[j + 1];
real_t cdist = from.distance_to(to);
@@ -349,7 +331,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
float d = inters.distance_to(mbpos);
if (d < 10 && d < closest_d) {
closest_d = d;
closest_seg = i;
Vector3 ray_from = p_camera->project_ray_origin(mbpos);
@@ -384,7 +365,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
return true;
} else {
Vector3 org;
if (c->get_point_count() == 0)
org = path->get_transform().get_origin();
@@ -396,7 +376,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
Vector3 inters;
if (p.intersects_ray(ray_from, ray_dir, &inters)) {
ur->create_action(TTR("Add Point to Curve"));
ur->add_do_method(c.ptr(), "add_point", it.xform(inters), Vector3(), Vector3(), -1);
ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count());
@@ -408,7 +387,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
}
} else if (mb->is_pressed() && ((mb->get_button_index() == BUTTON_LEFT && curve_del->is_pressed()) || (mb->get_button_index() == BUTTON_RIGHT && curve_edit->is_pressed()))) {
for (int i = 0; i < c->get_point_count(); i++) {
real_t dist_to_p = p_camera->unproject_position(gt.xform(c->get_point_position(i))).distance_to(mbpos);
real_t dist_to_p_out = p_camera->unproject_position(gt.xform(c->get_point_position(i) + c->get_point_out(i))).distance_to(mbpos);
@@ -417,7 +395,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
// Find the offset and point index of the place to break up.
// Also check for the control points.
if (dist_to_p < click_dist) {
UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove Path Point"));
ur->add_do_method(c.ptr(), "remove_point", i);
@@ -425,7 +402,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
ur->commit_action();
return true;
} else if (dist_to_p_out < click_dist) {
UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove Out-Control Point"));
ur->add_do_method(c.ptr(), "set_point_out", i, Vector3());
@@ -433,7 +409,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
ur->commit_action();
return true;
} else if (dist_to_p_in < click_dist) {
UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove In-Control Point"));
ur->add_do_method(c.ptr(), "set_point_in", i, Vector3());
@@ -449,11 +424,9 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
}
void Path3DEditorPlugin::edit(Object *p_object) {
if (p_object) {
path = Object::cast_to<Path3D>(p_object);
if (path) {
if (path->get_curve().is_valid()) {
path->get_curve()->emit_signal("changed");
}
@@ -469,14 +442,11 @@ void Path3DEditorPlugin::edit(Object *p_object) {
}
bool Path3DEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("Path3D");
}
void Path3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
curve_create->show();
curve_edit->show();
curve_del->show();
@@ -484,7 +454,6 @@ void Path3DEditorPlugin::make_visible(bool p_visible) {
handle_menu->show();
sep->show();
} else {
curve_create->hide();
curve_edit->hide();
curve_del->hide();
@@ -503,14 +472,12 @@ void Path3DEditorPlugin::make_visible(bool p_visible) {
}
void Path3DEditorPlugin::_mode_changed(int p_idx) {
curve_create->set_pressed(p_idx == 0);
curve_edit->set_pressed(p_idx == 1);
curve_del->set_pressed(p_idx == 2);
}
void Path3DEditorPlugin::_close_curve() {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
return;
@@ -520,7 +487,6 @@ void Path3DEditorPlugin::_close_curve() {
}
void Path3DEditorPlugin::_handle_option_pressed(int p_option) {
PopupMenu *pm;
pm = handle_menu->get_popup();
@@ -540,9 +506,7 @@ void Path3DEditorPlugin::_handle_option_pressed(int p_option) {
}
void Path3DEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
curve_create->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(0));
curve_edit->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(1));
curve_del->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(2));
@@ -556,7 +520,6 @@ void Path3DEditorPlugin::_bind_methods() {
Path3DEditorPlugin *Path3DEditorPlugin::singleton = nullptr;
Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) {
path = nullptr;
editor = p_node;
singleton = this;
@@ -646,7 +609,6 @@ int Path3DGizmoPlugin::get_priority() const {
}
Path3DGizmoPlugin::Path3DGizmoPlugin() {
Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8));
create_material("path_material", path_color);
create_material("path_thin_material", Color(0.5, 0.5, 0.5));