Skip to content

Commit fb62ae6

Browse files
committed
clang-format
1 parent cdfa428 commit fb62ae6

File tree

9 files changed

+67
-38
lines changed

9 files changed

+67
-38
lines changed

editor/blocky_library/types/voxel_blocky_type_library_editor_inspector_plugin.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ void VoxelBlockyTypeLibraryEditorInspectorPlugin::_zn_parse_end(Object *p_object
1717
Button *button = memnew(Button);
1818
button->set_text(ZN_TTR("Inspect IDs..."));
1919

20-
button->connect("pressed",
20+
button->connect(
21+
"pressed",
2122
callable_mp(this, &VoxelBlockyTypeLibraryEditorInspectorPlugin::_on_inspect_ids_button_pressed)
22-
.bind(library));
23+
.bind(library)
24+
);
2325

2426
// TODO I want to add this button at the end OF THE VoxelBlockyTypeLibrary PART OF THE INSPECTOR,
2527
// NOT AT THE VERY BOTTOM... but how do I do that?

editor/instance_library/voxel_instance_library_multimesh_item_inspector_plugin.cpp

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,20 @@ void VoxelInstanceLibraryMultiMeshItemInspectorPlugin::_zn_parse_group(Object *p
2525
Button *button = memnew(Button);
2626
button->set_tooltip_text(
2727
ZN_TTR("Set properties based on an existing scene. This might copy mesh and material data if "
28-
"the scene embeds them. Properties will not update if the scene changes later."));
28+
"the scene embeds them. Properties will not update if the scene changes later.")
29+
);
2930
button->set_text(ZN_TTR("Update from scene..."));
3031

3132
// Using a bind() instead of relying on "currently edited" item in the editor plugin allows to support
3233
// multiple sub-inspectors. Plugins are not instanced per-inspected-object, but custom controls are.
33-
button->connect("pressed",
34-
callable_mp(listener,
35-
&VoxelInstanceLibraryMultiMeshItemEditorPlugin::_on_update_from_scene_button_pressed)
36-
.bind(item));
34+
button->connect(
35+
"pressed",
36+
callable_mp(
37+
listener,
38+
&VoxelInstanceLibraryMultiMeshItemEditorPlugin::_on_update_from_scene_button_pressed
39+
)
40+
.bind(item)
41+
);
3742

3843
add_custom_control(button);
3944

@@ -52,9 +57,15 @@ void VoxelInstanceLibraryMultiMeshItemInspectorPlugin::_zn_parse_group(Object *p
5257
// }
5358
}
5459

55-
bool VoxelInstanceLibraryMultiMeshItemInspectorPlugin::_zn_parse_property(Object *p_object, const Variant::Type p_type,
56-
const String &p_path, const PropertyHint p_hint, const String &p_hint_text,
57-
const BitField<PropertyUsageFlags> p_usage, const bool p_wide) {
60+
bool VoxelInstanceLibraryMultiMeshItemInspectorPlugin::_zn_parse_property(
61+
Object *p_object,
62+
const Variant::Type p_type,
63+
const String &p_path,
64+
const PropertyHint p_hint,
65+
const String &p_hint_text,
66+
const BitField<PropertyUsageFlags> p_usage,
67+
const bool p_wide
68+
) {
5869
// TODO Godot invokes `parse_property` on ALL editor plugins when inspecting items of an Array!
5970
// See https://github.com/godotengine/godot/issues/71236
6071
if (p_object == nullptr) {
@@ -63,9 +74,12 @@ bool VoxelInstanceLibraryMultiMeshItemInspectorPlugin::_zn_parse_property(Object
6374
}
6475
// Hide manual properties if a scene is assigned, because it will override them
6576
const VoxelInstanceLibraryMultiMeshItem *item = Object::cast_to<VoxelInstanceLibraryMultiMeshItem>(p_object);
66-
ERR_FAIL_COND_V_MSG(item == nullptr, false,
77+
ERR_FAIL_COND_V_MSG(
78+
item == nullptr,
79+
false,
6780
String("Did not expect {0}, see https://github.com/godotengine/godot/issues/71236")
68-
.format(varray(p_object->get_class())));
81+
.format(varray(p_object->get_class()))
82+
);
6983
if (item->get_scene().is_null()) {
7084
return false;
7185
}

meshers/blocky/types/voxel_blocky_attribute_direction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ bool VoxelBlockyAttributeDirection::is_horizontal_only() const {
8686
void VoxelBlockyAttributeDirection::_bind_methods() {
8787
ClassDB::bind_method(D_METHOD("is_horizontal_only"), &VoxelBlockyAttributeDirection::is_horizontal_only);
8888
ClassDB::bind_method(
89-
D_METHOD("set_horizontal_only", "enabled"), &VoxelBlockyAttributeDirection::set_horizontal_only);
89+
D_METHOD("set_horizontal_only", "enabled"), &VoxelBlockyAttributeDirection::set_horizontal_only
90+
);
9091
ClassDB::bind_method(D_METHOD("from_vec3", "v"), &VoxelBlockyAttributeDirection::from_vec3);
9192

9293
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "horizontal_only"), "set_horizontal_only", "is_horizontal_only");

meshers/cubes/voxel_mesher_cubes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ void build_voxel_mesh_as_greedy_cubes(
335335

336336
// Check if the next rows of faces are the same along Y
337337
unsigned int ry = fy + 1;
338-
while (ry < mask_size_y && L::is_range_equal(mask, fx + ry * mask_size_x, rx + ry * mask_size_x, m)
339-
) {
338+
while (ry < mask_size_y &&
339+
L::is_range_equal(mask, fx + ry * mask_size_x, rx + ry * mask_size_x, m)) {
340340
++ry;
341341
}
342342

@@ -546,8 +546,8 @@ void build_voxel_mesh_as_greedy_cubes_atlased(
546546

547547
// Check if the next rows of faces are the same along Y
548548
unsigned int ry = fy + 1;
549-
while (ry < mask_size_y && L::is_range_equal(mask, fx + ry * mask_size_x, rx + ry * mask_size_x, m)
550-
) {
549+
while (ry < mask_size_y &&
550+
L::is_range_equal(mask, fx + ry * mask_size_x, rx + ry * mask_size_x, m)) {
551551
++ry;
552552
}
553553

meshers/mesh_block_task.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,13 @@ void MeshBlockTask::build_mesh() {
526526
// smooth terrain.
527527
Ref<VoxelMesherTransvoxel> transvoxel_mesher;
528528

529-
if (require_visual //
530-
&& zylann::godot::try_get_as(mesher, transvoxel_mesher) //
531-
&& detail_texture_settings.enabled //
532-
&& !mesh_is_empty //
533-
&& lod_index >= detail_texture_settings.begin_lod_index //
534-
&& require_detail_texture //
529+
if (
530+
require_visual //
531+
&& zylann::godot::try_get_as(mesher, transvoxel_mesher) //
532+
&& detail_texture_settings.enabled //
533+
&& !mesh_is_empty //
534+
&& lod_index >= detail_texture_settings.begin_lod_index //
535+
&& require_detail_texture //
535536
) {
536537
ZN_PROFILE_SCOPE_NAMED("Schedule detail render");
537538

meshers/transvoxel/voxel_mesher_transvoxel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ void simplify(
187187
sizeof(Vector3f),
188188
target_index_count,
189189
p_error_threshold,
190-
zylannmeshopt::meshopt_SimplifyLockBorder, // Crucial for chunk borders, see https://github.com/zeux/meshoptimizer/issues/311
190+
// Crucial for chunk borders, see https://github.com/zeux/meshoptimizer/issues/311
191+
zylannmeshopt::meshopt_SimplifyLockBorder,
191192
&lod_error
192193
);
193194

meshers/voxel_mesher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include "transvoxel/transvoxel_cell_iterator.h"
1010

1111
#ifdef VOXEL_ENABLE_SMOOTH_MESHING
12-
#include "../meshers/transvoxel/voxel_mesher_transvoxel.h"
1312
#include "../engine/detail_rendering/detail_rendering.h"
13+
#include "../meshers/transvoxel/voxel_mesher_transvoxel.h"
1414
#endif
1515

1616
using namespace zylann::godot;

streams/voxel_stream_script.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ void VoxelStreamScript::load_voxel_block(VoxelStream::VoxelQueryData &query_data
99
Variant output;
1010
// Create a temporary wrapper so Godot can pass it to scripts
1111
Ref<godot::VoxelBuffer> buffer_wrapper(memnew(
12-
godot::VoxelBuffer(static_cast<godot::VoxelBuffer::Allocator>(query_data.voxel_buffer.get_allocator()))));
12+
godot::VoxelBuffer(static_cast<godot::VoxelBuffer::Allocator>(query_data.voxel_buffer.get_allocator()))
13+
));
1314
buffer_wrapper->get_buffer().copy_format(query_data.voxel_buffer);
1415
buffer_wrapper->get_buffer().create(query_data.voxel_buffer.get_size());
1516

@@ -35,7 +36,8 @@ void VoxelStreamScript::load_voxel_block(VoxelStream::VoxelQueryData &query_data
3536
void VoxelStreamScript::save_voxel_block(VoxelStream::VoxelQueryData &query_data) {
3637
// For now the callee can exceptionally take ownership of this wrapper, because we copy the data to it.
3738
Ref<godot::VoxelBuffer> buffer_wrapper(memnew(
38-
godot::VoxelBuffer(static_cast<godot::VoxelBuffer::Allocator>(query_data.voxel_buffer.get_allocator()))));
39+
godot::VoxelBuffer(static_cast<godot::VoxelBuffer::Allocator>(query_data.voxel_buffer.get_allocator()))
40+
));
3941
query_data.voxel_buffer.copy_to(buffer_wrapper->get_buffer(), true);
4042
if (!GDVIRTUAL_CALL(_save_voxel_block, buffer_wrapper, query_data.position_in_blocks, query_data.lod_index)) {
4143
WARN_PRINT_ONCE("VoxelStreamScript::_save_voxel_block is unimplemented!");

util/thread/spatial_lock_3d.h

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace zylann {
1616

1717
// Locking on a large voxel data structure can be done with this, instead of putting RWLocks on every chunk or
1818
// every octree node. This also reduces the amount of required mutexes considerably (that matters on some platforms with
19-
// low limits).
19+
// low limits; it also reduces memory usage, as mutex implementations can occupy a lot of bytes).
2020
//
2121
// Some methods allow to `try` locking areas. They should be used in contextes where blocking is worse than
2222
// delaying operations. Such contextes may then postpone their work, or cancel it. If that's not possible, then it
@@ -48,11 +48,14 @@ class SpatialLock3D {
4848
bool try_lock_read(const BoxBounds3i &box) {
4949
_boxes_mutex.lock();
5050
if (can_lock_for_read(box)) {
51-
_boxes.push_back(Box{ box, MODE_READ,
51+
_boxes.push_back(
52+
Box{ box,
53+
MODE_READ,
5254
#ifdef ZN_SPATIAL_LOCK_3D_CHECKS
53-
Thread::get_caller_id()
55+
Thread::get_caller_id()
5456
#endif
55-
});
57+
}
58+
);
5659
_boxes_mutex.unlock();
5760
return true;
5861
} else {
@@ -74,11 +77,14 @@ class SpatialLock3D {
7477
bool try_lock_write(const BoxBounds3i &box) {
7578
_boxes_mutex.lock();
7679
if (can_lock_for_write(box)) {
77-
_boxes.push_back(Box{ box, MODE_WRITE,
80+
_boxes.push_back(
81+
Box{ box,
82+
MODE_WRITE,
7883
#ifdef ZN_SPATIAL_LOCK_3D_CHECKS
79-
Thread::get_caller_id()
84+
Thread::get_caller_id()
8085
#endif
81-
});
86+
}
87+
);
8288
_boxes_mutex.unlock();
8389
return true;
8490
} else {
@@ -144,8 +150,9 @@ class SpatialLock3D {
144150
// This is a deadlock.
145151
// Note: this is not true if threads only lock for reading, but if we didn't ever write we'd not use locks.
146152
// Note: this is also not true if threads use `try_lock` instead!
147-
ZN_ASSERT_RETURN_V_MSG(existing_box.thread_id != thread_id, false,
148-
"Locking two areas from the same threads is not allowed");
153+
ZN_ASSERT_RETURN_V_MSG(
154+
existing_box.thread_id != thread_id, false, "Locking two areas from the same threads is not allowed"
155+
);
149156
#endif
150157
if (existing_box.bounds.intersects(box) && existing_box.mode == MODE_WRITE) {
151158
return false;
@@ -164,8 +171,9 @@ class SpatialLock3D {
164171
const Box &existing_box = _boxes[i];
165172

166173
#ifdef ZN_SPATIAL_LOCK_3D_CHECKS
167-
ZN_ASSERT_RETURN_V_MSG(existing_box.thread_id != thread_id, false,
168-
"Locking two areas from the same threads is not allowed");
174+
ZN_ASSERT_RETURN_V_MSG(
175+
existing_box.thread_id != thread_id, false, "Locking two areas from the same threads is not allowed"
176+
);
169177
#endif
170178
if (existing_box.bounds.intersects(box)) {
171179
return false;

0 commit comments

Comments
 (0)