diff --git a/.clang-format b/.clang-format index a229510b..99ae00e6 100644 --- a/.clang-format +++ b/.clang-format @@ -31,7 +31,7 @@ AllowShortFunctionsOnASingleLine: Empty # AlwaysBreakAfterDefinitionReturnType: None # AlwaysBreakAfterReturnType: None # AlwaysBreakBeforeMultilineStrings: false -# AlwaysBreakTemplateDeclarations: MultiLine +AlwaysBreakTemplateDeclarations: Yes # AttributeMacros: # - __capability # BinPackArguments: true diff --git a/edition/voxel_tool.h b/edition/voxel_tool.h index 18b24d47..b47101cb 100644 --- a/edition/voxel_tool.h +++ b/edition/voxel_tool.h @@ -11,7 +11,8 @@ class VoxelBuffer; namespace zylann::voxel::ops { -template struct SdfOperation16bit { +template +struct SdfOperation16bit { Op op; Shape shape; inline uint16_t operator()(Vector3i pos, uint16_t sdf) const { diff --git a/server/struct_db.h b/server/struct_db.h index f2e4f3fe..77c23ef2 100644 --- a/server/struct_db.h +++ b/server/struct_db.h @@ -9,7 +9,8 @@ namespace zylann { // Stores uniquely-identified structs in a packed array. // Always use the IDs if you want to store a reference somewhere. Addresses aren't stable. // IDs are made unique with a generation system. -template class StructDB { +template +class StructDB { private: struct Slot { T data; @@ -130,7 +131,8 @@ public: return c; } - template inline void for_each(F f) { + template + inline void for_each(F f) { for (size_t i = 0; i < _slots.size(); ++i) { Slot &s = _slots[i]; if (s.valid) { @@ -139,7 +141,8 @@ public: } } - template inline void for_each(F f) const { + template + inline void for_each(F f) const { for (size_t i = 0; i < _slots.size(); ++i) { const Slot &s = _slots[i]; if (s.valid) { @@ -148,7 +151,8 @@ public: } } - template inline void for_each_with_id(F f) { + template + inline void for_each_with_id(F f) { for (size_t i = 0; i < _slots.size(); ++i) { Slot &s = _slots[i]; if (s.valid) { @@ -157,7 +161,8 @@ public: } } - template inline void for_each_with_id(F f) const { + template + inline void for_each_with_id(F f) const { for (size_t i = 0; i < _slots.size(); ++i) { const Slot &s = _slots[i]; if (s.valid) { diff --git a/server/voxel_server.h b/server/voxel_server.h index ebb3c295..dc1776fe 100644 --- a/server/voxel_server.h +++ b/server/voxel_server.h @@ -134,7 +134,8 @@ public: bool is_viewer_requiring_collisions(uint32_t viewer_id) const; bool viewer_exists(uint32_t viewer_id) const; - template inline void for_each_viewer(F f) const { + template + inline void for_each_viewer(F f) const { _world.viewers.for_each_with_id(f); } diff --git a/streams/vox_data.h b/streams/vox_data.h index 9a1fda91..59de767b 100644 --- a/streams/vox_data.h +++ b/streams/vox_data.h @@ -12,7 +12,8 @@ #include namespace std { -template <> struct hash { +template <> +struct hash { size_t operator()(const String &v) const { return v.hash(); } diff --git a/streams/voxel_block_serializer.cpp b/streams/voxel_block_serializer.cpp index 4f297775..47aef0a7 100644 --- a/streams/voxel_block_serializer.cpp +++ b/streams/voxel_block_serializer.cpp @@ -60,12 +60,14 @@ size_t get_metadata_size_in_bytes(const VoxelBufferInternal &buffer) { return size; } -template inline void write(uint8_t *&dst, T d) { +template +inline void write(uint8_t *&dst, T d) { *(T *)dst = d; dst += sizeof(T); } -template inline T read(uint8_t *&src) { +template +inline T read(uint8_t *&src) { T d = *(T *)src; src += sizeof(T); return d; diff --git a/streams/voxel_stream.h b/streams/voxel_stream.h index f57971e0..989b3d95 100644 --- a/streams/voxel_stream.h +++ b/streams/voxel_stream.h @@ -53,8 +53,7 @@ public: // TODO Merge support functions into a single getter with Feature bitmask virtual bool supports_instance_blocks() const; - virtual void load_instance_blocks( - Span out_blocks, Span out_results); + virtual void load_instance_blocks(Span out_blocks, Span out_results); virtual void save_instance_blocks(Span p_blocks); @@ -68,7 +67,9 @@ public: std::vector blocks; }; - virtual bool supports_loading_all_blocks() const { return false; } + virtual bool supports_loading_all_blocks() const { + return false; + } virtual void load_all_blocks(FullLoadingResult &result); diff --git a/terrain/lod_octree.h b/terrain/lod_octree.h index 8be7550b..984afe60 100644 --- a/terrain/lod_octree.h +++ b/terrain/lod_octree.h @@ -47,7 +47,8 @@ public: inline void operator()(Vector3i node_pos, int lod) {} }; - template void clear(DestroyAction_T &destroy_action) { + template + void clear(DestroyAction_T &destroy_action) { join_all_recursively(&_root, Vector3i(), _max_depth, destroy_action); _is_root_created = false; _max_depth = 0; @@ -116,7 +117,8 @@ public: // Nodes may be subdivided if conditions are met, or unsubdivided if they aren't. // This is not fully recursive. It is expected to be called over several frames, // so the shape is obtained progressively. - template void update(Vector3 view_pos, UpdateActions_T &actions) { + template + void update(Vector3 view_pos, UpdateActions_T &actions) { if (_is_root_created || _root.has_children()) { update(ROOT_INDEX, Vector3i(), _max_depth, view_pos, actions); } else { @@ -148,7 +150,8 @@ public: // The box is given in unit coordinates of the octree (1 unit is the size of a leaf node at maximum depth). // Returns true if the predicate matches any node, false otherwise. // predicate: `bool is_match(Vector3i node_pos, int lod_index, const NodeData &data)` - template bool find_in_box(Box3i box, Predicate_T predicate) const { + template + bool find_in_box(Box3i box, Predicate_T predicate) const { Box3i root_box(Vector3i(), Vector3iUtil::create(1 << _max_depth)); box.clip(root_box); return find_in_box_recursive(box, Vector3i(), ROOT_INDEX, _max_depth, predicate); @@ -156,7 +159,8 @@ public: // Executes a function on all leaf nodes intersecting the box. // f: `void f(Vector3i node_pos, int lod_index, NodeData &data)` - template void for_leaves_in_box(Box3i box, F f) { + template + void for_leaves_in_box(Box3i box, F f) { Box3i root_box(Vector3i(), Vector3iUtil::create(1 << _max_depth)); box.clip(root_box); return for_leaves_in_box_recursive(box, Vector3i(), ROOT_INDEX, _max_depth, f); @@ -164,7 +168,8 @@ public: // Executes a function on all leaf nodes of the octree. // f: `void f(Vector3i node_pos, int lod_index, const NodeData &data)` - template void for_each_leaf(F f) const { + template + void for_each_leaf(F f) const { return for_each_leaf_recursive(Vector3i(), ROOT_INDEX, _max_depth, f); } @@ -181,7 +186,8 @@ public: // Subdivides the octree recursively, solely based on `can_split`. // Does not unsubdivide existing nodes. - template void subdivide(Actions_T &actions) { + template + void subdivide(Actions_T &actions) { if (!_is_root_created && actions.can_split(Vector3i(), _max_depth, _root.data)) { actions.create_child(Vector3i(), _max_depth, _root.data); _is_root_created = true; @@ -398,7 +404,8 @@ private: return count; } - template void for_each_leaf_recursive(Vector3i node_pos, int node_index, int depth, F f) const { + template + void for_each_leaf_recursive(Vector3i node_pos, int node_index, int depth, F f) const { const Node *node = get_node(node_index); if (node->has_children()) { const int first_child_index = node->first_child; diff --git a/terrain/voxel_lod_terrain.h b/terrain/voxel_lod_terrain.h index 89234889..051dca9c 100644 --- a/terrain/voxel_lod_terrain.h +++ b/terrain/voxel_lod_terrain.h @@ -88,7 +88,8 @@ public: bool try_set_voxel_without_update(Vector3i pos, unsigned int channel, uint64_t value); void copy(Vector3i p_origin_voxels, VoxelBufferInternal &dst_buffer, uint8_t channels_mask); - template void write_box(const Box3i &p_voxel_box, unsigned int channel, F action) { + template + void write_box(const Box3i &p_voxel_box, unsigned int channel, F action) { const Box3i voxel_box = p_voxel_box.clipped(_bounds_in_voxels); if (_full_load_mode == false && !is_area_editable(voxel_box)) { PRINT_VERBOSE("Area not editable"); diff --git a/terrain/voxel_mesh_block.h b/terrain/voxel_mesh_block.h index 4794da98..5831f768 100644 --- a/terrain/voxel_mesh_block.h +++ b/terrain/voxel_mesh_block.h @@ -97,7 +97,8 @@ public: return _transition_mask; } - template void for_each_mesh_instance_with_transform(F f) const { + template + void for_each_mesh_instance_with_transform(F f) const { const Transform3D local_transform(Basis(), _position_in_voxels); const Transform3D world_transform = local_transform; f(_mesh_instance, world_transform); diff --git a/terrain/voxel_mesh_map.h b/terrain/voxel_mesh_map.h index 9701a9e7..a7af8542 100644 --- a/terrain/voxel_mesh_map.h +++ b/terrain/voxel_mesh_map.h @@ -18,10 +18,7 @@ public: } inline Vector3i to_local(Vector3i pos) const { - return Vector3i( - pos.x & _block_size_mask, - pos.y & _block_size_mask, - pos.z & _block_size_mask); + return Vector3i(pos.x & _block_size_mask, pos.y & _block_size_mask, pos.z & _block_size_mask); } // Converts block coodinates into voxel coordinates @@ -34,9 +31,15 @@ public: void create(unsigned int block_size_po2, int lod_index); - inline unsigned int get_block_size() const { return _block_size; } - inline unsigned int get_block_size_pow2() const { return _block_size_pow2; } - inline unsigned int get_block_size_mask() const { return _block_size_mask; } + inline unsigned int get_block_size() const { + return _block_size; + } + inline unsigned int get_block_size_pow2() const { + return _block_size_pow2; + } + inline unsigned int get_block_size_mask() const { + return _block_size_mask; + } void set_lod_index(int lod_index); unsigned int get_lod_index() const; diff --git a/tests/noise_tests.cpp b/tests/noise_tests.cpp index 80942ea3..a287dd24 100644 --- a/tests/noise_tests.cpp +++ b/tests/noise_tests.cpp @@ -19,7 +19,8 @@ enum Tests { // // Sample a maximum change across the given step. // The result is not normalized for performance. -template FloatT get_derivative(FloatT x, FloatT y, FloatT step, F2 noise_func_2d) { +template +FloatT get_derivative(FloatT x, FloatT y, FloatT step, F2 noise_func_2d) { FloatT n0, n1, d; FloatT max_derivative = 0.0; @@ -68,7 +69,8 @@ FloatT get_derivative(FloatT x, FloatT y, FloatT z, FloatT step, F3 noise_func_3 return max_derivative; } -template void test_min_max(F2 noise_func_2d, F3 noise_func_3d) { +template +void test_min_max(F2 noise_func_2d, F3 noise_func_3d) { FloatT min_value_2d = std::numeric_limits::max(); FloatT max_value_2d = std::numeric_limits::min(); @@ -96,7 +98,8 @@ template void test_min_max(F2 noise_ } // Generic analysis for noise functions -template void test_derivatives_tpl(F2 noise_func_2d, F3 noise_func_3d) { +template +void test_derivatives_tpl(F2 noise_func_2d, F3 noise_func_3d) { const int iterations = ITERATIONS; const int step_resolution_count = STEP_RESOLUTION_COUNT; const FloatT step_min = STEP_MIN; @@ -166,7 +169,8 @@ template void test_derivatives_tpl(F print_line(String("Min max derivative: {0}").format(varray(min_max_derivative))); } -template void test_derivatives_with_image(String fpath, double step, F3 noise_func_3d) { +template +void test_derivatives_with_image(String fpath, double step, F3 noise_func_3d) { const double x_min = 500.0; const double y = 500.0; const double z_min = 500.0; @@ -200,7 +204,8 @@ template void test_derivatives_with_image(String fpath, double ste im->save_png(fpath); } -template void test_derivatives_with_image(String fname, int steps_resolution, F3 noise_func_3d) { +template +void test_derivatives_with_image(String fname, int steps_resolution, F3 noise_func_3d) { for (int i = 0; i < steps_resolution; ++i) { const double step = Math::lerp(STEP_MIN, STEP_MAX, static_cast(i) / static_cast(steps_resolution)); @@ -209,7 +214,8 @@ template void test_derivatives_with_image(String fname, int steps_ } } -template void test_noise(String name, int tests, F2 noise_func_2d, F3 noise_func_3d) { +template +void test_noise(String name, int tests, F2 noise_func_2d, F3 noise_func_3d) { print_line(String("--- {0}:").format(varray(name))); if (tests & TEST_MIN_MAX) { diff --git a/util/funcs.h b/util/funcs.h index b62d4dc2..26569b2c 100644 --- a/util/funcs.h +++ b/util/funcs.h @@ -12,7 +12,8 @@ // Takes elements starting from a given position and moves them at the beginning, // then shrink the array to fit them. Other elements are discarded. -template void shift_up(Vector &v, unsigned int pos) { +template +void shift_up(Vector &v, unsigned int pos) { unsigned int j = 0; for (unsigned int i = pos; i < (unsigned int)v.size(); ++i, ++j) { v.write[j] = v[i]; @@ -21,7 +22,8 @@ template void shift_up(Vector &v, unsigned int pos) { v.resize(remaining); } -template void shift_up(std::vector &v, unsigned int pos) { +template +void shift_up(std::vector &v, unsigned int pos) { unsigned int j = 0; for (unsigned int i = pos; i < v.size(); ++i, ++j) { v[j] = v[i]; @@ -32,20 +34,23 @@ template void shift_up(std::vector &v, unsigned int pos) { // Pops the last element of the vector and place it at the given position. // (The element that was at this position is the one removed). -template void unordered_remove(Vector &v, unsigned int pos) { +template +void unordered_remove(Vector &v, unsigned int pos) { int last = v.size() - 1; v.write[pos] = v[last]; v.resize(last); } -template void unordered_remove(std::vector &v, unsigned int pos) { +template +void unordered_remove(std::vector &v, unsigned int pos) { v[pos] = v.back(); v.pop_back(); } // Removes all items satisfying the given predicate. // This can change the size of the container, and original order of items is not preserved. -template inline void unordered_remove_if(std::vector &vec, F predicate) { +template +inline void unordered_remove_if(std::vector &vec, F predicate) { for (unsigned int i = 0; i < vec.size(); ++i) { if (predicate(vec[i])) { vec[i] = vec.back(); @@ -57,7 +62,8 @@ template inline void unordered_remove_if(std::vector } } -template inline bool unordered_remove_value(std::vector &vec, T v) { +template +inline bool unordered_remove_value(std::vector &vec, T v) { for (size_t i = 0; i < vec.size(); ++i) { if (vec[i] == v) { vec[i] = vec.back(); @@ -68,7 +74,8 @@ template inline bool unordered_remove_value(std::vector &vec, T return false; } -template inline void append_array(std::vector &dst, const std::vector &src) { +template +inline void append_array(std::vector &dst, const std::vector &src) { dst.insert(dst.end(), src.begin(), src.end()); } @@ -94,20 +101,23 @@ inline String ptr2s(const void *p) { return String::num_uint64((uint64_t)p, 16); } -template void raw_copy_to(Vector &to, const std::vector &from) { +template +void raw_copy_to(Vector &to, const std::vector &from) { to.resize(from.size()); // resize can fail in case allocation was not possible ERR_FAIL_COND(from.size() != static_cast(to.size())); memcpy(to.ptrw(), from.data(), from.size() * sizeof(T)); } -template inline void sort(T &a, T &b) { +template +inline void sort(T &a, T &b) { if (a > b) { std::swap(a, b); } } -template inline void sort(T &a, T &b, T &c, T &d) { +template +inline void sort(T &a, T &b, T &c, T &d) { sort(a, b); sort(c, d); sort(a, c); @@ -117,7 +127,8 @@ template inline void sort(T &a, T &b, T &c, T &d) { // Tests if POD items in an array are all the same. // Better tailored for more than hundred items that have power-of-two size. -template inline bool is_uniform(const Item_T *p_data, size_t item_count) { +template +inline bool is_uniform(const Item_T *p_data, size_t item_count) { const Item_T v0 = p_data[0]; //typedef size_t Bucket_T; diff --git a/util/godot/funcs.cpp b/util/godot/funcs.cpp index cb647513..9e1ef5b5 100644 --- a/util/godot/funcs.cpp +++ b/util/godot/funcs.cpp @@ -234,7 +234,8 @@ Array generate_debug_seams_wireframe_surface(Ref src_mesh, int surface_ind // return wire_mesh; } -template void for_each_node_depth_first(Node *parent, F f) { +template +void for_each_node_depth_first(Node *parent, F f) { ERR_FAIL_COND(parent == nullptr); f(parent); for (int i = 0; i < parent->get_child_count(); ++i) { diff --git a/util/godot/funcs.h b/util/godot/funcs.h index fc5b2442..77a7e3c0 100644 --- a/util/godot/funcs.h +++ b/util/godot/funcs.h @@ -34,18 +34,21 @@ Array generate_debug_seams_wireframe_surface(Ref src_mesh, int surface_ind // `(ref1 = ref2).is_valid()` does not work because Ref does not implement an `operator=` returning the value. // So instead we can write it as `try_get_as(ref2, ref1)` -template inline bool try_get_as(Ref from, Ref &to) { +template +inline bool try_get_as(Ref from, Ref &to) { to = from; return to.is_valid(); } // Creates a shared_ptr which will use Godot's allocation functions -template inline std::shared_ptr gd_make_shared() { +template +inline std::shared_ptr gd_make_shared() { // std::make_shared() apparently wont allow us to specify custom new and delete return std::shared_ptr(memnew(T), memdelete); } -template inline std::shared_ptr gd_make_shared(Arg_T arg) { +template +inline std::shared_ptr gd_make_shared(Arg_T arg) { return std::shared_ptr(memnew(T(arg)), memdelete); } @@ -62,7 +65,8 @@ inline std::shared_ptr gd_make_shared(Arg0_T arg0, Arg1_T arg1, Arg2_T arg2) void set_nodes_owner(Node *root, Node *owner); void set_nodes_owner_except_root(Node *root, Node *owner); -template struct RefHasher { +template +struct RefHasher { static _FORCE_INLINE_ uint32_t hash(const Ref &v) { return uint32_t(uint64_t(v.ptr())) * (0x9e3779b1L); } diff --git a/util/math/box3i.h b/util/math/box3i.h index 183621ff..7252920b 100644 --- a/util/math/box3i.h +++ b/util/math/box3i.h @@ -98,7 +98,8 @@ public: inline void operator()(const Vector3i pos) {} }; - template inline void for_each_cell(A a) const { + template + inline void for_each_cell(A a) const { const Vector3i max = pos + size; Vector3i p; for (p.z = pos.z; p.z < max.z; ++p.z) { @@ -110,7 +111,8 @@ public: } } - template inline void for_each_cell_zxy(A a) const { + template + inline void for_each_cell_zxy(A a) const { const Vector3i max = pos + size; Vector3i p; for (p.z = pos.z; p.z < max.z; ++p.z) { @@ -123,7 +125,8 @@ public: } // Returns true if all cells of the box comply with the given predicate on their position. - template inline bool all_cells_match(A a) const { + template + inline bool all_cells_match(A a) const { const Vector3i max = pos + size; Vector3i p; for (p.z = pos.z; p.z < max.z; ++p.z) { @@ -151,7 +154,8 @@ public: // | B | // o---------o // - template void difference(const Box3i &b, A action) const { + template + void difference(const Box3i &b, A action) const { if (!intersects(b)) { action(*this); return; @@ -214,7 +218,8 @@ public: // Calls a function on all side cell positions belonging to the box. // This function was implemented with no particular order in mind. - template void for_inner_outline(F f) const { + template + void for_inner_outline(F f) const { // o-------o // /| /| // / | / | diff --git a/util/math/color8.h b/util/math/color8.h index 7caa2ff5..97637d8b 100644 --- a/util/math/color8.h +++ b/util/math/color8.h @@ -14,11 +14,9 @@ struct Color8 { uint8_t components[4]; }; - Color8() : - r(0), g(0), b(0), a(0) {} + Color8() : r(0), g(0), b(0), a(0) {} - Color8(uint8_t p_r, uint8_t p_g, uint8_t p_b, uint8_t p_a) : - r(p_r), g(p_g), b(p_b), a(p_a) {} + Color8(uint8_t p_r, uint8_t p_g, uint8_t p_b, uint8_t p_a) : r(p_r), g(p_g), b(p_b), a(p_a) {} Color8(Color c) { r = c.r * 255; @@ -29,44 +27,32 @@ struct Color8 { static inline Color8 from_u8(uint8_t v) { // rrggbbaa - return Color8( - v >> 6, - ((v >> 4) & 3), - ((v >> 2) & 3), - v & 3); + return Color8(v >> 6, ((v >> 4) & 3), ((v >> 2) & 3), v & 3); } static inline Color8 from_u16(uint16_t v) { // rrrrgggg bbbbaaaa 🐐 - return Color8( - v >> 12, - ((v >> 8) & 0xf), - ((v >> 4) & 0xf), - v & 0xf); + return Color8(v >> 12, ((v >> 8) & 0xf), ((v >> 4) & 0xf), v & 0xf); } static inline Color8 from_u32(uint32_t c) { // rrrrrrrr gggggggg bbbbbbbb aaaaaaaa - return Color8( - c >> 24, - (c >> 16) & 0xff, - (c >> 8) & 0xff, - c & 0xff); + return Color8(c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff); } inline uint8_t to_u8() const { // Lossy - return ((r >> 6) << 6) | - ((g >> 6) << 4) | - ((b >> 6) << 2) | + return ((r >> 6) << 6) | // + ((g >> 6) << 4) | // + ((b >> 6) << 2) | // (a >> 6); } inline uint16_t to_u16() const { // Lossy - return ((r >> 4) << 12) | - ((g >> 4) << 8) | - ((b >> 4) << 4) | + return ((r >> 4) << 12) | // + ((g >> 4) << 8) | // + ((b >> 4) << 4) | // (a >> 4); } diff --git a/util/math/funcs.h b/util/math/funcs.h index 663c49be..80aab180 100644 --- a/util/math/funcs.h +++ b/util/math/funcs.h @@ -35,27 +35,33 @@ inline T interpolate(const T v0, const T v1, const T v2, const T v3, const T v4, return res; } -template inline T min(const T a, const T b) { +template +inline T min(const T a, const T b) { return a < b ? a : b; } -template inline T max(const T a, const T b) { +template +inline T max(const T a, const T b) { return a > b ? a : b; } -template inline T min(const T a, const T b, const T c, const T d) { +template +inline T min(const T a, const T b, const T c, const T d) { return min(min(a, b), min(c, d)); } -template inline T max(const T a, const T b, const T c, const T d) { +template +inline T max(const T a, const T b, const T c, const T d) { return max(max(a, b), max(c, d)); } -template inline T min(const T a, const T b, const T c, const T d, const T e, const T f) { +template +inline T min(const T a, const T b, const T c, const T d, const T e, const T f) { return min(min(min(a, b), min(c, d)), min(e, f)); } -template inline T max(const T a, const T b, const T c, const T d, const T e, const T f) { +template +inline T max(const T a, const T b, const T c, const T d, const T e, const T f) { return max(max(max(a, b), max(c, d)), max(e, f)); } @@ -69,7 +75,8 @@ inline T max(const T a, const T b, const T c, const T d, const T e, const T f, c return max(max(a, b, c, d), max(e, f, g, h)); } -template inline T clamp(const T x, const T min_value, const T max_value) { +template +inline T clamp(const T x, const T min_value, const T max_value) { // TODO Optimization: clang can optimize a min/max implementation. Worth changing to that? if (x < min_value) { return min_value; @@ -80,7 +87,8 @@ template inline T clamp(const T x, const T min_value, const T max_v return x; } -template inline T squared(const T x) { +template +inline T squared(const T x) { return x * x; } diff --git a/util/math/vector3i.h b/util/math/vector3i.h index a83adc57..0566fed3 100644 --- a/util/math/vector3i.h +++ b/util/math/vector3i.h @@ -377,7 +377,8 @@ struct Vector3iHasher { // For STL namespace std { -template <> struct hash { +template <> +struct hash { size_t operator()(const Vector3i &v) const { return Vector3iHasher::hash(v); } diff --git a/util/noise/fast_noise_lite_gradient.h b/util/noise/fast_noise_lite_gradient.h index 7f2b142d..13408e33 100644 --- a/util/noise/fast_noise_lite_gradient.h +++ b/util/noise/fast_noise_lite_gradient.h @@ -30,7 +30,7 @@ public: // This one does not map directly to FastNoise unfortunately, // because Godot's UI wants consecutive values starting from 0... - enum FractalType { + enum FractalType { // FRACTAL_NONE, FRACTAL_DOMAIN_WARP_PROGRESSIVE, FRACTAL_DOMAIN_WARP_INDEPENDENT diff --git a/util/object_pool.h b/util/object_pool.h index 71147c1c..ca0389a7 100644 --- a/util/object_pool.h +++ b/util/object_pool.h @@ -6,7 +6,8 @@ namespace zylann { -template class ObjectPool { +template +class ObjectPool { public: T *create() { if (_objects.empty()) { diff --git a/util/span.h b/util/span.h index 11f65b17..61b00c1d 100644 --- a/util/span.h +++ b/util/span.h @@ -9,10 +9,7 @@ template class Span { public: - inline Span() : - _ptr(nullptr), - _size(0) { - } + inline Span() : _ptr(nullptr), _size(0) {} inline Span(T *p_ptr, size_t p_begin, size_t p_end) { CRASH_COND(p_end < p_begin); @@ -20,8 +17,7 @@ public: _size = p_end - p_begin; } - inline Span(T *p_ptr, size_t p_size) : - _ptr(p_ptr), _size(p_size) {} + inline Span(T *p_ptr, size_t p_size) : _ptr(p_ptr), _size(p_size) {} inline Span(Span &p_other, size_t p_begin, size_t p_end) { CRASH_COND(p_end < p_begin); diff --git a/util/tasks/threaded_task_runner.h b/util/tasks/threaded_task_runner.h index 97f45a18..dde219b4 100644 --- a/util/tasks/threaded_task_runner.h +++ b/util/tasks/threaded_task_runner.h @@ -88,7 +88,8 @@ public: void enqueue(Span tasks); // TODO Lambda might not be the best API. memcpying to a vector would ensure we lock for a shorter time. - template void dequeue_completed_tasks(F f) { + template + void dequeue_completed_tasks(F f) { MutexLock lock(_completed_tasks_mutex); for (size_t i = 0; i < _completed_tasks.size(); ++i) { IThreadedTask *task = _completed_tasks[i];