Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_args.h46
-rw-r--r--source/blender/blenlib/BLI_bitmap.h2
-rw-r--r--source/blender/blenlib/BLI_ghash.h7
-rw-r--r--source/blender/blenlib/BLI_linklist_stack.h14
-rw-r--r--source/blender/blenlib/BLI_map.hh16
-rw-r--r--source/blender/blenlib/BLI_math_geom.h8
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h8
-rw-r--r--source/blender/blenlib/BLI_noise.h85
-rw-r--r--source/blender/blenlib/BLI_set.hh2
-rw-r--r--source/blender/blenlib/BLI_string.h1
-rw-r--r--source/blender/blenlib/BLI_string_utf8.h1
-rw-r--r--source/blender/blenlib/intern/BLI_args.c76
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c3
-rw-r--r--source/blender/blenlib/intern/array_store.c16
-rw-r--r--source/blender/blenlib/intern/boxpack_2d.c4
-rw-r--r--source/blender/blenlib/intern/convexhull_2d.c3
-rw-r--r--source/blender/blenlib/intern/delaunay_2d.cc44
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c2
-rw-r--r--source/blender/blenlib/intern/math_boolean.cc2
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c1
-rw-r--r--source/blender/blenlib/intern/math_geom.c80
-rw-r--r--source/blender/blenlib/intern/math_interp.c6
-rw-r--r--source/blender/blenlib/intern/math_matrix.c67
-rw-r--r--source/blender/blenlib/intern/math_vector.c2
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c2
-rw-r--r--source/blender/blenlib/intern/mesh_boolean.cc2
-rw-r--r--source/blender/blenlib/intern/mesh_intersect.cc2
-rw-r--r--source/blender/blenlib/intern/noise.c301
-rw-r--r--source/blender/blenlib/intern/rct.c2
-rw-r--r--source/blender/blenlib/intern/scanfill_utils.c4
-rw-r--r--source/blender/blenlib/intern/smallhash.c1
-rw-r--r--source/blender/blenlib/intern/sort.c4
-rw-r--r--source/blender/blenlib/intern/storage_apple.mm2
-rw-r--r--source/blender/blenlib/intern/task_pool.cc10
-rw-r--r--source/blender/blenlib/intern/task_range.cc6
-rw-r--r--source/blender/blenlib/intern/voxel.c44
-rw-r--r--source/blender/blenlib/tests/BLI_array_store_test.cc18
-rw-r--r--source/blender/blenlib/tests/BLI_array_utils_test.cc2
-rw-r--r--source/blender/blenlib/tests/BLI_delaunay_2d_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc12
-rw-r--r--source/blender/blenlib/tests/BLI_ghash_test.cc18
-rw-r--r--source/blender/blenlib/tests/BLI_heap_simple_test.cc14
-rw-r--r--source/blender/blenlib/tests/BLI_heap_test.cc22
-rw-r--r--source/blender/blenlib/tests/BLI_kdopbvh_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc12
-rw-r--r--source/blender/blenlib/tests/BLI_listbase_test.cc22
-rw-r--r--source/blender/blenlib/tests/BLI_map_test.cc36
-rw-r--r--source/blender/blenlib/tests/BLI_path_util_test.cc86
-rw-r--r--source/blender/blenlib/tests/BLI_polyfill_2d_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_set_test.cc6
-rw-r--r--source/blender/blenlib/tests/BLI_stack_cxx_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_string_test.cc42
-rw-r--r--source/blender/blenlib/tests/BLI_string_utf8_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_task_graph_test.cc46
-rw-r--r--source/blender/blenlib/tests/BLI_task_test.cc16
-rw-r--r--source/blender/blenlib/tests/BLI_vector_set_test.cc6
-rw-r--r--source/blender/blenlib/tests/BLI_vector_test.cc16
-rw-r--r--source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc12
-rw-r--r--source/blender/blenlib/tests/performance/BLI_task_performance_test.cc4
59 files changed, 725 insertions, 561 deletions
diff --git a/source/blender/blenlib/BLI_args.h b/source/blender/blenlib/BLI_args.h
index 54b5161f15a..b12b7ff5d1e 100644
--- a/source/blender/blenlib/BLI_args.h
+++ b/source/blender/blenlib/BLI_args.h
@@ -38,41 +38,41 @@ typedef struct bArgs bArgs;
*/
typedef int (*BA_ArgCallback)(int argc, const char **argv, void *data);
-struct bArgs *BLI_argsInit(int argc, const char **argv);
-void BLI_argsFree(struct bArgs *ba);
+struct bArgs *BLI_args_create(int argc, const char **argv);
+void BLI_args_destroy(struct bArgs *ba);
+
+/** The pass to use for #BLI_args_add. */
+void BLI_args_pass_set(struct bArgs *ba, int current_pass);
/**
* Pass starts at 1, -1 means valid all the time
* short_arg or long_arg can be null to specify no short or long versions
*/
-void BLI_argsAdd(struct bArgs *ba,
- int pass,
- const char *short_arg,
- const char *long_arg,
- const char *doc,
- BA_ArgCallback cb,
- void *data);
+void BLI_args_add(struct bArgs *ba,
+ const char *short_arg,
+ const char *long_arg,
+ const char *doc,
+ BA_ArgCallback cb,
+ void *data);
/**
* Short_case and long_case specify if those arguments are case specific
*/
-void BLI_argsAddCase(struct bArgs *ba,
- int pass,
- const char *short_arg,
- int short_case,
- const char *long_arg,
- int long_case,
- const char *doc,
- BA_ArgCallback cb,
- void *data);
+void BLI_args_add_case(struct bArgs *ba,
+ const char *short_arg,
+ int short_case,
+ const char *long_arg,
+ int long_case,
+ const char *doc,
+ BA_ArgCallback cb,
+ void *data);
-void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *data);
+void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *data);
-void BLI_argsPrintArgDoc(struct bArgs *ba, const char *arg);
-void BLI_argsPrintOtherDoc(struct bArgs *ba);
+void BLI_args_print_arg_doc(struct bArgs *ba, const char *arg);
+void BLI_args_print_other_doc(struct bArgs *ba);
-void BLI_argsPrint(struct bArgs *ba);
-const char **BLI_argsArgv(struct bArgs *ba);
+void BLI_args_print(struct bArgs *ba);
#ifdef __cplusplus
}
diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h
index 960ce44c58c..c97be6eed3c 100644
--- a/source/blender/blenlib/BLI_bitmap.h
+++ b/source/blender/blenlib/BLI_bitmap.h
@@ -106,7 +106,7 @@ typedef unsigned int BLI_bitmap;
#define BLI_BITMAP_RESIZE(_bitmap, _tot) \
{ \
CHECK_TYPE(_bitmap, BLI_bitmap *); \
- (_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot)); \
+ (_bitmap) = MEM_recallocN(_bitmap, BLI_BITMAP_SIZE(_tot)); \
} \
(void)0
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index e38848e2967..bc517f81955 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -74,6 +74,7 @@ enum {
#endif
};
+/* -------------------------------------------------------------------- */
/** \name GHash API
*
* Defined in ``BLI_ghash.c``
@@ -124,6 +125,7 @@ void BLI_ghash_flag_clear(GHash *gh, unsigned int flag);
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GHash Iterator
* \{ */
@@ -175,6 +177,7 @@ BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GSet API
* A 'set' implementation (unordered collection of unique elements).
*
@@ -222,6 +225,7 @@ void *BLI_gset_pop_key(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GSet Iterator
* \{ */
@@ -272,6 +276,7 @@ BLI_INLINE bool BLI_gsetIterator_done(GSetIterator *gsi)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GHash/GSet Debugging API's
* \{ */
@@ -297,6 +302,7 @@ double BLI_gset_calc_quality(GSet *gs);
#endif /* GHASH_INTERNAL_API */
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GHash/GSet Macros
* \{ */
@@ -324,6 +330,7 @@ double BLI_gset_calc_quality(GSet *gs);
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GHash/GSet Utils
*
* Defined in ``BLI_ghash_utils.c``
diff --git a/source/blender/blenlib/BLI_linklist_stack.h b/source/blender/blenlib/BLI_linklist_stack.h
index 065ed12f353..be98304e6b5 100644
--- a/source/blender/blenlib/BLI_linklist_stack.h
+++ b/source/blender/blenlib/BLI_linklist_stack.h
@@ -32,12 +32,9 @@
*/
/* -------------------------------------------------------------------- */
-/* Linked Stack using BLI_mempool
- *
- * Uses mempool for storage.
- */
-
/** \name Linked Stack (mempool)
+ *
+ * Uses #BLI_mempool for storage.
* \{ */
#define BLI_LINKSTACK_DECLARE(var, type) \
@@ -94,13 +91,12 @@
/** \} */
/* -------------------------------------------------------------------- */
-/* Linked Stack, using stack memory (alloca)
+/** \name Linked Stack (alloca)
+ *
+ * Linked Stack, using stack memory (alloca).
*
* alloca never frees, pop'd items are stored in a free-list for reuse.
* only use for lists small enough to fit on the stack.
- */
-
-/** \name Linked Stack (alloca)
* \{ */
#ifdef __GNUC__
diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh
index 08fe1a3cdbc..9480af89107 100644
--- a/source/blender/blenlib/BLI_map.hh
+++ b/source/blender/blenlib/BLI_map.hh
@@ -230,19 +230,25 @@ class Map {
*/
void add_new(const Key &key, const Value &value)
{
- this->add_new__impl(key, value, hash_(key));
+ this->add_new_as(key, value);
}
void add_new(const Key &key, Value &&value)
{
- this->add_new__impl(key, std::move(value), hash_(key));
+ this->add_new_as(key, std::move(value));
}
void add_new(Key &&key, const Value &value)
{
- this->add_new__impl(std::move(key), value, hash_(key));
+ this->add_new_as(std::move(key), value);
}
void add_new(Key &&key, Value &&value)
{
- this->add_new__impl(std::move(key), std::move(value), hash_(key));
+ this->add_new_as(std::move(key), std::move(value));
+ }
+ template<typename ForwardKey, typename ForwardValue>
+ void add_new_as(ForwardKey &&key, ForwardValue &&value)
+ {
+ this->add_new__impl(
+ std::forward<ForwardKey>(key), std::forward<ForwardValue>(value), hash_(key));
}
/**
@@ -1010,7 +1016,7 @@ class Map {
return;
}
else {
- auto return_value = create_value(value_ptr);
+ auto &&return_value = create_value(value_ptr);
slot.occupy_no_value(std::forward<ForwardKey>(key), hash);
occupied_and_removed_slots_++;
return return_value;
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index a9a55b10a9e..c0a9ea91e75 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -358,6 +358,14 @@ bool isect_plane_plane_v3(const float plane_a[4],
float r_isect_co[3],
float r_isect_no[3]) ATTR_WARN_UNUSED_RESULT;
+bool isect_planes_v3_fn(
+ const float planes[][4],
+ const int planes_len,
+ const float eps_coplanar,
+ const float eps_isect,
+ void (*callback_fn)(const float co[3], int i, int j, int k, void *user_data),
+ void *user_data);
+
/* line/ray triangle */
bool isect_line_segment_tri_v3(const float p1[3],
const float p2[3],
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 9f6c56d698a..d971f48c4cf 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -322,9 +322,13 @@ void mat4_to_size(float size[3], const float M[4][4]);
void mat4_to_size_fix_shear(float size[3], const float M[4][4]);
+void translate_m3(float mat[3][3], float tx, float ty);
void translate_m4(float mat[4][4], float tx, float ty, float tz);
+void rotate_m3(float mat[3][3], const float angle);
void rotate_m4(float mat[4][4], const char axis, const float angle);
+void rescale_m3(float mat[3][3], const float scale[2]);
void rescale_m4(float mat[4][4], const float scale[3]);
+void transform_pivot_set_m3(float mat[3][3], const float pivot[2]);
void transform_pivot_set_m4(float mat[4][4], const float pivot[3]);
void mat3_to_rot_size(float rot[3][3], float size[3], const float mat3[3][3]);
@@ -334,6 +338,10 @@ void mat4_decompose(float loc[3], float quat[4], float size[3], const float wmat
void mat3_polar_decompose(const float mat3[3][3], float r_U[3][3], float r_P[3][3]);
+void loc_rot_size_to_mat3(float R[3][3],
+ const float loc[2],
+ const float angle,
+ const float size[2]);
void loc_rot_size_to_mat4(float R[4][4],
const float loc[3],
const float rot[3][3],
diff --git a/source/blender/blenlib/BLI_noise.h b/source/blender/blenlib/BLI_noise.h
index cb66b0552df..37afd8ee031 100644
--- a/source/blender/blenlib/BLI_noise.h
+++ b/source/blender/blenlib/BLI_noise.h
@@ -27,53 +27,54 @@
extern "C" {
#endif
-/* noise.h: */
-float BLI_hnoise(float noisesize, float x, float y, float z);
-float BLI_hnoisep(float noisesize, float x, float y, float z);
-float BLI_turbulence(float noisesize, float x, float y, float z, int nr);
-float BLI_turbulence1(float noisesize, float x, float y, float z, int nr);
+float BLI_noise_hnoise(float noisesize, float x, float y, float z);
+float BLI_noise_hnoisep(float noisesize, float x, float y, float z);
+float BLI_noise_turbulence(float noisesize, float x, float y, float z, int nr);
/* newnoise: generic noise & turbulence functions
- * to replace the above BLI_hnoise/p & BLI_turbulence/1.
+ * to replace the above BLI_noise_hnoise/p & BLI_noise_turbulence/1.
* This is done so different noise basis functions can be used */
-float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noisebasis);
-float BLI_gTurbulence(
- float noisesize, float x, float y, float z, int oct, int hard, int noisebasis);
+float BLI_noise_generic_noise(
+ float noisesize, float x, float y, float z, bool hard, int noisebasis);
+float BLI_noise_generic_turbulence(
+ float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis);
/* newnoise: musgrave functions */
-float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis);
-float mg_MultiFractal(
+float BLI_noise_mg_fbm(
float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis);
-float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nbas2);
-float mg_HeteroTerrain(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- int noisebasis);
-float mg_HybridMultiFractal(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- float gain,
- int noisebasis);
-float mg_RidgedMultiFractal(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- float gain,
- int noisebasis);
+float BLI_noise_mg_multi_fractal(
+ float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis);
+float BLI_noise_mg_variable_lacunarity(
+ float x, float y, float z, float distortion, int nbas1, int nbas2);
+float BLI_noise_mg_hetero_terrain(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ int noisebasis);
+float BLI_noise_mg_hybrid_multi_fractal(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ float gain,
+ int noisebasis);
+float BLI_noise_mg_ridged_multi_fractal(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ float gain,
+ int noisebasis);
/* newnoise: voronoi */
-void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype);
-/* newnoise: cellNoise & cellNoiseV (for vector/point/color) */
-float cellNoise(float x, float y, float z);
-void cellNoiseV(float x, float y, float z, float r_ca[3]);
+void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype);
+/* newnoise: BLI_noise_cell & BLI_noise_cell_v3 (for vector/point/color) */
+float BLI_noise_cell(float x, float y, float z);
+void BLI_noise_cell_v3(float x, float y, float z, float r_ca[3]);
#ifdef __cplusplus
}
diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh
index f1cf44018c9..06b56c3f8e5 100644
--- a/source/blender/blenlib/BLI_set.hh
+++ b/source/blender/blenlib/BLI_set.hh
@@ -48,7 +48,7 @@
* - Small buffer optimization is enabled by default, if the key is not too large.
* - The methods `add_new` and `remove_contained` should be used instead of `add` and `remove`
* whenever appropriate. Assumptions and intention are described better this way.
- * - Look-ups can be performed using types other than Key without conversion. For that use the
+ * - Lookups can be performed using types other than Key without conversion. For that use the
* methods ending with `_as`. The template parameters Hash and #IsEqual have to support the other
* key type. This can greatly improve performance when the set contains strings.
* - The default constructor is cheap, even when a large #InlineBufferCapacity is used. A large
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 6434464a012..2d745e63764 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -147,6 +147,7 @@ int BLI_string_find_split_words(const char *str,
int r_words[][2],
int words_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+/* -------------------------------------------------------------------- */
/** \name String Copy/Format Macros
* Avoid repeating destination with `sizeof(..)`.
* \note `ARRAY_SIZE` allows pointers on some platforms.
diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h
index b633bbfa435..65d9d7863c3 100644
--- a/source/blender/blenlib/BLI_string_utf8.h
+++ b/source/blender/blenlib/BLI_string_utf8.h
@@ -103,6 +103,7 @@ int BLI_str_utf8_offset_from_column(const char *str, int column);
#define BLI_UTF8_WIDTH_MAX 2 /* columns */
#define BLI_UTF8_ERR ((unsigned int)-1)
+/* -------------------------------------------------------------------- */
/** \name String Copy/Format Macros
* Avoid repeating destination with `sizeof(..)`.
* \note `ARRAY_SIZE` allows pointers on some platforms.
diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index 91aabca7747..3d4521a3304 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -63,6 +63,9 @@ struct bArgs {
int argc;
const char **argv;
int *passes;
+
+ /* Only use when initializing arguments. */
+ int current_pass;
};
static uint case_strhash(const void *ptr)
@@ -108,7 +111,7 @@ static bArgument *lookUp(struct bArgs *ba, const char *arg, int pass, int case_s
return BLI_ghash_lookup(ba->items, &key);
}
-bArgs *BLI_argsInit(int argc, const char **argv)
+bArgs *BLI_args_create(int argc, const char **argv)
{
bArgs *ba = MEM_callocN(sizeof(bArgs), "bArgs");
ba->passes = MEM_callocN(sizeof(int) * argc, "bArgs passes");
@@ -117,10 +120,13 @@ bArgs *BLI_argsInit(int argc, const char **argv)
ba->argc = argc;
ba->argv = argv;
+ /* Must be initialized by #BLI_args_pass_set. */
+ ba->current_pass = 0;
+
return ba;
}
-void BLI_argsFree(struct bArgs *ba)
+void BLI_args_destroy(struct bArgs *ba)
{
BLI_ghash_free(ba->items, MEM_freeN, MEM_freeN);
MEM_freeN(ba->passes);
@@ -128,7 +134,13 @@ void BLI_argsFree(struct bArgs *ba)
MEM_freeN(ba);
}
-void BLI_argsPrint(struct bArgs *ba)
+void BLI_args_pass_set(struct bArgs *ba, int current_pass)
+{
+ BLI_assert((current_pass != 0) && (current_pass >= -1));
+ ba->current_pass = current_pass;
+}
+
+void BLI_args_print(struct bArgs *ba)
{
int i;
for (i = 0; i < ba->argc; i++) {
@@ -136,11 +148,6 @@ void BLI_argsPrint(struct bArgs *ba)
}
}
-const char **BLI_argsArgv(struct bArgs *ba)
-{
- return ba->argv;
-}
-
static bArgDoc *internalDocs(struct bArgs *ba,
const char *short_arg,
const char *long_arg,
@@ -163,14 +170,10 @@ static bArgDoc *internalDocs(struct bArgs *ba,
return d;
}
-static void internalAdd(struct bArgs *ba,
- const char *arg,
- int pass,
- int case_str,
- BA_ArgCallback cb,
- void *data,
- bArgDoc *d)
+static void internalAdd(
+ struct bArgs *ba, const char *arg, int case_str, BA_ArgCallback cb, void *data, bArgDoc *d)
{
+ const int pass = ba->current_pass;
bArgument *a;
bAKey *key;
@@ -203,36 +206,34 @@ static void internalAdd(struct bArgs *ba,
BLI_ghash_insert(ba->items, key, a);
}
-void BLI_argsAddCase(struct bArgs *ba,
- int pass,
- const char *short_arg,
- int short_case,
- const char *long_arg,
- int long_case,
- const char *doc,
- BA_ArgCallback cb,
- void *data)
+void BLI_args_add_case(struct bArgs *ba,
+ const char *short_arg,
+ int short_case,
+ const char *long_arg,
+ int long_case,
+ const char *doc,
+ BA_ArgCallback cb,
+ void *data)
{
bArgDoc *d = internalDocs(ba, short_arg, long_arg, doc);
if (short_arg) {
- internalAdd(ba, short_arg, pass, short_case, cb, data, d);
+ internalAdd(ba, short_arg, short_case, cb, data, d);
}
if (long_arg) {
- internalAdd(ba, long_arg, pass, long_case, cb, data, d);
+ internalAdd(ba, long_arg, long_case, cb, data, d);
}
}
-void BLI_argsAdd(struct bArgs *ba,
- int pass,
- const char *short_arg,
- const char *long_arg,
- const char *doc,
- BA_ArgCallback cb,
- void *data)
+void BLI_args_add(struct bArgs *ba,
+ const char *short_arg,
+ const char *long_arg,
+ const char *doc,
+ BA_ArgCallback cb,
+ void *data)
{
- BLI_argsAddCase(ba, pass, short_arg, 0, long_arg, 0, doc, cb, data);
+ BLI_args_add_case(ba, short_arg, 0, long_arg, 0, doc, cb, data);
}
static void internalDocPrint(bArgDoc *d)
@@ -250,7 +251,7 @@ static void internalDocPrint(bArgDoc *d)
printf(" %s\n\n", d->documentation);
}
-void BLI_argsPrintArgDoc(struct bArgs *ba, const char *arg)
+void BLI_args_print_arg_doc(struct bArgs *ba, const char *arg)
{
bArgument *a = lookUp(ba, arg, -1, -1);
@@ -263,7 +264,7 @@ void BLI_argsPrintArgDoc(struct bArgs *ba, const char *arg)
}
}
-void BLI_argsPrintOtherDoc(struct bArgs *ba)
+void BLI_args_print_other_doc(struct bArgs *ba)
{
bArgDoc *d;
@@ -274,8 +275,9 @@ void BLI_argsPrintOtherDoc(struct bArgs *ba)
}
}
-void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
+void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
{
+ BLI_assert((pass != 0) && (pass >= -1));
int i = 0;
for (i = 1; i < ba->argc; i++) { /* skip argv[0] */
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index d20f0ce49d0..a221820d4c4 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -67,6 +67,7 @@ struct Heap {
} nodes;
};
+/* -------------------------------------------------------------------- */
/** \name Internal Functions
* \{ */
@@ -146,6 +147,7 @@ static void heap_up(Heap *heap, uint i)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Internal Memory Management
* \{ */
@@ -187,6 +189,7 @@ static void heap_node_free(Heap *heap, HeapNode *node)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Public Heap API
* \{ */
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index a6a0c21b104..847cb42186a 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -112,6 +112,7 @@
/* only for BLI_array_store_is_valid */
#include "BLI_ghash.h"
+/* -------------------------------------------------------------------- */
/** \name Defines
*
* Some of the logic for merging is quite involved,
@@ -206,6 +207,7 @@
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Internal Structs
* \{ */
@@ -313,6 +315,7 @@ typedef struct BTableRef {
static size_t bchunk_list_size(const BChunkList *chunk_list);
+/* -------------------------------------------------------------------- */
/** \name Internal BChunk API
* \{ */
@@ -360,6 +363,7 @@ static bool bchunk_data_compare(const BChunk *chunk,
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Internal BChunkList API
* \{ */
@@ -732,10 +736,11 @@ static void bchunk_list_fill_from_array(const BArrayInfo *info,
/** \} */
-/* ---------------------------------------------------------------------------
+/*
* Internal Table Lookup Functions
*/
+/* -------------------------------------------------------------------- */
/** \name Internal Hashing/De-Duplication API
*
* Only used by #bchunk_list_from_data_merge
@@ -1005,6 +1010,7 @@ static const BChunkRef *table_lookup(const BArrayInfo *info,
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Main Data De-Duplication Function
*
* \{ */
@@ -1307,7 +1313,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
ASSERT_CHUNKLIST_DATA(chunk_list, data);
/* its likely that the next chunk in the list will be a match, so check it! */
- while ((cref_found->next != NULL) && (cref_found->next != chunk_list_reference_last)) {
+ while (!ELEM(cref_found->next, NULL, chunk_list_reference_last)) {
cref_found = cref_found->next;
BChunk *chunk_found = cref_found->link;
@@ -1390,6 +1396,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Main Array Storage API
* \{ */
@@ -1405,7 +1412,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
*
* \param chunk_count: Number of elements to split each chunk into.
* - A small value increases the ability to de-duplicate chunks,
- * but adds overhead by increasing the number of chunks to look-up when searching for duplicates,
+ * but adds overhead by increasing the number of chunks to look up when searching for duplicates,
* as well as some overhead constructing the original array again, with more calls to ``memcpy``.
* - Larger values reduce the *book keeping* overhead,
* but increase the chance a small,
@@ -1496,6 +1503,7 @@ void BLI_array_store_clear(BArrayStore *bs)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name BArrayStore Statistics
* \{ */
@@ -1530,6 +1538,7 @@ size_t BLI_array_store_calc_size_compacted_get(const BArrayStore *bs)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name BArrayState Access
* \{ */
@@ -1653,6 +1662,7 @@ void *BLI_array_store_state_data_get_alloc(BArrayState *state, size_t *r_data_le
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Debugging API (for testing).
* \{ */
diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c
index 250a3fdf21b..9840dc77148 100644
--- a/source/blender/blenlib/intern/boxpack_2d.c
+++ b/source/blender/blenlib/intern/boxpack_2d.c
@@ -97,6 +97,7 @@ BLI_INLINE int quad_flag(uint q)
#define TL 2
#define BR 3
+/* -------------------------------------------------------------------- */
/** \name Box Accessor Functions
* \{ */
@@ -121,6 +122,7 @@ static float box_ymax_get(const BoxPack *box)
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Box Placement
* \{ */
@@ -165,6 +167,7 @@ static void box_ymax_set(BoxPack *box, const float f)
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Box Utils
* \{ */
@@ -203,6 +206,7 @@ static void vert_bias_update(BoxVert *v)
printf("\tBox Debug i %i, w:%.3f h:%.3f x:%.3f y:%.3f\n", b->index, b->w, b->h, b->x, b->y)
#endif
+/* -------------------------------------------------------------------- */
/** \name Box/Vert Sorting
* \{ */
diff --git a/source/blender/blenlib/intern/convexhull_2d.c b/source/blender/blenlib/intern/convexhull_2d.c
index 6e4a8623077..a3d24787d27 100644
--- a/source/blender/blenlib/intern/convexhull_2d.c
+++ b/source/blender/blenlib/intern/convexhull_2d.c
@@ -37,6 +37,7 @@
* http://softsurfer.com/Archive/algorithm_0203/algorithm_0203.htm
*/
+/* -------------------------------------------------------------------- */
/** \name Main Convex-Hull Calculation
* \{ */
@@ -227,9 +228,9 @@ int BLI_convexhull_2d(const float (*points)[2], const int n, int r_points[])
/** \} */
-/* -------------------------------------------------------------------- */
/* Helper functions */
+/* -------------------------------------------------------------------- */
/** \name Utility Convex-Hull Functions
* \{ */
diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc
index ac3662284d0..daa006fd5cc 100644
--- a/source/blender/blenlib/intern/delaunay_2d.cc
+++ b/source/blender/blenlib/intern/delaunay_2d.cc
@@ -654,12 +654,12 @@ template<typename T> inline bool is_border_edge(const CDTEdge<T> *e, const CDT_s
template<typename T> inline bool is_constrained_edge(const CDTEdge<T> *e)
{
- return e->input_ids != NULL;
+ return e->input_ids != nullptr;
}
template<typename T> inline bool is_deleted_edge(const CDTEdge<T> *e)
{
- return e->symedges[0].next == NULL;
+ return e->symedges[0].next == nullptr;
}
template<typename T> inline bool is_original_vert(const CDTVert<T> *v, CDT_state<T> *cdt)
@@ -1308,8 +1308,8 @@ template<typename T> inline int tri_orient(const SymEdge<T> *t)
* For case (a), 'vert' will be the vertex, and lambda will be 0, and 'in' will be the #SymEdge
* from 'vert' that has as face the one that you go through to get to this vertex. If you go
* exactly along an edge then we set 'in' to NULL, since it won't be needed. The first crossing
- * will have 'in' = NULL. We set 'out' to the #SymEdge that has the face we go through to get to the
- * next crossing, or, if the next crossing is a case (a), then it is the edge that goes to that
+ * will have 'in' = NULL. We set 'out' to the #SymEdge that has the face we go through to get to
+ * the next crossing, or, if the next crossing is a case (a), then it is the edge that goes to that
* next vertex. 'out' will be NULL for the last one.
*
* For case (b), vert will be NULL at first, and later filled in with the created split vertex,
@@ -1386,8 +1386,8 @@ void fill_crossdata_for_through_vert(CDTVert<T> *v,
cd_next->lambda = T(0);
cd_next->vert = v;
- cd_next->in = NULL;
- cd_next->out = NULL;
+ cd_next->in = nullptr;
+ cd_next->out = nullptr;
if (cd->lambda == 0) {
cd->out = cd_out;
}
@@ -1630,10 +1630,10 @@ void add_edge_constraint(
if (dbg_level > 0) {
std::cout << "\nADD EDGE CONSTRAINT\n" << vertname(v1) << " " << vertname(v2) << "\n";
}
- LinkNodePair edge_list = {NULL, NULL};
+ LinkNodePair edge_list = {nullptr, nullptr};
if (r_edges) {
- *r_edges = NULL;
+ *r_edges = nullptr;
}
/*
@@ -1648,7 +1648,7 @@ void add_edge_constraint(
if (t != nullptr) {
/* Segment already there. */
add_to_input_ids(&t->edge->input_ids, input_id);
- if (r_edges != NULL) {
+ if (r_edges != nullptr) {
BLI_linklist_append(&edge_list, t->edge);
*r_edges = edge_list.list;
}
@@ -1736,15 +1736,15 @@ void add_edge_constraint(
SymEdge<T> *se;
if (cd_prev->lambda == 0.0) {
se = find_symedge_between_verts(cd_prev->vert, v);
- if (se == NULL) {
+ if (se == nullptr) {
return;
}
cd_prev->out = se;
- cd->in = NULL;
+ cd->in = nullptr;
}
else {
se = find_symedge_with_face(v, sym(cd_prev->in)->face);
- if (se == NULL) {
+ if (se == nullptr) {
return;
}
cd->in = se;
@@ -1783,7 +1783,7 @@ void add_edge_constraint(
if (cd->lambda == -1.0) {
continue; /* This crossing was deleted. */
}
- t = NULL;
+ t = nullptr;
SymEdge<T> *tnext = t;
CDTEdge<T> *edge;
if (cd->lambda != 0.0) {
@@ -1795,7 +1795,7 @@ void add_edge_constraint(
else if (cd->lambda == 0.0) {
t = cd->in;
tnext = cd->out;
- if (t == NULL) {
+ if (t == nullptr) {
/* Previous non-deleted crossing must also have been a vert, and segment should exist. */
int j;
CrossData<T> *cd_prev;
@@ -1809,12 +1809,12 @@ void add_edge_constraint(
BLI_assert(cd_prev->out->next->vert == cd->vert);
edge = cd_prev->out->edge;
add_to_input_ids(&edge->input_ids, input_id);
- if (r_edges != NULL) {
+ if (r_edges != nullptr) {
BLI_linklist_append(&edge_list, edge);
}
}
}
- if (t != NULL) {
+ if (t != nullptr) {
if (tstart->next->vert == t->vert) {
edge = tstart->edge;
}
@@ -1822,7 +1822,7 @@ void add_edge_constraint(
edge = cdt_state->cdt.add_diagonal(tstart, t);
}
add_to_input_ids(&edge->input_ids, input_id);
- if (r_edges != NULL) {
+ if (r_edges != nullptr) {
BLI_linklist_append(&edge_list, edge);
}
/* Now retriangulate upper and lower gaps. */
@@ -1830,7 +1830,7 @@ void add_edge_constraint(
re_delaunay_triangulate(&cdt_state->cdt, &edge->symedges[1]);
}
if (i < ncrossings - 1) {
- if (tnext != NULL) {
+ if (tnext != nullptr) {
tstart = tnext;
}
}
@@ -2008,10 +2008,10 @@ template<typename T> void dissolve_symedge(CDT_state<T> *cdt_state, SymEdge<T> *
se = sym(se);
symse = sym(se);
}
- if (cdt->outer_face->symedge == se || cdt->outer_face->symedge == symse) {
+ if (ELEM(cdt->outer_face->symedge, se, symse)) {
/* Advancing by 2 to get past possible 'sym(se)'. */
if (se->next->next == se) {
- cdt->outer_face->symedge = NULL;
+ cdt->outer_face->symedge = nullptr;
}
else {
cdt->outer_face->symedge = se->next->next;
@@ -2177,9 +2177,9 @@ template<typename T> void remove_outer_edges_until_constraints(CDT_state<T> *cdt
}
se = se->next;
} while (se != se_start);
- while (to_dissolve != NULL) {
+ while (to_dissolve != nullptr) {
se = static_cast<SymEdge<T> *>(BLI_linklist_pop(&to_dissolve));
- if (se->next != NULL) {
+ if (se->next != nullptr) {
dissolve_symedge(cdt_state, se);
}
}
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 1b388dcf11f..8cc5c31a4c7 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -611,7 +611,7 @@ MINLINE int compare_ff_relative(float a, float b, const float max_diff, const in
MINLINE float signf(float f)
{
- return (f < 0.f) ? -1.f : 1.f;
+ return (f < 0.0f) ? -1.0f : 1.0f;
}
MINLINE float compatible_signf(float f)
diff --git a/source/blender/blenlib/intern/math_boolean.cc b/source/blender/blenlib/intern/math_boolean.cc
index f8bf8676f50..a345bc1d0af 100644
--- a/source/blender/blenlib/intern/math_boolean.cc
+++ b/source/blender/blenlib/intern/math_boolean.cc
@@ -470,7 +470,7 @@ void exactinit()
}
every_other = !every_other;
check = 1.0 + epsilon;
- } while ((check != 1.0) && (check != lastcheck));
+ } while (!ELEM(check, 1.0, lastcheck));
splitter += 1.0;
/* Error bounds for orientation and #incircle tests. */
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 85aabbb672a..1264620cf36 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -261,6 +261,7 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack)
r_col[2] = ((pack) >> 16) & 0xFF;
}
+/* -------------------------------------------------------------------- */
/** \name RGB/Grayscale Functions
*
* \warning
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 2f913a294e0..2b0018e7662 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1418,7 +1418,7 @@ int isect_seg_seg_v2_lambda_mu_db(const double v1[2],
/**
* \param l1, l2: Coordinates (point of line).
- * \param sp, r: Coordinate and radius (sphere).
+ * \param sp, r: Coordinate and radius (sphere).
* \return r_p1, r_p2: Intersection coordinates.
*
* \note The order of assignment for intersection points (\a r_p1, \a r_p2) is predictable,
@@ -2298,6 +2298,81 @@ bool isect_plane_plane_v3(const float plane_a[4],
}
/**
+ * Intersect all planes, calling `callback_fn` for each point that intersects
+ * 3 of the planes that isn't outside any of the other planes.
+ *
+ * This can be thought of as calculating a convex-hull from an array of planes.
+ *
+ * \param eps_coplanar: Epsilon for testing if two planes are aligned (co-planar).
+ * \param eps_isect: Epsilon for testing of a point is behind any of the planes.
+ *
+ * \warning As complexity is a little under `O(N^3)`, this is only suitable for small arrays.
+ *
+ * \note This function could be optimized by some spatial structure.
+ */
+bool isect_planes_v3_fn(
+ const float planes[][4],
+ const int planes_len,
+ const float eps_coplanar,
+ const float eps_isect,
+ void (*callback_fn)(const float co[3], int i, int j, int k, void *user_data),
+ void *user_data)
+{
+ bool found = false;
+
+ float n1n2[3], n2n3[3], n3n1[3];
+
+ for (int i = 0; i < planes_len; i++) {
+ const float *n1 = planes[i];
+ for (int j = i + 1; j < planes_len; j++) {
+ const float *n2 = planes[j];
+ cross_v3_v3v3(n1n2, n1, n2);
+ if (len_squared_v3(n1n2) <= eps_coplanar) {
+ continue;
+ }
+ for (int k = j + 1; k < planes_len; k++) {
+ const float *n3 = planes[k];
+ cross_v3_v3v3(n2n3, n2, n3);
+ if (len_squared_v3(n2n3) <= eps_coplanar) {
+ continue;
+ }
+
+ cross_v3_v3v3(n3n1, n3, n1);
+ if (len_squared_v3(n3n1) <= eps_coplanar) {
+ continue;
+ }
+ const float quotient = -dot_v3v3(n1, n2n3);
+ if (fabsf(quotient) < eps_coplanar) {
+ continue;
+ }
+ const float co_test[3] = {
+ ((n2n3[0] * n1[3]) + (n3n1[0] * n2[3]) + (n1n2[0] * n3[3])) / quotient,
+ ((n2n3[1] * n1[3]) + (n3n1[1] * n2[3]) + (n1n2[1] * n3[3])) / quotient,
+ ((n2n3[2] * n1[3]) + (n3n1[2] * n2[3]) + (n1n2[2] * n3[3])) / quotient,
+ };
+ int i_test;
+ for (i_test = 0; i_test < planes_len; i_test++) {
+ const float *np_test = planes[i_test];
+ if (((dot_v3v3(np_test, co_test) + np_test[3]) > eps_isect)) {
+ /* For low epsilon values the point could intersect it's own plane. */
+ if (!ELEM(i_test, i, j, k)) {
+ break;
+ }
+ }
+ }
+
+ if (i_test == planes_len) { /* ok */
+ callback_fn(co_test, i, j, k, user_data);
+ found = true;
+ }
+ }
+ }
+ }
+
+ return found;
+}
+
+/**
* Intersect two triangles.
*
* \param r_i1, r_i2: Retrieve the overlapping edge between the 2 triangles.
@@ -4181,6 +4256,7 @@ int interp_sparse_array(float *array, const int list_size, const float skipval)
return 1;
}
+/* -------------------------------------------------------------------- */
/** \name interp_weights_poly_v2, v3
* \{ */
@@ -5496,7 +5572,7 @@ void vcloud_estimate_transform_v3(const int list_size,
stunt[1] = q[1][1];
stunt[2] = q[2][2];
/* renormalizing for numeric stability */
- mul_m3_fl(q, 1.f / len_v3(stunt));
+ mul_m3_fl(q, 1.0f / len_v3(stunt));
/* this is pretty much Polardecompose 'inline' the algo based on Higham's thesis */
/* without the far case ... but seems to work here pretty neat */
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index 13a1816f1bd..3cec3db9806 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -517,7 +517,7 @@ void BLI_bilinear_interpolation_wrap_char(const unsigned char *buffer,
* otherwise at high texture magnifications circular artifacts are visible. */
#define EWA_MAXIDX 255
const float EWA_WTS[EWA_MAXIDX + 1] = {
- 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f,
+ 1.0f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f,
0.938216f, 0.929664f, 0.921178f, 0.912759f, 0.904405f, 0.896117f, 0.887893f,
0.879734f, 0.871638f, 0.863605f, 0.855636f, 0.847728f, 0.839883f, 0.832098f,
0.824375f, 0.816712f, 0.809108f, 0.801564f, 0.794079f, 0.786653f, 0.779284f,
@@ -553,7 +553,7 @@ const float EWA_WTS[EWA_MAXIDX + 1] = {
0.0324175f, 0.0309415f, 0.029477f, 0.0280239f, 0.0265822f, 0.0251517f, 0.0237324f,
0.0223242f, 0.020927f, 0.0195408f, 0.0181653f, 0.0168006f, 0.0154466f, 0.0141031f,
0.0127701f, 0.0114476f, 0.0101354f, 0.00883339f, 0.00754159f, 0.00625989f, 0.00498819f,
- 0.00372644f, 0.00247454f, 0.00123242f, 0.f,
+ 0.00372644f, 0.00247454f, 0.00123242f, 0.0f,
};
static void radangle2imp(float a2, float b2, float th, float *A, float *B, float *C, float *F)
@@ -625,7 +625,7 @@ void BLI_ewa_filter(const int width,
* Use a different radius based on interpolation switch,
* just enough to anti-alias when interpolation is off,
* and slightly larger to make result a bit smoother than bilinear interpolation when
- * interpolation is on (minimum values: const float rmin = intpol ? 1.f : 0.5f;) */
+ * interpolation is on (minimum values: const float rmin = intpol ? 1.0f : 0.5f;) */
const float rmin = (intpol ? 1.5625f : 0.765625f) / ff2;
BLI_ewa_imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
if ((b2 = b * b) < rmin) {
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 656f37c9f18..6b5efc3f8c4 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -274,7 +274,7 @@ void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4])
{
- BLI_assert(R != A && R != B);
+ BLI_assert(!ELEM(R, A, B));
/* matrix product: R[j][k] = A[j][i] . B[i][k] */
#ifdef __SSE2__
@@ -319,7 +319,7 @@ void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4])
void mul_m4_m4m4_db_uniq(double R[4][4], const double A[4][4], const double B[4][4])
{
- BLI_assert(R != A && R != B);
+ BLI_assert(!ELEM(R, A, B));
/* matrix product: R[j][k] = A[j][i] . B[i][k] */
@@ -347,7 +347,7 @@ void mul_m4_m4m4_db_uniq(double R[4][4], const double A[4][4], const double B[4]
void mul_m4db_m4db_m4fl_uniq(double R[4][4], const double A[4][4], const float B[4][4])
{
/* Remove second check since types don't match. */
- BLI_assert(R != A /* && R != B */);
+ BLI_assert(!ELEM(R, A /*, B */));
/* matrix product: R[j][k] = A[j][i] . B[i][k] */
@@ -419,7 +419,7 @@ void mul_m3_m3_post(float R[3][3], const float B[3][3])
void mul_m3_m3m3_uniq(float R[3][3], const float A[3][3], const float B[3][3])
{
- BLI_assert(R != A && R != B);
+ BLI_assert(!ELEM(R, A, B));
R[0][0] = B[0][0] * A[0][0] + B[0][1] * A[1][0] + B[0][2] * A[2][0];
R[0][1] = B[0][0] * A[0][1] + B[0][1] * A[1][1] + B[0][2] * A[2][1];
@@ -535,8 +535,10 @@ void mul_m3_m4m4(float R[3][3], const float A[4][4], const float B[4][4])
R[2][2] = B[2][0] * A[0][2] + B[2][1] * A[1][2] + B[2][2] * A[2][2];
}
+/* -------------------------------------------------------------------- */
/** \name Macro helpers for: mul_m3_series
* \{ */
+
void _va_mul_m3_series_3(float r[3][3], const float m1[3][3], const float m2[3][3])
{
mul_m3_m3m3(r, m1, m2);
@@ -621,8 +623,10 @@ void _va_mul_m3_series_9(float r[3][3],
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Macro helpers for: mul_m4_series
* \{ */
+
void _va_mul_m4_series_3(float r[4][4], const float m1[4][4], const float m2[4][4])
{
mul_m4_m4m4(r, m1, m2);
@@ -2219,6 +2223,12 @@ void scale_m4_fl(float R[4][4], float scale)
R[3][0] = R[3][1] = R[3][2] = 0.0;
}
+void translate_m3(float mat[3][3], float tx, float ty)
+{
+ mat[2][0] += (tx * mat[0][0] + ty * mat[1][0]);
+ mat[2][1] += (tx * mat[0][1] + ty * mat[1][1]);
+}
+
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
{
mat[3][0] += (Tx * mat[0][0] + Ty * mat[1][0] + Tz * mat[2][0]);
@@ -2226,6 +2236,18 @@ void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
mat[3][2] += (Tx * mat[0][2] + Ty * mat[1][2] + Tz * mat[2][2]);
}
+void rotate_m3(float mat[3][3], const float angle)
+{
+ const float angle_cos = cosf(angle);
+ const float angle_sin = sinf(angle);
+
+ for (int col = 0; col < 3; col++) {
+ float temp = angle_cos * mat[0][col] + angle_sin * mat[1][col];
+ mat[1][col] = -angle_sin * mat[0][col] + angle_cos * mat[1][col];
+ mat[0][col] = temp;
+ }
+}
+
/* TODO: enum for axis? */
/**
* Rotate a matrix in-place.
@@ -2271,6 +2293,12 @@ void rotate_m4(float mat[4][4], const char axis, const float angle)
}
}
+void rescale_m3(float mat[3][3], const float scale[2])
+{
+ mul_v3_fl(mat[0], scale[0]);
+ mul_v3_fl(mat[1], scale[1]);
+}
+
/** Scale a matrix in-place. */
void rescale_m4(float mat[4][4], const float scale[3])
{
@@ -2301,6 +2329,20 @@ void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
mul_m4_m4m4(mat, mat, tmat);
}
+void transform_pivot_set_m3(float mat[3][3], const float pivot[2])
+{
+ float tmat[3][3];
+
+ unit_m3(tmat);
+
+ copy_v2_v2(tmat[2], pivot);
+ mul_m3_m3m3(mat, tmat, mat);
+
+ /* invert the matrix */
+ negate_v2(tmat[2]);
+ mul_m3_m3m3(mat, mat, tmat);
+}
+
void blend_m3_m3m3(float out[3][3],
const float dst[3][3],
const float src[3][3],
@@ -2481,6 +2523,21 @@ bool equals_m4m4(const float mat1[4][4], const float mat2[4][4])
}
/**
+ * Make a 3x3 matrix out of 3 transform components.
+ * Matrices are made in the order: `loc * rot * scale`
+ */
+void loc_rot_size_to_mat3(float R[3][3],
+ const float loc[2],
+ const float angle,
+ const float size[2])
+{
+ unit_m3(R);
+ translate_m3(R, loc[0], loc[1]);
+ rotate_m3(R, angle);
+ rescale_m3(R, size);
+}
+
+/**
* Make a 4x4 matrix out of 3 transform components.
* Matrices are made in the order: `scale * rot * loc`
*/
@@ -2863,7 +2920,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
if (ks == k) {
break;
}
- t = (ks != p ? fabsf(e[ks]) : 0.f) + (ks != k + 1 ? fabsf(e[ks - 1]) : 0.0f);
+ t = (ks != p ? fabsf(e[ks]) : 0.0f) + (ks != k + 1 ? fabsf(e[ks - 1]) : 0.0f);
if (fabsf(s[ks]) <= eps * t) {
s[ks] = 0.0f;
break;
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 4d7efa4b6f4..5f3297134c6 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -162,6 +162,7 @@ void interp_v2_v2v2_slerp_safe(float target[2], const float a[2], const float b[
}
}
+/* -------------------------------------------------------------------- */
/** \name Cubic curve interpolation (bezier spline).
* \{ */
@@ -1395,6 +1396,7 @@ void copy_vn_fl(float *array_tar, const int size, const float val)
}
}
+/* -------------------------------------------------------------------- */
/** \name Double precision versions 'db'.
* \{ */
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index f6841ef52b0..f17b7535258 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -1288,6 +1288,7 @@ MINLINE bool is_one_v3(const float v[3])
return (v[0] == 1.0f && v[1] == 1.0f && v[2] == 1.0f);
}
+/* -------------------------------------------------------------------- */
/** \name Vector Comparison
*
* \note use ``value <= limit``, so a limit of zero doesn't fail on an exact match.
@@ -1395,6 +1396,7 @@ MINLINE bool compare_size_v3v3(const float v1[3], const float v2[3], const float
return true;
}
+/* -------------------------------------------------------------------- */
/** \name Vector Clamping
* \{ */
diff --git a/source/blender/blenlib/intern/mesh_boolean.cc b/source/blender/blenlib/intern/mesh_boolean.cc
index bad0b84d10f..c85adf835fe 100644
--- a/source/blender/blenlib/intern/mesh_boolean.cc
+++ b/source/blender/blenlib/intern/mesh_boolean.cc
@@ -2851,7 +2851,7 @@ static bool dissolve_leaves_valid_bmesh(FaceMergeState *fms,
* saying which faces a vertex touches. */
for (int a_v_index = 0; ok && a_v_index < alen; ++a_v_index) {
const Vert *a_v = mf_left.vert[a_v_index];
- if (a_v != me.v1 && a_v != me.v2) {
+ if (!ELEM(a_v, me.v1, me.v2)) {
for (int b_v_index = 0; b_v_index < blen; ++b_v_index) {
const Vert *b_v = mf_right.vert[b_v_index];
if (a_v == b_v) {
diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc
index 5f7258ebb6a..fffc88525c1 100644
--- a/source/blender/blenlib/intern/mesh_intersect.cc
+++ b/source/blender/blenlib/intern/mesh_intersect.cc
@@ -2333,7 +2333,7 @@ static CDT_data calc_cluster_subdivided(const CoplanarClusterInfo &clinfo,
std::pair<int, int> key = canon_int_pair(t, t_other);
if (itt_map.contains(key)) {
ITT_value itt = itt_map.lookup(key);
- if (itt.kind != INONE && itt.kind != ICOPLANAR) {
+ if (!ELEM(itt.kind, INONE, ICOPLANAR)) {
itts.append(itt);
if (dbg_level > 0) {
std::cout << " itt = " << itt << "\n";
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 1ae1c91a3bd..4ba533c72aa 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -24,7 +24,9 @@
#include <math.h>
#include "BLI_compiler_compat.h"
-#include "BLI_noise.h"
+#include "BLI_sys_types.h"
+
+#include "BLI_noise.h" /* Own include. */
/* local */
static float noise3_perlin(const float vec[3]);
@@ -319,7 +321,8 @@ static float newPerlin(float x, float y, float z)
lerp(u, grad(hash[AB + 1], x, y - 1, z - 1), grad(hash[BB + 1], x - 1, y - 1, z - 1))));
}
-/* for use with BLI_gNoise()/BLI_gTurbulence(), returns unsigned improved perlin noise */
+/* for use with BLI_noise_generic_noise()/BLI_noise_generic_turbulence(), returns unsigned improved
+ * perlin noise */
static float newPerlinU(float x, float y, float z)
{
return (0.5f + 0.5f * newPerlin(x, y, z));
@@ -329,7 +332,7 @@ static float newPerlinU(float x, float y, float z)
/* END OF IMPROVED PERLIN */
/**************************/
-/* Was BLI_hnoise(), removed noisesize, so other functions can call it without scaling. */
+/* Was BLI_noise_hnoise(), removed noisesize, so other functions can call it without scaling. */
static float orgBlenderNoise(float x, float y, float z)
{
float cn1, cn2, cn3, cn4, cn5, cn6, i;
@@ -425,7 +428,7 @@ static float orgBlenderNoiseS(float x, float y, float z)
}
/* separated from orgBlenderNoise above, with scaling */
-float BLI_hnoise(float noisesize, float x, float y, float z)
+float BLI_noise_hnoise(float noisesize, float x, float y, float z)
{
if (noisesize == 0.0f) {
return 0.0f;
@@ -437,32 +440,15 @@ float BLI_hnoise(float noisesize, float x, float y, float z)
}
/* original turbulence functions */
-float BLI_turbulence(float noisesize, float x, float y, float z, int nr)
-{
- float s, d = 0.5, div = 1.0;
-
- s = BLI_hnoise(noisesize, x, y, z);
-
- while (nr > 0) {
-
- s += d * BLI_hnoise(noisesize * d, x, y, z);
- div += d;
- d *= 0.5f;
-
- nr--;
- }
- return s / div;
-}
-
-float BLI_turbulence1(float noisesize, float x, float y, float z, int nr)
+float BLI_noise_turbulence(float noisesize, float x, float y, float z, int nr)
{
float s, d = 0.5, div = 1.0;
- s = fabsf((-1.0f + 2.0f * BLI_hnoise(noisesize, x, y, z)));
+ s = BLI_noise_hnoise(noisesize, x, y, z);
while (nr > 0) {
- s += fabsf(d * (-1.0f + 2.0f * BLI_hnoise(noisesize * d, x, y, z)));
+ s += d * BLI_noise_hnoise(noisesize * d, x, y, z);
div += d;
d *= 0.5f;
@@ -786,14 +772,13 @@ static float noise3_perlin(const float vec[3])
int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, rz0, rz1, sx, sy, sz, a, b, c, d, t, u, v;
const float *q;
- int i, j;
SETUP(vec[0], bx0, bx1, rx0, rx1);
SETUP(vec[1], by0, by1, ry0, ry1);
SETUP(vec[2], bz0, bz1, rz0, rz1);
- i = p[bx0];
- j = p[bx1];
+ int i = p[bx0];
+ int j = p[bx1];
b00 = p[i + by0];
b10 = p[j + by0];
@@ -843,31 +828,23 @@ static float noise3_perlin(const float vec[3])
#undef SURVE
}
-/* for use with BLI_gNoise/gTurbulence, returns signed noise */
+/* for use with BLI_noise_generic_noise/gTurbulence, returns signed noise */
static float orgPerlinNoise(float x, float y, float z)
{
- float v[3];
-
- v[0] = x;
- v[1] = y;
- v[2] = z;
+ float v[3] = {x, y, z};
return noise3_perlin(v);
}
-/* for use with BLI_gNoise/gTurbulence, returns unsigned noise */
+/* for use with BLI_noise_generic_noise/gTurbulence, returns unsigned noise */
static float orgPerlinNoiseU(float x, float y, float z)
{
- float v[3];
-
- v[0] = x;
- v[1] = y;
- v[2] = z;
+ float v[3] = {x, y, z};
return (0.5f + 0.5f * noise3_perlin(v));
}
/* *************** CALL AS: *************** */
-float BLI_hnoisep(float noisesize, float x, float y, float z)
+float BLI_noise_hnoisep(float noisesize, float x, float y, float z)
{
float vec[3];
@@ -906,13 +883,12 @@ static float dist_Manhattan(float x, float y, float z, float e)
/* Chebychev */
static float dist_Chebychev(float x, float y, float z, float e)
{
- float t;
(void)e;
x = fabsf(x);
y = fabsf(y);
z = fabsf(z);
- t = (x > y) ? x : y;
+ float t = (x > y) ? x : y;
return ((z > t) ? z : t);
}
@@ -942,11 +918,8 @@ static float dist_Minkovsky(float x, float y, float z, float e)
/* Not 'pure' Worley, but the results are virtually the same.
* Returns distances in da and point coords in pa */
-void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
+void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
{
- int xx, yy, zz, xi, yi, zi;
- float xd, yd, zd, d;
-
float (*distfunc)(float, float, float, float);
switch (dtype) {
case 1:
@@ -973,18 +946,18 @@ void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtyp
break;
}
- xi = (int)(floor(x));
- yi = (int)(floor(y));
- zi = (int)(floor(z));
+ int xi = (int)(floor(x));
+ int yi = (int)(floor(y));
+ int zi = (int)(floor(z));
da[0] = da[1] = da[2] = da[3] = 1e10f;
- for (xx = xi - 1; xx <= xi + 1; xx++) {
- for (yy = yi - 1; yy <= yi + 1; yy++) {
- for (zz = zi - 1; zz <= zi + 1; zz++) {
+ for (int xx = xi - 1; xx <= xi + 1; xx++) {
+ for (int yy = yi - 1; yy <= yi + 1; yy++) {
+ for (int zz = zi - 1; zz <= zi + 1; zz++) {
const float *p = HASHPNT(xx, yy, zz);
- xd = x - (p[0] + xx);
- yd = y - (p[1] + yy);
- zd = z - (p[2] + zz);
- d = distfunc(xd, yd, zd, me);
+ float xd = x - (p[0] + xx);
+ float yd = y - (p[1] + yy);
+ float zd = z - (p[2] + zz);
+ float d = distfunc(xd, yd, zd, me);
if (d < da[0]) {
da[3] = da[2];
da[2] = da[1];
@@ -1038,39 +1011,39 @@ void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtyp
}
}
-/* returns different feature points for use in BLI_gNoise() */
+/* returns different feature points for use in BLI_noise_generic_noise() */
static float voronoi_F1(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return da[0];
}
static float voronoi_F2(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return da[1];
}
static float voronoi_F3(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return da[2];
}
static float voronoi_F4(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return da[3];
}
static float voronoi_F1F2(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (da[1] - da[0]);
}
@@ -1078,8 +1051,8 @@ static float voronoi_F1F2(float x, float y, float z)
static float voronoi_Cr(float x, float y, float z)
{
float t = 10 * voronoi_F1F2(x, y, z);
- if (t > 1.f) {
- return 1.f;
+ if (t > 1.0f) {
+ return 1.0f;
}
return t;
}
@@ -1090,35 +1063,35 @@ static float voronoi_Cr(float x, float y, float z)
static float voronoi_F1S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * da[0] - 1.0f);
}
static float voronoi_F2S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * da[1] - 1.0f);
}
static float voronoi_F3S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * da[2] - 1.0f);
}
static float voronoi_F4S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * da[3] - 1.0f);
}
static float voronoi_F1F2S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * (da[1] - da[0]) - 1.0f);
}
@@ -1126,8 +1099,8 @@ static float voronoi_F1F2S(float x, float y, float z)
static float voronoi_CrS(float x, float y, float z)
{
float t = 10 * voronoi_F1F2(x, y, z);
- if (t > 1.f) {
- return 1.f;
+ if (t > 1.0f) {
+ return 1.0f;
}
return (2.0f * t - 1.0f);
}
@@ -1141,7 +1114,7 @@ static float voronoi_CrS(float x, float y, float z)
/*************/
/* returns unsigned cellnoise */
-static float cellNoiseU(float x, float y, float z)
+static float BLI_cellNoiseU(float x, float y, float z)
{
/* avoid precision issues on unit coordinates */
x = (x + 0.000001f) * 1.00001f;
@@ -1157,13 +1130,13 @@ static float cellNoiseU(float x, float y, float z)
}
/* idem, signed */
-float cellNoise(float x, float y, float z)
+float BLI_noise_cell(float x, float y, float z)
{
- return (2.0f * cellNoiseU(x, y, z) - 1.0f);
+ return (2.0f * BLI_cellNoiseU(x, y, z) - 1.0f);
}
/* returns a vector/point/color in ca, using point hasharray directly */
-void cellNoiseV(float x, float y, float z, float ca[3])
+void BLI_noise_cell_v3(float x, float y, float z, float ca[3])
{
/* avoid precision issues on unit coordinates */
x = (x + 0.000001f) * 1.00001f;
@@ -1184,7 +1157,8 @@ void cellNoiseV(float x, float y, float z, float ca[3])
/*****************/
/* newnoise: generic noise function for use with different noisebases */
-float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noisebasis)
+float BLI_noise_generic_noise(
+ float noisesize, float x, float y, float z, bool hard, int noisebasis)
{
float (*noisefunc)(float, float, float);
@@ -1214,12 +1188,12 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise
noisefunc = voronoi_Cr;
break;
case 14:
- noisefunc = cellNoiseU;
+ noisefunc = BLI_cellNoiseU;
break;
case 0:
default: {
noisefunc = orgBlenderNoise;
- /* add one to make return value same as BLI_hnoise */
+ /* add one to make return value same as BLI_noise_hnoise */
x += 1;
y += 1;
z += 1;
@@ -1241,13 +1215,10 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise
}
/* newnoise: generic turbulence function for use with different noisebasis */
-float BLI_gTurbulence(
- float noisesize, float x, float y, float z, int oct, int hard, int noisebasis)
+float BLI_noise_generic_turbulence(
+ float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
{
float (*noisefunc)(float, float, float);
- float sum, t, amp = 1, fscale = 1;
- int i;
-
switch (noisebasis) {
case 1:
noisefunc = orgPerlinNoiseU;
@@ -1274,7 +1245,7 @@ float BLI_gTurbulence(
noisefunc = voronoi_Cr;
break;
case 14:
- noisefunc = cellNoiseU;
+ noisefunc = BLI_cellNoiseU;
break;
case 0:
default:
@@ -1292,9 +1263,9 @@ float BLI_gTurbulence(
z *= noisesize;
}
- sum = 0;
- for (i = 0; i <= oct; i++, amp *= 0.5f, fscale *= 2.0f) {
- t = noisefunc(fscale * x, fscale * y, fscale * z);
+ float sum = 0, amp = 1, fscale = 1;
+ for (int i = 0; i <= oct; i++, amp *= 0.5f, fscale *= 2.0f) {
+ float t = noisefunc(fscale * x, fscale * y, fscale * z);
if (hard) {
t = fabsf(2.0f * t - 1.0f);
}
@@ -1319,11 +1290,9 @@ float BLI_gTurbulence(
* ``lacunarity'' is the gap between successive frequencies
* ``octaves'' is the number of frequencies in the fBm
*/
-float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
+float BLI_noise_mg_fbm(
+ float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
{
- float rmd, value = 0.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
- int i;
-
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:
@@ -1351,7 +1320,7 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1360,7 +1329,8 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
}
}
- for (i = 0; i < (int)octaves; i++) {
+ float value = 0.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
+ for (int i = 0; i < (int)octaves; i++) {
value += noisefunc(x, y, z) * pwr;
pwr *= pwHL;
x *= lacunarity;
@@ -1368,7 +1338,7 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
z *= lacunarity;
}
- rmd = octaves - floorf(octaves);
+ float rmd = octaves - floorf(octaves);
if (rmd != 0.0f) {
value += rmd * noisefunc(x, y, z) * pwr;
}
@@ -1391,12 +1361,9 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
/* this one is in fact rather confusing,
* there seem to be errors in the original source code (in all three versions of proc.text&mod),
* I modified it to something that made sense to me, so it might be wrong... */
-float mg_MultiFractal(
+float BLI_noise_mg_multi_fractal(
float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
{
- float rmd, value = 1.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
- int i;
-
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:
@@ -1424,7 +1391,7 @@ float mg_MultiFractal(
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1433,14 +1400,15 @@ float mg_MultiFractal(
}
}
- for (i = 0; i < (int)octaves; i++) {
+ float value = 1.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
+ for (int i = 0; i < (int)octaves; i++) {
value *= (pwr * noisefunc(x, y, z) + 1.0f);
pwr *= pwHL;
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
}
- rmd = octaves - floorf(octaves);
+ float rmd = octaves - floorf(octaves);
if (rmd != 0.0f) {
value *= (rmd * noisefunc(x, y, z) * pwr + 1.0f);
}
@@ -1459,20 +1427,15 @@ float mg_MultiFractal(
* ``octaves'' is the number of frequencies in the fBm
* ``offset'' raises the terrain from `sea level'
*/
-float mg_HeteroTerrain(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- int noisebasis)
+float BLI_noise_mg_hetero_terrain(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ int noisebasis)
{
- float value, increment, rmd;
- int i;
- float pwHL = powf(lacunarity, -H);
- float pwr = pwHL; /* starts with i=1 instead of 0 */
-
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:
@@ -1500,7 +1463,7 @@ float mg_HeteroTerrain(float x,
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1510,13 +1473,15 @@ float mg_HeteroTerrain(float x,
}
/* first unscaled octave of function; later octaves are scaled */
- value = offset + noisefunc(x, y, z);
+ float value = offset + noisefunc(x, y, z);
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
- for (i = 1; i < (int)octaves; i++) {
- increment = (noisefunc(x, y, z) + offset) * pwr * value;
+ float pwHL = powf(lacunarity, -H);
+ float pwr = pwHL; /* starts with i=1 instead of 0 */
+ for (int i = 1; i < (int)octaves; i++) {
+ float increment = (noisefunc(x, y, z) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
x *= lacunarity;
@@ -1524,9 +1489,9 @@ float mg_HeteroTerrain(float x,
z *= lacunarity;
}
- rmd = octaves - floorf(octaves);
+ float rmd = octaves - floorf(octaves);
if (rmd != 0.0f) {
- increment = (noisefunc(x, y, z) + offset) * pwr * value;
+ float increment = (noisefunc(x, y, z) + offset) * pwr * value;
value += rmd * increment;
}
return value;
@@ -1539,22 +1504,17 @@ float mg_HeteroTerrain(float x,
* H: 0.25
* offset: 0.7
*/
-float mg_HybridMultiFractal(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- float gain,
- int noisebasis)
+float BLI_noise_mg_hybrid_multi_fractal(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ float gain,
+ int noisebasis)
{
- float result, signal, weight, rmd;
- int i;
- float pwHL = powf(lacunarity, -H);
- float pwr = pwHL; /* starts with i=1 instead of 0 */
float (*noisefunc)(float, float, float);
-
switch (noisebasis) {
case 1:
noisefunc = orgPerlinNoise;
@@ -1581,7 +1541,7 @@ float mg_HybridMultiFractal(float x,
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1590,17 +1550,19 @@ float mg_HybridMultiFractal(float x,
}
}
- result = noisefunc(x, y, z) + offset;
- weight = gain * result;
+ float result = noisefunc(x, y, z) + offset;
+ float weight = gain * result;
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
- for (i = 1; (weight > 0.001f) && (i < (int)octaves); i++) {
+ float pwHL = powf(lacunarity, -H);
+ float pwr = pwHL; /* starts with i=1 instead of 0 */
+ for (int i = 1; (weight > 0.001f) && (i < (int)octaves); i++) {
if (weight > 1.0f) {
weight = 1.0f;
}
- signal = (noisefunc(x, y, z) + offset) * pwr;
+ float signal = (noisefunc(x, y, z) + offset) * pwr;
pwr *= pwHL;
result += weight * signal;
weight *= gain * signal;
@@ -1609,8 +1571,8 @@ float mg_HybridMultiFractal(float x,
z *= lacunarity;
}
- rmd = octaves - floorf(octaves);
- if (rmd != 0.f) {
+ float rmd = octaves - floorf(octaves);
+ if (rmd != 0.0f) {
result += rmd * ((noisefunc(x, y, z) + offset) * pwr);
}
@@ -1626,21 +1588,16 @@ float mg_HybridMultiFractal(float x,
* offset: 1.0
* gain: 2.0
*/
-float mg_RidgedMultiFractal(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- float gain,
- int noisebasis)
+float BLI_noise_mg_ridged_multi_fractal(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ float gain,
+ int noisebasis)
{
- float result, signal, weight;
- int i;
- float pwHL = powf(lacunarity, -H);
- float pwr = pwHL; /* starts with i=1 instead of 0 */
-
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:
@@ -1668,7 +1625,7 @@ float mg_RidgedMultiFractal(float x,
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1677,15 +1634,15 @@ float mg_RidgedMultiFractal(float x,
}
}
- signal = offset - fabsf(noisefunc(x, y, z));
- signal *= signal;
- result = signal;
-
- for (i = 1; i < (int)octaves; i++) {
+ float signal = powf(offset - fabsf(noisefunc(x, y, z)), 2);
+ float result = signal;
+ for (int i = 1; i < (int)octaves; i++) {
+ float pwHL = powf(lacunarity, -H);
+ float pwr = pwHL; /* starts with i=1 instead of 0 */
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
- weight = signal * gain;
+ float weight = signal * gain;
if (weight > 1.0f) {
weight = 1.0f;
}
@@ -1705,12 +1662,10 @@ float mg_RidgedMultiFractal(float x,
/* "Variable Lacunarity Noise"
* A distorted variety of Perlin noise.
*/
-float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nbas2)
+float BLI_noise_mg_variable_lacunarity(
+ float x, float y, float z, float distortion, int nbas1, int nbas2)
{
- float rv[3];
float (*noisefunc1)(float, float, float);
- float (*noisefunc2)(float, float, float);
-
switch (nbas1) {
case 1:
noisefunc1 = orgPerlinNoise;
@@ -1737,7 +1692,7 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
noisefunc1 = voronoi_CrS;
break;
case 14:
- noisefunc1 = cellNoise;
+ noisefunc1 = BLI_noise_cell;
break;
case 0:
default: {
@@ -1746,6 +1701,7 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
}
}
+ float (*noisefunc2)(float, float, float);
switch (nbas2) {
case 1:
noisefunc2 = orgPerlinNoise;
@@ -1772,7 +1728,7 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
noisefunc2 = voronoi_CrS;
break;
case 14:
- noisefunc2 = cellNoise;
+ noisefunc2 = BLI_noise_cell;
break;
case 0:
default: {
@@ -1782,9 +1738,12 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
}
/* get a random vector and scale the randomization */
- rv[0] = noisefunc1(x + 13.5f, y + 13.5f, z + 13.5f) * distortion;
- rv[1] = noisefunc1(x, y, z) * distortion;
- rv[2] = noisefunc1(x - 13.5f, y - 13.5f, z - 13.5f) * distortion;
+ float rv[3] = {
+ rv[0] = noisefunc1(x + 13.5f, y + 13.5f, z + 13.5f) * distortion,
+ rv[1] = noisefunc1(x, y, z) * distortion,
+ rv[2] = noisefunc1(x - 13.5f, y - 13.5f, z - 13.5f) * distortion,
+ };
+
return noisefunc2(x + rv[0], y + rv[1], z + rv[2]); /* distorted-domain noise */
}
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index bec5f0ab3ba..61e0ec393cb 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -1085,9 +1085,9 @@ void print_rcti(const char *str, const rcti *rect)
BLI_rcti_size_y(rect));
}
-/* -------------------------------------------------------------------- */
/* Comprehensive math (float only) */
+/* -------------------------------------------------------------------- */
/** \name Rect math functions
* \{ */
diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c
index 660d3dca807..b49239547c2 100644
--- a/source/blender/blenlib/intern/scanfill_utils.c
+++ b/source/blender/blenlib/intern/scanfill_utils.c
@@ -157,14 +157,14 @@ static ScanFillEdge *edge_step(PolyInfo *poly_info,
eed = (e_curr->next && e_curr != poly_info[poly_nr].edge_last) ? e_curr->next :
poly_info[poly_nr].edge_first;
if ((v_curr == eed->v1 || v_curr == eed->v2) == true &&
- (v_prev == eed->v1 || v_prev == eed->v2) == false) {
+ (ELEM(v_prev, eed->v1, eed->v2)) == false) {
return eed;
}
eed = (e_curr->prev && e_curr != poly_info[poly_nr].edge_first) ? e_curr->prev :
poly_info[poly_nr].edge_last;
if ((v_curr == eed->v1 || v_curr == eed->v2) == true &&
- (v_prev == eed->v1 || v_prev == eed->v2) == false) {
+ (ELEM(v_prev, eed->v1, eed->v2)) == false) {
return eed;
}
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index a091b41af23..5961893cae3 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -349,6 +349,7 @@ void **BLI_smallhash_iternew_p(const SmallHash *sh, SmallHashIter *iter, uintptr
return BLI_smallhash_iternext_p(iter, key);
}
+/* -------------------------------------------------------------------- */
/** \name Debugging & Introspection
* \{ */
diff --git a/source/blender/blenlib/intern/sort.c b/source/blender/blenlib/intern/sort.c
index e65be760a2c..6a13c0aa6f0 100644
--- a/source/blender/blenlib/intern/sort.c
+++ b/source/blender/blenlib/intern/sort.c
@@ -45,8 +45,8 @@
*
* \note modified to use glibc arg order for callbacks.
*/
-BLI_INLINE char *med3(char */*a*/, char */*b*/, char */*c*/, BLI_sort_cmp_t /*cmp*/, void */*thunk*/);
-BLI_INLINE void swapfunc(char */*a*/, char */*b*/, int /*n*/, int /*swaptype*/);
+BLI_INLINE char *med3(char *a, char *b, char *c, BLI_sort_cmp_t cmp, void *thunk);
+BLI_INLINE void swapfunc(char *a, char *b, int n, int swaptype);
#define min(a, b) (a) < (b) ? (a) : (b)
#define swapcode(TYPE, parmi, parmj, n) \
diff --git a/source/blender/blenlib/intern/storage_apple.mm b/source/blender/blenlib/intern/storage_apple.mm
index 564ef5a199a..2a4bbffa60e 100644
--- a/source/blender/blenlib/intern/storage_apple.mm
+++ b/source/blender/blenlib/intern/storage_apple.mm
@@ -29,7 +29,7 @@
#include "BLI_path_util.h"
/**
- * \param r_targetpath Buffer for the target path an alias points to.
+ * \param r_targetpath: Buffer for the target path an alias points to.
* \return Whether the file at the input path is an alias.
*/
/* False alarm by clang-tidy: #getFileSystemRepresentation changes the return value argument. */
diff --git a/source/blender/blenlib/intern/task_pool.cc b/source/blender/blenlib/intern/task_pool.cc
index cf328ec407c..1a119e135d5 100644
--- a/source/blender/blenlib/intern/task_pool.cc
+++ b/source/blender/blenlib/intern/task_pool.cc
@@ -83,11 +83,11 @@ class Task {
free_taskdata(other.free_taskdata),
freedata(other.freedata)
{
- other.pool = NULL;
- other.run = NULL;
- other.taskdata = NULL;
+ other.pool = nullptr;
+ other.run = nullptr;
+ other.taskdata = nullptr;
other.free_taskdata = false;
- other.freedata = NULL;
+ other.freedata = nullptr;
}
#if defined(WITH_TBB) && TBB_INTERFACE_VERSION_MAJOR < 10
@@ -302,7 +302,7 @@ static void *background_task_run(void *userdata)
task->~Task();
MEM_freeN(task);
}
- return NULL;
+ return nullptr;
}
static void background_task_pool_create(TaskPool *pool)
diff --git a/source/blender/blenlib/intern/task_range.cc b/source/blender/blenlib/intern/task_range.cc
index 27e0fb0ed07..229129bd088 100644
--- a/source/blender/blenlib/intern/task_range.cc
+++ b/source/blender/blenlib/intern/task_range.cc
@@ -70,7 +70,7 @@ struct RangeTask {
~RangeTask()
{
- if (settings->func_free != NULL) {
+ if (settings->func_free != nullptr) {
settings->func_free(userdata, userdata_chunk);
}
MEM_SAFE_FREE(userdata_chunk);
@@ -83,7 +83,7 @@ struct RangeTask {
memcpy(userdata_chunk, from_chunk, settings->userdata_chunk_size);
}
else {
- userdata_chunk = NULL;
+ userdata_chunk = nullptr;
}
}
@@ -139,7 +139,7 @@ void BLI_task_parallel_range(const int start,
for (int i = start; i < stop; i++) {
func(userdata, i, &tls);
}
- if (settings->func_free != NULL) {
+ if (settings->func_free != nullptr) {
settings->func_free(userdata, settings->userdata_chunk);
}
}
diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c
index 2c8eb9f5a13..eac01a0e2aa 100644
--- a/source/blender/blenlib/intern/voxel.c
+++ b/source/blender/blenlib/intern/voxel.c
@@ -51,7 +51,7 @@ float BLI_voxel_sample_nearest(const float *data, const int res[3], const float
BLI_INLINE int FLOORI(float x)
{
const int r = (int)x;
- return ((x >= 0.f) || (float)r == x) ? r : (r - 1);
+ return ((x >= 0.0f) || (float)r == x) ? r : (r - 1);
}
/* clamp function, cannot use the CLAMPIS macro,
@@ -92,9 +92,9 @@ float BLI_voxel_sample_trilinear(const float *data, const int res[3], const floa
const float dy = yf - (float)y;
const float dz = zf - (float)z;
- const float u[2] = {1.f - dx, dx};
- const float v[2] = {1.f - dy, dy};
- const float w[2] = {1.f - dz, dz};
+ const float u[2] = {1.0f - dx, dx};
+ const float v[2] = {1.0f - dy, dy};
+ const float w[2] = {1.0f - dz, dz};
return w[0] *
(v[0] * (u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]]) +
@@ -103,7 +103,7 @@ float BLI_voxel_sample_trilinear(const float *data, const int res[3], const floa
(v[0] * (u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]]) +
v[1] * (u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]]));
}
- return 0.f;
+ return 0.0f;
}
float BLI_voxel_sample_triquadratic(const float *data, const int res[3], const float co[3])
@@ -132,9 +132,9 @@ float BLI_voxel_sample_triquadratic(const float *data, const int res[3], const f
};
const float dx = xf - (float)x, dy = yf - (float)y, dz = zf - (float)z;
- const float u[3] = {dx * (0.5f * dx - 1.f) + 0.5f, dx * (1.0f - dx) + 0.5f, 0.5f * dx * dx};
- const float v[3] = {dy * (0.5f * dy - 1.f) + 0.5f, dy * (1.0f - dy) + 0.5f, 0.5f * dy * dy};
- const float w[3] = {dz * (0.5f * dz - 1.f) + 0.5f, dz * (1.0f - dz) + 0.5f, 0.5f * dz * dz};
+ const float u[3] = {dx * (0.5f * dx - 1.0f) + 0.5f, dx * (1.0f - dx) + 0.5f, 0.5f * dx * dx};
+ const float v[3] = {dy * (0.5f * dy - 1.0f) + 0.5f, dy * (1.0f - dy) + 0.5f, 0.5f * dy * dy};
+ const float w[3] = {dz * (0.5f * dz - 1.0f) + 0.5f, dz * (1.0f - dz) + 0.5f, 0.5f * dz * dz};
return w[0] *
(v[0] * (u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] +
@@ -158,7 +158,7 @@ float BLI_voxel_sample_triquadratic(const float *data, const int res[3], const f
v[2] * (u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] +
u[2] * data[xc[2] + yc[2] + zc[2]]));
}
- return 0.f;
+ return 0.0f;
}
float BLI_voxel_sample_tricubic(const float *data,
@@ -195,18 +195,18 @@ float BLI_voxel_sample_tricubic(const float *data,
float u[4], v[4], w[4];
if (bspline) { // B-Spline
- u[0] = (((-1.f / 6.f) * dx + 0.5f) * dx - 0.5f) * dx + (1.f / 6.f);
- u[1] = ((0.5f * dx - 1.f) * dx) * dx + (2.f / 3.f);
- u[2] = ((-0.5f * dx + 0.5f) * dx + 0.5f) * dx + (1.f / 6.f);
- u[3] = (1.f / 6.f) * dx * dx * dx;
- v[0] = (((-1.f / 6.f) * dy + 0.5f) * dy - 0.5f) * dy + (1.f / 6.f);
- v[1] = ((0.5f * dy - 1.f) * dy) * dy + (2.f / 3.f);
- v[2] = ((-0.5f * dy + 0.5f) * dy + 0.5f) * dy + (1.f / 6.f);
- v[3] = (1.f / 6.f) * dy * dy * dy;
- w[0] = (((-1.f / 6.f) * dz + 0.5f) * dz - 0.5f) * dz + (1.f / 6.f);
- w[1] = ((0.5f * dz - 1.f) * dz) * dz + (2.f / 3.f);
- w[2] = ((-0.5f * dz + 0.5f) * dz + 0.5f) * dz + (1.f / 6.f);
- w[3] = (1.f / 6.f) * dz * dz * dz;
+ u[0] = (((-1.0f / 6.0f) * dx + 0.5f) * dx - 0.5f) * dx + (1.0f / 6.0f);
+ u[1] = ((0.5f * dx - 1.0f) * dx) * dx + (2.0f / 3.0f);
+ u[2] = ((-0.5f * dx + 0.5f) * dx + 0.5f) * dx + (1.0f / 6.0f);
+ u[3] = (1.0f / 6.0f) * dx * dx * dx;
+ v[0] = (((-1.0f / 6.0f) * dy + 0.5f) * dy - 0.5f) * dy + (1.0f / 6.0f);
+ v[1] = ((0.5f * dy - 1.0f) * dy) * dy + (2.0f / 3.0f);
+ v[2] = ((-0.5f * dy + 0.5f) * dy + 0.5f) * dy + (1.0f / 6.0f);
+ v[3] = (1.0f / 6.0f) * dy * dy * dy;
+ w[0] = (((-1.0f / 6.0f) * dz + 0.5f) * dz - 0.5f) * dz + (1.0f / 6.0f);
+ w[1] = ((0.5f * dz - 1.0f) * dz) * dz + (2.0f / 3.0f);
+ w[2] = ((-0.5f * dz + 0.5f) * dz + 0.5f) * dz + (1.0f / 6.0f);
+ w[3] = (1.0f / 6.0f) * dz * dz * dz;
}
else { // Catmull-Rom
u[0] = ((-0.5f * dx + 1.0f) * dx - 0.5f) * dx;
@@ -260,5 +260,5 @@ float BLI_voxel_sample_tricubic(const float *data,
v[3] * (u[0] * data[xc[0] + yc[3] + zc[3]] + u[1] * data[xc[1] + yc[3] + zc[3]] +
u[2] * data[xc[2] + yc[3] + zc[3]] + u[3] * data[xc[3] + yc[3] + zc[3]]));
}
- return 0.f;
+ return 0.0f;
}
diff --git a/source/blender/blenlib/tests/BLI_array_store_test.cc b/source/blender/blenlib/tests/BLI_array_store_test.cc
index a1ec8ec7bb3..ff050ce24db 100644
--- a/source/blender/blenlib/tests/BLI_array_store_test.cc
+++ b/source/blender/blenlib/tests/BLI_array_store_test.cc
@@ -125,7 +125,7 @@ static TestBuffer *testbuffer_list_add(ListBase *lb, const void *data, size_t da
TestBuffer *tb = (TestBuffer *)MEM_mallocN(sizeof(*tb), __func__);
tb->data = data;
tb->data_len = data_len;
- tb->state = NULL;
+ tb->state = nullptr;
BLI_addtail(lb, tb);
return tb;
}
@@ -244,10 +244,10 @@ static void testbuffer_list_data_randomize(ListBase *lb, unsigned int random_see
static void testbuffer_list_store_populate(BArrayStore *bs, ListBase *lb)
{
- for (TestBuffer *tb = (TestBuffer *)lb->first, *tb_prev = NULL; tb;
+ for (TestBuffer *tb = (TestBuffer *)lb->first, *tb_prev = nullptr; tb;
tb_prev = tb, tb = tb->next) {
tb->state = BLI_array_store_state_add(
- bs, tb->data, tb->data_len, (tb_prev ? tb_prev->state : NULL));
+ bs, tb->data, tb->data_len, (tb_prev ? tb_prev->state : nullptr));
}
}
@@ -255,7 +255,7 @@ static void testbuffer_list_store_clear(BArrayStore *bs, ListBase *lb)
{
for (TestBuffer *tb = (TestBuffer *)lb->first; tb; tb = tb->next) {
BLI_array_store_state_remove(bs, tb->state);
- tb->state = NULL;
+ tb->state = nullptr;
}
}
@@ -313,7 +313,7 @@ TEST(array_store, NopState)
{
BArrayStore *bs = BLI_array_store_create(1, 32);
const unsigned char data[] = "test";
- BArrayState *state = BLI_array_store_state_add(bs, data, sizeof(data) - 1, NULL);
+ BArrayState *state = BLI_array_store_state_add(bs, data, sizeof(data) - 1, nullptr);
EXPECT_EQ(BLI_array_store_state_size_get(state), sizeof(data) - 1);
BLI_array_store_state_remove(bs, state);
BLI_array_store_destroy(bs);
@@ -324,7 +324,7 @@ TEST(array_store, Single)
BArrayStore *bs = BLI_array_store_create(1, 32);
const char data_src[] = "test";
const char *data_dst;
- BArrayState *state = BLI_array_store_state_add(bs, data_src, sizeof(data_src), NULL);
+ BArrayState *state = BLI_array_store_state_add(bs, data_src, sizeof(data_src), nullptr);
size_t data_dst_len;
data_dst = (char *)BLI_array_store_state_data_get_alloc(state, &data_dst_len);
EXPECT_STREQ(data_src, data_dst);
@@ -339,7 +339,7 @@ TEST(array_store, DoubleNop)
const char data_src[] = "test";
const char *data_dst;
- BArrayState *state_a = BLI_array_store_state_add(bs, data_src, sizeof(data_src), NULL);
+ BArrayState *state_a = BLI_array_store_state_add(bs, data_src, sizeof(data_src), nullptr);
BArrayState *state_b = BLI_array_store_state_add(bs, data_src, sizeof(data_src), state_a);
EXPECT_EQ(BLI_array_store_calc_size_compacted_get(bs), sizeof(data_src));
@@ -366,7 +366,7 @@ TEST(array_store, DoubleDiff)
const char data_src_b[] = "####";
const char *data_dst;
- BArrayState *state_a = BLI_array_store_state_add(bs, data_src_a, sizeof(data_src_a), NULL);
+ BArrayState *state_a = BLI_array_store_state_add(bs, data_src_a, sizeof(data_src_a), nullptr);
BArrayState *state_b = BLI_array_store_state_add(bs, data_src_b, sizeof(data_src_b), state_a);
size_t data_dst_len;
@@ -594,7 +594,7 @@ static void testbuffer_list_state_random_data(ListBase *lb,
size_t data_len = rand_range_i(rng, data_min_len, data_max_len + stride, stride);
char *data = (char *)MEM_mallocN(data_len, __func__);
- if (lb->last == NULL) {
+ if (lb->last == nullptr) {
BLI_rng_get_char_n(rng, data, data_len);
}
else {
diff --git a/source/blender/blenlib/tests/BLI_array_utils_test.cc b/source/blender/blenlib/tests/BLI_array_utils_test.cc
index 33b4cd35d52..5d12b8fbd4d 100644
--- a/source/blender/blenlib/tests/BLI_array_utils_test.cc
+++ b/source/blender/blenlib/tests/BLI_array_utils_test.cc
@@ -91,7 +91,7 @@ TEST(array_utils, FindIndexInt4_DupeMid)
TEST(array_utils, FindIndexPointer)
{
- const char *data[4] = {NULL};
+ const char *data[4] = {nullptr};
STACK_DECLARE(data);
STACK_INIT(data, ARRAY_SIZE(data));
diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
index 14db4254f70..338d6f96bef 100644
--- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
@@ -667,7 +667,7 @@ template<typename T> void crosssegs_test()
if (out.vert.size() == 5) {
int v_intersect = -1;
for (int i = 0; i < 5; i++) {
- if (i != v0_out && i != v1_out && i != v2_out && i != v3_out) {
+ if (!ELEM(i, v0_out, v1_out, v2_out, v3_out)) {
EXPECT_EQ(v_intersect, -1);
v_intersect = i;
}
@@ -1513,7 +1513,7 @@ TEST(delaunay_d, CintTwoFace)
input.edges_len = 0;
input.faces_len = 2;
input.vert_coords = vert_coords;
- input.edges = NULL;
+ input.edges = nullptr;
input.faces = faces;
input.faces_len_table = faces_len;
input.faces_start_table = faces_start;
diff --git a/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc b/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc
index aad21ae4ad4..390f687dbd1 100644
--- a/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc
+++ b/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc
@@ -12,7 +12,7 @@
static void expr_pylike_parse_fail_test(const char *str)
{
- ExprPyLike_Parsed *expr = BLI_expr_pylike_parse(str, NULL, 0);
+ ExprPyLike_Parsed *expr = BLI_expr_pylike_parse(str, nullptr, 0);
EXPECT_FALSE(BLI_expr_pylike_is_valid(expr));
@@ -21,7 +21,7 @@ static void expr_pylike_parse_fail_test(const char *str)
static void expr_pylike_const_test(const char *str, double value, bool force_const)
{
- ExprPyLike_Parsed *expr = BLI_expr_pylike_parse(str, NULL, 0);
+ ExprPyLike_Parsed *expr = BLI_expr_pylike_parse(str, nullptr, 0);
if (force_const) {
EXPECT_TRUE(BLI_expr_pylike_is_constant(expr));
@@ -32,7 +32,7 @@ static void expr_pylike_const_test(const char *str, double value, bool force_con
}
double result;
- eExprPyLike_EvalStatus status = BLI_expr_pylike_eval(expr, NULL, 0, &result);
+ eExprPyLike_EvalStatus status = BLI_expr_pylike_eval(expr, nullptr, 0, &result);
EXPECT_EQ(status, EXPR_PYLIKE_SUCCESS);
EXPECT_EQ(result, value);
@@ -344,10 +344,10 @@ TEST_ERROR(Mixed3, "sqrt(x) + 1 / max(0, x)", 1.0, EXPR_PYLIKE_SUCCESS)
TEST(expr_pylike, Error_Invalid)
{
- ExprPyLike_Parsed *expr = BLI_expr_pylike_parse("", NULL, 0);
+ ExprPyLike_Parsed *expr = BLI_expr_pylike_parse("", nullptr, 0);
double result;
- EXPECT_EQ(BLI_expr_pylike_eval(expr, NULL, 0, &result), EXPR_PYLIKE_INVALID);
+ EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID);
BLI_expr_pylike_free(expr);
}
@@ -357,7 +357,7 @@ TEST(expr_pylike, Error_ArgumentCount)
ExprPyLike_Parsed *expr = parse_for_eval("x", false);
double result;
- EXPECT_EQ(BLI_expr_pylike_eval(expr, NULL, 0, &result), EXPR_PYLIKE_FATAL_ERROR);
+ EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_FATAL_ERROR);
BLI_expr_pylike_free(expr);
}
diff --git a/source/blender/blenlib/tests/BLI_ghash_test.cc b/source/blender/blenlib/tests/BLI_ghash_test.cc
index 484f158a85c..a0b24e96fcc 100644
--- a/source/blender/blenlib/tests/BLI_ghash_test.cc
+++ b/source/blender/blenlib/tests/BLI_ghash_test.cc
@@ -77,7 +77,7 @@ TEST(ghash, InsertLookup)
EXPECT_EQ(POINTER_AS_UINT(v), *k);
}
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
}
/* Here we simply insert and then remove all keys, ensuring we do get an empty,
@@ -98,14 +98,14 @@ TEST(ghash, InsertRemove)
bkt_size = BLI_ghash_buckets_len(ghash);
for (i = TESTCASE_SIZE, k = keys; i--; k++) {
- void *v = BLI_ghash_popkey(ghash, POINTER_FROM_UINT(*k), NULL);
+ void *v = BLI_ghash_popkey(ghash, POINTER_FROM_UINT(*k), nullptr);
EXPECT_EQ(POINTER_AS_UINT(v), *k);
}
EXPECT_EQ(BLI_ghash_len(ghash), 0);
EXPECT_EQ(BLI_ghash_buckets_len(ghash), bkt_size);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
}
/* Same as above, but this time we allow ghash to shrink. */
@@ -126,14 +126,14 @@ TEST(ghash, InsertRemoveShrink)
bkt_size = BLI_ghash_buckets_len(ghash);
for (i = TESTCASE_SIZE, k = keys; i--; k++) {
- void *v = BLI_ghash_popkey(ghash, POINTER_FROM_UINT(*k), NULL);
+ void *v = BLI_ghash_popkey(ghash, POINTER_FROM_UINT(*k), nullptr);
EXPECT_EQ(POINTER_AS_UINT(v), *k);
}
EXPECT_EQ(BLI_ghash_len(ghash), 0);
EXPECT_LT(BLI_ghash_buckets_len(ghash), bkt_size);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
}
/* Check copy. */
@@ -152,7 +152,7 @@ TEST(ghash, Copy)
EXPECT_EQ(BLI_ghash_len(ghash), TESTCASE_SIZE);
- ghash_copy = BLI_ghash_copy(ghash, NULL, NULL);
+ ghash_copy = BLI_ghash_copy(ghash, nullptr, nullptr);
EXPECT_EQ(BLI_ghash_len(ghash_copy), TESTCASE_SIZE);
EXPECT_EQ(BLI_ghash_buckets_len(ghash_copy), BLI_ghash_buckets_len(ghash));
@@ -162,8 +162,8 @@ TEST(ghash, Copy)
EXPECT_EQ(POINTER_AS_UINT(v), *k);
}
- BLI_ghash_free(ghash, NULL, NULL);
- BLI_ghash_free(ghash_copy, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
+ BLI_ghash_free(ghash_copy, nullptr, nullptr);
}
/* Check pop. */
@@ -205,5 +205,5 @@ TEST(ghash, Pop)
}
EXPECT_EQ(BLI_ghash_len(ghash), 0);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
}
diff --git a/source/blender/blenlib/tests/BLI_heap_simple_test.cc b/source/blender/blenlib/tests/BLI_heap_simple_test.cc
index e717a6e2653..f3a65125eeb 100644
--- a/source/blender/blenlib/tests/BLI_heap_simple_test.cc
+++ b/source/blender/blenlib/tests/BLI_heap_simple_test.cc
@@ -29,7 +29,7 @@ TEST(heap, SimpleEmpty)
heap = BLI_heapsimple_new();
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
EXPECT_EQ(BLI_heapsimple_len(heap), 0);
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
TEST(heap, SimpleOne)
@@ -45,7 +45,7 @@ TEST(heap, SimpleOne)
EXPECT_EQ(in, BLI_heapsimple_pop_min(heap));
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
EXPECT_EQ(BLI_heapsimple_len(heap), 0);
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
TEST(heap, SimpleRange)
@@ -59,7 +59,7 @@ TEST(heap, SimpleRange)
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
}
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
TEST(heap, SimpleRangeReverse)
@@ -73,7 +73,7 @@ TEST(heap, SimpleRangeReverse)
EXPECT_EQ(-out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
}
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
TEST(heap, SimpleDuplicates)
@@ -81,13 +81,13 @@ TEST(heap, SimpleDuplicates)
const int items_total = SIZE;
HeapSimple *heap = BLI_heapsimple_new();
for (int in = 0; in < items_total; in++) {
- BLI_heapsimple_insert(heap, 1.0f, 0);
+ BLI_heapsimple_insert(heap, 1.0f, nullptr);
}
for (int out_test = 0; out_test < items_total; out_test++) {
EXPECT_EQ(0, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
}
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
static void random_heapsimple_helper(const int items_total, const int random_seed)
@@ -103,7 +103,7 @@ static void random_heapsimple_helper(const int items_total, const int random_see
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
}
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
MEM_freeN(values);
}
diff --git a/source/blender/blenlib/tests/BLI_heap_test.cc b/source/blender/blenlib/tests/BLI_heap_test.cc
index 87e68c175a2..8b207c17c84 100644
--- a/source/blender/blenlib/tests/BLI_heap_test.cc
+++ b/source/blender/blenlib/tests/BLI_heap_test.cc
@@ -28,7 +28,7 @@ TEST(heap, Empty)
heap = BLI_heap_new();
EXPECT_TRUE(BLI_heap_is_empty(heap));
EXPECT_EQ(BLI_heap_len(heap), 0);
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
TEST(heap, One)
@@ -44,7 +44,7 @@ TEST(heap, One)
EXPECT_EQ(in, BLI_heap_pop_min(heap));
EXPECT_TRUE(BLI_heap_is_empty(heap));
EXPECT_EQ(BLI_heap_len(heap), 0);
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
TEST(heap, Range)
@@ -58,7 +58,7 @@ TEST(heap, Range)
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
TEST(heap, RangeReverse)
@@ -72,7 +72,7 @@ TEST(heap, RangeReverse)
EXPECT_EQ(-out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
TEST(heap, RangeRemove)
@@ -85,13 +85,13 @@ TEST(heap, RangeRemove)
}
for (int i = 0; i < items_total; i += 2) {
BLI_heap_remove(heap, nodes[i]);
- nodes[i] = NULL;
+ nodes[i] = nullptr;
}
for (int out_test = 1; out_test < items_total; out_test += 2) {
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
MEM_freeN(nodes);
}
@@ -100,13 +100,13 @@ TEST(heap, Duplicates)
const int items_total = SIZE;
Heap *heap = BLI_heap_new();
for (int in = 0; in < items_total; in++) {
- BLI_heap_insert(heap, 1.0f, 0);
+ BLI_heap_insert(heap, 1.0f, nullptr);
}
for (int out_test = 0; out_test < items_total; out_test++) {
EXPECT_EQ(0, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
static void random_heap_helper(const int items_total, const int random_seed)
@@ -122,7 +122,7 @@ static void random_heap_helper(const int items_total, const int random_seed)
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
MEM_freeN(values);
}
@@ -156,7 +156,7 @@ TEST(heap, ReInsertSimple)
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
MEM_freeN(nodes);
}
@@ -181,7 +181,7 @@ static void random_heap_reinsert_helper(const int items_total, const int random_
BLI_heap_pop_min(heap);
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
MEM_freeN(nodes);
}
diff --git a/source/blender/blenlib/tests/BLI_kdopbvh_test.cc b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
index 2e8032400e3..f921c3ae2a4 100644
--- a/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
+++ b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
@@ -82,11 +82,11 @@ static void find_nearest_points_test(
BLI_bvhtree_balance(tree);
/* first find each point */
- BVHTree_NearestPointCallback callback = optimal ? optimal_check_callback : NULL;
+ BVHTree_NearestPointCallback callback = optimal ? optimal_check_callback : nullptr;
int flags = optimal ? BVH_NEAREST_OPTIMAL_ORDER : 0;
for (int i = 0; i < points_len; i++) {
- const int j = BLI_bvhtree_find_nearest_ex(tree, points[i], NULL, callback, points, flags);
+ const int j = BLI_bvhtree_find_nearest_ex(tree, points[i], nullptr, callback, points, flags);
if (j != i) {
#if 0
const float dist = len_v3v3(points[i], points[j]);
diff --git a/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
index d1a527d57ac..f2ae121e8ae 100644
--- a/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
+++ b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
@@ -15,7 +15,7 @@ TEST(LockfreeLinkList, Init)
BLI_linklist_lockfree_init(&list);
EXPECT_EQ(list.head, &list.dummy_node);
EXPECT_EQ(list.tail, &list.dummy_node);
- BLI_linklist_lockfree_free(&list, NULL);
+ BLI_linklist_lockfree_free(&list, nullptr);
}
TEST(LockfreeLinkList, InsertSingle)
@@ -27,7 +27,7 @@ TEST(LockfreeLinkList, InsertSingle)
EXPECT_EQ(list.head, &list.dummy_node);
EXPECT_EQ(list.head->next, &node);
EXPECT_EQ(list.tail, &node);
- BLI_linklist_lockfree_free(&list, NULL);
+ BLI_linklist_lockfree_free(&list, nullptr);
}
TEST(LockfreeLinkList, InsertMultiple)
@@ -45,7 +45,7 @@ TEST(LockfreeLinkList, InsertMultiple)
EXPECT_EQ(list.tail, &nodes[num_nodes - 1]);
/* Check rest of the nodes. */
int node_index = 0;
- for (LockfreeLinkNode *node = BLI_linklist_lockfree_begin(&list); node != NULL;
+ for (LockfreeLinkNode *node = BLI_linklist_lockfree_begin(&list); node != nullptr;
node = node->next, ++node_index) {
EXPECT_EQ(node, &nodes[node_index]);
if (node_index != num_nodes - 1) {
@@ -53,7 +53,7 @@ TEST(LockfreeLinkList, InsertMultiple)
}
}
/* Free list. */
- BLI_linklist_lockfree_free(&list, NULL);
+ BLI_linklist_lockfree_free(&list, nullptr);
}
namespace {
@@ -84,7 +84,7 @@ TEST(LockfreeLinkList, InsertMultipleConcurrent)
TaskPool *pool = BLI_task_pool_create_suspended(&list, TASK_PRIORITY_HIGH);
/* Push tasks to the pool. */
for (int i = 0; i < num_nodes; ++i) {
- BLI_task_pool_push(pool, concurrent_insert, POINTER_FROM_INT(i), false, NULL);
+ BLI_task_pool_push(pool, concurrent_insert, POINTER_FROM_INT(i), false, nullptr);
}
/* Run all the tasks. */
BLI_task_pool_work_and_wait(pool);
@@ -92,7 +92,7 @@ TEST(LockfreeLinkList, InsertMultipleConcurrent)
EXPECT_EQ(list.head, &list.dummy_node);
bool *visited_nodes = (bool *)MEM_callocN(sizeof(bool) * num_nodes, "visited nodes");
/* First, we make sure that none of the nodes are added twice. */
- for (LockfreeLinkNode *node_v = BLI_linklist_lockfree_begin(&list); node_v != NULL;
+ for (LockfreeLinkNode *node_v = BLI_linklist_lockfree_begin(&list); node_v != nullptr;
node_v = node_v->next) {
IndexedNode *node = (IndexedNode *)node_v;
EXPECT_GE(node->index, 0);
diff --git a/source/blender/blenlib/tests/BLI_listbase_test.cc b/source/blender/blenlib/tests/BLI_listbase_test.cc
index e5b504a0040..ff85cf79e87 100644
--- a/source/blender/blenlib/tests/BLI_listbase_test.cc
+++ b/source/blender/blenlib/tests/BLI_listbase_test.cc
@@ -22,19 +22,19 @@ static bool listbase_is_valid(const ListBase *listbase)
if (listbase->first) {
const Link *prev, *link;
link = (Link *)listbase->first;
- TESTFAIL(link->prev == NULL);
+ TESTFAIL(link->prev == nullptr);
link = (Link *)listbase->last;
- TESTFAIL(link->next == NULL);
+ TESTFAIL(link->next == nullptr);
- prev = NULL;
+ prev = nullptr;
link = (Link *)listbase->first;
do {
TESTFAIL(link->prev == prev);
} while ((void)(prev = link), (link = link->next));
TESTFAIL(prev == listbase->last);
- prev = NULL;
+ prev = nullptr;
link = (Link *)listbase->last;
do {
TESTFAIL(link->next == prev);
@@ -42,7 +42,7 @@ static bool listbase_is_valid(const ListBase *listbase)
TESTFAIL(prev == listbase->first);
}
else {
- TESTFAIL(listbase->last == NULL);
+ TESTFAIL(listbase->last == nullptr);
}
#undef TESTFAIL
@@ -73,12 +73,12 @@ TEST(listbase, FindLinkOrIndex)
/* Empty list */
BLI_listbase_clear(&lb);
- EXPECT_EQ(BLI_findlink(&lb, -1), (void *)NULL);
- EXPECT_EQ(BLI_findlink(&lb, 0), (void *)NULL);
- EXPECT_EQ(BLI_findlink(&lb, 1), (void *)NULL);
- EXPECT_EQ(BLI_rfindlink(&lb, -1), (void *)NULL);
- EXPECT_EQ(BLI_rfindlink(&lb, 0), (void *)NULL);
- EXPECT_EQ(BLI_rfindlink(&lb, 1), (void *)NULL);
+ EXPECT_EQ(BLI_findlink(&lb, -1), (void *)nullptr);
+ EXPECT_EQ(BLI_findlink(&lb, 0), (void *)nullptr);
+ EXPECT_EQ(BLI_findlink(&lb, 1), (void *)nullptr);
+ EXPECT_EQ(BLI_rfindlink(&lb, -1), (void *)nullptr);
+ EXPECT_EQ(BLI_rfindlink(&lb, 0), (void *)nullptr);
+ EXPECT_EQ(BLI_rfindlink(&lb, 1), (void *)nullptr);
EXPECT_EQ(BLI_findindex(&lb, link1), -1);
/* One link */
diff --git a/source/blender/blenlib/tests/BLI_map_test.cc b/source/blender/blenlib/tests/BLI_map_test.cc
index 91c6335b949..ecdf2627520 100644
--- a/source/blender/blenlib/tests/BLI_map_test.cc
+++ b/source/blender/blenlib/tests/BLI_map_test.cc
@@ -295,6 +295,24 @@ TEST(map, AddOrModify)
EXPECT_EQ(map.lookup(1), 15.0f);
}
+TEST(map, AddOrModifyReference)
+{
+ Map<int, std::unique_ptr<int>> map;
+ auto create_func = [](std::unique_ptr<int> *value) -> int & {
+ new (value) std::unique_ptr<int>(new int{10});
+ return **value;
+ };
+ auto modify_func = [](std::unique_ptr<int> *value) -> int & {
+ **value += 5;
+ return **value;
+ };
+ EXPECT_EQ(map.add_or_modify(1, create_func, modify_func), 10);
+ int &a = map.add_or_modify(1, create_func, modify_func);
+ EXPECT_EQ(a, 15);
+ a = 100;
+ EXPECT_EQ(*map.lookup(1), 100);
+}
+
TEST(map, AddOverwrite)
{
Map<int, float> map;
@@ -401,9 +419,9 @@ TEST(map, Clear)
TEST(map, UniquePtrValue)
{
- auto value1 = std::unique_ptr<int>(new int());
- auto value2 = std::unique_ptr<int>(new int());
- auto value3 = std::unique_ptr<int>(new int());
+ auto value1 = std::unique_ptr<int>(std::make_unique<int>());
+ auto value2 = std::unique_ptr<int>(std::make_unique<int>());
+ auto value3 = std::unique_ptr<int>(std::make_unique<int>());
int *value1_ptr = value1.get();
@@ -411,12 +429,12 @@ TEST(map, UniquePtrValue)
map.add_new(1, std::move(value1));
map.add(2, std::move(value2));
map.add_overwrite(3, std::move(value3));
- map.lookup_or_add_cb(4, []() { return std::unique_ptr<int>(new int()); });
- map.add_new(5, std::unique_ptr<int>(new int()));
- map.add(6, std::unique_ptr<int>(new int()));
- map.add_overwrite(7, std::unique_ptr<int>(new int()));
- map.lookup_or_add(8, std::unique_ptr<int>(new int()));
- map.pop_default(9, std::unique_ptr<int>(new int()));
+ map.lookup_or_add_cb(4, []() { return std::unique_ptr<int>(std::make_unique<int>()); });
+ map.add_new(5, std::unique_ptr<int>(std::make_unique<int>()));
+ map.add(6, std::unique_ptr<int>(std::make_unique<int>()));
+ map.add_overwrite(7, std::unique_ptr<int>(std::make_unique<int>()));
+ map.lookup_or_add(8, std::unique_ptr<int>(std::make_unique<int>()));
+ map.pop_default(9, std::unique_ptr<int>(std::make_unique<int>()));
EXPECT_EQ(map.lookup(1).get(), value1_ptr);
EXPECT_EQ(map.lookup_ptr(100), nullptr);
diff --git a/source/blender/blenlib/tests/BLI_path_util_test.cc b/source/blender/blenlib/tests/BLI_path_util_test.cc
index 927d24d2c4c..cf5135731e2 100644
--- a/source/blender/blenlib/tests/BLI_path_util_test.cc
+++ b/source/blender/blenlib/tests/BLI_path_util_test.cc
@@ -18,46 +18,46 @@ TEST(path_util, Clean)
/* "/./" -> "/" */
{
char path[FILE_MAX] = "/a/./b/./c/./";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/a/b/c/", path);
}
{
char path[FILE_MAX] = "/./././";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/", path);
}
{
char path[FILE_MAX] = "/a/./././b/";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/a/b/", path);
}
/* "//" -> "/" */
{
char path[FILE_MAX] = "a////";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("a/", path);
}
- if (0) /* FIXME */
+ if (false) /* FIXME */
{
char path[FILE_MAX] = "./a////";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("./a/", path);
}
/* "foo/bar/../" -> "foo/" */
{
char path[FILE_MAX] = "/a/b/c/../../../";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/", path);
}
{
char path[FILE_MAX] = "/a/../a/b/../b/c/../c/";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/a/b/c/", path);
}
@@ -96,10 +96,10 @@ TEST(path_util, NameAtIndex_Single)
AT_INDEX("//a//", 0, "a");
AT_INDEX("a/b", 0, "a");
- AT_INDEX("/a", 1, NULL);
- AT_INDEX("/a/", 1, NULL);
- AT_INDEX("a/", 1, NULL);
- AT_INDEX("//a//", 1, NULL);
+ AT_INDEX("/a", 1, nullptr);
+ AT_INDEX("/a/", 1, nullptr);
+ AT_INDEX("a/", 1, nullptr);
+ AT_INDEX("//a//", 1, nullptr);
}
TEST(path_util, NameAtIndex_SingleNeg)
{
@@ -109,10 +109,10 @@ TEST(path_util, NameAtIndex_SingleNeg)
AT_INDEX("//a//", -1, "a");
AT_INDEX("a/b", -1, "b");
- AT_INDEX("/a", -2, NULL);
- AT_INDEX("/a/", -2, NULL);
- AT_INDEX("a/", -2, NULL);
- AT_INDEX("//a//", -2, NULL);
+ AT_INDEX("/a", -2, nullptr);
+ AT_INDEX("/a/", -2, nullptr);
+ AT_INDEX("a/", -2, nullptr);
+ AT_INDEX("//a//", -2, nullptr);
}
TEST(path_util, NameAtIndex_Double)
@@ -123,10 +123,10 @@ TEST(path_util, NameAtIndex_Double)
AT_INDEX("//ab//", 0, "ab");
AT_INDEX("ab/c", 0, "ab");
- AT_INDEX("/ab", 1, NULL);
- AT_INDEX("/ab/", 1, NULL);
- AT_INDEX("ab/", 1, NULL);
- AT_INDEX("//ab//", 1, NULL);
+ AT_INDEX("/ab", 1, nullptr);
+ AT_INDEX("/ab/", 1, nullptr);
+ AT_INDEX("ab/", 1, nullptr);
+ AT_INDEX("//ab//", 1, nullptr);
}
TEST(path_util, NameAtIndex_DoublNeg)
@@ -137,10 +137,10 @@ TEST(path_util, NameAtIndex_DoublNeg)
AT_INDEX("//ab//", -1, "ab");
AT_INDEX("ab/c", -1, "c");
- AT_INDEX("/ab", -2, NULL);
- AT_INDEX("/ab/", -2, NULL);
- AT_INDEX("ab/", -2, NULL);
- AT_INDEX("//ab//", -2, NULL);
+ AT_INDEX("/ab", -2, nullptr);
+ AT_INDEX("/ab/", -2, nullptr);
+ AT_INDEX("ab/", -2, nullptr);
+ AT_INDEX("//ab//", -2, nullptr);
}
TEST(path_util, NameAtIndex_Misc)
@@ -149,8 +149,8 @@ TEST(path_util, NameAtIndex_Misc)
AT_INDEX("/how/now/brown/cow", 1, "now");
AT_INDEX("/how/now/brown/cow", 2, "brown");
AT_INDEX("/how/now/brown/cow", 3, "cow");
- AT_INDEX("/how/now/brown/cow", 4, NULL);
- AT_INDEX("/how/now/brown/cow/", 4, NULL);
+ AT_INDEX("/how/now/brown/cow", 4, nullptr);
+ AT_INDEX("/how/now/brown/cow/", 4, nullptr);
}
TEST(path_util, NameAtIndex_MiscNeg)
@@ -159,8 +159,8 @@ TEST(path_util, NameAtIndex_MiscNeg)
AT_INDEX("/how/now/brown/cow", 1, "now");
AT_INDEX("/how/now/brown/cow", 2, "brown");
AT_INDEX("/how/now/brown/cow", 3, "cow");
- AT_INDEX("/how/now/brown/cow", 4, NULL);
- AT_INDEX("/how/now/brown/cow/", 4, NULL);
+ AT_INDEX("/how/now/brown/cow", 4, nullptr);
+ AT_INDEX("/how/now/brown/cow/", 4, nullptr);
}
TEST(path_util, NameAtIndex_MiscComplex)
@@ -169,8 +169,8 @@ TEST(path_util, NameAtIndex_MiscComplex)
AT_INDEX("//how///now\\/brown/cow", 1, "now");
AT_INDEX("/how/now\\//brown\\/cow", 2, "brown");
AT_INDEX("/how/now/brown/cow//\\", 3, "cow");
- AT_INDEX("/how/now/brown/\\cow", 4, NULL);
- AT_INDEX("how/now/brown/\\cow\\", 4, NULL);
+ AT_INDEX("/how/now/brown/\\cow", 4, nullptr);
+ AT_INDEX("how/now/brown/\\cow\\", 4, nullptr);
}
TEST(path_util, NameAtIndex_MiscComplexNeg)
@@ -179,24 +179,24 @@ TEST(path_util, NameAtIndex_MiscComplexNeg)
AT_INDEX("//how///now\\/brown/cow", -3, "now");
AT_INDEX("/how/now\\//brown\\/cow", -2, "brown");
AT_INDEX("/how/now/brown/cow//\\", -1, "cow");
- AT_INDEX("/how/now/brown/\\cow", -5, NULL);
- AT_INDEX("how/now/brown/\\cow\\", -5, NULL);
+ AT_INDEX("/how/now/brown/\\cow", -5, nullptr);
+ AT_INDEX("how/now/brown/\\cow\\", -5, nullptr);
}
TEST(path_util, NameAtIndex_NoneComplex)
{
- AT_INDEX("", 0, NULL);
- AT_INDEX("/", 0, NULL);
- AT_INDEX("//", 0, NULL);
- AT_INDEX("///", 0, NULL);
+ AT_INDEX("", 0, nullptr);
+ AT_INDEX("/", 0, nullptr);
+ AT_INDEX("//", 0, nullptr);
+ AT_INDEX("///", 0, nullptr);
}
TEST(path_util, NameAtIndex_NoneComplexNeg)
{
- AT_INDEX("", -1, NULL);
- AT_INDEX("/", -1, NULL);
- AT_INDEX("//", -1, NULL);
- AT_INDEX("///", -1, NULL);
+ AT_INDEX("", -1, nullptr);
+ AT_INDEX("/", -1, nullptr);
+ AT_INDEX("//", -1, nullptr);
+ AT_INDEX("///", -1, nullptr);
}
#undef AT_INDEX
@@ -590,9 +590,9 @@ TEST(path_util, PathFrameGet)
/* BLI_path_extension */
TEST(path_util, PathExtension)
{
- EXPECT_EQ(NULL, BLI_path_extension("some.def/file"));
- EXPECT_EQ(NULL, BLI_path_extension("Text"));
- EXPECT_EQ(NULL, BLI_path_extension("Text…001"));
+ EXPECT_EQ(nullptr, BLI_path_extension("some.def/file"));
+ EXPECT_EQ(nullptr, BLI_path_extension("Text"));
+ EXPECT_EQ(nullptr, BLI_path_extension("Text…001"));
EXPECT_STREQ(".", BLI_path_extension("some/file."));
EXPECT_STREQ(".gz", BLI_path_extension("some/file.tar.gz"));
diff --git a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
index 624a296e758..3c9d12c7178 100644
--- a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
@@ -118,7 +118,7 @@ static void test_polyfill_topology(const float /*poly*/[][2],
}
BLI_edgehashIterator_free(ehi);
- BLI_edgehash_free(edgehash, NULL);
+ BLI_edgehash_free(edgehash, nullptr);
}
/**
@@ -205,7 +205,7 @@ static void test_polyfill_template(const char *id,
test_polyfill_template_check(id, is_degenerate, poly, poly_tot, tris, tris_tot);
BLI_memarena_free(pf_arena);
- BLI_heap_free(pf_heap, NULL);
+ BLI_heap_free(pf_heap, nullptr);
}
#endif
}
diff --git a/source/blender/blenlib/tests/BLI_set_test.cc b/source/blender/blenlib/tests/BLI_set_test.cc
index dbe820c9d15..840472e4c0b 100644
--- a/source/blender/blenlib/tests/BLI_set_test.cc
+++ b/source/blender/blenlib/tests/BLI_set_test.cc
@@ -221,10 +221,10 @@ TEST(set, OftenAddRemoveContained)
TEST(set, UniquePtrValues)
{
Set<std::unique_ptr<int>> set;
- set.add_new(std::unique_ptr<int>(new int()));
- auto value1 = std::unique_ptr<int>(new int());
+ set.add_new(std::unique_ptr<int>(std::make_unique<int>()));
+ auto value1 = std::unique_ptr<int>(std::make_unique<int>());
set.add_new(std::move(value1));
- set.add(std::unique_ptr<int>(new int()));
+ set.add(std::unique_ptr<int>(std::make_unique<int>()));
EXPECT_EQ(set.size(), 3);
}
diff --git a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc
index c03893c5596..57e7bfdfdce 100644
--- a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc
+++ b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc
@@ -170,8 +170,8 @@ TEST(stack, Peek)
TEST(stack, UniquePtrValues)
{
Stack<std::unique_ptr<int>> stack;
- stack.push(std::unique_ptr<int>(new int()));
- stack.push(std::unique_ptr<int>(new int()));
+ stack.push(std::unique_ptr<int>(std::make_unique<int>()));
+ stack.push(std::unique_ptr<int>(std::make_unique<int>()));
std::unique_ptr<int> a = stack.pop();
std::unique_ptr<int> &b = stack.peek();
UNUSED_VARS(a, b);
diff --git a/source/blender/blenlib/tests/BLI_string_test.cc b/source/blender/blenlib/tests/BLI_string_test.cc
index e8fe505a6c9..58135adbcca 100644
--- a/source/blender/blenlib/tests/BLI_string_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_test.cc
@@ -66,8 +66,8 @@ TEST(string, StrPartition)
/* "" -> "", NULL, NULL, 0 */
pre_ln = BLI_str_partition(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 0);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
{
@@ -76,8 +76,8 @@ TEST(string, StrPartition)
/* "material" -> "material", NULL, NULL, 8 */
pre_ln = BLI_str_partition(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 8);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -125,8 +125,8 @@ TEST(string, StrRPartition)
/* "" -> "", NULL, NULL, 0 */
pre_ln = BLI_str_rpartition(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 0);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
{
@@ -135,8 +135,8 @@ TEST(string, StrRPartition)
/* "material" -> "material", NULL, NULL, 8 */
pre_ln = BLI_str_rpartition(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 8);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -166,8 +166,8 @@ TEST(string, StrPartitionEx)
/* "mate.rial" over "mate" -> "mate.rial", NULL, NULL, 4 */
pre_ln = BLI_str_partition_ex(str, str + 4, delim, &sep, &suf, true);
EXPECT_EQ(pre_ln, 4);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -215,8 +215,8 @@ TEST(string, StrPartitionUtf8)
/* "" -> "", NULL, NULL, 0 */
pre_ln = BLI_str_partition_utf8(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 0);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
{
@@ -225,8 +225,8 @@ TEST(string, StrPartitionUtf8)
/* "material" -> "material", NULL, NULL, 8 */
pre_ln = BLI_str_partition_utf8(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 8);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -274,8 +274,8 @@ TEST(string, StrRPartitionUtf8)
/* "" -> "", NULL, NULL, 0 */
pre_ln = BLI_str_rpartition_utf8(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 0);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
{
@@ -284,8 +284,8 @@ TEST(string, StrRPartitionUtf8)
/* "material" -> "material", NULL, NULL, 8 */
pre_ln = BLI_str_rpartition_utf8(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 8);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -316,8 +316,8 @@ TEST(string, StrPartitionExUtf8)
/* "mate\xe2\x98\xafrial" over "mate" -> "mate\xe2\x98\xafrial", NULL, NULL, 4 */
pre_ln = BLI_str_partition_ex_utf8(str, str + 4, delim, &sep, &suf, true);
EXPECT_EQ(pre_ln, 4);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -567,7 +567,7 @@ TEST(string, StringStrncasestr)
EXPECT_EQ(res, str_test0 + 1);
res = BLI_strncasestr(str_test0, "not there", 9);
- EXPECT_EQ(res, (void *)NULL);
+ EXPECT_EQ(res, (void *)nullptr);
}
/* BLI_string_max_possible_word_count */
diff --git a/source/blender/blenlib/tests/BLI_string_utf8_test.cc b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
index 9743c1387a0..1833945b3fd 100644
--- a/source/blender/blenlib/tests/BLI_string_utf8_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
@@ -262,14 +262,14 @@ const char *utf8_invalid_tests[][3] = {
/* For now, we ignore those, they do not seem to be crucial anyway... */
/* 5.3.3 U+FDD0 .. U+FDEF
* 5.3.4 U+nFFFE U+nFFFF (for n = 1..10) */
- {NULL, NULL, NULL},
+ {nullptr, nullptr, nullptr},
};
/* clang-format on */
/* BLI_utf8_invalid_strip (and indirectly, BLI_utf8_invalid_byte). */
TEST(string, Utf8InvalidBytes)
{
- for (int i = 0; utf8_invalid_tests[i][0] != NULL; i++) {
+ for (int i = 0; utf8_invalid_tests[i][0] != nullptr; i++) {
const char *tst = utf8_invalid_tests[i][0];
const char *tst_stripped = utf8_invalid_tests[i][1];
const int num_errors = (int)utf8_invalid_tests[i][2][0];
diff --git a/source/blender/blenlib/tests/BLI_task_graph_test.cc b/source/blender/blenlib/tests/BLI_task_graph_test.cc
index efcbf923625..3374411b2bd 100644
--- a/source/blender/blenlib/tests/BLI_task_graph_test.cc
+++ b/source/blender/blenlib/tests/BLI_task_graph_test.cc
@@ -52,16 +52,16 @@ TEST(task, GraphSequential)
TaskGraph *graph = BLI_task_graph_create();
/* 0 => 1 */
- TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
/* 1 => 2 */
TaskNode *node_b = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_value, &data, NULL);
+ graph, TaskData_multiply_by_two_value, &data, nullptr);
/* 2 => 1 */
- TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_decrease_value, &data, NULL);
+ TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_decrease_value, &data, nullptr);
/* 2 => 1 */
- TaskNode *node_d = BLI_task_graph_node_create(graph, TaskData_square_value, &data, NULL);
+ TaskNode *node_d = BLI_task_graph_node_create(graph, TaskData_square_value, &data, nullptr);
/* 1 => 1 */
- TaskNode *node_e = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ TaskNode *node_e = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
/* 1 => 2 */
const int expected_value = 2;
@@ -82,12 +82,12 @@ TEST(task, GraphStartAtAnyNode)
TaskData data = {4};
TaskGraph *graph = BLI_task_graph_create();
- TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
TaskNode *node_b = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_value, &data, NULL);
- TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_decrease_value, &data, NULL);
- TaskNode *node_d = BLI_task_graph_node_create(graph, TaskData_square_value, &data, NULL);
- TaskNode *node_e = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ graph, TaskData_multiply_by_two_value, &data, nullptr);
+ TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_decrease_value, &data, nullptr);
+ TaskNode *node_d = BLI_task_graph_node_create(graph, TaskData_square_value, &data, nullptr);
+ TaskNode *node_e = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
// ((4 - 1) * (4 - 1)) + 1
const int expected_value = 10;
@@ -109,11 +109,11 @@ TEST(task, GraphSplit)
TaskData data = {1};
TaskGraph *graph = BLI_task_graph_create();
- TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
- TaskNode *node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data, NULL);
- TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
+ TaskNode *node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data, nullptr);
+ TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
TaskNode *node_d = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_store, &data, NULL);
+ graph, TaskData_multiply_by_two_store, &data, nullptr);
BLI_task_graph_edge_create(node_a, node_b);
BLI_task_graph_edge_create(node_b, node_c);
BLI_task_graph_edge_create(node_b, node_d);
@@ -134,12 +134,12 @@ TEST(task, GraphForest)
{
TaskNode *tree1_node_a = BLI_task_graph_node_create(
- graph, TaskData_increase_value, &data1, NULL);
- TaskNode *tree1_node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data1, NULL);
+ graph, TaskData_increase_value, &data1, nullptr);
+ TaskNode *tree1_node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data1, nullptr);
TaskNode *tree1_node_c = BLI_task_graph_node_create(
- graph, TaskData_increase_value, &data1, NULL);
+ graph, TaskData_increase_value, &data1, nullptr);
TaskNode *tree1_node_d = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_store, &data1, NULL);
+ graph, TaskData_multiply_by_two_store, &data1, nullptr);
BLI_task_graph_edge_create(tree1_node_a, tree1_node_b);
BLI_task_graph_edge_create(tree1_node_b, tree1_node_c);
BLI_task_graph_edge_create(tree1_node_b, tree1_node_d);
@@ -148,12 +148,12 @@ TEST(task, GraphForest)
{
TaskNode *tree2_node_a = BLI_task_graph_node_create(
- graph, TaskData_increase_value, &data2, NULL);
- TaskNode *tree2_node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data2, NULL);
+ graph, TaskData_increase_value, &data2, nullptr);
+ TaskNode *tree2_node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data2, nullptr);
TaskNode *tree2_node_c = BLI_task_graph_node_create(
- graph, TaskData_increase_value, &data2, NULL);
+ graph, TaskData_increase_value, &data2, nullptr);
TaskNode *tree2_node_d = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_store, &data2, NULL);
+ graph, TaskData_multiply_by_two_store, &data2, nullptr);
BLI_task_graph_edge_create(tree2_node_a, tree2_node_b);
BLI_task_graph_edge_create(tree2_node_b, tree2_node_c);
BLI_task_graph_edge_create(tree2_node_b, tree2_node_d);
@@ -175,7 +175,7 @@ TEST(task, GraphTaskData)
TaskGraph *graph = BLI_task_graph_create();
TaskNode *node_a = BLI_task_graph_node_create(
graph, TaskData_store_value, &data, TaskData_increase_value);
- TaskNode *node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data, NULL);
+ TaskNode *node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data, nullptr);
BLI_task_graph_edge_create(node_a, node_b);
EXPECT_TRUE(BLI_task_graph_node_push_work(node_a));
BLI_task_graph_work_and_wait(graph);
diff --git a/source/blender/blenlib/tests/BLI_task_test.cc b/source/blender/blenlib/tests/BLI_task_test.cc
index 3abaf6a6c0b..2a3fddf5e3d 100644
--- a/source/blender/blenlib/tests/BLI_task_test.cc
+++ b/source/blender/blenlib/tests/BLI_task_test.cc
@@ -72,7 +72,7 @@ static void task_mempool_iter_func(void *userdata, MempoolIterData *item)
int *data = (int *)item;
int *count = (int *)userdata;
- EXPECT_TRUE(data != NULL);
+ EXPECT_TRUE(data != nullptr);
*data += 1;
atomic_sub_and_fetch_uint32((uint32_t *)count, 1);
@@ -97,12 +97,12 @@ TEST(task, MempoolIter)
for (i = 0; i < NUM_ITEMS; i += 3) {
BLI_mempool_free(mempool, data[i]);
- data[i] = NULL;
+ data[i] = nullptr;
num_items--;
}
for (i = 0; i < NUM_ITEMS; i += 7) {
- if (data[i] == NULL) {
+ if (data[i] == nullptr) {
data[i] = (int *)BLI_mempool_alloc(mempool);
*data[i] = i - 1;
num_items++;
@@ -111,9 +111,9 @@ TEST(task, MempoolIter)
for (i = 0; i < NUM_ITEMS - 5; i += 23) {
for (int j = 0; j < 5; j++) {
- if (data[i + j] != NULL) {
+ if (data[i + j] != nullptr) {
BLI_mempool_free(mempool, data[i + j]);
- data[i + j] = NULL;
+ data[i + j] = nullptr;
num_items--;
}
}
@@ -125,7 +125,7 @@ TEST(task, MempoolIter)
* expected. */
EXPECT_EQ(num_items, 0);
for (i = 0; i < NUM_ITEMS; i++) {
- if (data[i] != NULL) {
+ if (data[i] != nullptr) {
EXPECT_EQ(*data[i], i);
}
}
@@ -150,7 +150,7 @@ static void task_listbase_iter_func(void *userdata,
TEST(task, ListBaseIter)
{
- ListBase list = {NULL, NULL};
+ ListBase list = {nullptr, nullptr};
LinkData *items_buffer = (LinkData *)MEM_calloc_arrayN(
NUM_ITEMS, sizeof(*items_buffer), __func__);
BLI_threadapi_init();
@@ -172,7 +172,7 @@ TEST(task, ListBaseIter)
* as expected. */
EXPECT_EQ(num_items, 0);
LinkData *item;
- for (i = 0, item = (LinkData *)list.first; i < NUM_ITEMS && item != NULL;
+ for (i = 0, item = (LinkData *)list.first; i < NUM_ITEMS && item != nullptr;
i++, item = item->next) {
EXPECT_EQ(POINTER_AS_INT(item->data), i);
}
diff --git a/source/blender/blenlib/tests/BLI_vector_set_test.cc b/source/blender/blenlib/tests/BLI_vector_set_test.cc
index 320cb15f450..cbdc597255a 100644
--- a/source/blender/blenlib/tests/BLI_vector_set_test.cc
+++ b/source/blender/blenlib/tests/BLI_vector_set_test.cc
@@ -142,9 +142,9 @@ TEST(vector_set, AddMultipleTimes)
TEST(vector_set, UniquePtrValue)
{
VectorSet<std::unique_ptr<int>> set;
- set.add_new(std::unique_ptr<int>(new int()));
- set.add(std::unique_ptr<int>(new int()));
- set.index_of_try(std::unique_ptr<int>(new int()));
+ set.add_new(std::unique_ptr<int>(std::make_unique<int>()));
+ set.add(std::unique_ptr<int>(std::make_unique<int>()));
+ set.index_of_try(std::unique_ptr<int>(std::make_unique<int>()));
std::unique_ptr<int> value = set.pop();
UNUSED_VARS(value);
}
diff --git a/source/blender/blenlib/tests/BLI_vector_test.cc b/source/blender/blenlib/tests/BLI_vector_test.cc
index e6b2e7c6365..0088ae21983 100644
--- a/source/blender/blenlib/tests/BLI_vector_test.cc
+++ b/source/blender/blenlib/tests/BLI_vector_test.cc
@@ -79,11 +79,11 @@ struct TestListValue {
TEST(vector, ListBaseConstructor)
{
- TestListValue *value1 = new TestListValue{0, 0, 4};
- TestListValue *value2 = new TestListValue{0, 0, 5};
- TestListValue *value3 = new TestListValue{0, 0, 6};
+ TestListValue *value1 = new TestListValue{nullptr, nullptr, 4};
+ TestListValue *value2 = new TestListValue{nullptr, nullptr, 5};
+ TestListValue *value3 = new TestListValue{nullptr, nullptr, 6};
- ListBase list = {NULL, NULL};
+ ListBase list = {nullptr, nullptr};
BLI_addtail(&list, value1);
BLI_addtail(&list, value2);
BLI_addtail(&list, value3);
@@ -456,10 +456,10 @@ TEST(vector, AppendNTimes)
TEST(vector, UniquePtrValue)
{
Vector<std::unique_ptr<int>> vec;
- vec.append(std::unique_ptr<int>(new int()));
- vec.append(std::unique_ptr<int>(new int()));
- vec.append(std::unique_ptr<int>(new int()));
- vec.append(std::unique_ptr<int>(new int()));
+ vec.append(std::unique_ptr<int>(std::make_unique<int>()));
+ vec.append(std::unique_ptr<int>(std::make_unique<int>()));
+ vec.append(std::unique_ptr<int>(std::make_unique<int>()));
+ vec.append(std::unique_ptr<int>(std::make_unique<int>()));
EXPECT_EQ(vec.size(), 4);
std::unique_ptr<int> &a = vec.last();
diff --git a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
index 6400bec93f9..9a374cd0b1f 100644
--- a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
@@ -152,7 +152,7 @@ static void str_ghash_tests(GHash *ghash, const char *id)
TIMEIT_END(string_lookup);
}
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
MEM_freeN(data);
MEM_freeN(data_p);
MEM_freeN(data_w);
@@ -227,7 +227,7 @@ static void int_ghash_tests(GHash *ghash, const char *id, const unsigned int nbr
}
EXPECT_EQ(BLI_ghash_len(ghash), 0);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
printf("========== ENDED %s ==========\n\n", id);
}
@@ -309,7 +309,7 @@ static void randint_ghash_tests(GHash *ghash, const char *id, const unsigned int
TIMEIT_END(int_lookup);
}
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
MEM_freeN(data);
printf("========== ENDED %s ==========\n\n", id);
@@ -421,7 +421,7 @@ static void int4_ghash_tests(GHash *ghash, const char *id, const unsigned int nb
TIMEIT_END(int_v4_lookup);
}
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
MEM_freeN(data);
printf("========== ENDED %s ==========\n\n", id);
@@ -506,7 +506,7 @@ static void multi_small_ghash_tests_one(GHash *ghash, RNG *rng, const unsigned i
EXPECT_EQ(POINTER_AS_UINT(v), *dt);
}
- BLI_ghash_clear(ghash, NULL, NULL);
+ BLI_ghash_clear(ghash, nullptr, nullptr);
MEM_freeN(data);
}
@@ -538,7 +538,7 @@ static void multi_small_ghash_tests(GHash *ghash, const char *id, const unsigned
TIMEIT_END(multi_small2_ghash);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
BLI_rng_free(rng);
printf("========== ENDED %s ==========\n\n", id);
diff --git a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
index 208f168b599..c5b0f86e384 100644
--- a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
@@ -119,7 +119,7 @@ static void task_listbase_test_do(ListBase *list,
}
LinkData *item;
int j;
- for (j = 0, item = (LinkData *)list->first; j < num_items && item != NULL;
+ for (j = 0, item = (LinkData *)list->first; j < num_items && item != nullptr;
j++, item = item->next) {
EXPECT_EQ(POINTER_AS_INT(item->data), j);
item->data = POINTER_FROM_INT(0);
@@ -139,7 +139,7 @@ static void task_listbase_test(const char *id, const int nbr, const bool use_thr
{
printf("\n========== STARTING %s ==========\n", id);
- ListBase list = {NULL, NULL};
+ ListBase list = {nullptr, nullptr};
LinkData *items_buffer = (LinkData *)MEM_calloc_arrayN(nbr, sizeof(*items_buffer), __func__);
BLI_threadapi_init();