You've already forked godot
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:
@@ -40,7 +40,6 @@
|
||||
#include "thirdparty/misc/clipper.hpp"
|
||||
|
||||
void Sprite2DEditor::_node_removed(Node *p_node) {
|
||||
|
||||
if (p_node == node) {
|
||||
node = nullptr;
|
||||
options->hide();
|
||||
@@ -48,7 +47,6 @@ void Sprite2DEditor::_node_removed(Node *p_node) {
|
||||
}
|
||||
|
||||
void Sprite2DEditor::edit(Sprite2D *p_sprite) {
|
||||
|
||||
node = p_sprite;
|
||||
}
|
||||
|
||||
@@ -63,7 +61,6 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float
|
||||
ClipperLib::PolyTree out;
|
||||
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
|
||||
subj << ClipperLib::IntPoint(points[i].x * PRECISION, points[i].y * PRECISION);
|
||||
}
|
||||
ClipperLib::ClipperOffset co;
|
||||
@@ -104,7 +101,6 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float
|
||||
int lasti = p2->Contour.size() - 1;
|
||||
Vector2 prev = Vector2(p2->Contour[lasti].X / PRECISION, p2->Contour[lasti].Y / PRECISION);
|
||||
for (uint64_t i = 0; i < p2->Contour.size(); i++) {
|
||||
|
||||
Vector2 cur = Vector2(p2->Contour[i].X / PRECISION, p2->Contour[i].Y / PRECISION);
|
||||
if (cur.distance_to(prev) > 0.5) {
|
||||
outPoints.push_back(cur);
|
||||
@@ -115,7 +111,6 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float
|
||||
}
|
||||
|
||||
void Sprite2DEditor::_menu_option(int p_option) {
|
||||
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
@@ -124,7 +119,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
|
||||
|
||||
switch (p_option) {
|
||||
case MENU_OPTION_CONVERT_TO_MESH_2D: {
|
||||
|
||||
debug_uv_dialog->get_ok()->set_text(TTR("Create Mesh2D"));
|
||||
debug_uv_dialog->set_title(TTR("Mesh2D Preview"));
|
||||
|
||||
@@ -134,7 +128,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
|
||||
|
||||
} break;
|
||||
case MENU_OPTION_CONVERT_TO_POLYGON_2D: {
|
||||
|
||||
debug_uv_dialog->get_ok()->set_text(TTR("Create Polygon2D"));
|
||||
debug_uv_dialog->set_title(TTR("Polygon2D Preview"));
|
||||
|
||||
@@ -143,7 +136,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
|
||||
debug_uv->update();
|
||||
} break;
|
||||
case MENU_OPTION_CREATE_COLLISION_POLY_2D: {
|
||||
|
||||
debug_uv_dialog->get_ok()->set_text(TTR("Create CollisionPolygon2D"));
|
||||
debug_uv_dialog->set_title(TTR("CollisionPolygon2D Preview"));
|
||||
|
||||
@@ -153,7 +145,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
|
||||
|
||||
} break;
|
||||
case MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D: {
|
||||
|
||||
debug_uv_dialog->get_ok()->set_text(TTR("Create LightOccluder2D"));
|
||||
debug_uv_dialog->set_title(TTR("LightOccluder2D Preview"));
|
||||
|
||||
@@ -166,7 +157,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
|
||||
}
|
||||
|
||||
void Sprite2DEditor::_update_mesh_data() {
|
||||
|
||||
Ref<Texture2D> texture = node->get_texture();
|
||||
if (texture.is_null()) {
|
||||
err_dialog->set_text(TTR("Sprite2D is empty!"));
|
||||
@@ -218,7 +208,6 @@ void Sprite2DEditor::_update_mesh_data() {
|
||||
}
|
||||
|
||||
if (selected_menu_item == MENU_OPTION_CONVERT_TO_MESH_2D) {
|
||||
|
||||
for (int j = 0; j < lines.size(); j++) {
|
||||
int index_ofs = computed_vertices.size();
|
||||
|
||||
@@ -262,7 +251,6 @@ void Sprite2DEditor::_update_mesh_data() {
|
||||
outline_lines.resize(lines.size());
|
||||
computed_outline_lines.resize(lines.size());
|
||||
for (int pi = 0; pi < lines.size(); pi++) {
|
||||
|
||||
Vector<Vector2> ol;
|
||||
Vector<Vector2> col;
|
||||
|
||||
@@ -314,7 +302,6 @@ void Sprite2DEditor::_create_node() {
|
||||
}
|
||||
|
||||
void Sprite2DEditor::_convert_to_mesh_2d_node() {
|
||||
|
||||
if (computed_vertices.size() < 3) {
|
||||
err_dialog->set_text(TTR("Invalid geometry, can't replace by mesh."));
|
||||
err_dialog->popup_centered();
|
||||
@@ -345,7 +332,6 @@ void Sprite2DEditor::_convert_to_mesh_2d_node() {
|
||||
}
|
||||
|
||||
void Sprite2DEditor::_convert_to_polygon_2d_node() {
|
||||
|
||||
if (computed_outline_lines.empty()) {
|
||||
err_dialog->set_text(TTR("Invalid geometry, can't create polygon."));
|
||||
err_dialog->popup_centered();
|
||||
@@ -372,7 +358,6 @@ void Sprite2DEditor::_convert_to_polygon_2d_node() {
|
||||
polys.resize(computed_outline_lines.size());
|
||||
|
||||
for (int i = 0; i < computed_outline_lines.size(); i++) {
|
||||
|
||||
Vector<Vector2> outline = computed_outline_lines[i];
|
||||
Vector<Vector2> uv_outline = outline_lines[i];
|
||||
|
||||
@@ -404,7 +389,6 @@ void Sprite2DEditor::_convert_to_polygon_2d_node() {
|
||||
}
|
||||
|
||||
void Sprite2DEditor::_create_collision_polygon_2d_node() {
|
||||
|
||||
if (computed_outline_lines.empty()) {
|
||||
err_dialog->set_text(TTR("Invalid geometry, can't create collision polygon."));
|
||||
err_dialog->popup_centered();
|
||||
@@ -412,7 +396,6 @@ void Sprite2DEditor::_create_collision_polygon_2d_node() {
|
||||
}
|
||||
|
||||
for (int i = 0; i < computed_outline_lines.size(); i++) {
|
||||
|
||||
Vector<Vector2> outline = computed_outline_lines[i];
|
||||
|
||||
CollisionPolygon2D *collision_polygon_2d_instance = memnew(CollisionPolygon2D);
|
||||
@@ -428,7 +411,6 @@ void Sprite2DEditor::_create_collision_polygon_2d_node() {
|
||||
}
|
||||
|
||||
void Sprite2DEditor::_create_light_occluder_2d_node() {
|
||||
|
||||
if (computed_outline_lines.empty()) {
|
||||
err_dialog->set_text(TTR("Invalid geometry, can't create light occluder."));
|
||||
err_dialog->popup_centered();
|
||||
@@ -436,7 +418,6 @@ void Sprite2DEditor::_create_light_occluder_2d_node() {
|
||||
}
|
||||
|
||||
for (int i = 0; i < computed_outline_lines.size(); i++) {
|
||||
|
||||
Vector<Vector2> outline = computed_outline_lines[i];
|
||||
|
||||
Ref<OccluderPolygon2D> polygon;
|
||||
@@ -475,7 +456,6 @@ void Sprite2DEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node
|
||||
}
|
||||
|
||||
void Sprite2DEditor::_debug_uv_draw() {
|
||||
|
||||
Ref<Texture2D> tex = node->get_texture();
|
||||
ERR_FAIL_COND(!tex.is_valid());
|
||||
|
||||
@@ -503,12 +483,10 @@ void Sprite2DEditor::_debug_uv_draw() {
|
||||
}
|
||||
|
||||
void Sprite2DEditor::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_add_as_sibling_or_child", &Sprite2DEditor::_add_as_sibling_or_child);
|
||||
}
|
||||
|
||||
Sprite2DEditor::Sprite2DEditor() {
|
||||
|
||||
options = memnew(MenuButton);
|
||||
|
||||
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);
|
||||
@@ -577,28 +555,23 @@ Sprite2DEditor::Sprite2DEditor() {
|
||||
}
|
||||
|
||||
void Sprite2DEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
sprite_editor->edit(Object::cast_to<Sprite2D>(p_object));
|
||||
}
|
||||
|
||||
bool Sprite2DEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
return p_object->is_class("Sprite2D");
|
||||
}
|
||||
|
||||
void Sprite2DEditorPlugin::make_visible(bool p_visible) {
|
||||
|
||||
if (p_visible) {
|
||||
sprite_editor->options->show();
|
||||
} else {
|
||||
|
||||
sprite_editor->options->hide();
|
||||
sprite_editor->edit(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Sprite2DEditorPlugin::Sprite2DEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor = p_node;
|
||||
sprite_editor = memnew(Sprite2DEditor);
|
||||
editor->get_viewport()->add_child(sprite_editor);
|
||||
|
||||
Reference in New Issue
Block a user