You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +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:
@@ -39,13 +39,15 @@
|
||||
#include "core/os/keyboard.h"
|
||||
|
||||
void GridMapEditor::_node_removed(Node *p_node) {
|
||||
if (p_node == node)
|
||||
if (p_node == node) {
|
||||
node = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void GridMapEditor::_configure() {
|
||||
if (!node)
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_grid();
|
||||
}
|
||||
@@ -212,8 +214,9 @@ void GridMapEditor::_menu_option(int p_option) {
|
||||
|
||||
case MENU_OPTION_SELECTION_DUPLICATE:
|
||||
case MENU_OPTION_SELECTION_CUT: {
|
||||
if (!(selection.active && input_action == INPUT_NONE))
|
||||
if (!(selection.active && input_action == INPUT_NONE)) {
|
||||
break;
|
||||
}
|
||||
|
||||
_set_clipboard_data();
|
||||
|
||||
@@ -230,15 +233,17 @@ void GridMapEditor::_menu_option(int p_option) {
|
||||
_update_paste_indicator();
|
||||
} break;
|
||||
case MENU_OPTION_SELECTION_CLEAR: {
|
||||
if (!selection.active)
|
||||
if (!selection.active) {
|
||||
break;
|
||||
}
|
||||
|
||||
_delete_selection();
|
||||
|
||||
} break;
|
||||
case MENU_OPTION_SELECTION_FILL: {
|
||||
if (!selection.active)
|
||||
if (!selection.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
_fill_selection();
|
||||
|
||||
@@ -302,17 +307,21 @@ void GridMapEditor::_update_selection_transform() {
|
||||
}
|
||||
|
||||
void GridMapEditor::_validate_selection() {
|
||||
if (!selection.active)
|
||||
if (!selection.active) {
|
||||
return;
|
||||
}
|
||||
selection.begin = selection.click;
|
||||
selection.end = selection.current;
|
||||
|
||||
if (selection.begin.x > selection.end.x)
|
||||
if (selection.begin.x > selection.end.x) {
|
||||
SWAP(selection.begin.x, selection.end.x);
|
||||
if (selection.begin.y > selection.end.y)
|
||||
}
|
||||
if (selection.begin.y > selection.end.y) {
|
||||
SWAP(selection.begin.y, selection.end.y);
|
||||
if (selection.begin.z > selection.end.z)
|
||||
}
|
||||
if (selection.begin.z > selection.end.z) {
|
||||
SWAP(selection.begin.z, selection.end.z);
|
||||
}
|
||||
|
||||
_update_selection_transform();
|
||||
}
|
||||
@@ -335,16 +344,20 @@ void GridMapEditor::_set_selection(bool p_active, const Vector3 &p_begin, const
|
||||
}
|
||||
|
||||
bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
|
||||
if (!spatial_editor)
|
||||
if (!spatial_editor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selected_palette < 0 && input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE)
|
||||
if (selected_palette < 0 && input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE) {
|
||||
return false;
|
||||
}
|
||||
Ref<MeshLibrary> mesh_library = node->get_mesh_library();
|
||||
if (mesh_library.is_null())
|
||||
if (mesh_library.is_null()) {
|
||||
return false;
|
||||
if (input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE && !mesh_library->has_item(selected_palette))
|
||||
}
|
||||
if (input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE && !mesh_library->has_item(selected_palette)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Camera *camera = p_camera;
|
||||
Vector3 from = camera->project_ray_origin(p_point);
|
||||
@@ -359,27 +372,30 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
|
||||
p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
|
||||
|
||||
Vector3 inters;
|
||||
if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters))
|
||||
if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure the intersection is inside the frustum planes, to avoid
|
||||
// Painting on invisible regions.
|
||||
for (int i = 0; i < planes.size(); i++) {
|
||||
Plane fp = local_xform.xform(planes[i]);
|
||||
if (fp.is_point_over(inters))
|
||||
if (fp.is_point_over(inters)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int cell[3];
|
||||
float cell_size[3] = { node->get_cell_size().x, node->get_cell_size().y, node->get_cell_size().z };
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (i == edit_axis)
|
||||
if (i == edit_axis) {
|
||||
cell[i] = edit_floor[i];
|
||||
else {
|
||||
} else {
|
||||
cell[i] = inters[i] / node->get_cell_size()[i];
|
||||
if (inters[i] < 0)
|
||||
if (inters[i] < 0) {
|
||||
cell[i] -= 1; // Compensate negative.
|
||||
}
|
||||
grid_ofs[i] = cell[i] * cell_size[i];
|
||||
}
|
||||
}
|
||||
@@ -403,8 +419,9 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
|
||||
|
||||
} else if (input_action == INPUT_SELECT) {
|
||||
selection.current = Vector3(cell[0], cell[1], cell[2]);
|
||||
if (p_click)
|
||||
if (p_click) {
|
||||
selection.click = selection.current;
|
||||
}
|
||||
selection.active = true;
|
||||
_validate_selection();
|
||||
|
||||
@@ -445,8 +462,9 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
|
||||
}
|
||||
|
||||
void GridMapEditor::_delete_selection() {
|
||||
if (!selection.active)
|
||||
if (!selection.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
undo_redo->create_action(TTR("GridMap Delete Selection"));
|
||||
for (int i = selection.begin.x; i <= selection.end.x; i++) {
|
||||
@@ -463,8 +481,9 @@ void GridMapEditor::_delete_selection() {
|
||||
}
|
||||
|
||||
void GridMapEditor::_fill_selection() {
|
||||
if (!selection.active)
|
||||
if (!selection.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
undo_redo->create_action(TTR("GridMap Fill Selection"));
|
||||
for (int i = selection.begin.x; i <= selection.end.x; i++) {
|
||||
@@ -497,8 +516,9 @@ void GridMapEditor::_set_clipboard_data() {
|
||||
for (int j = selection.begin.y; j <= selection.end.y; j++) {
|
||||
for (int k = selection.begin.z; k <= selection.end.z; k++) {
|
||||
int itm = node->get_cell_item(i, j, k);
|
||||
if (itm == GridMap::INVALID_CELL_ITEM)
|
||||
if (itm == GridMap::INVALID_CELL_ITEM) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Ref<Mesh> mesh = meshLibrary->get_item_mesh(itm);
|
||||
|
||||
@@ -592,13 +612,15 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
|
||||
|
||||
if (mb.is_valid()) {
|
||||
if (mb->get_button_index() == BUTTON_WHEEL_UP && (mb->get_command() || mb->get_shift())) {
|
||||
if (mb->is_pressed())
|
||||
if (mb->is_pressed()) {
|
||||
floor->set_value(floor->get_value() + mb->get_factor());
|
||||
}
|
||||
|
||||
return true; // Eaten.
|
||||
} else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && (mb->get_command() || mb->get_shift())) {
|
||||
if (mb->is_pressed())
|
||||
if (mb->is_pressed()) {
|
||||
floor->set_value(floor->get_value() - mb->get_factor());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -858,8 +880,9 @@ void GridMapEditor::update_palette() {
|
||||
name = "#" + itos(id);
|
||||
}
|
||||
|
||||
if (filter != "" && !filter.is_subsequence_ofi(name))
|
||||
if (filter != "" && !filter.is_subsequence_ofi(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mesh_library_palette->add_item("");
|
||||
if (!preview.is_null()) {
|
||||
@@ -880,8 +903,9 @@ void GridMapEditor::update_palette() {
|
||||
}
|
||||
|
||||
void GridMapEditor::edit(GridMap *p_gridmap) {
|
||||
if (!p_gridmap && node)
|
||||
if (!p_gridmap && node) {
|
||||
node->disconnect("cell_size_changed", this, "_draw_grids");
|
||||
}
|
||||
|
||||
node = p_gridmap;
|
||||
|
||||
@@ -920,10 +944,11 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
|
||||
|
||||
void GridMapEditor::_update_clip() {
|
||||
node->set_meta("_editor_clip_", clip_mode);
|
||||
if (clip_mode == CLIP_DISABLED)
|
||||
if (clip_mode == CLIP_DISABLED) {
|
||||
node->set_clip(false);
|
||||
else
|
||||
} else {
|
||||
node->set_clip(true, clip_mode == CLIP_ABOVE, edit_floor[edit_axis], edit_axis);
|
||||
}
|
||||
}
|
||||
|
||||
void GridMapEditor::update_grid() {
|
||||
@@ -947,8 +972,9 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
|
||||
Vector3 edited_floor = node->has_meta("_editor_floor_") ? node->get_meta("_editor_floor_") : Variant();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (VS::get_singleton()->mesh_get_surface_count(grid[i]) > 0)
|
||||
if (VS::get_singleton()->mesh_get_surface_count(grid[i]) > 0) {
|
||||
VS::get_singleton()->mesh_remove_surface(grid[i], 0);
|
||||
}
|
||||
edit_floor[i] = edited_floor[i];
|
||||
}
|
||||
|
||||
@@ -1049,8 +1075,9 @@ void GridMapEditor::_notification(int p_what) {
|
||||
grid_xform = xf;
|
||||
}
|
||||
Ref<MeshLibrary> cgmt = node->get_mesh_library();
|
||||
if (cgmt.operator->() != last_mesh_library)
|
||||
if (cgmt.operator->() != last_mesh_library) {
|
||||
update_palette();
|
||||
}
|
||||
|
||||
if (lock_view) {
|
||||
EditorNode *editor = Object::cast_to<EditorNode>(get_tree()->get_root()->get_child(0));
|
||||
@@ -1061,8 +1088,9 @@ void GridMapEditor::_notification(int p_what) {
|
||||
p = node->get_transform().xform(p); // plane to snap
|
||||
|
||||
SpatialEditorPlugin *sep = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
|
||||
if (sep)
|
||||
if (sep) {
|
||||
sep->snap_cursor_to_plane(p);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -1078,8 +1106,9 @@ void GridMapEditor::_update_cursor_instance() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cursor_instance.is_valid())
|
||||
if (cursor_instance.is_valid()) {
|
||||
VisualServer::get_singleton()->free(cursor_instance);
|
||||
}
|
||||
cursor_instance = RID();
|
||||
|
||||
if (selected_palette >= 0) {
|
||||
@@ -1100,8 +1129,9 @@ void GridMapEditor::_item_selected_cbk(int idx) {
|
||||
}
|
||||
|
||||
void GridMapEditor::_floor_changed(float p_value) {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
edit_floor[edit_axis] = p_value;
|
||||
node->set_meta("_editor_floor_", Vector3(edit_floor[0], edit_floor[1], edit_floor[2]));
|
||||
@@ -1301,10 +1331,11 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
|
||||
v[2] = v[1] * (1 - 2 * (j & 1));
|
||||
|
||||
for (int k = 0; k < 3; k++) {
|
||||
if (i < 3)
|
||||
if (i < 3) {
|
||||
face_points[j][(i + k) % 3] = v[k];
|
||||
else
|
||||
} else {
|
||||
face_points[3 - j][(i + k) % 3] = -v[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1413,25 +1444,32 @@ GridMapEditor::~GridMapEditor() {
|
||||
_clear_clipboard_data();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (grid[i].is_valid())
|
||||
if (grid[i].is_valid()) {
|
||||
VisualServer::get_singleton()->free(grid[i]);
|
||||
if (grid_instance[i].is_valid())
|
||||
}
|
||||
if (grid_instance[i].is_valid()) {
|
||||
VisualServer::get_singleton()->free(grid_instance[i]);
|
||||
if (cursor_instance.is_valid())
|
||||
}
|
||||
if (cursor_instance.is_valid()) {
|
||||
VisualServer::get_singleton()->free(cursor_instance);
|
||||
if (selection_level_instance[i].is_valid())
|
||||
}
|
||||
if (selection_level_instance[i].is_valid()) {
|
||||
VisualServer::get_singleton()->free(selection_level_instance[i]);
|
||||
if (selection_level_mesh[i].is_valid())
|
||||
}
|
||||
if (selection_level_mesh[i].is_valid()) {
|
||||
VisualServer::get_singleton()->free(selection_level_mesh[i]);
|
||||
}
|
||||
}
|
||||
|
||||
VisualServer::get_singleton()->free(selection_mesh);
|
||||
if (selection_instance.is_valid())
|
||||
if (selection_instance.is_valid()) {
|
||||
VisualServer::get_singleton()->free(selection_instance);
|
||||
}
|
||||
|
||||
VisualServer::get_singleton()->free(paste_mesh);
|
||||
if (paste_instance.is_valid())
|
||||
if (paste_instance.is_valid()) {
|
||||
VisualServer::get_singleton()->free(paste_instance);
|
||||
}
|
||||
}
|
||||
|
||||
void GridMapEditorPlugin::_notification(int p_what) {
|
||||
|
||||
Reference in New Issue
Block a user