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_array_utils.h2
-rw-r--r--source/blender/blenlib/BLI_boxpack_2d.h5
-rw-r--r--source/blender/blenlib/BLI_dot_export.hh2
-rw-r--r--source/blender/blenlib/BLI_dynstr.h2
-rw-r--r--source/blender/blenlib/BLI_edgehash.h17
-rw-r--r--source/blender/blenlib/BLI_fileops.h10
-rw-r--r--source/blender/blenlib/BLI_ghash.h8
-rw-r--r--source/blender/blenlib/BLI_gsqueue.h10
-rw-r--r--source/blender/blenlib/BLI_kdopbvh.h2
-rw-r--r--source/blender/blenlib/BLI_listbase.h3
-rw-r--r--source/blender/blenlib/BLI_math_color.h4
-rw-r--r--source/blender/blenlib/BLI_math_geom.h49
-rw-r--r--source/blender/blenlib/BLI_math_interp.h2
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h80
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h6
-rw-r--r--source/blender/blenlib/BLI_math_statistics.h2
-rw-r--r--source/blender/blenlib/BLI_math_vector.h8
-rw-r--r--source/blender/blenlib/BLI_memblock.h4
-rw-r--r--source/blender/blenlib/BLI_mesh_boolean.hh4
-rw-r--r--source/blender/blenlib/BLI_path_util.h7
-rw-r--r--source/blender/blenlib/BLI_rect.h4
-rw-r--r--source/blender/blenlib/BLI_string.h5
-rw-r--r--source/blender/blenlib/BLI_string_utf8.h4
-rw-r--r--source/blender/blenlib/BLI_task.h2
-rw-r--r--source/blender/blenlib/BLI_timecode.h6
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c8
-rw-r--r--source/blender/blenlib/intern/array_utils.c6
-rw-r--r--source/blender/blenlib/intern/gsqueue.c14
-rw-r--r--source/blender/blenlib/intern/hash_mm3.c8
-rw-r--r--source/blender/blenlib/intern/jitter_2d.c46
-rw-r--r--source/blender/blenlib/intern/math_geom.c54
-rw-r--r--source/blender/blenlib/intern/math_matrix.c918
-rw-r--r--source/blender/blenlib/intern/math_rotation.c256
-rw-r--r--source/blender/blenlib/intern/math_vector.c102
-rw-r--r--source/blender/blenlib/intern/memory_utils.c14
-rw-r--r--source/blender/blenlib/intern/smallhash.c6
-rw-r--r--source/blender/blenlib/intern/storage.c14
-rw-r--r--source/blender/blenlib/tests/BLI_edgehash_test.cc6
-rw-r--r--source/blender/blenlib/tests/BLI_string_test.cc8
39 files changed, 858 insertions, 850 deletions
diff --git a/source/blender/blenlib/BLI_array_utils.h b/source/blender/blenlib/BLI_array_utils.h
index b8d63e7cdc1..bd37d22023b 100644
--- a/source/blender/blenlib/BLI_array_utils.h
+++ b/source/blender/blenlib/BLI_array_utils.h
@@ -37,7 +37,7 @@ void _bli_array_wrap(void *arr, unsigned int arr_len, size_t arr_stride, int dir
void _bli_array_permute(void *arr,
const unsigned int arr_len,
const size_t arr_stride,
- const unsigned int *index,
+ const unsigned int *order,
void *arr_temp);
#define BLI_array_permute(arr, arr_len, order) \
_bli_array_permute(arr, arr_len, sizeof(*(arr)), order, NULL)
diff --git a/source/blender/blenlib/BLI_boxpack_2d.h b/source/blender/blenlib/BLI_boxpack_2d.h
index c36cbc03928..7e347d0b0d7 100644
--- a/source/blender/blenlib/BLI_boxpack_2d.h
+++ b/source/blender/blenlib/BLI_boxpack_2d.h
@@ -44,10 +44,7 @@ typedef struct BoxPack {
int index;
} BoxPack;
-void BLI_box_pack_2d(BoxPack *boxarray,
- const unsigned int len,
- float *tot_width,
- float *tot_height);
+void BLI_box_pack_2d(BoxPack *boxarray, const unsigned int len, float *r_tot_x, float *r_tot_y);
typedef struct FixedSizeBoxPack {
struct FixedSizeBoxPack *next, *prev;
diff --git a/source/blender/blenlib/BLI_dot_export.hh b/source/blender/blenlib/BLI_dot_export.hh
index a026a85dd62..0de8b3b8747 100644
--- a/source/blender/blenlib/BLI_dot_export.hh
+++ b/source/blender/blenlib/BLI_dot_export.hh
@@ -115,7 +115,7 @@ class Cluster {
return "cluster_" + std::to_string((uintptr_t)this);
}
- void set_parent_cluster(Cluster *cluster);
+ void set_parent_cluster(Cluster *new_parent);
void set_parent_cluster(Cluster &cluster)
{
this->set_parent_cluster(&cluster);
diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h
index 075786c4424..4733812746d 100644
--- a/source/blender/blenlib/BLI_dynstr.h
+++ b/source/blender/blenlib/BLI_dynstr.h
@@ -55,7 +55,7 @@ void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, v
int BLI_dynstr_get_len(DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
char *BLI_dynstr_get_cstring(DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-void BLI_dynstr_get_cstring_ex(DynStr *__restrict ds, char *__restrict str) ATTR_NONNULL();
+void BLI_dynstr_get_cstring_ex(DynStr *__restrict ds, char *__restrict rets) ATTR_NONNULL();
void BLI_dynstr_clear(DynStr *ds) ATTR_NONNULL();
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_edgehash.h b/source/blender/blenlib/BLI_edgehash.h
index 44dc3cf096b..a53a1b252eb 100644
--- a/source/blender/blenlib/BLI_edgehash.h
+++ b/source/blender/blenlib/BLI_edgehash.h
@@ -53,7 +53,7 @@ enum {
EdgeHash *BLI_edgehash_new_ex(const char *info, const unsigned int nentries_reserve);
EdgeHash *BLI_edgehash_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
-void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp);
+void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP free_value);
void BLI_edgehash_print(EdgeHash *eh);
void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
bool BLI_edgehash_reinsert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
@@ -61,21 +61,22 @@ void *BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_W
void *BLI_edgehash_lookup_default(EdgeHash *eh,
unsigned int v0,
unsigned int v1,
- void *val_default) ATTR_WARN_UNUSED_RESULT;
+ void *default_value) ATTR_WARN_UNUSED_RESULT;
void **BLI_edgehash_lookup_p(EdgeHash *eh,
unsigned int v0,
unsigned int v1) ATTR_WARN_UNUSED_RESULT;
bool BLI_edgehash_ensure_p(EdgeHash *eh, unsigned int v0, unsigned int v1, void ***r_val)
ATTR_WARN_UNUSED_RESULT;
-bool BLI_edgehash_remove(EdgeHash *eh, unsigned int v0, unsigned int v1, EdgeHashFreeFP valfreefp);
+bool BLI_edgehash_remove(EdgeHash *eh,
+ unsigned int v0,
+ unsigned int v1,
+ EdgeHashFreeFP free_value);
void *BLI_edgehash_popkey(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
bool BLI_edgehash_haskey(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
int BLI_edgehash_len(EdgeHash *eh) ATTR_WARN_UNUSED_RESULT;
-void BLI_edgehash_clear_ex(EdgeHash *eh,
- EdgeHashFreeFP valfreefp,
- const unsigned int nentries_reserve);
-void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp);
+void BLI_edgehash_clear_ex(EdgeHash *eh, EdgeHashFreeFP free_value, const uint UNUSED(reserve));
+void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP free_value);
EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
void BLI_edgehashIterator_init(EdgeHashIterator *ehi, EdgeHash *eh);
@@ -134,7 +135,7 @@ bool BLI_edgeset_haskey(EdgeSet *es, unsigned int v0, unsigned int v1) ATTR_WARN
void BLI_edgeset_free(EdgeSet *es);
/* rely on inline api for now */
-EdgeSetIterator *BLI_edgesetIterator_new(EdgeSet *gs);
+EdgeSetIterator *BLI_edgesetIterator_new(EdgeSet *es);
void BLI_edgesetIterator_free(EdgeSetIterator *esi);
BLI_INLINE void BLI_edgesetIterator_getKey(EdgeSetIterator *esi,
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index e61e20ee5e9..922039e8862 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -47,10 +47,10 @@ extern "C" {
/* Common */
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-int BLI_copy(const char *path, const char *to) ATTR_NONNULL();
+int BLI_copy(const char *file, const char *to) ATTR_NONNULL();
int BLI_rename(const char *from, const char *to) ATTR_NONNULL();
-int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL();
-int BLI_delete_soft(const char *path, const char **error_message) ATTR_NONNULL();
+int BLI_delete(const char *file, bool dir, bool recursive) ATTR_NONNULL();
+int BLI_delete_soft(const char *file, const char **error_message) ATTR_NONNULL();
#if 0 /* Unused */
int BLI_move(const char *path, const char *to) ATTR_NONNULL();
int BLI_create_symlink(const char *path, const char *to) ATTR_NONNULL();
@@ -108,7 +108,7 @@ bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BLI_dir_create_recursive(const char *dir) ATTR_NONNULL();
double BLI_dir_free_space(const char *dir) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-char *BLI_current_working_dir(char *dir, const size_t maxlen) ATTR_WARN_UNUSED_RESULT
+char *BLI_current_working_dir(char *dir, const size_t maxncpy) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL();
eFileAttributes BLI_file_attributes(const char *path);
@@ -161,7 +161,7 @@ size_t BLI_gzip_mem_to_file_at_pos(void *buf,
size_t BLI_ungzip_file_to_mem_at_pos(void *buf, size_t len, FILE *file, size_t gz_stream_offset)
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
size_t BLI_file_descriptor_size(int file) ATTR_WARN_UNUSED_RESULT;
-size_t BLI_file_size(const char *file) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+size_t BLI_file_size(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* compare if one was last modified before the other */
bool BLI_file_older(const char *file1, const char *file2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index cd84dd4f327..e38848e2967 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -204,7 +204,7 @@ unsigned int BLI_gset_len(GSet *gs) ATTR_WARN_UNUSED_RESULT;
void BLI_gset_flag_set(GSet *gs, unsigned int flag);
void BLI_gset_flag_clear(GSet *gs, unsigned int flag);
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp);
-void BLI_gset_insert(GSet *gh, void *key);
+void BLI_gset_insert(GSet *gs, void *key);
bool BLI_gset_add(GSet *gs, void *key);
bool BLI_gset_ensure_p_ex(GSet *gs, const void *key, void ***r_key);
bool BLI_gset_reinsert(GSet *gh, void *key, GSetKeyFreeFP keyfreefp);
@@ -217,7 +217,7 @@ void BLI_gset_clear_ex(GSet *gs, GSetKeyFreeFP keyfreefp, const unsigned int nen
void BLI_gset_clear(GSet *gs, GSetKeyFreeFP keyfreefp);
/* When set's are used for key & value. */
-void *BLI_gset_lookup(GSet *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
+void *BLI_gset_lookup(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
void *BLI_gset_pop_key(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
/** \} */
@@ -342,8 +342,8 @@ bool BLI_ghashutil_ptrcmp(const void *a, const void *b);
unsigned int BLI_ghashutil_strhash_n(const char *key, size_t n);
#define BLI_ghashutil_strhash(key) \
(CHECK_TYPE_ANY(key, char *, const char *, const char *const), BLI_ghashutil_strhash_p(key))
-unsigned int BLI_ghashutil_strhash_p(const void *key);
-unsigned int BLI_ghashutil_strhash_p_murmur(const void *key);
+unsigned int BLI_ghashutil_strhash_p(const void *ptr);
+unsigned int BLI_ghashutil_strhash_p_murmur(const void *ptr);
bool BLI_ghashutil_strcmp(const void *a, const void *b);
#define BLI_ghashutil_inthash(key) \
diff --git a/source/blender/blenlib/BLI_gsqueue.h b/source/blender/blenlib/BLI_gsqueue.h
index 077d1646d1d..9cc61bc8059 100644
--- a/source/blender/blenlib/BLI_gsqueue.h
+++ b/source/blender/blenlib/BLI_gsqueue.h
@@ -32,11 +32,11 @@ extern "C" {
typedef struct _GSQueue GSQueue;
GSQueue *BLI_gsqueue_new(const size_t elem_size);
-bool BLI_gsqueue_is_empty(const GSQueue *gq);
-size_t BLI_gsqueue_len(const GSQueue *gq);
-void BLI_gsqueue_pop(GSQueue *gq, void *r_item);
-void BLI_gsqueue_push(GSQueue *gq, const void *item);
-void BLI_gsqueue_free(GSQueue *gq);
+bool BLI_gsqueue_is_empty(const GSQueue *queue);
+size_t BLI_gsqueue_len(const GSQueue *queue);
+void BLI_gsqueue_pop(GSQueue *queue, void *r_item);
+void BLI_gsqueue_push(GSQueue *queue, const void *item);
+void BLI_gsqueue_free(GSQueue *queue);
#ifdef __cplusplus
}
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index 5e317c89625..c34b71a60f9 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -246,7 +246,7 @@ int BLI_bvhtree_find_nearest_projected(BVHTree *tree,
float winsize[2],
float mval[2],
float clip_planes[6][4],
- int clip_num,
+ int clip_plane_len,
BVHTreeNearest *nearest,
BVHTree_NearestProjectedCallback callback,
void *userdata);
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index aff80a2bd86..345d9d93d03 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -85,7 +85,8 @@ void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnew
ATTR_NONNULL(1);
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink)
ATTR_NONNULL(1);
-void BLI_insertlinkreplace(ListBase *listbase, void *v_l_src, void *v_l_dst) ATTR_NONNULL(1, 2, 3);
+void BLI_insertlinkreplace(ListBase *listbase, void *vreplacelink, void *vnewlink)
+ ATTR_NONNULL(1, 2, 3);
void BLI_listbase_sort(struct ListBase *listbase, int (*cmp)(const void *, const void *))
ATTR_NONNULL(1, 2);
void BLI_listbase_sort_r(ListBase *listbase,
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 7b48b62b6e7..9e613270538 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -45,8 +45,8 @@ extern "C" {
void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b);
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3]);
-void hsl_to_rgb(float h, float c, float l, float *r_r, float *r_g, float *r_b);
-void hsl_to_rgb_v(const float hcl[3], float r_rgb[3]);
+void hsl_to_rgb(float h, float s, float l, float *r_r, float *r_g, float *r_b);
+void hsl_to_rgb_v(const float hsl[3], float r_rgb[3]);
void hex_to_rgb(const char *hexcol, float *r_r, float *r_g, float *r_b);
void yuv_to_rgb(float y, float u, float v, float *r_r, float *r_g, float *r_b, int colorspace);
void ycc_to_rgb(float y, float cb, float cr, float *r_r, float *r_g, float *r_b, int colorspace);
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 213f5a029b0..a9a55b10a9e 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -40,22 +40,25 @@ extern "C" {
/********************************** Polygons *********************************/
-float normal_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
+float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3]);
float normal_quad_v3(
- float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
-float normal_poly_v3(float r[3], const float verts[][3], unsigned int nr);
+ float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
+float normal_poly_v3(float n[3], const float verts[][3], unsigned int nr);
-MINLINE float area_tri_v2(const float a[2], const float b[2], const float c[2]);
-MINLINE float area_squared_tri_v2(const float a[2], const float b[2], const float c[2]);
+MINLINE float area_tri_v2(const float v1[2], const float v2[2], const float v3[2]);
+MINLINE float area_squared_tri_v2(const float v1[2], const float v2[2], const float v3[2]);
MINLINE float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]);
-float area_tri_v3(const float a[3], const float b[3], const float c[3]);
-float area_squared_tri_v3(const float a[3], const float b[3], const float c[3]);
+float area_tri_v3(const float v1[3], const float v2[3], const float v3[3]);
+float area_squared_tri_v3(const float v1[3], const float v2[3], const float v3[3]);
float area_tri_signed_v3(const float v1[3],
const float v2[3],
const float v3[3],
const float normal[3]);
-float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]);
-float area_squared_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]);
+float area_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
+float area_squared_quad_v3(const float v1[3],
+ const float v2[3],
+ const float v3[3],
+ const float v4[3]);
float area_poly_v3(const float verts[][3], unsigned int nr);
float area_poly_v2(const float verts[][2], unsigned int nr);
float area_squared_poly_v3(const float verts[][3], unsigned int nr);
@@ -212,9 +215,9 @@ void closest_to_plane_v3(float r_close[3], const float plane[4], const float pt[
void closest_to_plane3_normalized_v3(float r_close[3], const float plane[3], const float pt[3]);
void closest_to_plane3_v3(float r_close[3], const float plane[3], const float pt[3]);
-/* Set 'r' to the point in triangle (t1, t2, t3) closest to point 'p' */
+/* Set 'r' to the point in triangle (v1, v2, v3) closest to point 'p' */
void closest_on_tri_to_point_v3(
- float r[3], const float p[3], const float t1[3], const float t2[3], const float t3[3]);
+ float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3]);
float ray_point_factor_v3_ex(const float p[3],
const float ray_origin[3],
@@ -256,7 +259,7 @@ void limit_dist_v3(float v1[3], float v2[3], const float dist);
#define ISECT_LINE_LINE_EXACT 1
#define ISECT_LINE_LINE_CROSS 2
-int isect_seg_seg_v2(const float a1[2], const float a2[2], const float b1[2], const float b2[2]);
+int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
void isect_seg_seg_v3(const float a0[3],
const float a1[3],
const float b0[3],
@@ -264,7 +267,7 @@ void isect_seg_seg_v3(const float a0[3],
float r_a[3],
float r_b[3]);
-int isect_seg_seg_v2_int(const int a1[2], const int a2[2], const int b1[2], const int b2[2]);
+int isect_seg_seg_v2_int(const int v1[2], const int v2[2], const int v3[2], const int v4[2]);
int isect_seg_seg_v2_point_ex(const float v0[2],
const float v1[2],
const float v2[2],
@@ -474,7 +477,7 @@ bool isect_point_poly_v2_int(const int pt[2],
const bool use_holes);
int isect_point_quad_v2(
- const float p[2], const float a[2], const float b[2], const float c[2], const float d[2]);
+ const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2]);
bool isect_point_tri_v2_cw(const float pt[2],
@@ -551,13 +554,13 @@ bool point_in_slice_seg(float p[3], float l1[3], float l2[3]);
/****************************** Interpolation ********************************/
void interp_weights_tri_v3(
- float w[3], const float a[3], const float b[3], const float c[3], const float p[3]);
+ float w[3], const float v1[3], const float v2[3], const float v3[3], const float co[3]);
void interp_weights_quad_v3(float w[4],
- const float a[3],
- const float b[3],
- const float c[3],
- const float d[3],
- const float p[3]);
+ const float v1[3],
+ const float v2[3],
+ const float v3[3],
+ const float v4[3],
+ const float co[3]);
void interp_weights_poly_v3(float w[], float v[][3], const int n, const float co[3]);
void interp_weights_poly_v2(float w[], float v[][2], const int n, const float co[2]);
@@ -569,7 +572,7 @@ void interp_cubic_v3(float x[3],
const float v2[3],
const float t);
-int interp_sparse_array(float *array, const int list_size, const float invalid);
+int interp_sparse_array(float *array, const int list_size, const float skipval);
void transform_point_by_tri_v3(float pt_tar[3],
float const pt_src[3],
@@ -664,8 +667,8 @@ void planes_from_projmat(const float mat[4][4],
float right[4],
float top[4],
float bottom[4],
- float front[4],
- float back[4]);
+ float near[4],
+ float far[4]);
void projmat_dimensions(const float projmat[4][4],
float *r_left,
diff --git a/source/blender/blenlib/BLI_math_interp.h b/source/blender/blenlib/BLI_math_interp.h
index 3e9839b4d3a..cc025b469e3 100644
--- a/source/blender/blenlib/BLI_math_interp.h
+++ b/source/blender/blenlib/BLI_math_interp.h
@@ -88,7 +88,7 @@ void BLI_ewa_filter(const int width,
const float du[2],
const float dv[2],
ewa_filter_read_pixel_cb read_pixel_cb,
- void *customdata,
+ void *userdata,
float result[4]);
#ifdef __cplusplus
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 09f2d5a7cdc..9f6c56d698a 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -34,33 +34,33 @@ extern "C" {
/********************************* Init **************************************/
-void zero_m2(float R[2][2]);
-void zero_m3(float R[3][3]);
-void zero_m4(float R[4][4]);
+void zero_m2(float m[2][2]);
+void zero_m3(float m[3][3]);
+void zero_m4(float m[4][4]);
-void unit_m2(float R[2][2]);
-void unit_m3(float R[3][3]);
-void unit_m4(float R[4][4]);
+void unit_m2(float m[2][2]);
+void unit_m3(float m[3][3]);
+void unit_m4(float m[4][4]);
void unit_m4_db(double m[4][4]);
-void copy_m2_m2(float R[2][2], const float A[2][2]);
-void copy_m3_m3(float R[3][3], const float A[3][3]);
-void copy_m4_m4(float R[4][4], const float A[4][4]);
-void copy_m3_m4(float R[3][3], const float A[4][4]);
-void copy_m4_m3(float R[4][4], const float A[3][3]);
-void copy_m3_m2(float R[3][3], const float A[2][2]);
-void copy_m4_m2(float R[4][4], const float A[2][2]);
+void copy_m2_m2(float m1[2][2], const float m2[2][2]);
+void copy_m3_m3(float m1[3][3], const float m2[3][3]);
+void copy_m4_m4(float m1[4][4], const float m2[4][4]);
+void copy_m3_m4(float m1[3][3], const float m2[4][4]);
+void copy_m4_m3(float m1[4][4], const float m2[3][3]);
+void copy_m3_m2(float m1[3][3], const float m2[2][2]);
+void copy_m4_m2(float m1[4][4], const float m2[2][2]);
void copy_m4_m4_db(double m1[4][4], const double m2[4][4]);
/* double->float */
-void copy_m3_m3d(float R[3][3], const double A[3][3]);
+void copy_m3_m3d(float m1[3][3], const double m2[3][3]);
/* float->double */
-void copy_m4d_m4(double R[4][4], const float A[4][4]);
+void copy_m4d_m4(double m1[4][4], const float m2[4][4]);
-void swap_m3m3(float A[3][3], float B[3][3]);
-void swap_m4m4(float A[4][4], float B[4][4]);
+void swap_m3m3(float m1[3][3], float m2[3][3]);
+void swap_m4m4(float m1[4][4], float m2[4][4]);
/* Build index shuffle matrix */
void shuffle_m4(float R[4][4], const int index[4]);
@@ -240,25 +240,25 @@ void mul_m3_v3_db(const double M[3][3], double r[3]);
/****************************** Linear Algebra *******************************/
void transpose_m3(float R[3][3]);
-void transpose_m3_m3(float R[3][3], const float A[3][3]);
-void transpose_m3_m4(float R[3][3], const float A[4][4]);
+void transpose_m3_m3(float R[3][3], const float M[3][3]);
+void transpose_m3_m4(float R[3][3], const float M[4][4]);
void transpose_m4(float R[4][4]);
-void transpose_m4_m4(float R[4][4], const float A[4][4]);
+void transpose_m4_m4(float R[4][4], const float M[4][4]);
-int compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit);
+bool compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit);
void normalize_m2_ex(float R[2][2], float r_scale[2]) ATTR_NONNULL();
void normalize_m2(float R[2][2]) ATTR_NONNULL();
-void normalize_m2_m2_ex(float R[2][2], const float A[2][2], float r_scale[2]) ATTR_NONNULL();
-void normalize_m2_m2(float R[2][2], const float A[2][2]) ATTR_NONNULL();
+void normalize_m2_m2_ex(float R[2][2], const float M[2][2], float r_scale[2]) ATTR_NONNULL();
+void normalize_m2_m2(float R[2][2], const float M[2][2]) ATTR_NONNULL();
void normalize_m3_ex(float R[3][3], float r_scale[3]) ATTR_NONNULL();
void normalize_m3(float R[3][3]) ATTR_NONNULL();
-void normalize_m3_m3_ex(float R[3][3], const float A[3][3], float r_scale[3]) ATTR_NONNULL();
-void normalize_m3_m3(float R[3][3], const float A[3][3]) ATTR_NONNULL();
+void normalize_m3_m3_ex(float R[3][3], const float M[3][3], float r_scale[3]) ATTR_NONNULL();
+void normalize_m3_m3(float R[3][3], const float M[3][3]) ATTR_NONNULL();
void normalize_m4_ex(float R[4][4], float r_scale[3]) ATTR_NONNULL();
void normalize_m4(float R[4][4]) ATTR_NONNULL();
-void normalize_m4_m4_ex(float R[4][4], const float A[4][4], float r_scale[3]) ATTR_NONNULL();
-void normalize_m4_m4(float R[4][4], const float A[4][4]) ATTR_NONNULL();
+void normalize_m4_m4_ex(float R[4][4], const float M[4][4], float r_scale[3]) ATTR_NONNULL();
+void normalize_m4_m4(float R[4][4], const float M[4][4]) ATTR_NONNULL();
void orthogonalize_m3(float R[3][3], int axis);
void orthogonalize_m4(float R[4][4], int axis);
@@ -278,16 +278,16 @@ bool is_uniform_scaled_m4(const float m[4][4]);
* Nowadays 'adjoint' usually refers to the conjugate transpose,
* which for real-valued matrices is simply the transpose.
*/
-void adjoint_m2_m2(float R[2][2], const float A[2][2]);
-void adjoint_m3_m3(float R[3][3], const float A[3][3]);
-void adjoint_m4_m4(float R[4][4], const float A[4][4]);
+void adjoint_m2_m2(float R[2][2], const float M[2][2]);
+void adjoint_m3_m3(float R[3][3], const float M[3][3]);
+void adjoint_m4_m4(float R[4][4], const float M[4][4]);
float determinant_m2(float a, float b, float c, float d);
float determinant_m3(
- float a, float b, float c, float d, float e, float f, float g, float h, float i);
+ float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3);
float determinant_m3_array(const float m[3][3]);
float determinant_m4_mat3_array(const float m[4][4]);
-float determinant_m4(const float A[4][4]);
+float determinant_m4(const float m[4][4]);
#define PSEUDOINVERSE_EPSILON 1e-8f
@@ -317,10 +317,10 @@ float mat4_to_xy_scale(const float M[4][4]);
void size_to_mat3(float R[3][3], const float size[3]);
void size_to_mat4(float R[4][4], const float size[3]);
-void mat3_to_size(float r[3], const float M[3][3]);
-void mat4_to_size(float r[3], const float M[4][4]);
+void mat3_to_size(float size[3], const float M[3][3]);
+void mat4_to_size(float size[3], const float M[4][4]);
-void mat4_to_size_fix_shear(float r[3], const float M[4][4]);
+void mat4_to_size_fix_shear(float size[3], const float M[4][4]);
void translate_m4(float mat[4][4], float tx, float ty, float tz);
void rotate_m4(float mat[4][4], const char axis, const float angle);
@@ -354,8 +354,14 @@ void loc_axisangle_size_to_mat4(float R[4][4],
const float angle,
const float size[3]);
-void blend_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3], const float t);
-void blend_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4], const float t);
+void blend_m3_m3m3(float out[3][3],
+ const float dst[3][3],
+ const float src[3][3],
+ const float srcweight);
+void blend_m4_m4m4(float out[4][4],
+ const float dst[4][4],
+ const float src[4][4],
+ const float srcweight);
void interp_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3], const float t);
void interp_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4], const float t);
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index 61708528e24..15d4dc21f8d 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -64,7 +64,7 @@ void conjugate_qt(float q[4]);
void conjugate_qt_qt(float q1[4], const float q2[4]);
float dot_qtqt(const float a[4], const float b[4]);
float normalize_qt(float q[4]);
-float normalize_qt_qt(float q1[4], const float q2[4]);
+float normalize_qt_qt(float r[4], const float q[4]);
/* comparison */
bool is_zero_qt(const float q[4]);
@@ -221,10 +221,10 @@ void rotate_eulO(float eul[3], const short order, char axis, float angle);
void copy_dq_dq(DualQuat *r, const DualQuat *dq);
void normalize_dq(DualQuat *dq, float totw);
-void add_weighted_dq_dq(DualQuat *r, const DualQuat *dq, float weight);
+void add_weighted_dq_dq(DualQuat *dq_sum, const DualQuat *dq, float weight);
void mul_v3m3_dq(float r[3], float R[3][3], DualQuat *dq);
-void mat4_to_dquat(DualQuat *r, const float base[4][4], const float M[4][4]);
+void mat4_to_dquat(DualQuat *dq, const float basemat[4][4], const float mat[4][4]);
void dquat_to_mat4(float R[4][4], const DualQuat *dq);
void quat_apply_track(float quat[4], short axis, short upflag);
diff --git a/source/blender/blenlib/BLI_math_statistics.h b/source/blender/blenlib/BLI_math_statistics.h
index aebc445002b..ad6cb1a3c1e 100644
--- a/source/blender/blenlib/BLI_math_statistics.h
+++ b/source/blender/blenlib/BLI_math_statistics.h
@@ -39,7 +39,7 @@ extern "C" {
void BLI_covariance_m_vn_ex(const int n,
const float *cos_vn,
- const int nbr_cos_v3,
+ const int nbr_cos_vn,
const float *center,
const bool use_sample_correction,
float *r_covmat);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 1425e7da1bc..af39135f3d3 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -427,7 +427,7 @@ void ortho_v3_v3(float out[3], const float v[3]);
void ortho_v2_v2(float out[2], const float v[2]);
void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]);
void rotate_v2_v2fl(float r[2], const float p[2], const float angle);
-void rotate_v3_v3v3fl(float v[3], const float p[3], const float axis[3], const float angle);
+void rotate_v3_v3v3fl(float r[3], const float p[3], const float axis[3], const float angle);
void rotate_normalized_v3_v3v3fl(float out[3],
const float p[3],
const float axis[3],
@@ -435,9 +435,9 @@ void rotate_normalized_v3_v3v3fl(float out[3],
/*********************************** Other ***********************************/
-void print_v2(const char *str, const float a[2]);
-void print_v3(const char *str, const float a[3]);
-void print_v4(const char *str, const float a[4]);
+void print_v2(const char *str, const float v[2]);
+void print_v3(const char *str, const float v[3]);
+void print_v4(const char *str, const float v[4]);
void print_vn(const char *str, const float v[], const int n);
#define print_v2_id(v) print_v2(STRINGIFY(v), v)
diff --git a/source/blender/blenlib/BLI_memblock.h b/source/blender/blenlib/BLI_memblock.h
index cb6b31d54e0..a9a3928394d 100644
--- a/source/blender/blenlib/BLI_memblock.h
+++ b/source/blender/blenlib/BLI_memblock.h
@@ -38,7 +38,7 @@ typedef void (*MemblockValFreeFP)(void *val);
BLI_memblock *BLI_memblock_create_ex(uint elem_size, uint chunk_size) ATTR_WARN_UNUSED_RESULT;
void *BLI_memblock_alloc(BLI_memblock *mblk) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
-void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP valfreefp) ATTR_NONNULL(1);
+void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1);
void BLI_memblock_destroy(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1);
#define BLI_memblock_create(elem_size) BLI_memblock_create_ex(elem_size, BLI_MEM_BLOCK_CHUNK_SIZE)
@@ -53,7 +53,7 @@ typedef struct BLI_memblock_iter {
int elem_ofs;
} BLI_memblock_iter;
-void BLI_memblock_iternew(BLI_memblock *pool, BLI_memblock_iter *iter) ATTR_NONNULL();
+void BLI_memblock_iternew(BLI_memblock *mblk, BLI_memblock_iter *iter) ATTR_NONNULL();
void *BLI_memblock_iterstep(BLI_memblock_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void *BLI_memblock_elem_get(BLI_memblock *mblk, int chunk, int elem) ATTR_WARN_UNUSED_RESULT
diff --git a/source/blender/blenlib/BLI_mesh_boolean.hh b/source/blender/blenlib/BLI_mesh_boolean.hh
index cb6fc203dc7..94b2694893b 100644
--- a/source/blender/blenlib/BLI_mesh_boolean.hh
+++ b/source/blender/blenlib/BLI_mesh_boolean.hh
@@ -59,7 +59,7 @@ IMesh boolean_mesh(IMesh &imesh,
int nshapes,
std::function<int(int)> shape_fn,
bool use_self,
- IMesh *pm_triangulated,
+ IMesh *imesh_triangulated,
IMeshArena *arena);
/**
@@ -67,7 +67,7 @@ IMesh boolean_mesh(IMesh &imesh,
* It is exposed mainly for unit testing, at the moment: boolean_mesh() uses
* it to do most of its work.
*/
-IMesh boolean_trimesh(IMesh &trimesh,
+IMesh boolean_trimesh(IMesh &tm_in,
BoolOpType op,
int nshapes,
std::function<int(int)> shape_fn,
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 05c256ccf1c..2a56d11276a 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -43,7 +43,7 @@ const char *BLI_path_extension(const char *filepath) ATTR_NONNULL();
void BLI_path_append(char *__restrict dst, const size_t maxlen, const char *__restrict file)
ATTR_NONNULL();
-void BLI_join_dirfile(char *__restrict string,
+void BLI_join_dirfile(char *__restrict dst,
const size_t maxlen,
const char *__restrict dir,
const char *__restrict file) ATTR_NONNULL();
@@ -77,7 +77,10 @@ bool BLI_path_extension_glob_validate(char *ext_fnmatch) ATTR_NONNULL();
bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext) ATTR_NONNULL();
bool BLI_path_extension_ensure(char *path, size_t maxlen, const char *ext) ATTR_NONNULL();
bool BLI_path_filename_ensure(char *filepath, size_t maxlen, const char *filename) ATTR_NONNULL();
-int BLI_path_sequence_decode(const char *string, char *head, char *start, unsigned short *numlen);
+int BLI_path_sequence_decode(const char *string,
+ char *head,
+ char *tail,
+ unsigned short *r_num_len);
void BLI_path_sequence_encode(
char *string, const char *head, const char *tail, unsigned short numlen, int pic);
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index ae3eb9d2144..1d15a10ebc0 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -105,8 +105,8 @@ bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], const flo
bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], const float radius);
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b);
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b);
-void BLI_rcti_union(struct rcti *rcti1, const struct rcti *rcti2);
-void BLI_rctf_union(struct rctf *rctf1, const struct rctf *rctf2);
+void BLI_rcti_union(struct rcti *rct1, const struct rcti *rct2);
+void BLI_rctf_union(struct rctf *rct1, const struct rctf *rct2);
void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src);
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src);
void BLI_rcti_rctf_copy_floor(struct rcti *dst, const struct rctf *src);
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 4968b4ee159..6434464a012 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -73,7 +73,7 @@ size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict
size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
ATTR_NONNULL(1, 3) ATTR_PRINTF_FORMAT(3, 4);
-size_t BLI_vsnprintf(char *__restrict dst,
+size_t BLI_vsnprintf(char *__restrict buffer,
size_t maxncpy,
const char *__restrict format,
va_list arg) ATTR_PRINTF_FORMAT(3, 0);
@@ -90,7 +90,8 @@ size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const siz
size_t BLI_str_format_int_grouped(char dst[16], int num) ATTR_NONNULL();
size_t BLI_str_format_uint64_grouped(char dst[16], uint64_t num) ATTR_NONNULL();
-void BLI_str_format_byte_unit(char dst[15], long long int size, const bool base_10) ATTR_NONNULL();
+void BLI_str_format_byte_unit(char dst[15], long long int bytes, const bool base_10)
+ ATTR_NONNULL();
int BLI_strcaseeq(const char *a, const char *b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
char *BLI_strcasestr(const char *s, const char *find) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h
index 3620a3ccc55..b633bbfa435 100644
--- a/source/blender/blenlib/BLI_string_utf8.h
+++ b/source/blender/blenlib/BLI_string_utf8.h
@@ -67,10 +67,10 @@ size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, size_t *r_len_
size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen) ATTR_NONNULL();
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst,
const wchar_t *__restrict src,
- const size_t maxcpy) ATTR_NONNULL();
+ const size_t maxncpy) ATTR_NONNULL();
size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst,
const char *__restrict src,
- const size_t maxcpy) ATTR_NONNULL();
+ const size_t maxncpy) ATTR_NONNULL();
/* count columns that character/string occupies, based on wcwidth.c */
int BLI_wcwidth(char32_t ucs);
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index eee304a9b72..838993583a2 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -308,7 +308,7 @@ void BLI_task_graph_work_and_wait(struct TaskGraph *task_graph);
void BLI_task_graph_free(struct TaskGraph *task_graph);
struct TaskNode *BLI_task_graph_node_create(struct TaskGraph *task_graph,
TaskGraphNodeRunFunction run,
- void *task_data,
+ void *user_data,
TaskGraphNodeFreeFunction free_func);
bool BLI_task_graph_node_push_work(struct TaskNode *task_node);
void BLI_task_graph_edge_create(struct TaskNode *from_node, struct TaskNode *to_node);
diff --git a/source/blender/blenlib/BLI_timecode.h b/source/blender/blenlib/BLI_timecode.h
index 1dff50efa23..12f4f93f700 100644
--- a/source/blender/blenlib/BLI_timecode.h
+++ b/source/blender/blenlib/BLI_timecode.h
@@ -30,18 +30,18 @@ extern "C" {
#endif
size_t BLI_timecode_string_from_time(char *str,
- const size_t len,
+ const size_t maxncpy,
const int brevity_level,
const float time_seconds,
const double scene_fps,
const short timecode_style) ATTR_NONNULL();
size_t BLI_timecode_string_from_time_simple(char *str,
- const size_t maxlen,
+ const size_t maxncpy,
const double time_seconds) ATTR_NONNULL();
size_t BLI_timecode_string_from_time_seconds(char *str,
- const size_t len,
+ const size_t maxncpy,
const int brevity_level,
const float time_seconds) ATTR_NONNULL();
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index f8d78213980..c39d8a05d08 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -393,14 +393,14 @@ void BLI_heap_node_value_update_ptr(Heap *heap, HeapNode *node, float value, voi
}
}
-float BLI_heap_node_value(const HeapNode *node)
+float BLI_heap_node_value(const HeapNode *heap)
{
- return node->value;
+ return heap->value;
}
-void *BLI_heap_node_ptr(const HeapNode *node)
+void *BLI_heap_node_ptr(const HeapNode *heap)
{
- return node->ptr;
+ return heap->ptr;
}
static bool heap_is_minheap(const Heap *heap, uint root)
diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c
index e9ef5e2a927..2da2bbbc2a5 100644
--- a/source/blender/blenlib/intern/array_utils.c
+++ b/source/blender/blenlib/intern/array_utils.c
@@ -88,7 +88,7 @@ void _bli_array_wrap(void *arr_v, unsigned int arr_len, size_t arr_stride, int d
*
* Access via #BLI_array_wrap
*/
-void _bli_array_permute(void *arr_v,
+void _bli_array_permute(void *arr,
const unsigned int arr_len,
const size_t arr_stride,
const unsigned int *order,
@@ -106,11 +106,11 @@ void _bli_array_permute(void *arr_v,
arr_orig = arr_temp;
}
- memcpy(arr_orig, arr_v, len);
+ memcpy(arr_orig, arr, len);
for (i = 0; i < arr_len; i++) {
BLI_assert(order[i] < arr_len);
- memcpy(POINTER_OFFSET(arr_v, arr_stride_uint * i),
+ memcpy(POINTER_OFFSET(arr, arr_stride_uint * i),
POINTER_OFFSET(arr_orig, arr_stride_uint * order[i]),
arr_stride);
}
diff --git a/source/blender/blenlib/intern/gsqueue.c b/source/blender/blenlib/intern/gsqueue.c
index 36040536cac..118d19418d4 100644
--- a/source/blender/blenlib/intern/gsqueue.c
+++ b/source/blender/blenlib/intern/gsqueue.c
@@ -114,12 +114,12 @@ void BLI_gsqueue_free(GSQueue *queue)
/**
* Copies the source value onto the end of the queue
*
- * \note This copies #GSQueue.elem_size bytes from \a src,
+ * \note This copies #GSQueue.elem_size bytes from \a item,
* (the pointer itself is not stored).
*
- * \param src: source data to be copied to the queue.
+ * \param item: source data to be copied to the queue.
*/
-void BLI_gsqueue_push(GSQueue *queue, const void *src)
+void BLI_gsqueue_push(GSQueue *queue, const void *item)
{
queue->chunk_last_index++;
queue->totelem++;
@@ -150,20 +150,20 @@ void BLI_gsqueue_push(GSQueue *queue, const void *src)
BLI_assert(queue->chunk_last_index < queue->chunk_elem_max);
/* Return last of queue */
- memcpy(queue_get_last_elem(queue), src, queue->elem_size);
+ memcpy(queue_get_last_elem(queue), item, queue->elem_size);
}
/**
* Retrieves and removes the first element from the queue.
- * The value is copies to \a dst, which must be at least \a elem_size bytes.
+ * The value is copies to \a r_item, which must be at least \a elem_size bytes.
*
* Does not reduce amount of allocated memory.
*/
-void BLI_gsqueue_pop(GSQueue *queue, void *dst)
+void BLI_gsqueue_pop(GSQueue *queue, void *r_item)
{
BLI_assert(BLI_gsqueue_is_empty(queue) == false);
- memcpy(dst, queue_get_first_elem(queue), queue->elem_size);
+ memcpy(r_item, queue_get_first_elem(queue), queue->elem_size);
queue->chunk_first_index++;
queue->totelem--;
diff --git a/source/blender/blenlib/intern/hash_mm3.c b/source/blender/blenlib/intern/hash_mm3.c
index e557789a5fd..4a175f67f30 100644
--- a/source/blender/blenlib/intern/hash_mm3.c
+++ b/source/blender/blenlib/intern/hash_mm3.c
@@ -83,9 +83,9 @@ BLI_INLINE uint64_t fmix64(uint64_t k)
return k;
}
-uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
+uint32_t BLI_hash_mm3(const unsigned char *data, size_t len, uint32_t seed)
{
- const uint8_t *data = (const uint8_t *)in;
+ const uint8_t *in_data = (const uint8_t *)data;
const int nblocks = len / 4;
uint32_t h1 = seed;
@@ -95,7 +95,7 @@ uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
/* body */
- const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4);
+ const uint32_t *blocks = (const uint32_t *)(in_data + nblocks * 4);
for (int i = -nblocks; i; i++) {
uint32_t k1 = getblock32(blocks, i);
@@ -111,7 +111,7 @@ uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
/* tail */
- const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
+ const uint8_t *tail = (const uint8_t *)(in_data + nblocks * 4);
uint32_t k1 = 0;
diff --git a/source/blender/blenlib/intern/jitter_2d.c b/source/blender/blenlib/intern/jitter_2d.c
index a5b13caf985..c92aeddb27d 100644
--- a/source/blender/blenlib/intern/jitter_2d.c
+++ b/source/blender/blenlib/intern/jitter_2d.c
@@ -31,7 +31,7 @@
#include "BLI_strict_flags.h"
-void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float rad1)
+void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float radius1)
{
int i, j, k;
float vecx, vecy, dvecx, dvecy, x, y, len;
@@ -45,30 +45,30 @@ void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float rad1)
vecx = jit1[j][0] - x - 1.0f;
vecy = jit1[j][1] - y - 1.0f;
for (k = 3; k > 0; k--) {
- if (fabsf(vecx) < rad1 && fabsf(vecy) < rad1) {
+ if (fabsf(vecx) < radius1 && fabsf(vecy) < radius1) {
len = sqrtf(vecx * vecx + vecy * vecy);
- if (len > 0 && len < rad1) {
- len = len / rad1;
+ if (len > 0 && len < radius1) {
+ len = len / radius1;
dvecx += vecx / len;
dvecy += vecy / len;
}
}
vecx += 1.0f;
- if (fabsf(vecx) < rad1 && fabsf(vecy) < rad1) {
+ if (fabsf(vecx) < radius1 && fabsf(vecy) < radius1) {
len = sqrtf(vecx * vecx + vecy * vecy);
- if (len > 0 && len < rad1) {
- len = len / rad1;
+ if (len > 0 && len < radius1) {
+ len = len / radius1;
dvecx += vecx / len;
dvecy += vecy / len;
}
}
vecx += 1.0f;
- if (fabsf(vecx) < rad1 && fabsf(vecy) < rad1) {
+ if (fabsf(vecx) < radius1 && fabsf(vecy) < radius1) {
len = sqrtf(vecx * vecx + vecy * vecy);
- if (len > 0 && len < rad1) {
- len = len / rad1;
+ if (len > 0 && len < radius1) {
+ len = len / radius1;
dvecx += vecx / len;
dvecy += vecy / len;
}
@@ -89,7 +89,7 @@ void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float rad1)
memcpy(jit1, jit2, 2 * (unsigned int)num * sizeof(float));
}
-void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float rad2)
+void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float radius2)
{
int i, j;
float vecx, vecy, dvecx, dvecy, x, y;
@@ -103,28 +103,28 @@ void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float rad2)
vecx = jit1[j][0] - x - 1.0f;
vecy = jit1[j][1] - y - 1.0f;
- if (fabsf(vecx) < rad2) {
- dvecx += vecx * rad2;
+ if (fabsf(vecx) < radius2) {
+ dvecx += vecx * radius2;
}
vecx += 1.0f;
- if (fabsf(vecx) < rad2) {
- dvecx += vecx * rad2;
+ if (fabsf(vecx) < radius2) {
+ dvecx += vecx * radius2;
}
vecx += 1.0f;
- if (fabsf(vecx) < rad2) {
- dvecx += vecx * rad2;
+ if (fabsf(vecx) < radius2) {
+ dvecx += vecx * radius2;
}
- if (fabsf(vecy) < rad2) {
- dvecy += vecy * rad2;
+ if (fabsf(vecy) < radius2) {
+ dvecy += vecy * radius2;
}
vecy += 1.0f;
- if (fabsf(vecy) < rad2) {
- dvecy += vecy * rad2;
+ if (fabsf(vecy) < radius2) {
+ dvecy += vecy * radius2;
}
vecy += 1.0f;
- if (fabsf(vecy) < rad2) {
- dvecy += vecy * rad2;
+ if (fabsf(vecy) < radius2) {
+ dvecy += vecy * radius2;
}
}
}
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 1afcf83bf73..9cf1341b16a 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -802,14 +802,14 @@ float dist_squared_ray_to_aabb_v3(const struct DistRayAABB_Precalc *data,
float dist_squared_ray_to_aabb_v3_simple(const float ray_origin[3],
const float ray_direction[3],
- const float bbmin[3],
- const float bbmax[3],
+ const float bb_min[3],
+ const float bb_max[3],
float r_point[3],
float *r_depth)
{
struct DistRayAABB_Precalc data;
dist_squared_ray_to_aabb_v3_precalc(&data, ray_origin, ray_direction);
- return dist_squared_ray_to_aabb_v3(&data, bbmin, bbmax, r_point, r_depth);
+ return dist_squared_ray_to_aabb_v3(&data, bb_min, bb_max, r_point, r_depth);
}
/** \} */
@@ -1022,31 +1022,31 @@ float dist_squared_to_projected_aabb_simple(const float projmat[4][4],
*
* Set 'r' to the point in triangle (a, b, c) closest to point 'p' */
void closest_on_tri_to_point_v3(
- float r[3], const float p[3], const float a[3], const float b[3], const float c[3])
+ float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
{
float ab[3], ac[3], ap[3], d1, d2;
float bp[3], d3, d4, vc, cp[3], d5, d6, vb, va;
float denom, v, w;
/* Check if P in vertex region outside A */
- sub_v3_v3v3(ab, b, a);
- sub_v3_v3v3(ac, c, a);
- sub_v3_v3v3(ap, p, a);
+ sub_v3_v3v3(ab, v2, v1);
+ sub_v3_v3v3(ac, v3, v1);
+ sub_v3_v3v3(ap, p, v1);
d1 = dot_v3v3(ab, ap);
d2 = dot_v3v3(ac, ap);
if (d1 <= 0.0f && d2 <= 0.0f) {
/* barycentric coordinates (1,0,0) */
- copy_v3_v3(r, a);
+ copy_v3_v3(r, v1);
return;
}
/* Check if P in vertex region outside B */
- sub_v3_v3v3(bp, p, b);
+ sub_v3_v3v3(bp, p, v2);
d3 = dot_v3v3(ab, bp);
d4 = dot_v3v3(ac, bp);
if (d3 >= 0.0f && d4 <= d3) {
/* barycentric coordinates (0,1,0) */
- copy_v3_v3(r, b);
+ copy_v3_v3(r, v2);
return;
}
/* Check if P in edge region of AB, if so return projection of P onto AB */
@@ -1054,16 +1054,16 @@ void closest_on_tri_to_point_v3(
if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) {
v = d1 / (d1 - d3);
/* barycentric coordinates (1-v,v,0) */
- madd_v3_v3v3fl(r, a, ab, v);
+ madd_v3_v3v3fl(r, v1, ab, v);
return;
}
/* Check if P in vertex region outside C */
- sub_v3_v3v3(cp, p, c);
+ sub_v3_v3v3(cp, p, v3);
d5 = dot_v3v3(ab, cp);
d6 = dot_v3v3(ac, cp);
if (d6 >= 0.0f && d5 <= d6) {
/* barycentric coordinates (0,0,1) */
- copy_v3_v3(r, c);
+ copy_v3_v3(r, v3);
return;
}
/* Check if P in edge region of AC, if so return projection of P onto AC */
@@ -1071,7 +1071,7 @@ void closest_on_tri_to_point_v3(
if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) {
w = d2 / (d2 - d6);
/* barycentric coordinates (1-w,0,w) */
- madd_v3_v3v3fl(r, a, ac, w);
+ madd_v3_v3v3fl(r, v1, ac, w);
return;
}
/* Check if P in edge region of BC, if so return projection of P onto BC */
@@ -1079,9 +1079,9 @@ void closest_on_tri_to_point_v3(
if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) {
w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
/* barycentric coordinates (0,1-w,w) */
- sub_v3_v3v3(r, c, b);
+ sub_v3_v3v3(r, v3, v2);
mul_v3_fl(r, w);
- add_v3_v3(r, b);
+ add_v3_v3(r, v2);
return;
}
@@ -1094,7 +1094,7 @@ void closest_on_tri_to_point_v3(
/* ac * w */
mul_v3_fl(ac, w);
/* a + ab * v */
- madd_v3_v3v3fl(r, a, ab, v);
+ madd_v3_v3v3fl(r, v1, ab, v);
/* a + ab * v + ac * w */
add_v3_v3(r, ac);
}
@@ -4972,28 +4972,28 @@ void projmat_from_subregion(const float projmat[4][4],
}
}
-static void i_multmatrix(const float icand[4][4], float Vm[4][4])
+static void i_multmatrix(const float icand[4][4], float mat[4][4])
{
int row, col;
float temp[4][4];
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++) {
- temp[row][col] = (icand[row][0] * Vm[0][col] + icand[row][1] * Vm[1][col] +
- icand[row][2] * Vm[2][col] + icand[row][3] * Vm[3][col]);
+ temp[row][col] = (icand[row][0] * mat[0][col] + icand[row][1] * mat[1][col] +
+ icand[row][2] * mat[2][col] + icand[row][3] * mat[3][col]);
}
}
- copy_m4_m4(Vm, temp);
+ copy_m4_m4(mat, temp);
}
-void polarview_m4(float Vm[4][4], float dist, float azimuth, float incidence, float twist)
+void polarview_m4(float mat[4][4], float dist, float azimuth, float incidence, float twist)
{
- unit_m4(Vm);
+ unit_m4(mat);
- translate_m4(Vm, 0.0, 0.0, -dist);
- rotate_m4(Vm, 'Z', -twist);
- rotate_m4(Vm, 'X', -incidence);
- rotate_m4(Vm, 'Z', -azimuth);
+ translate_m4(mat, 0.0, 0.0, -dist);
+ rotate_m4(mat, 'Z', -twist);
+ rotate_m4(mat, 'X', -incidence);
+ rotate_m4(mat, 'Z', -azimuth);
}
void lookat_m4(
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index f523bd07c09..08c7d3b1e91 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -204,20 +204,20 @@ void copy_m4d_m4(double m1[4][4], const float m2[4][4])
m1[3][3] = m2[3][3];
}
-void copy_m3_m3d(float R[3][3], const double A[3][3])
+void copy_m3_m3d(float m1[3][3], const double m2[3][3])
{
/* Keep it stupid simple for better data flow in CPU. */
- R[0][0] = (float)A[0][0];
- R[0][1] = (float)A[0][1];
- R[0][2] = (float)A[0][2];
+ m1[0][0] = (float)m2[0][0];
+ m1[0][1] = (float)m2[0][1];
+ m1[0][2] = (float)m2[0][2];
- R[1][0] = (float)A[1][0];
- R[1][1] = (float)A[1][1];
- R[1][2] = (float)A[1][2];
+ m1[1][0] = (float)m2[1][0];
+ m1[1][1] = (float)m2[1][1];
+ m1[1][2] = (float)m2[1][2];
- R[2][0] = (float)A[2][0];
- R[2][1] = (float)A[2][1];
- R[2][2] = (float)A[2][2];
+ m1[2][0] = (float)m2[2][0];
+ m1[2][1] = (float)m2[2][1];
+ m1[2][2] = (float)m2[2][2];
}
void swap_m3m3(float m1[3][3], float m2[3][3])
@@ -435,105 +435,105 @@ void mul_m3_m3m3_uniq(float R[3][3], const float A[3][3], const float B[3][3])
R[2][2] = B[2][0] * A[0][2] + B[2][1] * A[1][2] + B[2][2] * A[2][2];
}
-void mul_m4_m4m3(float m1[4][4], const float m3_[4][4], const float m2_[3][3])
+void mul_m4_m4m3(float R[4][4], const float A[4][4], const float B[3][3])
{
- float m2[3][3], m3[4][4];
+ float B_[3][3], A_[4][4];
- /* copy so it works when m1 is the same pointer as m2 or m3 */
+ /* copy so it works when R is the same pointer as A or B */
/* TODO: avoid copying when matrices are different */
- copy_m3_m3(m2, m2_);
- copy_m4_m4(m3, m3_);
+ copy_m4_m4(A_, A);
+ copy_m3_m3(B_, B);
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ 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];
+ R[0][2] = B_[0][0] * A_[0][2] + B_[0][1] * A_[1][2] + B_[0][2] * A_[2][2];
+ R[1][0] = B_[1][0] * A_[0][0] + B_[1][1] * A_[1][0] + B_[1][2] * A_[2][0];
+ R[1][1] = B_[1][0] * A_[0][1] + B_[1][1] * A_[1][1] + B_[1][2] * A_[2][1];
+ R[1][2] = B_[1][0] * A_[0][2] + B_[1][1] * A_[1][2] + B_[1][2] * A_[2][2];
+ R[2][0] = B_[2][0] * A_[0][0] + B_[2][1] * A_[1][0] + B_[2][2] * A_[2][0];
+ R[2][1] = B_[2][0] * A_[0][1] + B_[2][1] * A_[1][1] + B_[2][2] * A_[2][1];
+ R[2][2] = B_[2][0] * A_[0][2] + B_[2][1] * A_[1][2] + B_[2][2] * A_[2][2];
}
-/* m1 = m2 * m3, ignore the elements on the 4th row/column of m2 */
-void mul_m3_m3m4(float m1[3][3], const float m3_[3][3], const float m2_[4][4])
+/* R = A * B, ignore the elements on the 4th row/column of A */
+void mul_m3_m3m4(float R[3][3], const float A[3][3], const float B[4][4])
{
- float m2[4][4], m3[3][3];
+ float B_[4][4], A_[3][3];
- /* copy so it works when m1 is the same pointer as m2 or m3 */
+ /* copy so it works when R is the same pointer as A or B */
/* TODO: avoid copying when matrices are different */
- copy_m4_m4(m2, m2_);
- copy_m3_m3(m3, m3_);
+ copy_m3_m3(A_, A);
+ copy_m4_m4(B_, B);
- /* m1[i][j] = m2[i][k] * m3[k][j] */
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
+ /* R[i][j] = B_[i][k] * A_[k][j] */
+ 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];
+ R[0][2] = B_[0][0] * A_[0][2] + B_[0][1] * A_[1][2] + B_[0][2] * A_[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
+ R[1][0] = B_[1][0] * A_[0][0] + B_[1][1] * A_[1][0] + B_[1][2] * A_[2][0];
+ R[1][1] = B_[1][0] * A_[0][1] + B_[1][1] * A_[1][1] + B_[1][2] * A_[2][1];
+ R[1][2] = B_[1][0] * A_[0][2] + B_[1][1] * A_[1][2] + B_[1][2] * A_[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ R[2][0] = B_[2][0] * A_[0][0] + B_[2][1] * A_[1][0] + B_[2][2] * A_[2][0];
+ R[2][1] = B_[2][0] * A_[0][1] + B_[2][1] * A_[1][1] + B_[2][2] * A_[2][1];
+ R[2][2] = B_[2][0] * A_[0][2] + B_[2][1] * A_[1][2] + B_[2][2] * A_[2][2];
}
-/* m1 = m2 * m3, ignore the elements on the 4th row/column of m3 */
-void mul_m3_m4m3(float m1[3][3], const float m3_[4][4], const float m2_[3][3])
+/* R = A * B, ignore the elements on the 4th row/column of B */
+void mul_m3_m4m3(float R[3][3], const float A[4][4], const float B[3][3])
{
- float m2[3][3], m3[4][4];
+ float B_[3][3], A_[4][4];
- /* copy so it works when m1 is the same pointer as m2 or m3 */
+ /* copy so it works when R is the same pointer as A or B */
/* TODO: avoid copying when matrices are different */
- copy_m3_m3(m2, m2_);
- copy_m4_m4(m3, m3_);
+ copy_m4_m4(A_, A);
+ copy_m3_m3(B_, B);
- /* m1[i][j] = m2[i][k] * m3[k][j] */
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
+ /* R[i][j] = B[i][k] * A[k][j] */
+ 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];
+ R[0][2] = B_[0][0] * A_[0][2] + B_[0][1] * A_[1][2] + B_[0][2] * A_[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
+ R[1][0] = B_[1][0] * A_[0][0] + B_[1][1] * A_[1][0] + B_[1][2] * A_[2][0];
+ R[1][1] = B_[1][0] * A_[0][1] + B_[1][1] * A_[1][1] + B_[1][2] * A_[2][1];
+ R[1][2] = B_[1][0] * A_[0][2] + B_[1][1] * A_[1][2] + B_[1][2] * A_[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ R[2][0] = B_[2][0] * A_[0][0] + B_[2][1] * A_[1][0] + B_[2][2] * A_[2][0];
+ R[2][1] = B_[2][0] * A_[0][1] + B_[2][1] * A_[1][1] + B_[2][2] * A_[2][1];
+ R[2][2] = B_[2][0] * A_[0][2] + B_[2][1] * A_[1][2] + B_[2][2] * A_[2][2];
}
-void mul_m4_m3m4(float m1[4][4], const float m3_[3][3], const float m2_[4][4])
+void mul_m4_m3m4(float R[4][4], const float A[3][3], const float B[4][4])
{
- float m2[4][4], m3[3][3];
+ float B_[4][4], A_[3][3];
- /* copy so it works when m1 is the same pointer as m2 or m3 */
+ /* copy so it works when R is the same pointer as A or B */
/* TODO: avoid copying when matrices are different */
- copy_m4_m4(m2, m2_);
- copy_m3_m3(m3, m3_);
+ copy_m3_m3(A_, A);
+ copy_m4_m4(B_, B);
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ 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];
+ R[0][2] = B_[0][0] * A_[0][2] + B_[0][1] * A_[1][2] + B_[0][2] * A_[2][2];
+ R[1][0] = B_[1][0] * A_[0][0] + B_[1][1] * A_[1][0] + B_[1][2] * A_[2][0];
+ R[1][1] = B_[1][0] * A_[0][1] + B_[1][1] * A_[1][1] + B_[1][2] * A_[2][1];
+ R[1][2] = B_[1][0] * A_[0][2] + B_[1][1] * A_[1][2] + B_[1][2] * A_[2][2];
+ R[2][0] = B_[2][0] * A_[0][0] + B_[2][1] * A_[1][0] + B_[2][2] * A_[2][0];
+ R[2][1] = B_[2][0] * A_[0][1] + B_[2][1] * A_[1][1] + B_[2][2] * A_[2][1];
+ R[2][2] = B_[2][0] * A_[0][2] + B_[2][1] * A_[1][2] + B_[2][2] * A_[2][2];
}
-void mul_m3_m4m4(float m1[3][3], const float m3[4][4], const float m2[4][4])
+void mul_m3_m4m4(float R[3][3], const float A[4][4], const float B[4][4])
{
- m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0];
- m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1];
- m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2];
- m1[1][0] = m2[1][0] * m3[0][0] + m2[1][1] * m3[1][0] + m2[1][2] * m3[2][0];
- m1[1][1] = m2[1][0] * m3[0][1] + m2[1][1] * m3[1][1] + m2[1][2] * m3[2][1];
- m1[1][2] = m2[1][0] * m3[0][2] + m2[1][1] * m3[1][2] + m2[1][2] * m3[2][2];
- m1[2][0] = m2[2][0] * m3[0][0] + m2[2][1] * m3[1][0] + m2[2][2] * m3[2][0];
- m1[2][1] = m2[2][0] * m3[0][1] + m2[2][1] * m3[1][1] + m2[2][2] * m3[2][1];
- m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2];
+ 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];
+ R[0][2] = B[0][0] * A[0][2] + B[0][1] * A[1][2] + B[0][2] * A[2][2];
+ R[1][0] = B[1][0] * A[0][0] + B[1][1] * A[1][0] + B[1][2] * A[2][0];
+ R[1][1] = B[1][0] * A[0][1] + B[1][1] * A[1][1] + B[1][2] * A[2][1];
+ R[1][2] = B[1][0] * A[0][2] + B[1][1] * A[1][2] + B[1][2] * A[2][2];
+ R[2][0] = B[2][0] * A[0][0] + B[2][1] * A[1][0] + B[2][2] * A[2][0];
+ R[2][1] = B[2][0] * A[0][1] + B[2][1] * A[1][1] + B[2][2] * A[2][1];
+ 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
@@ -726,14 +726,14 @@ void mul_m3_v2(const float m[3][3], float r[2])
mul_v2_m3v2(r, m, r);
}
-void mul_m4_v3(const float mat[4][4], float vec[3])
+void mul_m4_v3(const float M[4][4], float r[3])
{
- const float x = vec[0];
- const float y = vec[1];
+ const float x = r[0];
+ const float y = r[1];
- vec[0] = x * mat[0][0] + y * mat[1][0] + mat[2][0] * vec[2] + mat[3][0];
- vec[1] = x * mat[0][1] + y * mat[1][1] + mat[2][1] * vec[2] + mat[3][1];
- vec[2] = x * mat[0][2] + y * mat[1][2] + mat[2][2] * vec[2] + mat[3][2];
+ r[0] = x * M[0][0] + y * M[1][0] + M[2][0] * r[2] + M[3][0];
+ r[1] = x * M[0][1] + y * M[1][1] + M[2][1] * r[2] + M[3][1];
+ r[2] = x * M[0][2] + y * M[1][2] + M[2][2] * r[2] + M[3][2];
}
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
@@ -788,14 +788,14 @@ void mul_m2_v2(const float mat[2][2], float vec[2])
}
/** Same as #mul_m4_v3() but doesn't apply translation component. */
-void mul_mat3_m4_v3(const float mat[4][4], float vec[3])
+void mul_mat3_m4_v3(const float M[4][4], float r[3])
{
- const float x = vec[0];
- const float y = vec[1];
+ const float x = r[0];
+ const float y = r[1];
- vec[0] = x * mat[0][0] + y * mat[1][0] + mat[2][0] * vec[2];
- vec[1] = x * mat[0][1] + y * mat[1][1] + mat[2][1] * vec[2];
- vec[2] = x * mat[0][2] + y * mat[1][2] + mat[2][2] * vec[2];
+ r[0] = x * M[0][0] + y * M[1][0] + M[2][0] * r[2];
+ r[1] = x * M[0][1] + y * M[1][1] + M[2][1] * r[2];
+ r[2] = x * M[0][2] + y * M[1][2] + M[2][2] * r[2];
}
void mul_v3_mat3_m4v3(float r[3], const float mat[4][4], const float vec[3])
@@ -934,164 +934,164 @@ void mul_m3_v3_db(const double M[3][3], double r[3])
mul_v3_m3v3_db(r, M, (const double[3]){UNPACK3(r)});
}
-void mul_transposed_m3_v3(const float mat[3][3], float vec[3])
+void mul_transposed_m3_v3(const float M[3][3], float r[3])
{
- const float x = vec[0];
- const float y = vec[1];
+ const float x = r[0];
+ const float y = r[1];
- vec[0] = x * mat[0][0] + y * mat[0][1] + mat[0][2] * vec[2];
- vec[1] = x * mat[1][0] + y * mat[1][1] + mat[1][2] * vec[2];
- vec[2] = x * mat[2][0] + y * mat[2][1] + mat[2][2] * vec[2];
+ r[0] = x * M[0][0] + y * M[0][1] + M[0][2] * r[2];
+ r[1] = x * M[1][0] + y * M[1][1] + M[1][2] * r[2];
+ r[2] = x * M[2][0] + y * M[2][1] + M[2][2] * r[2];
}
-void mul_transposed_mat3_m4_v3(const float mat[4][4], float vec[3])
+void mul_transposed_mat3_m4_v3(const float M[4][4], float r[3])
{
- const float x = vec[0];
- const float y = vec[1];
+ const float x = r[0];
+ const float y = r[1];
- vec[0] = x * mat[0][0] + y * mat[0][1] + mat[0][2] * vec[2];
- vec[1] = x * mat[1][0] + y * mat[1][1] + mat[1][2] * vec[2];
- vec[2] = x * mat[2][0] + y * mat[2][1] + mat[2][2] * vec[2];
+ r[0] = x * M[0][0] + y * M[0][1] + M[0][2] * r[2];
+ r[1] = x * M[1][0] + y * M[1][1] + M[1][2] * r[2];
+ r[2] = x * M[2][0] + y * M[2][1] + M[2][2] * r[2];
}
-void mul_m3_fl(float m[3][3], float f)
+void mul_m3_fl(float R[3][3], float f)
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m[i][j] *= f;
+ R[i][j] *= f;
}
}
}
-void mul_m4_fl(float m[4][4], float f)
+void mul_m4_fl(float R[4][4], float f)
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m[i][j] *= f;
+ R[i][j] *= f;
}
}
}
-void mul_mat3_m4_fl(float m[4][4], float f)
+void mul_mat3_m4_fl(float R[4][4], float f)
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m[i][j] *= f;
+ R[i][j] *= f;
}
}
}
-void negate_m3(float m[3][3])
+void negate_m3(float R[3][3])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m[i][j] *= -1.0f;
+ R[i][j] *= -1.0f;
}
}
}
-void negate_mat3_m4(float m[4][4])
+void negate_mat3_m4(float R[4][4])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m[i][j] *= -1.0f;
+ R[i][j] *= -1.0f;
}
}
}
-void negate_m4(float m[4][4])
+void negate_m4(float R[4][4])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m[i][j] *= -1.0f;
+ R[i][j] *= -1.0f;
}
}
}
-void mul_m3_v3_double(const float mat[3][3], double vec[3])
+void mul_m3_v3_double(const float M[3][3], double r[3])
{
- const double x = vec[0];
- const double y = vec[1];
+ const double x = r[0];
+ const double y = r[1];
- vec[0] = x * (double)mat[0][0] + y * (double)mat[1][0] + (double)mat[2][0] * vec[2];
- vec[1] = x * (double)mat[0][1] + y * (double)mat[1][1] + (double)mat[2][1] * vec[2];
- vec[2] = x * (double)mat[0][2] + y * (double)mat[1][2] + (double)mat[2][2] * vec[2];
+ r[0] = x * (double)M[0][0] + y * (double)M[1][0] + (double)M[2][0] * r[2];
+ r[1] = x * (double)M[0][1] + y * (double)M[1][1] + (double)M[2][1] * r[2];
+ r[2] = x * (double)M[0][2] + y * (double)M[1][2] + (double)M[2][2] * r[2];
}
-void add_m3_m3m3(float m1[3][3], const float m2[3][3], const float m3[3][3])
+void add_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m1[i][j] = m2[i][j] + m3[i][j];
+ R[i][j] = A[i][j] + B[i][j];
}
}
}
-void add_m4_m4m4(float m1[4][4], const float m2[4][4], const float m3[4][4])
+void add_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m1[i][j] = m2[i][j] + m3[i][j];
+ R[i][j] = A[i][j] + B[i][j];
}
}
}
-void madd_m3_m3m3fl(float m1[3][3], const float m2[3][3], const float m3[3][3], const float f)
+void madd_m3_m3m3fl(float R[3][3], const float A[3][3], const float B[3][3], const float f)
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m1[i][j] = m2[i][j] + m3[i][j] * f;
+ R[i][j] = A[i][j] + B[i][j] * f;
}
}
}
-void madd_m4_m4m4fl(float m1[4][4], const float m2[4][4], const float m3[4][4], const float f)
+void madd_m4_m4m4fl(float R[4][4], const float A[4][4], const float B[4][4], const float f)
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m1[i][j] = m2[i][j] + m3[i][j] * f;
+ R[i][j] = A[i][j] + B[i][j] * f;
}
}
}
-void sub_m3_m3m3(float m1[3][3], const float m2[3][3], const float m3[3][3])
+void sub_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
- m1[i][j] = m2[i][j] - m3[i][j];
+ R[i][j] = A[i][j] - B[i][j];
}
}
}
-void sub_m4_m4m4(float m1[4][4], const float m2[4][4], const float m3[4][4])
+void sub_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- m1[i][j] = m2[i][j] - m3[i][j];
+ R[i][j] = A[i][j] - B[i][j];
}
}
}
@@ -1306,113 +1306,112 @@ void mul_m4_m4m4_aligned_scale(float R[4][4], const float A[4][4], const float B
/****************************** Linear Algebra *******************************/
-void transpose_m3(float mat[3][3])
+void transpose_m3(float R[3][3])
{
float t;
- t = mat[0][1];
- mat[0][1] = mat[1][0];
- mat[1][0] = t;
- t = mat[0][2];
- mat[0][2] = mat[2][0];
- mat[2][0] = t;
- t = mat[1][2];
- mat[1][2] = mat[2][1];
- mat[2][1] = t;
+ t = R[0][1];
+ R[0][1] = R[1][0];
+ R[1][0] = t;
+ t = R[0][2];
+ R[0][2] = R[2][0];
+ R[2][0] = t;
+ t = R[1][2];
+ R[1][2] = R[2][1];
+ R[2][1] = t;
}
-void transpose_m3_m3(float rmat[3][3], const float mat[3][3])
+void transpose_m3_m3(float R[3][3], const float M[3][3])
{
- BLI_assert(rmat != mat);
+ BLI_assert(R != M);
- rmat[0][0] = mat[0][0];
- rmat[0][1] = mat[1][0];
- rmat[0][2] = mat[2][0];
- rmat[1][0] = mat[0][1];
- rmat[1][1] = mat[1][1];
- rmat[1][2] = mat[2][1];
- rmat[2][0] = mat[0][2];
- rmat[2][1] = mat[1][2];
- rmat[2][2] = mat[2][2];
+ R[0][0] = M[0][0];
+ R[0][1] = M[1][0];
+ R[0][2] = M[2][0];
+ R[1][0] = M[0][1];
+ R[1][1] = M[1][1];
+ R[1][2] = M[2][1];
+ R[2][0] = M[0][2];
+ R[2][1] = M[1][2];
+ R[2][2] = M[2][2];
}
/* seems obscure but in-fact a common operation */
-void transpose_m3_m4(float rmat[3][3], const float mat[4][4])
+void transpose_m3_m4(float R[3][3], const float M[4][4])
{
- BLI_assert(&rmat[0][0] != &mat[0][0]);
+ BLI_assert(&R[0][0] != &M[0][0]);
- rmat[0][0] = mat[0][0];
- rmat[0][1] = mat[1][0];
- rmat[0][2] = mat[2][0];
- rmat[1][0] = mat[0][1];
- rmat[1][1] = mat[1][1];
- rmat[1][2] = mat[2][1];
- rmat[2][0] = mat[0][2];
- rmat[2][1] = mat[1][2];
- rmat[2][2] = mat[2][2];
+ R[0][0] = M[0][0];
+ R[0][1] = M[1][0];
+ R[0][2] = M[2][0];
+ R[1][0] = M[0][1];
+ R[1][1] = M[1][1];
+ R[1][2] = M[2][1];
+ R[2][0] = M[0][2];
+ R[2][1] = M[1][2];
+ R[2][2] = M[2][2];
}
-void transpose_m4(float mat[4][4])
+void transpose_m4(float R[4][4])
{
float t;
- t = mat[0][1];
- mat[0][1] = mat[1][0];
- mat[1][0] = t;
- t = mat[0][2];
- mat[0][2] = mat[2][0];
- mat[2][0] = t;
- t = mat[0][3];
- mat[0][3] = mat[3][0];
- mat[3][0] = t;
-
- t = mat[1][2];
- mat[1][2] = mat[2][1];
- mat[2][1] = t;
- t = mat[1][3];
- mat[1][3] = mat[3][1];
- mat[3][1] = t;
-
- t = mat[2][3];
- mat[2][3] = mat[3][2];
- mat[3][2] = t;
-}
-
-void transpose_m4_m4(float rmat[4][4], const float mat[4][4])
-{
- BLI_assert(rmat != mat);
-
- rmat[0][0] = mat[0][0];
- rmat[0][1] = mat[1][0];
- rmat[0][2] = mat[2][0];
- rmat[0][3] = mat[3][0];
- rmat[1][0] = mat[0][1];
- rmat[1][1] = mat[1][1];
- rmat[1][2] = mat[2][1];
- rmat[1][3] = mat[3][1];
- rmat[2][0] = mat[0][2];
- rmat[2][1] = mat[1][2];
- rmat[2][2] = mat[2][2];
- rmat[2][3] = mat[3][2];
- rmat[3][0] = mat[0][3];
- rmat[3][1] = mat[1][3];
- rmat[3][2] = mat[2][3];
- rmat[3][3] = mat[3][3];
-}
-
-/* TODO: return bool */
-int compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit)
+ t = R[0][1];
+ R[0][1] = R[1][0];
+ R[1][0] = t;
+ t = R[0][2];
+ R[0][2] = R[2][0];
+ R[2][0] = t;
+ t = R[0][3];
+ R[0][3] = R[3][0];
+ R[3][0] = t;
+
+ t = R[1][2];
+ R[1][2] = R[2][1];
+ R[2][1] = t;
+ t = R[1][3];
+ R[1][3] = R[3][1];
+ R[3][1] = t;
+
+ t = R[2][3];
+ R[2][3] = R[3][2];
+ R[3][2] = t;
+}
+
+void transpose_m4_m4(float R[4][4], const float M[4][4])
+{
+ BLI_assert(R != M);
+
+ R[0][0] = M[0][0];
+ R[0][1] = M[1][0];
+ R[0][2] = M[2][0];
+ R[0][3] = M[3][0];
+ R[1][0] = M[0][1];
+ R[1][1] = M[1][1];
+ R[1][2] = M[2][1];
+ R[1][3] = M[3][1];
+ R[2][0] = M[0][2];
+ R[2][1] = M[1][2];
+ R[2][2] = M[2][2];
+ R[2][3] = M[3][2];
+ R[3][0] = M[0][3];
+ R[3][1] = M[1][3];
+ R[3][2] = M[2][3];
+ R[3][3] = M[3][3];
+}
+
+bool compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit)
{
if (compare_v4v4(mat1[0], mat2[0], limit)) {
if (compare_v4v4(mat1[1], mat2[1], limit)) {
if (compare_v4v4(mat1[2], mat2[2], limit)) {
if (compare_v4v4(mat1[3], mat2[3], limit)) {
- return 1;
+ return true;
}
}
}
}
- return 0;
+ return false;
}
/**
@@ -1420,88 +1419,88 @@ int compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit)
*
* \param axis: Axis to build the orthonormal basis around.
*/
-void orthogonalize_m3(float mat[3][3], int axis)
+void orthogonalize_m3(float R[3][3], int axis)
{
float size[3];
- mat3_to_size(size, mat);
- normalize_v3(mat[axis]);
+ mat3_to_size(size, R);
+ normalize_v3(R[axis]);
switch (axis) {
case 0:
- if (dot_v3v3(mat[0], mat[1]) < 1) {
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ if (dot_v3v3(R[0], R[1]) < 1) {
+ cross_v3_v3v3(R[2], R[0], R[1]);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
- else if (dot_v3v3(mat[0], mat[2]) < 1) {
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
- normalize_v3(mat[1]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ else if (dot_v3v3(R[0], R[2]) < 1) {
+ cross_v3_v3v3(R[1], R[2], R[0]);
+ normalize_v3(R[1]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
else {
float vec[3];
- vec[0] = mat[0][1];
- vec[1] = mat[0][2];
- vec[2] = mat[0][0];
+ vec[0] = R[0][1];
+ vec[1] = R[0][2];
+ vec[2] = R[0][0];
- cross_v3_v3v3(mat[2], mat[0], vec);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ cross_v3_v3v3(R[2], R[0], vec);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
break;
case 1:
- if (dot_v3v3(mat[1], mat[0]) < 1) {
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
+ if (dot_v3v3(R[1], R[0]) < 1) {
+ cross_v3_v3v3(R[2], R[0], R[1]);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[0], R[1], R[2]);
}
- else if (dot_v3v3(mat[0], mat[2]) < 1) {
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ else if (dot_v3v3(R[0], R[2]) < 1) {
+ cross_v3_v3v3(R[0], R[1], R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
else {
float vec[3];
- vec[0] = mat[1][1];
- vec[1] = mat[1][2];
- vec[2] = mat[1][0];
+ vec[0] = R[1][1];
+ vec[1] = R[1][2];
+ vec[2] = R[1][0];
- cross_v3_v3v3(mat[0], mat[1], vec);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ cross_v3_v3v3(R[0], R[1], vec);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
break;
case 2:
- if (dot_v3v3(mat[2], mat[0]) < 1) {
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
- normalize_v3(mat[1]);
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
+ if (dot_v3v3(R[2], R[0]) < 1) {
+ cross_v3_v3v3(R[1], R[2], R[0]);
+ normalize_v3(R[1]);
+ cross_v3_v3v3(R[0], R[1], R[2]);
}
- else if (dot_v3v3(mat[2], mat[1]) < 1) {
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ else if (dot_v3v3(R[2], R[1]) < 1) {
+ cross_v3_v3v3(R[0], R[1], R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
else {
float vec[3];
- vec[0] = mat[2][1];
- vec[1] = mat[2][2];
- vec[2] = mat[2][0];
+ vec[0] = R[2][1];
+ vec[1] = R[2][2];
+ vec[2] = R[2][0];
- cross_v3_v3v3(mat[0], vec, mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ cross_v3_v3v3(R[0], vec, R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
break;
default:
BLI_assert(0);
break;
}
- mul_v3_fl(mat[0], size[0]);
- mul_v3_fl(mat[1], size[1]);
- mul_v3_fl(mat[2], size[2]);
+ mul_v3_fl(R[0], size[0]);
+ mul_v3_fl(R[1], size[1]);
+ mul_v3_fl(R[2], size[2]);
}
/**
@@ -1509,88 +1508,88 @@ void orthogonalize_m3(float mat[3][3], int axis)
*
* \param axis: Axis to build the orthonormal basis around.
*/
-void orthogonalize_m4(float mat[4][4], int axis)
+void orthogonalize_m4(float R[4][4], int axis)
{
float size[3];
- mat4_to_size(size, mat);
- normalize_v3(mat[axis]);
+ mat4_to_size(size, R);
+ normalize_v3(R[axis]);
switch (axis) {
case 0:
- if (dot_v3v3(mat[0], mat[1]) < 1) {
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ if (dot_v3v3(R[0], R[1]) < 1) {
+ cross_v3_v3v3(R[2], R[0], R[1]);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
- else if (dot_v3v3(mat[0], mat[2]) < 1) {
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
- normalize_v3(mat[1]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ else if (dot_v3v3(R[0], R[2]) < 1) {
+ cross_v3_v3v3(R[1], R[2], R[0]);
+ normalize_v3(R[1]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
else {
float vec[3];
- vec[0] = mat[0][1];
- vec[1] = mat[0][2];
- vec[2] = mat[0][0];
+ vec[0] = R[0][1];
+ vec[1] = R[0][2];
+ vec[2] = R[0][0];
- cross_v3_v3v3(mat[2], mat[0], vec);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ cross_v3_v3v3(R[2], R[0], vec);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
break;
case 1:
- if (dot_v3v3(mat[1], mat[0]) < 1) {
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
- normalize_v3(mat[2]);
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
+ if (dot_v3v3(R[1], R[0]) < 1) {
+ cross_v3_v3v3(R[2], R[0], R[1]);
+ normalize_v3(R[2]);
+ cross_v3_v3v3(R[0], R[1], R[2]);
}
- else if (dot_v3v3(mat[0], mat[2]) < 1) {
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ else if (dot_v3v3(R[0], R[2]) < 1) {
+ cross_v3_v3v3(R[0], R[1], R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
else {
float vec[3];
- vec[0] = mat[1][1];
- vec[1] = mat[1][2];
- vec[2] = mat[1][0];
+ vec[0] = R[1][1];
+ vec[1] = R[1][2];
+ vec[2] = R[1][0];
- cross_v3_v3v3(mat[0], mat[1], vec);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[2], mat[0], mat[1]);
+ cross_v3_v3v3(R[0], R[1], vec);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[2], R[0], R[1]);
}
break;
case 2:
- if (dot_v3v3(mat[2], mat[0]) < 1) {
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
- normalize_v3(mat[1]);
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
+ if (dot_v3v3(R[2], R[0]) < 1) {
+ cross_v3_v3v3(R[1], R[2], R[0]);
+ normalize_v3(R[1]);
+ cross_v3_v3v3(R[0], R[1], R[2]);
}
- else if (dot_v3v3(mat[2], mat[1]) < 1) {
- cross_v3_v3v3(mat[0], mat[1], mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ else if (dot_v3v3(R[2], R[1]) < 1) {
+ cross_v3_v3v3(R[0], R[1], R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
else {
float vec[3];
- vec[0] = mat[2][1];
- vec[1] = mat[2][2];
- vec[2] = mat[2][0];
+ vec[0] = R[2][1];
+ vec[1] = R[2][2];
+ vec[2] = R[2][0];
- cross_v3_v3v3(mat[0], vec, mat[2]);
- normalize_v3(mat[0]);
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ cross_v3_v3v3(R[0], vec, R[2]);
+ normalize_v3(R[0]);
+ cross_v3_v3v3(R[1], R[2], R[0]);
}
break;
default:
BLI_assert(0);
break;
}
- mul_v3_fl(mat[0], size[0]);
- mul_v3_fl(mat[1], size[1]);
- mul_v3_fl(mat[2], size[2]);
+ mul_v3_fl(R[0], size[0]);
+ mul_v3_fl(R[1], size[1]);
+ mul_v3_fl(R[2], size[2]);
}
/** Make an orthonormal basis around v1 in a way that is stable and symmetric. */
@@ -1793,84 +1792,84 @@ bool is_uniform_scaled_m4(const float m[4][4])
return is_uniform_scaled_m3(t);
}
-void normalize_m2_ex(float mat[2][2], float r_scale[2])
+void normalize_m2_ex(float R[2][2], float r_scale[2])
{
int i;
for (i = 0; i < 2; i++) {
- r_scale[i] = normalize_v2(mat[i]);
+ r_scale[i] = normalize_v2(R[i]);
}
}
-void normalize_m2(float mat[2][2])
+void normalize_m2(float R[2][2])
{
int i;
for (i = 0; i < 2; i++) {
- normalize_v2(mat[i]);
+ normalize_v2(R[i]);
}
}
-void normalize_m2_m2_ex(float rmat[2][2], const float mat[2][2], float r_scale[2])
+void normalize_m2_m2_ex(float R[2][2], const float M[2][2], float r_scale[2])
{
int i;
for (i = 0; i < 2; i++) {
- r_scale[i] = normalize_v2_v2(rmat[i], mat[i]);
+ r_scale[i] = normalize_v2_v2(R[i], M[i]);
}
}
-void normalize_m2_m2(float rmat[2][2], const float mat[2][2])
+void normalize_m2_m2(float R[2][2], const float M[2][2])
{
int i;
for (i = 0; i < 2; i++) {
- normalize_v2_v2(rmat[i], mat[i]);
+ normalize_v2_v2(R[i], M[i]);
}
}
-void normalize_m3_ex(float mat[3][3], float r_scale[3])
+void normalize_m3_ex(float R[3][3], float r_scale[3])
{
int i;
for (i = 0; i < 3; i++) {
- r_scale[i] = normalize_v3(mat[i]);
+ r_scale[i] = normalize_v3(R[i]);
}
}
-void normalize_m3(float mat[3][3])
+void normalize_m3(float R[3][3])
{
int i;
for (i = 0; i < 3; i++) {
- normalize_v3(mat[i]);
+ normalize_v3(R[i]);
}
}
-void normalize_m3_m3_ex(float rmat[3][3], const float mat[3][3], float r_scale[3])
+void normalize_m3_m3_ex(float R[3][3], const float M[3][3], float r_scale[3])
{
int i;
for (i = 0; i < 3; i++) {
- r_scale[i] = normalize_v3_v3(rmat[i], mat[i]);
+ r_scale[i] = normalize_v3_v3(R[i], M[i]);
}
}
-void normalize_m3_m3(float rmat[3][3], const float mat[3][3])
+void normalize_m3_m3(float R[3][3], const float M[3][3])
{
int i;
for (i = 0; i < 3; i++) {
- normalize_v3_v3(rmat[i], mat[i]);
+ normalize_v3_v3(R[i], M[i]);
}
}
-void normalize_m4_ex(float mat[4][4], float r_scale[3])
+void normalize_m4_ex(float R[4][4], float r_scale[3])
{
int i;
for (i = 0; i < 3; i++) {
- r_scale[i] = normalize_v3(mat[i]);
+ r_scale[i] = normalize_v3(R[i]);
if (r_scale[i] != 0.0f) {
- mat[i][3] /= r_scale[i];
+ R[i][3] /= r_scale[i];
}
}
}
-void normalize_m4(float mat[4][4])
+void normalize_m4(float R[4][4])
{
int i;
for (i = 0; i < 3; i++) {
- float len = normalize_v3(mat[i]);
+ float len = normalize_v3(R[i]);
if (len != 0.0f) {
- mat[i][3] /= len;
+ R[i][3] /= len;
}
}
}
@@ -1894,75 +1893,75 @@ void normalize_m4_m4(float rmat[4][4], const float mat[4][4])
copy_v4_v4(rmat[3], mat[3]);
}
-void adjoint_m2_m2(float m1[2][2], const float m[2][2])
+void adjoint_m2_m2(float R[2][2], const float M[2][2])
{
- BLI_assert(m1 != m);
- m1[0][0] = m[1][1];
- m1[0][1] = -m[0][1];
- m1[1][0] = -m[1][0];
- m1[1][1] = m[0][0];
+ BLI_assert(R != M);
+ R[0][0] = M[1][1];
+ R[0][1] = -M[0][1];
+ R[1][0] = -M[1][0];
+ R[1][1] = M[0][0];
}
-void adjoint_m3_m3(float m1[3][3], const float m[3][3])
+void adjoint_m3_m3(float R[3][3], const float M[3][3])
{
- BLI_assert(m1 != m);
- m1[0][0] = m[1][1] * m[2][2] - m[1][2] * m[2][1];
- m1[0][1] = -m[0][1] * m[2][2] + m[0][2] * m[2][1];
- m1[0][2] = m[0][1] * m[1][2] - m[0][2] * m[1][1];
+ BLI_assert(R != M);
+ R[0][0] = M[1][1] * M[2][2] - M[1][2] * M[2][1];
+ R[0][1] = -M[0][1] * M[2][2] + M[0][2] * M[2][1];
+ R[0][2] = M[0][1] * M[1][2] - M[0][2] * M[1][1];
- m1[1][0] = -m[1][0] * m[2][2] + m[1][2] * m[2][0];
- m1[1][1] = m[0][0] * m[2][2] - m[0][2] * m[2][0];
- m1[1][2] = -m[0][0] * m[1][2] + m[0][2] * m[1][0];
+ R[1][0] = -M[1][0] * M[2][2] + M[1][2] * M[2][0];
+ R[1][1] = M[0][0] * M[2][2] - M[0][2] * M[2][0];
+ R[1][2] = -M[0][0] * M[1][2] + M[0][2] * M[1][0];
- m1[2][0] = m[1][0] * m[2][1] - m[1][1] * m[2][0];
- m1[2][1] = -m[0][0] * m[2][1] + m[0][1] * m[2][0];
- m1[2][2] = m[0][0] * m[1][1] - m[0][1] * m[1][0];
+ R[2][0] = M[1][0] * M[2][1] - M[1][1] * M[2][0];
+ R[2][1] = -M[0][0] * M[2][1] + M[0][1] * M[2][0];
+ R[2][2] = M[0][0] * M[1][1] - M[0][1] * M[1][0];
}
-void adjoint_m4_m4(float out[4][4], const float in[4][4]) /* out = ADJ(in) */
+void adjoint_m4_m4(float R[4][4], const float M[4][4]) /* out = ADJ(in) */
{
float a1, a2, a3, a4, b1, b2, b3, b4;
float c1, c2, c3, c4, d1, d2, d3, d4;
- a1 = in[0][0];
- b1 = in[0][1];
- c1 = in[0][2];
- d1 = in[0][3];
+ a1 = M[0][0];
+ b1 = M[0][1];
+ c1 = M[0][2];
+ d1 = M[0][3];
- a2 = in[1][0];
- b2 = in[1][1];
- c2 = in[1][2];
- d2 = in[1][3];
+ a2 = M[1][0];
+ b2 = M[1][1];
+ c2 = M[1][2];
+ d2 = M[1][3];
- a3 = in[2][0];
- b3 = in[2][1];
- c3 = in[2][2];
- d3 = in[2][3];
+ a3 = M[2][0];
+ b3 = M[2][1];
+ c3 = M[2][2];
+ d3 = M[2][3];
- a4 = in[3][0];
- b4 = in[3][1];
- c4 = in[3][2];
- d4 = in[3][3];
+ a4 = M[3][0];
+ b4 = M[3][1];
+ c4 = M[3][2];
+ d4 = M[3][3];
- out[0][0] = determinant_m3(b2, b3, b4, c2, c3, c4, d2, d3, d4);
- out[1][0] = -determinant_m3(a2, a3, a4, c2, c3, c4, d2, d3, d4);
- out[2][0] = determinant_m3(a2, a3, a4, b2, b3, b4, d2, d3, d4);
- out[3][0] = -determinant_m3(a2, a3, a4, b2, b3, b4, c2, c3, c4);
+ R[0][0] = determinant_m3(b2, b3, b4, c2, c3, c4, d2, d3, d4);
+ R[1][0] = -determinant_m3(a2, a3, a4, c2, c3, c4, d2, d3, d4);
+ R[2][0] = determinant_m3(a2, a3, a4, b2, b3, b4, d2, d3, d4);
+ R[3][0] = -determinant_m3(a2, a3, a4, b2, b3, b4, c2, c3, c4);
- out[0][1] = -determinant_m3(b1, b3, b4, c1, c3, c4, d1, d3, d4);
- out[1][1] = determinant_m3(a1, a3, a4, c1, c3, c4, d1, d3, d4);
- out[2][1] = -determinant_m3(a1, a3, a4, b1, b3, b4, d1, d3, d4);
- out[3][1] = determinant_m3(a1, a3, a4, b1, b3, b4, c1, c3, c4);
+ R[0][1] = -determinant_m3(b1, b3, b4, c1, c3, c4, d1, d3, d4);
+ R[1][1] = determinant_m3(a1, a3, a4, c1, c3, c4, d1, d3, d4);
+ R[2][1] = -determinant_m3(a1, a3, a4, b1, b3, b4, d1, d3, d4);
+ R[3][1] = determinant_m3(a1, a3, a4, b1, b3, b4, c1, c3, c4);
- out[0][2] = determinant_m3(b1, b2, b4, c1, c2, c4, d1, d2, d4);
- out[1][2] = -determinant_m3(a1, a2, a4, c1, c2, c4, d1, d2, d4);
- out[2][2] = determinant_m3(a1, a2, a4, b1, b2, b4, d1, d2, d4);
- out[3][2] = -determinant_m3(a1, a2, a4, b1, b2, b4, c1, c2, c4);
+ R[0][2] = determinant_m3(b1, b2, b4, c1, c2, c4, d1, d2, d4);
+ R[1][2] = -determinant_m3(a1, a2, a4, c1, c2, c4, d1, d2, d4);
+ R[2][2] = determinant_m3(a1, a2, a4, b1, b2, b4, d1, d2, d4);
+ R[3][2] = -determinant_m3(a1, a2, a4, b1, b2, b4, c1, c2, c4);
- out[0][3] = -determinant_m3(b1, b2, b3, c1, c2, c3, d1, d2, d3);
- out[1][3] = determinant_m3(a1, a2, a3, c1, c2, c3, d1, d2, d3);
- out[2][3] = -determinant_m3(a1, a2, a3, b1, b2, b3, d1, d2, d3);
- out[3][3] = determinant_m3(a1, a2, a3, b1, b2, b3, c1, c2, c3);
+ R[0][3] = -determinant_m3(b1, b2, b3, c1, c2, c3, d1, d2, d3);
+ R[1][3] = determinant_m3(a1, a2, a3, c1, c2, c3, d1, d2, d3);
+ R[2][3] = -determinant_m3(a1, a2, a3, b1, b2, b3, d1, d2, d3);
+ R[3][3] = determinant_m3(a1, a2, a3, b1, b2, b3, c1, c2, c3);
}
float determinant_m2(float a, float b, float c, float d)
@@ -2017,65 +2016,65 @@ float determinant_m4(const float m[4][4])
/****************************** Transformations ******************************/
-void size_to_mat3(float mat[3][3], const float size[3])
+void size_to_mat3(float R[3][3], const float size[3])
{
- mat[0][0] = size[0];
- mat[0][1] = 0.0f;
- mat[0][2] = 0.0f;
- mat[1][1] = size[1];
- mat[1][0] = 0.0f;
- mat[1][2] = 0.0f;
- mat[2][2] = size[2];
- mat[2][1] = 0.0f;
- mat[2][0] = 0.0f;
+ R[0][0] = size[0];
+ R[0][1] = 0.0f;
+ R[0][2] = 0.0f;
+ R[1][1] = size[1];
+ R[1][0] = 0.0f;
+ R[1][2] = 0.0f;
+ R[2][2] = size[2];
+ R[2][1] = 0.0f;
+ R[2][0] = 0.0f;
}
-void size_to_mat4(float mat[4][4], const float size[3])
+void size_to_mat4(float R[4][4], const float size[3])
{
- mat[0][0] = size[0];
- mat[0][1] = 0.0f;
- mat[0][2] = 0.0f;
- mat[0][3] = 0.0f;
- mat[1][0] = 0.0f;
- mat[1][1] = size[1];
- mat[1][2] = 0.0f;
- mat[1][3] = 0.0f;
- mat[2][0] = 0.0f;
- mat[2][1] = 0.0f;
- mat[2][2] = size[2];
- mat[2][3] = 0.0f;
- mat[3][0] = 0.0f;
- mat[3][1] = 0.0f;
- mat[3][2] = 0.0f;
- mat[3][3] = 1.0f;
+ R[0][0] = size[0];
+ R[0][1] = 0.0f;
+ R[0][2] = 0.0f;
+ R[0][3] = 0.0f;
+ R[1][0] = 0.0f;
+ R[1][1] = size[1];
+ R[1][2] = 0.0f;
+ R[1][3] = 0.0f;
+ R[2][0] = 0.0f;
+ R[2][1] = 0.0f;
+ R[2][2] = size[2];
+ R[2][3] = 0.0f;
+ R[3][0] = 0.0f;
+ R[3][1] = 0.0f;
+ R[3][2] = 0.0f;
+ R[3][3] = 1.0f;
}
-void mat3_to_size(float size[3], const float mat[3][3])
+void mat3_to_size(float size[3], const float M[3][3])
{
- size[0] = len_v3(mat[0]);
- size[1] = len_v3(mat[1]);
- size[2] = len_v3(mat[2]);
+ size[0] = len_v3(M[0]);
+ size[1] = len_v3(M[1]);
+ size[2] = len_v3(M[2]);
}
-void mat4_to_size(float size[3], const float mat[4][4])
+void mat4_to_size(float size[3], const float M[4][4])
{
- size[0] = len_v3(mat[0]);
- size[1] = len_v3(mat[1]);
- size[2] = len_v3(mat[2]);
+ size[0] = len_v3(M[0]);
+ size[1] = len_v3(M[1]);
+ size[2] = len_v3(M[2]);
}
/**
* Extract scale factors from the matrix, with correction to ensure
* exact volume in case of a sheared matrix.
*/
-void mat4_to_size_fix_shear(float size[3], const float mat[4][4])
+void mat4_to_size_fix_shear(float size[3], const float M[4][4])
{
- mat4_to_size(size, mat);
+ mat4_to_size(size, M);
float volume = size[0] * size[1] * size[2];
if (volume != 0.0f) {
- mul_v3_fl(size, cbrtf(fabsf(mat4_to_volume_scale(mat) / volume)));
+ mul_v3_fl(size, cbrtf(fabsf(mat4_to_volume_scale(M) / volume)));
}
}
@@ -2203,22 +2202,22 @@ void mat3_polar_decompose(const float mat3[3][3], float r_U[3][3], float r_P[3][
}
#endif
-void scale_m3_fl(float m[3][3], float scale)
+void scale_m3_fl(float R[3][3], float scale)
{
- m[0][0] = m[1][1] = m[2][2] = scale;
- m[0][1] = m[0][2] = 0.0;
- m[1][0] = m[1][2] = 0.0;
- m[2][0] = m[2][1] = 0.0;
+ R[0][0] = R[1][1] = R[2][2] = scale;
+ R[0][1] = R[0][2] = 0.0;
+ R[1][0] = R[1][2] = 0.0;
+ R[2][0] = R[2][1] = 0.0;
}
-void scale_m4_fl(float m[4][4], float scale)
+void scale_m4_fl(float R[4][4], float scale)
{
- m[0][0] = m[1][1] = m[2][2] = scale;
- m[3][3] = 1.0;
- m[0][1] = m[0][2] = m[0][3] = 0.0;
- m[1][0] = m[1][2] = m[1][3] = 0.0;
- m[2][0] = m[2][1] = m[2][3] = 0.0;
- m[3][0] = m[3][1] = m[3][2] = 0.0;
+ R[0][0] = R[1][1] = R[2][2] = scale;
+ R[3][3] = 1.0;
+ R[0][1] = R[0][2] = R[0][3] = 0.0;
+ R[1][0] = R[1][2] = R[1][3] = 0.0;
+ R[2][0] = R[2][1] = R[2][3] = 0.0;
+ R[3][0] = R[3][1] = R[3][2] = 0.0;
}
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
@@ -2486,14 +2485,14 @@ bool equals_m4m4(const float mat1[4][4], const float mat2[4][4])
* Make a 4x4 matrix out of 3 transform components.
* Matrices are made in the order: `scale * rot * loc`
*/
-void loc_rot_size_to_mat4(float mat[4][4],
+void loc_rot_size_to_mat4(float R[4][4],
const float loc[3],
const float rot[3][3],
const float size[3])
{
- copy_m4_m3(mat, rot);
- rescale_m4(mat, size);
- copy_v3_v3(mat[3], loc);
+ copy_m4_m3(R, rot);
+ rescale_m4(R, size);
+ copy_v3_v3(R[3], loc);
}
/**
@@ -2502,7 +2501,7 @@ void loc_rot_size_to_mat4(float mat[4][4],
*
* TODO: need to have a version that allows for rotation order...
*/
-void loc_eul_size_to_mat4(float mat[4][4],
+void loc_eul_size_to_mat4(float R[4][4],
const float loc[3],
const float eul[3],
const float size[3])
@@ -2510,7 +2509,7 @@ void loc_eul_size_to_mat4(float mat[4][4],
float rmat[3][3], smat[3][3], tmat[3][3];
/* initialize new matrix */
- unit_m4(mat);
+ unit_m4(R);
/* make rotation + scaling part */
eul_to_mat3(rmat, eul);
@@ -2518,19 +2517,19 @@ void loc_eul_size_to_mat4(float mat[4][4],
mul_m3_m3m3(tmat, rmat, smat);
/* copy rot/scale part to output matrix*/
- copy_m4_m3(mat, tmat);
+ copy_m4_m3(R, tmat);
/* copy location to matrix */
- mat[3][0] = loc[0];
- mat[3][1] = loc[1];
- mat[3][2] = loc[2];
+ R[3][0] = loc[0];
+ R[3][1] = loc[1];
+ R[3][2] = loc[2];
}
/**
* Make a 4x4 matrix out of 3 transform components.
* Matrices are made in the order: `scale * rot * loc`
*/
-void loc_eulO_size_to_mat4(float mat[4][4],
+void loc_eulO_size_to_mat4(float R[4][4],
const float loc[3],
const float eul[3],
const float size[3],
@@ -2539,7 +2538,7 @@ void loc_eulO_size_to_mat4(float mat[4][4],
float rmat[3][3], smat[3][3], tmat[3][3];
/* initialize new matrix */
- unit_m4(mat);
+ unit_m4(R);
/* make rotation + scaling part */
eulO_to_mat3(rmat, eul, rotOrder);
@@ -2547,19 +2546,19 @@ void loc_eulO_size_to_mat4(float mat[4][4],
mul_m3_m3m3(tmat, rmat, smat);
/* copy rot/scale part to output matrix*/
- copy_m4_m3(mat, tmat);
+ copy_m4_m3(R, tmat);
/* copy location to matrix */
- mat[3][0] = loc[0];
- mat[3][1] = loc[1];
- mat[3][2] = loc[2];
+ R[3][0] = loc[0];
+ R[3][1] = loc[1];
+ R[3][2] = loc[2];
}
/**
* Make a 4x4 matrix out of 3 transform components.
* Matrices are made in the order: `scale * rot * loc`
*/
-void loc_quat_size_to_mat4(float mat[4][4],
+void loc_quat_size_to_mat4(float R[4][4],
const float loc[3],
const float quat[4],
const float size[3])
@@ -2567,7 +2566,7 @@ void loc_quat_size_to_mat4(float mat[4][4],
float rmat[3][3], smat[3][3], tmat[3][3];
/* initialize new matrix */
- unit_m4(mat);
+ unit_m4(R);
/* make rotation + scaling part */
quat_to_mat3(rmat, quat);
@@ -2575,23 +2574,20 @@ void loc_quat_size_to_mat4(float mat[4][4],
mul_m3_m3m3(tmat, rmat, smat);
/* copy rot/scale part to output matrix*/
- copy_m4_m3(mat, tmat);
+ copy_m4_m3(R, tmat);
/* copy location to matrix */
- mat[3][0] = loc[0];
- mat[3][1] = loc[1];
- mat[3][2] = loc[2];
+ R[3][0] = loc[0];
+ R[3][1] = loc[1];
+ R[3][2] = loc[2];
}
-void loc_axisangle_size_to_mat4(float mat[4][4],
- const float loc[3],
- const float axis[3],
- const float angle,
- const float size[3])
+void loc_axisangle_size_to_mat4(
+ float R[4][4], const float loc[3], const float axis[3], const float angle, const float size[3])
{
float q[4];
axis_angle_to_quat(q, axis, angle);
- loc_quat_size_to_mat4(mat, loc, q, size);
+ loc_quat_size_to_mat4(R, loc, q, size);
}
/*********************************** Other ***********************************/
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index d38c081ec2b..7c4ac934695 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -50,12 +50,12 @@ void unit_qt(float q[4])
q[1] = q[2] = q[3] = 0.0f;
}
-void copy_qt_qt(float q1[4], const float q2[4])
+void copy_qt_qt(float q[4], const float a[4])
{
- q1[0] = q2[0];
- q1[1] = q2[1];
- q1[2] = q2[2];
- q1[3] = q2[3];
+ q[0] = a[0];
+ q[1] = a[1];
+ q[2] = a[2];
+ q[3] = a[3];
}
bool is_zero_qt(const float q[4])
@@ -63,14 +63,14 @@ bool is_zero_qt(const float q[4])
return (q[0] == 0 && q[1] == 0 && q[2] == 0 && q[3] == 0);
}
-void mul_qt_qtqt(float q[4], const float q1[4], const float q2[4])
+void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
{
float t0, t1, t2;
- t0 = q1[0] * q2[0] - q1[1] * q2[1] - q1[2] * q2[2] - q1[3] * q2[3];
- t1 = q1[0] * q2[1] + q1[1] * q2[0] + q1[2] * q2[3] - q1[3] * q2[2];
- t2 = q1[0] * q2[2] + q1[2] * q2[0] + q1[3] * q2[1] - q1[1] * q2[3];
- q[3] = q1[0] * q2[3] + q1[3] * q2[0] + q1[1] * q2[2] - q1[2] * q2[1];
+ t0 = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
+ t1 = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
+ t2 = a[0] * b[2] + a[2] * b[0] + a[3] * b[1] - a[1] * b[3];
+ q[3] = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
q[0] = t0;
q[1] = t1;
q[2] = t2;
@@ -95,22 +95,22 @@ void mul_qt_qtqt(float q[4], const float q1[4], const float q2[4])
*
* \note Multiplying by 3x3 matrix is ~25% faster.
*/
-void mul_qt_v3(const float q[4], float v[3])
+void mul_qt_v3(const float q[4], float r[3])
{
float t0, t1, t2;
- t0 = -q[1] * v[0] - q[2] * v[1] - q[3] * v[2];
- t1 = q[0] * v[0] + q[2] * v[2] - q[3] * v[1];
- t2 = q[0] * v[1] + q[3] * v[0] - q[1] * v[2];
- v[2] = q[0] * v[2] + q[1] * v[1] - q[2] * v[0];
- v[0] = t1;
- v[1] = t2;
+ t0 = -q[1] * r[0] - q[2] * r[1] - q[3] * r[2];
+ t1 = q[0] * r[0] + q[2] * r[2] - q[3] * r[1];
+ t2 = q[0] * r[1] + q[3] * r[0] - q[1] * r[2];
+ r[2] = q[0] * r[2] + q[1] * r[1] - q[2] * r[0];
+ r[0] = t1;
+ r[1] = t2;
- t1 = t0 * -q[1] + v[0] * q[0] - v[1] * q[3] + v[2] * q[2];
- t2 = t0 * -q[2] + v[1] * q[0] - v[2] * q[1] + v[0] * q[3];
- v[2] = t0 * -q[3] + v[2] * q[0] - v[0] * q[2] + v[1] * q[1];
- v[0] = t1;
- v[1] = t2;
+ t1 = t0 * -q[1] + r[0] * q[0] - r[1] * q[3] + r[2] * q[2];
+ t2 = t0 * -q[2] + r[1] * q[0] - r[2] * q[1] + r[0] * q[3];
+ r[2] = t0 * -q[3] + r[2] * q[0] - r[0] * q[2] + r[1] * q[1];
+ r[0] = t1;
+ r[1] = t2;
}
void conjugate_qt_qt(float q1[4], const float q2[4])
@@ -128,9 +128,9 @@ void conjugate_qt(float q[4])
q[3] = -q[3];
}
-float dot_qtqt(const float q1[4], const float q2[4])
+float dot_qtqt(const float a[4], const float b[4])
{
- return q1[0] * q2[0] + q1[1] * q2[1] + q1[2] * q2[2] + q1[3] * q2[3];
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
}
void invert_qt(float q[4])
@@ -177,16 +177,16 @@ void mul_qt_fl(float q[4], const float f)
q[3] *= f;
}
-void sub_qt_qtqt(float q[4], const float q1[4], const float q2[4])
+void sub_qt_qtqt(float q[4], const float a[4], const float b[4])
{
- float nq2[4];
+ float n_b[4];
- nq2[0] = -q2[0];
- nq2[1] = q2[1];
- nq2[2] = q2[2];
- nq2[3] = q2[3];
+ n_b[0] = -b[0];
+ n_b[1] = b[1];
+ n_b[2] = b[2];
+ n_b[3] = b[3];
- mul_qt_qtqt(q, q1, nq2);
+ mul_qt_qtqt(q, a, n_b);
}
/* raise a unit quaternion to the specified power */
@@ -867,38 +867,38 @@ void interp_dot_slerp(const float t, const float cosom, float r_w[2])
}
}
-void interp_qt_qtqt(float result[4], const float quat1[4], const float quat2[4], const float t)
+void interp_qt_qtqt(float q[4], const float a[4], const float b[4], const float t)
{
float quat[4], cosom, w[2];
- BLI_ASSERT_UNIT_QUAT(quat1);
- BLI_ASSERT_UNIT_QUAT(quat2);
+ BLI_ASSERT_UNIT_QUAT(a);
+ BLI_ASSERT_UNIT_QUAT(b);
- cosom = dot_qtqt(quat1, quat2);
+ cosom = dot_qtqt(a, b);
/* rotate around shortest angle */
if (cosom < 0.0f) {
cosom = -cosom;
- negate_v4_v4(quat, quat1);
+ negate_v4_v4(quat, a);
}
else {
- copy_qt_qt(quat, quat1);
+ copy_qt_qt(quat, a);
}
interp_dot_slerp(t, cosom, w);
- result[0] = w[0] * quat[0] + w[1] * quat2[0];
- result[1] = w[0] * quat[1] + w[1] * quat2[1];
- result[2] = w[0] * quat[2] + w[1] * quat2[2];
- result[3] = w[0] * quat[3] + w[1] * quat2[3];
+ q[0] = w[0] * quat[0] + w[1] * b[0];
+ q[1] = w[0] * quat[1] + w[1] * b[1];
+ q[2] = w[0] * quat[2] + w[1] * b[2];
+ q[3] = w[0] * quat[3] + w[1] * b[3];
}
-void add_qt_qtqt(float result[4], const float quat1[4], const float quat2[4], const float t)
+void add_qt_qtqt(float q[4], const float a[4], const float b[4], const float t)
{
- result[0] = quat1[0] + t * quat2[0];
- result[1] = quat1[1] + t * quat2[1];
- result[2] = quat1[2] + t * quat2[2];
- result[3] = quat1[3] + t * quat2[3];
+ q[0] = a[0] + t * b[0];
+ q[1] = a[1] + t * b[1];
+ q[2] = a[2] + t * b[2];
+ q[3] = a[3] + t * b[3];
}
/* same as tri_to_quat() but takes pre-computed normal from the triangle
@@ -958,12 +958,12 @@ void tri_to_quat_ex(
/**
* \return the length of the normal, use to test for degenerate triangles.
*/
-float tri_to_quat(float quat[4], const float v1[3], const float v2[3], const float v3[3])
+float tri_to_quat(float q[4], const float a[3], const float b[3], const float c[3])
{
float vec[3];
- const float len = normal_tri_v3(vec, v1, v2, v3);
+ const float len = normal_tri_v3(vec, a, b, c);
- tri_to_quat_ex(quat, v1, v2, v3, vec);
+ tri_to_quat_ex(q, a, b, c, vec);
return len;
}
@@ -974,25 +974,25 @@ void print_qt(const char *str, const float q[4])
/******************************** Axis Angle *********************************/
-void axis_angle_normalized_to_quat(float q[4], const float axis[3], const float angle)
+void axis_angle_normalized_to_quat(float r[4], const float axis[3], const float angle)
{
const float phi = 0.5f * angle;
const float si = sinf(phi);
const float co = cosf(phi);
BLI_ASSERT_UNIT_V3(axis);
- q[0] = co;
- mul_v3_v3fl(q + 1, axis, si);
+ r[0] = co;
+ mul_v3_v3fl(r + 1, axis, si);
}
-void axis_angle_to_quat(float q[4], const float axis[3], const float angle)
+void axis_angle_to_quat(float r[4], const float axis[3], const float angle)
{
float nor[3];
if (LIKELY(normalize_v3_v3(nor, axis) != 0.0f)) {
- axis_angle_normalized_to_quat(q, nor, angle);
+ axis_angle_normalized_to_quat(r, nor, angle);
}
else {
- unit_qt(q);
+ unit_qt(r);
}
}
@@ -1094,33 +1094,33 @@ void axis_angle_normalized_to_mat3_ex(float mat[3][3],
mat[2][2] = n_22 + angle_cos;
}
-void axis_angle_normalized_to_mat3(float mat[3][3], const float axis[3], const float angle)
+void axis_angle_normalized_to_mat3(float R[3][3], const float axis[3], const float angle)
{
- axis_angle_normalized_to_mat3_ex(mat, axis, sinf(angle), cosf(angle));
+ axis_angle_normalized_to_mat3_ex(R, axis, sinf(angle), cosf(angle));
}
/* axis angle to 3x3 matrix - safer version (normalization of axis performed) */
-void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle)
+void axis_angle_to_mat3(float R[3][3], const float axis[3], const float angle)
{
float nor[3];
/* normalize the axis first (to remove unwanted scaling) */
if (normalize_v3_v3(nor, axis) == 0.0f) {
- unit_m3(mat);
+ unit_m3(R);
return;
}
- axis_angle_normalized_to_mat3(mat, nor, angle);
+ axis_angle_normalized_to_mat3(R, nor, angle);
}
/* axis angle to 4x4 matrix - safer version (normalization of axis performed) */
-void axis_angle_to_mat4(float mat[4][4], const float axis[3], const float angle)
+void axis_angle_to_mat4(float R[4][4], const float axis[3], const float angle)
{
float tmat[3][3];
axis_angle_to_mat3(tmat, axis, angle);
- unit_m4(mat);
- copy_m4_m3(mat, tmat);
+ unit_m4(R);
+ copy_m4_m3(R, tmat);
}
/* 3x3 matrix to axis angle */
@@ -1165,52 +1165,52 @@ void mat4_to_axis_angle(float axis[3], float *angle, const float mat[4][4])
quat_to_axis_angle(axis, angle, q);
}
-void axis_angle_to_mat4_single(float mat[4][4], const char axis, const float angle)
+void axis_angle_to_mat4_single(float R[4][4], const char axis, const float angle)
{
float mat3[3][3];
axis_angle_to_mat3_single(mat3, axis, angle);
- copy_m4_m3(mat, mat3);
+ copy_m4_m3(R, mat3);
}
/* rotation matrix from a single axis */
-void axis_angle_to_mat3_single(float mat[3][3], const char axis, const float angle)
+void axis_angle_to_mat3_single(float R[3][3], const char axis, const float angle)
{
const float angle_cos = cosf(angle);
const float angle_sin = sinf(angle);
switch (axis) {
case 'X': /* rotation around X */
- mat[0][0] = 1.0f;
- mat[0][1] = 0.0f;
- mat[0][2] = 0.0f;
- mat[1][0] = 0.0f;
- mat[1][1] = angle_cos;
- mat[1][2] = angle_sin;
- mat[2][0] = 0.0f;
- mat[2][1] = -angle_sin;
- mat[2][2] = angle_cos;
+ R[0][0] = 1.0f;
+ R[0][1] = 0.0f;
+ R[0][2] = 0.0f;
+ R[1][0] = 0.0f;
+ R[1][1] = angle_cos;
+ R[1][2] = angle_sin;
+ R[2][0] = 0.0f;
+ R[2][1] = -angle_sin;
+ R[2][2] = angle_cos;
break;
case 'Y': /* rotation around Y */
- mat[0][0] = angle_cos;
- mat[0][1] = 0.0f;
- mat[0][2] = -angle_sin;
- mat[1][0] = 0.0f;
- mat[1][1] = 1.0f;
- mat[1][2] = 0.0f;
- mat[2][0] = angle_sin;
- mat[2][1] = 0.0f;
- mat[2][2] = angle_cos;
+ R[0][0] = angle_cos;
+ R[0][1] = 0.0f;
+ R[0][2] = -angle_sin;
+ R[1][0] = 0.0f;
+ R[1][1] = 1.0f;
+ R[1][2] = 0.0f;
+ R[2][0] = angle_sin;
+ R[2][1] = 0.0f;
+ R[2][2] = angle_cos;
break;
case 'Z': /* rotation around Z */
- mat[0][0] = angle_cos;
- mat[0][1] = angle_sin;
- mat[0][2] = 0.0f;
- mat[1][0] = -angle_sin;
- mat[1][1] = angle_cos;
- mat[1][2] = 0.0f;
- mat[2][0] = 0.0f;
- mat[2][1] = 0.0f;
- mat[2][2] = 1.0f;
+ R[0][0] = angle_cos;
+ R[0][1] = angle_sin;
+ R[0][2] = 0.0f;
+ R[1][0] = -angle_sin;
+ R[1][1] = angle_cos;
+ R[1][2] = 0.0f;
+ R[2][0] = 0.0f;
+ R[2][1] = 0.0f;
+ R[2][2] = 1.0f;
break;
default:
BLI_assert(0);
@@ -1218,16 +1218,16 @@ void axis_angle_to_mat3_single(float mat[3][3], const char axis, const float ang
}
}
-void angle_to_mat2(float mat[2][2], const float angle)
+void angle_to_mat2(float R[2][2], const float angle)
{
const float angle_cos = cosf(angle);
const float angle_sin = sinf(angle);
/* 2D rotation matrix */
- mat[0][0] = angle_cos;
- mat[0][1] = angle_sin;
- mat[1][0] = -angle_sin;
- mat[1][1] = angle_cos;
+ R[0][0] = angle_cos;
+ R[0][1] = angle_sin;
+ R[1][0] = -angle_sin;
+ R[1][1] = angle_cos;
}
void axis_angle_to_quat_single(float q[4], const char axis, const float angle)
@@ -1989,7 +1989,7 @@ void mat4_to_dquat(DualQuat *dq, const float basemat[4][4], const float mat[4][4
dq->trans[3] = 0.5f * (t[0] * q[2] - t[1] * q[1] + t[2] * q[0]);
}
-void dquat_to_mat4(float mat[4][4], const DualQuat *dq)
+void dquat_to_mat4(float R[4][4], const DualQuat *dq)
{
float len, q0[4];
const float *t;
@@ -2005,40 +2005,40 @@ void dquat_to_mat4(float mat[4][4], const DualQuat *dq)
mul_qt_fl(q0, len);
/* rotation */
- quat_to_mat4(mat, q0);
+ quat_to_mat4(R, q0);
/* translation */
t = dq->trans;
- mat[3][0] = 2.0f * (-t[0] * q0[1] + t[1] * q0[0] - t[2] * q0[3] + t[3] * q0[2]) * len;
- mat[3][1] = 2.0f * (-t[0] * q0[2] + t[1] * q0[3] + t[2] * q0[0] - t[3] * q0[1]) * len;
- mat[3][2] = 2.0f * (-t[0] * q0[3] - t[1] * q0[2] + t[2] * q0[1] + t[3] * q0[0]) * len;
+ R[3][0] = 2.0f * (-t[0] * q0[1] + t[1] * q0[0] - t[2] * q0[3] + t[3] * q0[2]) * len;
+ R[3][1] = 2.0f * (-t[0] * q0[2] + t[1] * q0[3] + t[2] * q0[0] - t[3] * q0[1]) * len;
+ R[3][2] = 2.0f * (-t[0] * q0[3] - t[1] * q0[2] + t[2] * q0[1] + t[3] * q0[0]) * len;
/* scaling */
if (dq->scale_weight) {
- mul_m4_m4m4(mat, mat, dq->scale);
+ mul_m4_m4m4(R, R, dq->scale);
}
}
-void add_weighted_dq_dq(DualQuat *dqsum, const DualQuat *dq, float weight)
+void add_weighted_dq_dq(DualQuat *dq_sum, const DualQuat *dq, float weight)
{
bool flipped = false;
/* make sure we interpolate quats in the right direction */
- if (dot_qtqt(dq->quat, dqsum->quat) < 0) {
+ if (dot_qtqt(dq->quat, dq_sum->quat) < 0) {
flipped = true;
weight = -weight;
}
/* interpolate rotation and translation */
- dqsum->quat[0] += weight * dq->quat[0];
- dqsum->quat[1] += weight * dq->quat[1];
- dqsum->quat[2] += weight * dq->quat[2];
- dqsum->quat[3] += weight * dq->quat[3];
+ dq_sum->quat[0] += weight * dq->quat[0];
+ dq_sum->quat[1] += weight * dq->quat[1];
+ dq_sum->quat[2] += weight * dq->quat[2];
+ dq_sum->quat[3] += weight * dq->quat[3];
- dqsum->trans[0] += weight * dq->trans[0];
- dqsum->trans[1] += weight * dq->trans[1];
- dqsum->trans[2] += weight * dq->trans[2];
- dqsum->trans[3] += weight * dq->trans[3];
+ dq_sum->trans[0] += weight * dq->trans[0];
+ dq_sum->trans[1] += weight * dq->trans[1];
+ dq_sum->trans[2] += weight * dq->trans[2];
+ dq_sum->trans[3] += weight * dq->trans[3];
/* Interpolate scale - but only if there is scale present. If any dual
* quaternions without scale are added, they will be compensated for in
@@ -2053,8 +2053,8 @@ void add_weighted_dq_dq(DualQuat *dqsum, const DualQuat *dq, float weight)
copy_m4_m4(wmat, (float(*)[4])dq->scale);
mul_m4_fl(wmat, weight);
- add_m4_m4m4(dqsum->scale, dqsum->scale, wmat);
- dqsum->scale_weight += weight;
+ add_m4_m4m4(dq_sum->scale, dq_sum->scale, wmat);
+ dq_sum->scale_weight += weight;
}
}
@@ -2083,7 +2083,7 @@ void normalize_dq(DualQuat *dq, float totweight)
}
}
-void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
+void mul_v3m3_dq(float r[3], float R[3][3], DualQuat *dq)
{
float M[3][3], t[3], scalemat[3][3], len2;
float w = dq->quat[0], x = dq->quat[1], y = dq->quat[2], z = dq->quat[3];
@@ -2114,31 +2114,31 @@ void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
/* apply scaling */
if (dq->scale_weight) {
- mul_m4_v3(dq->scale, co);
+ mul_m4_v3(dq->scale, r);
}
/* apply rotation and translation */
- mul_m3_v3(M, co);
- co[0] = (co[0] + t[0]) * len2;
- co[1] = (co[1] + t[1]) * len2;
- co[2] = (co[2] + t[2]) * len2;
+ mul_m3_v3(M, r);
+ r[0] = (r[0] + t[0]) * len2;
+ r[1] = (r[1] + t[1]) * len2;
+ r[2] = (r[2] + t[2]) * len2;
/* Compute crazy-space correction matrix. */
- if (mat) {
+ if (R) {
if (dq->scale_weight) {
copy_m3_m4(scalemat, dq->scale);
- mul_m3_m3m3(mat, M, scalemat);
+ mul_m3_m3m3(R, M, scalemat);
}
else {
- copy_m3_m3(mat, M);
+ copy_m3_m3(R, M);
}
- mul_m3_fl(mat, len2);
+ mul_m3_fl(R, len2);
}
}
-void copy_dq_dq(DualQuat *dq1, const DualQuat *dq2)
+void copy_dq_dq(DualQuat *r, const DualQuat *dq)
{
- memcpy(dq1, dq2, sizeof(DualQuat));
+ memcpy(r, dq, sizeof(DualQuat));
}
/* axis matches eTrackToAxis_Modes */
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index dc6e213d0b5..4d7efa4b6f4 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -30,40 +30,40 @@
//******************************* Interpolation *******************************/
-void interp_v2_v2v2(float target[2], const float a[2], const float b[2], const float t)
+void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t)
{
const float s = 1.0f - t;
- target[0] = s * a[0] + t * b[0];
- target[1] = s * a[1] + t * b[1];
+ r[0] = s * a[0] + t * b[0];
+ r[1] = s * a[1] + t * b[1];
}
/* weight 3 2D vectors,
* 'w' must be unit length but is not a vector, just 3 weights */
void interp_v2_v2v2v2(
- float p[2], const float v1[2], const float v2[2], const float v3[2], const float w[3])
+ float r[2], const float a[2], const float b[2], const float c[2], const float t[3])
{
- p[0] = v1[0] * w[0] + v2[0] * w[1] + v3[0] * w[2];
- p[1] = v1[1] * w[0] + v2[1] * w[1] + v3[1] * w[2];
+ r[0] = a[0] * t[0] + b[0] * t[1] + c[0] * t[2];
+ r[1] = a[1] * t[0] + b[1] * t[1] + c[1] * t[2];
}
-void interp_v3_v3v3(float target[3], const float a[3], const float b[3], const float t)
+void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
{
const float s = 1.0f - t;
- target[0] = s * a[0] + t * b[0];
- target[1] = s * a[1] + t * b[1];
- target[2] = s * a[2] + t * b[2];
+ r[0] = s * a[0] + t * b[0];
+ r[1] = s * a[1] + t * b[1];
+ r[2] = s * a[2] + t * b[2];
}
-void interp_v4_v4v4(float target[4], const float a[4], const float b[4], const float t)
+void interp_v4_v4v4(float r[4], const float a[4], const float b[4], const float t)
{
const float s = 1.0f - t;
- target[0] = s * a[0] + t * b[0];
- target[1] = s * a[1] + t * b[1];
- target[2] = s * a[2] + t * b[2];
- target[3] = s * a[3] + t * b[3];
+ r[0] = s * a[0] + t * b[0];
+ r[1] = s * a[1] + t * b[1];
+ r[2] = s * a[2] + t * b[2];
+ r[3] = s * a[3] + t * b[3];
}
/**
@@ -267,17 +267,17 @@ void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], const
interp_v4_v4v4_uchar((uchar *)target, (const uchar *)a, (const uchar *)b, t);
}
-void mid_v3_v3v3(float v[3], const float v1[3], const float v2[3])
+void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
{
- v[0] = 0.5f * (v1[0] + v2[0]);
- v[1] = 0.5f * (v1[1] + v2[1]);
- v[2] = 0.5f * (v1[2] + v2[2]);
+ r[0] = 0.5f * (a[0] + b[0]);
+ r[1] = 0.5f * (a[1] + b[1]);
+ r[2] = 0.5f * (a[2] + b[2]);
}
-void mid_v2_v2v2(float v[2], const float v1[2], const float v2[2])
+void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
{
- v[0] = 0.5f * (v1[0] + v2[0]);
- v[1] = 0.5f * (v1[1] + v2[1]);
+ r[0] = 0.5f * (a[0] + b[0]);
+ r[1] = 0.5f * (a[1] + b[1]);
}
void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
@@ -408,12 +408,12 @@ bool is_finite_v4(const float v[4])
* note that when v1/v2/v3 represent 3 points along a straight line
* that the angle returned will be pi (180deg), rather then 0.0
*/
-float angle_v3v3v3(const float v1[3], const float v2[3], const float v3[3])
+float angle_v3v3v3(const float a[3], const float b[3], const float c[3])
{
float vec1[3], vec2[3];
- sub_v3_v3v3(vec1, v2, v1);
- sub_v3_v3v3(vec2, v2, v3);
+ sub_v3_v3v3(vec1, b, a);
+ sub_v3_v3v3(vec2, b, c);
normalize_v3(vec1);
normalize_v3(vec2);
@@ -434,25 +434,25 @@ float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3])
}
/* Return the shortest angle in radians between the 2 vectors */
-float angle_v3v3(const float v1[3], const float v2[3])
+float angle_v3v3(const float a[3], const float b[3])
{
float vec1[3], vec2[3];
- normalize_v3_v3(vec1, v1);
- normalize_v3_v3(vec2, v2);
+ normalize_v3_v3(vec1, a);
+ normalize_v3_v3(vec2, b);
return angle_normalized_v3v3(vec1, vec2);
}
-float angle_v2v2v2(const float v1[2], const float v2[2], const float v3[2])
+float angle_v2v2v2(const float a[2], const float b[2], const float c[2])
{
float vec1[2], vec2[2];
- vec1[0] = v2[0] - v1[0];
- vec1[1] = v2[1] - v1[1];
+ vec1[0] = b[0] - a[0];
+ vec1[1] = b[1] - a[1];
- vec2[0] = v2[0] - v3[0];
- vec2[1] = v2[1] - v3[1];
+ vec2[0] = b[0] - c[0];
+ vec2[1] = b[1] - c[1];
normalize_v2(vec1);
normalize_v2(vec2);
@@ -474,15 +474,15 @@ float cos_v2v2v2(const float p1[2], const float p2[2], const float p3[2])
}
/* Return the shortest angle in radians between the 2 vectors */
-float angle_v2v2(const float v1[2], const float v2[2])
+float angle_v2v2(const float a[2], const float b[2])
{
float vec1[2], vec2[2];
- vec1[0] = v1[0];
- vec1[1] = v1[1];
+ vec1[0] = a[0];
+ vec1[1] = a[1];
- vec2[0] = v2[0];
- vec2[1] = v2[1];
+ vec2[0] = b[0];
+ vec2[1] = b[1];
normalize_v2(vec1);
normalize_v2(vec2);
@@ -512,20 +512,20 @@ float angle_normalized_v3v3(const float v1[3], const float v2[3])
return (float)M_PI - 2.0f * saasin(len_v3v3(v1, v2_n) / 2.0f);
}
-float angle_normalized_v2v2(const float v1[2], const float v2[2])
+float angle_normalized_v2v2(const float a[2], const float b[2])
{
/* double check they are normalized */
- BLI_ASSERT_UNIT_V2(v1);
- BLI_ASSERT_UNIT_V2(v2);
+ BLI_ASSERT_UNIT_V2(a);
+ BLI_ASSERT_UNIT_V2(b);
/* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */
- if (dot_v2v2(v1, v2) >= 0.0f) {
- return 2.0f * saasin(len_v2v2(v1, v2) / 2.0f);
+ if (dot_v2v2(a, b) >= 0.0f) {
+ return 2.0f * saasin(len_v2v2(a, b) / 2.0f);
}
float v2_n[2];
- negate_v2_v2(v2_n, v2);
- return (float)M_PI - 2.0f * saasin(len_v2v2(v1, v2_n) / 2.0f);
+ negate_v2_v2(v2_n, b);
+ return (float)M_PI - 2.0f * saasin(len_v2v2(a, v2_n) / 2.0f);
}
/**
@@ -766,16 +766,16 @@ void project_v3_plane(float out[3], const float plane_no[3], const float plane_c
sub_v3_v3(out, vector);
}
-/* Returns a vector bisecting the angle at v2 formed by v1, v2 and v3 */
-void bisect_v3_v3v3v3(float out[3], const float v1[3], const float v2[3], const float v3[3])
+/* Returns a vector bisecting the angle at b formed by a, b and c */
+void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
{
float d_12[3], d_23[3];
- sub_v3_v3v3(d_12, v2, v1);
- sub_v3_v3v3(d_23, v3, v2);
+ sub_v3_v3v3(d_12, b, a);
+ sub_v3_v3v3(d_23, c, b);
normalize_v3(d_12);
normalize_v3(d_23);
- add_v3_v3v3(out, d_12, d_23);
- normalize_v3(out);
+ add_v3_v3v3(r, d_12, d_23);
+ normalize_v3(r);
}
/**
diff --git a/source/blender/blenlib/intern/memory_utils.c b/source/blender/blenlib/intern/memory_utils.c
index 91e75861dde..d477c20a242 100644
--- a/source/blender/blenlib/intern/memory_utils.c
+++ b/source/blender/blenlib/intern/memory_utils.c
@@ -31,16 +31,16 @@
#include "BLI_strict_flags.h"
/**
- * Check if memory is zero'd, as with memset(s, 0, nbytes)
+ * Check if memory is zero'd, as with memset(arr, 0, arr_size)
*/
-bool BLI_memory_is_zero(const void *s, const size_t nbytes)
+bool BLI_memory_is_zero(const void *arr, const size_t arr_size)
{
- const char *s_byte = s;
- const char *s_end = (const char *)s + nbytes;
+ const char *arr_byte = arr;
+ const char *arr_end = (const char *)arr + arr_size;
- while ((s_byte != s_end) && (*s_byte == 0)) {
- s_byte++;
+ while ((arr_byte != arr_end) && (*arr_byte == 0)) {
+ arr_byte++;
}
- return (s_byte == s_end);
+ return (arr_byte == arr_end);
}
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index ab2b0fd2928..4a2915ef24e 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -222,12 +222,12 @@ void BLI_smallhash_release(SmallHash *sh)
}
}
-void BLI_smallhash_insert(SmallHash *sh, uintptr_t key, void *val)
+void BLI_smallhash_insert(SmallHash *sh, uintptr_t key, void *item)
{
SmallHashEntry *e;
BLI_assert(key != SMHASH_KEY_UNUSED);
- BLI_assert(smallhash_val_is_used(val));
+ BLI_assert(smallhash_val_is_used(item));
BLI_assert(BLI_smallhash_haskey(sh, key) == false);
if (UNLIKELY(smallhash_test_expand_buckets(++sh->nentries, sh->nbuckets))) {
@@ -236,7 +236,7 @@ void BLI_smallhash_insert(SmallHash *sh, uintptr_t key, void *val)
e = smallhash_lookup_first_free(sh, key);
e->key = key;
- e->val = val;
+ e->val = item;
}
/**
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index db062ff50fd..a841068bfdb 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -341,11 +341,11 @@ bool BLI_file_alias_target(
* Returns the st_mode from stat-ing the specified path name, or 0 if stat fails
* (most likely doesn't exist or no access).
*/
-int BLI_exists(const char *name)
+int BLI_exists(const char *path)
{
#if defined(WIN32)
BLI_stat_t st;
- wchar_t *tmp_16 = alloc_utf16_from_8(name, 1);
+ wchar_t *tmp_16 = alloc_utf16_from_8(path, 1);
int len, res;
len = wcslen(tmp_16);
@@ -375,9 +375,9 @@ int BLI_exists(const char *name)
}
#else
struct stat st;
- BLI_assert(!BLI_path_is_rel(name));
- if (stat(name, &st)) {
- return 0;
+ BLI_assert(!BLI_path_is_rel(path));
+ if (stat(path, &st)) {
+ return (0);
}
#endif
return (st.st_mode);
@@ -582,9 +582,9 @@ void *BLI_file_read_text_as_mem_with_newline_as_nil(const char *filepath,
/**
* Reads the contents of a text file and returns the lines in a linked list.
*/
-LinkNode *BLI_file_read_as_lines(const char *name)
+LinkNode *BLI_file_read_as_lines(const char *filepath)
{
- FILE *fp = BLI_fopen(name, "r");
+ FILE *fp = BLI_fopen(filepath, "r");
LinkNodePair lines = {NULL, NULL};
char *buf;
size_t size;
diff --git a/source/blender/blenlib/tests/BLI_edgehash_test.cc b/source/blender/blenlib/tests/BLI_edgehash_test.cc
index 7106033df36..f9f0f99daa8 100644
--- a/source/blender/blenlib/tests/BLI_edgehash_test.cc
+++ b/source/blender/blenlib/tests/BLI_edgehash_test.cc
@@ -242,11 +242,11 @@ TEST(edgehash, IteratorFindsAllValues)
BLI_edgehash_insert(eh, 1, 4, VALUE_3);
EdgeHashIterator *ehi = BLI_edgehashIterator_new(eh);
- auto a = BLI_edgehashIterator_getValue(ehi);
+ auto *a = BLI_edgehashIterator_getValue(ehi);
BLI_edgehashIterator_step(ehi);
- auto b = BLI_edgehashIterator_getValue(ehi);
+ auto *b = BLI_edgehashIterator_getValue(ehi);
BLI_edgehashIterator_step(ehi);
- auto c = BLI_edgehashIterator_getValue(ehi);
+ auto *c = BLI_edgehashIterator_getValue(ehi);
BLI_edgehashIterator_step(ehi);
ASSERT_NE(a, b);
diff --git a/source/blender/blenlib/tests/BLI_string_test.cc b/source/blender/blenlib/tests/BLI_string_test.cc
index a5fd3e31c31..12f0fd5ac62 100644
--- a/source/blender/blenlib/tests/BLI_string_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_test.cc
@@ -608,21 +608,21 @@ class StringCasecmpNatural : public testing::Test {
void testReturnsZeroForAll(const CompareWordsArray &items)
{
- for (auto &item : items) {
+ for (const auto &item : items) {
int res = BLI_strcasecmp_natural(item[0], item[1]);
EXPECT_EQ(res, 0);
}
}
void testReturnsLessThanZeroForAll(const CompareWordsArray &items)
{
- for (auto &item : items) {
+ for (const auto &item : items) {
int res = BLI_strcasecmp_natural(item[0], item[1]);
EXPECT_LT(res, 0);
}
}
void testReturnsMoreThanZeroForAll(const CompareWordsArray &items)
{
- for (auto &item : items) {
+ for (const auto &item : items) {
int res = BLI_strcasecmp_natural(item[0], item[1]);
EXPECT_GT(res, 0);
}
@@ -635,7 +635,7 @@ class StringCasecmpNatural : public testing::Test {
/* E.g. {{"a", "b"}, {"ab", "cd"}} becomes {{"b", "a"}, {"cd", "ab"}} */
ret_array.reserve(items.size());
- for (auto &item : items) {
+ for (const auto &item : items) {
ret_array.push_back({item[1], item[0]});
}