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
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/BLI_math_base.h14
-rw-r--r--source/blender/blenlib/BLI_math_color.h19
-rw-r--r--source/blender/blenlib/BLI_math_geom.h1
-rw-r--r--source/blender/blenlib/BLI_math_vector.h2
-rw-r--r--source/blender/blenlib/intern/math_base.c4
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c2
-rw-r--r--source/blender/blenlib/intern/math_color.c55
-rw-r--r--source/blender/blenlib/intern/math_color_blend_inline.c50
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c12
-rw-r--r--source/blender/blenlib/intern/math_geom.c61
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c2
-rw-r--r--source/blender/blenlib/intern/math_interp.c40
-rw-r--r--source/blender/blenlib/intern/math_matrix.c36
-rw-r--r--source/blender/blenlib/intern/math_rotation.c74
-rw-r--r--source/blender/blenlib/intern/math_vector.c8
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c8
16 files changed, 212 insertions, 176 deletions
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 14c1055cd3a..6d37f794ce2 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -139,6 +139,9 @@ static const int NAN_INT = 0x7FC00000;
#ifndef hypotf
#define hypotf(a, b) ((float)hypot(a, b))
#endif
+#ifndef copysignf
+#define copysignf(a, b) ((float)copysign(a, b))
+#endif
#endif /* C99 or POSIX.1-2001 */
@@ -214,9 +217,17 @@ MINLINE float interpf(float a, float b, float t);
MINLINE float min_ff(float a, float b);
MINLINE float max_ff(float a, float b);
+MINLINE float min_fff(float a, float b, float c);
+MINLINE float max_fff(float a, float b, float c);
+MINLINE float min_ffff(float a, float b, float c, float d);
+MINLINE float max_ffff(float a, float b, float c, float d);
MINLINE int min_ii(int a, int b);
MINLINE int max_ii(int a, int b);
+MINLINE int min_iii(int a, int b, int c);
+MINLINE int max_iii(int a, int b, int c);
+MINLINE int min_iiii(int a, int b, int c, int d);
+MINLINE int max_iiii(int a, int b, int c, int d);
MINLINE float signf(float f);
@@ -230,6 +241,9 @@ MINLINE int power_of_2_min_i(int n);
MINLINE int divide_round_i(int a, int b);
MINLINE int mod_i(int i, int n);
+MINLINE unsigned int highest_order_bit_i(unsigned int n);
+MINLINE unsigned short highest_order_bit_s(unsigned short n);
+
MINLINE float shell_angle_to_dist(const float angle);
#if (defined(WIN32) || defined(WIN64)) && !defined(FREE_WINDOWS)
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 6f432761a55..7167aad9551 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -76,7 +76,12 @@ void rgb_to_xyz(float r, float g, float b, float *x, float *y, float *z);
unsigned int rgb_to_cpack(float r, float g, float b);
unsigned int hsv_to_cpack(float h, float s, float v);
-/* rgb_to_grayscale & rgb_to_luma functions moved to math_color_inline.c */
+MINLINE float rgb_to_bw(const float rgb[3]);
+MINLINE float rgb_to_grayscale(const float rgb[3]);
+MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]);
+MINLINE float rgb_to_luma(const float rgb[3]);
+MINLINE unsigned char rgb_to_luma_byte(const unsigned char rgb[3]);
+MINLINE float rgb_to_luma_y(const float rgb[3]);
/**************** Profile Transformations *****************/
@@ -95,6 +100,11 @@ MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4]);
MINLINE void srgb_to_linearrgb_predivide_v4(float linear[4], const float srgb[4]);
MINLINE void linearrgb_to_srgb_predivide_v4(float srgb[4], const float linear[4]);
+MINLINE unsigned short to_srgb_table_lookup(const float f);
+MINLINE void linearrgb_to_srgb_ushort4(unsigned short srgb[4], const float linear[4]);
+MINLINE void srgb_to_linearrgb_uchar4(float linear[4], const unsigned char srgb[4]);
+MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned char srgb[4]);
+
MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[3], const float linear[3]);
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4]);
@@ -126,6 +136,13 @@ void xyz_to_lab(float x, float y, float z, float *l, float *a, float *b);
MINLINE int compare_rgb_uchar(const unsigned char a[3], const unsigned char b[3], const int limit);
+#define rgba_char_args_set_fl(col, r, g, b, a) \
+ rgba_char_args_set(col, (r) * 255, (g) * 255, (b) * 255, (a) * 255)
+
+MINLINE void rgba_char_args_set(char col[4], const char r, const char g, const char b, const char a);
+MINLINE void rgba_char_args_test_set(char col[4], const char r, const char g, const char b, const char a);
+MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack);
+
/********* lift/gamma/gain / ASC-CDL conversion ***********/
void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power);
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index ad7dab0d7a6..4f41ac86a0e 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -284,6 +284,7 @@ MINLINE void zero_sh(float r[9]);
MINLINE void copy_sh_sh(float r[9], const float a[9]);
MINLINE void mul_sh_fl(float r[9], const float f);
MINLINE void add_sh_shsh(float r[9], const float a[9], const float b[9]);
+MINLINE float dot_shsh(const float a[9], const float b[9]);
MINLINE float eval_shv3(float r[9], const float v[3]);
MINLINE float diffuse_shv3(float r[9], const float v[3]);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 21bafef8678..3c0f215b165 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -125,6 +125,7 @@ MINLINE float dot_m4_v3_row_x(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_
MINLINE float dot_m4_v3_row_y(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT;
MINLINE float dot_m4_v3_row_z(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f);
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f);
@@ -174,6 +175,7 @@ MINLINE float normalize_v2(float r[2]);
MINLINE float normalize_v2_v2(float r[2], const float a[2]);
MINLINE float normalize_v3(float r[3]);
MINLINE float normalize_v3_v3(float r[3], const float a[3]);
+MINLINE double normalize_v3_d(double n[3]);
/******************************* Interpolation *******************************/
diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c
index 38d303e667a..3ff1af3513e 100644
--- a/source/blender/blenlib/intern/math_base.c
+++ b/source/blender/blenlib/intern/math_base.c
@@ -27,10 +27,10 @@
* \ingroup bli
*/
-
-
#include "BLI_math.h"
+#include "BLI_strict_flags.h"
+
/* WARNING: MSVC compiling hack for double_round() */
#if (defined(WIN32) || defined(WIN64)) && !(defined(FREE_WINDOWS))
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index c68ca3e3921..a215d99e32d 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -182,7 +182,7 @@ MINLINE unsigned short highest_order_bit_s(unsigned short n)
n |= (n >> 2);
n |= (n >> 4);
n |= (n >> 8);
- return n - (n >> 1);
+ return (unsigned short)(n - (n >> 1));
}
MINLINE float min_ff(float a, float b)
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 8cfe4706937..f57ae96e933 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -27,7 +27,6 @@
* \ingroup bli
*/
-
#include <assert.h>
#include "MEM_guardedalloc.h"
@@ -36,26 +35,26 @@
#include "BLI_rand.h"
#include "BLI_utildefines.h"
+#include "BLI_strict_flags.h"
+
void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b)
{
- int i;
- float f, p, q, t;
-
- if (s == 0.0f) {
+ if (UNLIKELY(s == 0.0f)) {
*r = v;
*g = v;
*b = v;
}
else {
+ float i, f, p, q, t;
h = (h - floorf(h)) * 6.0f;
- i = (int)floorf(h);
+ i = floorf(h);
f = h - i;
p = v * (1.0f - s);
q = v * (1.0f - (s * f));
t = v * (1.0f - (s * (1.0f - f)));
- switch (i) {
+ switch ((int)i) {
case 0:
*r = v;
*g = t;
@@ -213,9 +212,9 @@ void hex_to_rgb(char *hexcol, float *r, float *g, float *b)
return;
}
- *r = ri * (1.0f / 255.0f);
- *g = gi * (1.0f / 255.0f);
- *b = bi * (1.0f / 255.0f);
+ *r = (float)ri * (1.0f / 255.0f);
+ *g = (float)gi * (1.0f / 255.0f);
+ *b = (float)bi * (1.0f / 255.0f);
CLAMP(*r, 0.0f, 1.0f);
CLAMP(*g, 0.0f, 1.0f);
CLAMP(*b, 0.0f, 1.0f);
@@ -365,15 +364,15 @@ void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b, int
unsigned int hsv_to_cpack(float h, float s, float v)
{
- short r, g, b;
+ unsigned int r, g, b;
float rf, gf, bf;
unsigned int col;
hsv_to_rgb(h, s, v, &rf, &gf, &bf);
- r = (short) (rf * 255.0f);
- g = (short) (gf * 255.0f);
- b = (short) (bf * 255.0f);
+ r = (unsigned int) (rf * 255.0f);
+ g = (unsigned int) (gf * 255.0f);
+ b = (unsigned int) (bf * 255.0f);
col = (r + (g * 256) + (b * 256 * 256));
return col;
@@ -381,17 +380,15 @@ unsigned int hsv_to_cpack(float h, float s, float v)
unsigned int rgb_to_cpack(float r, float g, float b)
{
- int ir, ig, ib;
+ unsigned int ir, ig, ib;
+
+ ir = (unsigned int)floorf(255.0f * max_ff(r, 0.0f));
+ ig = (unsigned int)floorf(255.0f * max_ff(g, 0.0f));
+ ib = (unsigned int)floorf(255.0f * max_ff(b, 0.0f));
- ir = (int)floor(255.0f * r);
- if (ir < 0) ir = 0;
- else if (ir > 255) ir = 255;
- ig = (int)floor(255.0f * g);
- if (ig < 0) ig = 0;
- else if (ig > 255) ig = 255;
- ib = (int)floor(255.0f * b);
- if (ib < 0) ib = 0;
- else if (ib > 255) ib = 255;
+ if (ir > 255) ir = 255;
+ if (ig > 255) ig = 255;
+ if (ib > 255) ib = 255;
return (ir + (ig * 256) + (ib * 256 * 256));
}
@@ -601,14 +598,14 @@ static float index_to_float(const unsigned short i)
void BLI_init_srgb_conversion(void)
{
static int initialized = 0;
- int i, b;
+ unsigned int i, b;
if (initialized) return;
initialized = 1;
/* Fill in the lookup table to convert floats to bytes: */
for (i = 0; i < 0x10000; i++) {
- float f = linearrgb_to_srgb(index_to_float(i)) * 255.0f;
+ float f = linearrgb_to_srgb(index_to_float((unsigned short)i)) * 255.0f;
if (f <= 0) BLI_color_to_srgb_table[i] = 0;
else if (f < 255) BLI_color_to_srgb_table[i] = (unsigned short) (f * 0x100 + 0.5f);
else BLI_color_to_srgb_table[i] = 0xff00;
@@ -620,13 +617,13 @@ void BLI_init_srgb_conversion(void)
BLI_color_from_srgb_table[b] = f;
i = hipart(f);
/* replace entries so byte->float->byte does not change the data: */
- BLI_color_to_srgb_table[i] = b * 0x100;
+ BLI_color_to_srgb_table[i] = (unsigned short)(b * 0x100);
}
}
static float inverse_srgb_companding(float v)
{
if (v > 0.04045f) {
- return powf((v + 0.055f) / 1.055f, 2.4);
+ return powf((v + 0.055f) / 1.055f, 2.4f);
}
else {
return v / 12.92f;
@@ -650,7 +647,7 @@ static float xyz_to_lab_component(float v)
const float k = 903.3f;
if (v > eps) {
- return pow(v, 1.0f / 3.0f);
+ return powf(v, 1.0f / 3.0f);
}
else {
return (k * v + 16.0f) / 116.0f;
diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c
index 52947fcee08..4810fe757fa 100644
--- a/source/blender/blenlib/intern/math_color_blend_inline.c
+++ b/source/blender/blenlib/intern/math_color_blend_inline.c
@@ -60,10 +60,10 @@ MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1
tmp[2] = (mt * src1[3] * src1[2]) + (t * 255 * src2[2]);
tmp[3] = (mt * src1[3]) + (t * 255);
- dst[0] = divide_round_i(tmp[0], tmp[3]);
- dst[1] = divide_round_i(tmp[1], tmp[3]);
- dst[2] = divide_round_i(tmp[2], tmp[3]);
- dst[3] = divide_round_i(tmp[3], 255);
+ dst[0] = (unsigned char)divide_round_i(tmp[0], tmp[3]);
+ dst[1] = (unsigned char)divide_round_i(tmp[1], tmp[3]);
+ dst[2] = (unsigned char)divide_round_i(tmp[2], tmp[3]);
+ dst[3] = (unsigned char)divide_round_i(tmp[3], 255);
}
else {
/* no op */
@@ -85,9 +85,9 @@ MINLINE void blend_color_add_byte(unsigned char dst[4], const unsigned char src1
tmp[1] = (src1[1] * 255) + (src2[1] * t);
tmp[2] = (src1[2] * 255) + (src2[2] * t);
- dst[0] = min_ii(divide_round_i(tmp[0], 255), 255);
- dst[1] = min_ii(divide_round_i(tmp[1], 255), 255);
- dst[2] = min_ii(divide_round_i(tmp[2], 255), 255);
+ dst[0] = (unsigned char)min_ii(divide_round_i(tmp[0], 255), 255);
+ dst[1] = (unsigned char)min_ii(divide_round_i(tmp[1], 255), 255);
+ dst[2] = (unsigned char)min_ii(divide_round_i(tmp[2], 255), 255);
dst[3] = src1[3];
}
else {
@@ -110,9 +110,9 @@ MINLINE void blend_color_sub_byte(unsigned char dst[4], const unsigned char src1
tmp[1] = (src1[1] * 255) - (src2[1] * t);
tmp[2] = (src1[2] * 255) - (src2[2] * t);
- dst[0] = max_ii(divide_round_i(tmp[0], 255), 0);
- dst[1] = max_ii(divide_round_i(tmp[1], 255), 0);
- dst[2] = max_ii(divide_round_i(tmp[2], 255), 0);
+ dst[0] = (unsigned char)max_ii(divide_round_i(tmp[0], 255), 0);
+ dst[1] = (unsigned char)max_ii(divide_round_i(tmp[1], 255), 0);
+ dst[2] = (unsigned char)max_ii(divide_round_i(tmp[2], 255), 0);
dst[3] = src1[3];
}
else {
@@ -136,9 +136,9 @@ MINLINE void blend_color_mul_byte(unsigned char dst[4], const unsigned char src1
tmp[1] = (mt * src1[1] * 255) + (t * src1[1] * src2[1]);
tmp[2] = (mt * src1[2] * 255) + (t * src1[2] * src2[2]);
- dst[0] = divide_round_i(tmp[0], 255 * 255);
- dst[1] = divide_round_i(tmp[1], 255 * 255);
- dst[2] = divide_round_i(tmp[2], 255 * 255);
+ dst[0] = (unsigned char)divide_round_i(tmp[0], 255 * 255);
+ dst[1] = (unsigned char)divide_round_i(tmp[1], 255 * 255);
+ dst[2] = (unsigned char)divide_round_i(tmp[2], 255 * 255);
dst[3] = src1[3];
}
else {
@@ -162,9 +162,9 @@ MINLINE void blend_color_lighten_byte(unsigned char dst[4], const unsigned char
tmp[1] = (mt * src1[1]) + (t * max_ii(src1[1], src2[1]));
tmp[2] = (mt * src1[2]) + (t * max_ii(src1[2], src2[2]));
- dst[0] = divide_round_i(tmp[0], 255);
- dst[1] = divide_round_i(tmp[1], 255);
- dst[2] = divide_round_i(tmp[2], 255);
+ dst[0] = (unsigned char)divide_round_i(tmp[0], 255);
+ dst[1] = (unsigned char)divide_round_i(tmp[1], 255);
+ dst[2] = (unsigned char)divide_round_i(tmp[2], 255);
dst[3] = src1[3];
}
else {
@@ -188,9 +188,9 @@ MINLINE void blend_color_darken_byte(unsigned char dst[4], const unsigned char s
tmp[1] = (mt * src1[1]) + (t * min_ii(src1[1], src2[1]));
tmp[2] = (mt * src1[2]) + (t * min_ii(src1[2], src2[2]));
- dst[0] = divide_round_i(tmp[0], 255);
- dst[1] = divide_round_i(tmp[1], 255);
- dst[2] = divide_round_i(tmp[2], 255);
+ dst[0] = (unsigned char)divide_round_i(tmp[0], 255);
+ dst[1] = (unsigned char)divide_round_i(tmp[1], 255);
+ dst[2] = (unsigned char)divide_round_i(tmp[2], 255);
dst[3] = src1[3];
}
else {
@@ -211,7 +211,7 @@ MINLINE void blend_color_erase_alpha_byte(unsigned char dst[4], const unsigned c
dst[0] = src1[0];
dst[1] = src1[1];
dst[2] = src1[2];
- dst[3] = max_ii(src1[3] - divide_round_i(t * src2[3], 255), 0);
+ dst[3] = (unsigned char)max_ii(src1[3] - divide_round_i(t * src2[3], 255), 0);
}
else {
/* no op */
@@ -231,7 +231,7 @@ MINLINE void blend_color_add_alpha_byte(unsigned char dst[4], const unsigned cha
dst[0] = src1[0];
dst[1] = src1[1];
dst[2] = src1[2];
- dst[3] = min_ii(src1[3] + divide_round_i(t * src2[3], 255), 255);
+ dst[3] = (unsigned char)min_ii(src1[3] + divide_round_i(t * src2[3], 255), 255);
}
else {
/* no op */
@@ -251,10 +251,10 @@ MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned c
int tmp = (mt * src1[3] + t * src2[3]);
if (tmp > 0) {
- dst[0] = divide_round_i(mt * src1[0] * src1[3] + t * src2[0] * src2[3], tmp);
- dst[1] = divide_round_i(mt * src1[1] * src1[3] + t * src2[1] * src2[3], tmp);
- dst[2] = divide_round_i(mt * src1[2] * src1[3] + t * src2[2] * src2[3], tmp);
- dst[3] = divide_round_i(tmp, 255);
+ dst[0] = (unsigned char)divide_round_i(mt * src1[0] * src1[3] + t * src2[0] * src2[3], tmp);
+ dst[1] = (unsigned char)divide_round_i(mt * src1[1] * src1[3] + t * src2[1] * src2[3], tmp);
+ dst[2] = (unsigned char)divide_round_i(mt * src1[2] * src1[3] + t * src2[2] * src2[3], tmp);
+ dst[3] = (unsigned char)divide_round_i(tmp, 255);
}
else {
dst[0] = src1[0];
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 4af1307c521..bb2201541d9 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -173,10 +173,6 @@ MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned
srgb_to_linearrgb_predivide_v4(linear, fsrgb);
}
-/* color macros for themes */
-#define rgba_char_args_set_fl(col, r, g, b, a) \
- rgba_char_args_set(col, (r) * 255, (g) * 255, (b) * 255, (a) * 255)
-
MINLINE void rgba_char_args_set(char col[4], const char r, const char g, const char b, const char a)
{
col[0] = r;
@@ -228,7 +224,9 @@ MINLINE float rgb_to_grayscale(const float rgb[3])
MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
{
- return (76 * (unsigned short) rgb[0] + 148 * (unsigned short) rgb[1] + 31 * (unsigned short) rgb[2]) / 255;
+ return (unsigned char)(((76 * (unsigned short)rgb[0]) +
+ (148 * (unsigned short)rgb[1]) +
+ (31 * (unsigned short)rgb[2])) / 255);
}
/* luma from defined by 'YCC_JFIF', see #rgb_to_ycc */
@@ -239,7 +237,9 @@ MINLINE float rgb_to_luma(const float rgb[3])
MINLINE unsigned char rgb_to_luma_byte(const unsigned char rgb[3])
{
- return (76 * (unsigned short) rgb[0] + 150 * (unsigned short) rgb[1] + 29 * (unsigned short) rgb[2]) / 255;
+ return (unsigned char)(((76 * (unsigned short)rgb[0]) +
+ (150 * (unsigned short)rgb[1]) +
+ (29 * (unsigned short)rgb[2])) / 255);
}
/* gamma-corrected RGB --> CIE XYZ
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index aefdc6d1eb8..11875722d27 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -27,14 +27,14 @@
* \ingroup bli
*/
-
-
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_utildefines.h"
+#include "BLI_strict_flags.h"
+
/********************************** Polygons *********************************/
void cent_tri_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3])
@@ -321,7 +321,7 @@ float dist_squared_to_plane_v3(const float pt[3], const float plane[4])
const float length = len_squared_v3(plane);
const float side = plane_point_side_v3(plane, pt);
const float fac = side / length;
- return copysign(length * (fac * fac), side);
+ return copysignf(length * (fac * fac), side);
}
/**
@@ -394,7 +394,7 @@ void closest_on_tri_to_point_v3(float r[3], const float p[3],
/* Check if P in edge region of AB, if so return projection of P onto AB */
vc = d1 * d4 - d3 * d2;
if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) {
- float v = d1 / (d1 - d3);
+ v = d1 / (d1 - d3);
/* barycentric coordinates (1-v,v,0) */
madd_v3_v3v3fl(r, a, ab, v);
return;
@@ -411,7 +411,7 @@ void closest_on_tri_to_point_v3(float r[3], const float p[3],
/* Check if P in edge region of AC, if so return projection of P onto AC */
vb = d5 * d2 - d1 * d6;
if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) {
- float w = d2 / (d2 - d6);
+ w = d2 / (d2 - d6);
/* barycentric coordinates (1-w,0,w) */
madd_v3_v3v3fl(r, a, ac, w);
return;
@@ -419,7 +419,7 @@ void closest_on_tri_to_point_v3(float r[3], const float p[3],
/* Check if P in edge region of BC, if so return projection of P onto BC */
va = d3 * d6 - d5 * d4;
if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) {
- float w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
+ w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
/* barycentric coordinates (0,1-w,w) */
sub_v3_v3v3(r, c, b);
mul_v3_fl(r, w);
@@ -451,9 +451,9 @@ int isect_line_line_v2_int(const int v1[2], const int v2[2], const int v3[2], co
div = (float)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
if (div == 0.0f) return ISECT_LINE_LINE_COLINEAR;
- lambda = ((float)(v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
+ lambda = (float)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
- mu = ((float)(v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
+ mu = (float)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
if (lambda >= 0.0f && lambda <= 1.0f && mu >= 0.0f && mu <= 1.0f) {
if (lambda == 0.0f || lambda == 1.0f || mu == 0.0f || mu == 1.0f) return ISECT_LINE_LINE_EXACT;
@@ -637,7 +637,7 @@ int isect_line_sphere_v3(const float l1[3], const float l2[3],
return 1;
}
else if (i > 0.0f) {
- const float i_sqrt = sqrt(i); /* avoid calc twice */
+ const float i_sqrt = sqrtf(i); /* avoid calc twice */
/* first intersection */
mu = (-b + i_sqrt) / (2.0f * a);
@@ -689,7 +689,7 @@ int isect_line_sphere_v2(const float l1[2], const float l2[2],
return 1;
}
else if (i > 0.0f) {
- const float i_sqrt = sqrt(i); /* avoid calc twice */
+ const float i_sqrt = sqrtf(i); /* avoid calc twice */
/* first intersection */
mu = (-b + i_sqrt) / (2.0f * a);
@@ -747,9 +747,9 @@ bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsign
angletot = fabsf(angletot);
if (use_holes) {
- const int nested = floorf((angletot / (float)(M_PI * 2.0)) + 0.00001f);
+ const float nested = floorf((angletot / (float)(M_PI * 2.0)) + 0.00001f);
angletot -= nested * (float)(M_PI * 2.0);
- return (angletot > 4.0f) != (nested % 2);
+ return (angletot > 4.0f) != ((int)nested % 2);
}
else {
return (angletot > 4.0f);
@@ -795,9 +795,9 @@ bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsign
angletot = fabsf(angletot);
if (use_holes) {
- const int nested = floorf((angletot / (float)(M_PI * 2.0)) + 0.00001f);
+ const float nested = floorf((angletot / (float)(M_PI * 2.0)) + 0.00001f);
angletot -= nested * (float)(M_PI * 2.0);
- return (angletot > 4.0f) != (nested % 2);
+ return (angletot > 4.0f) != ((int)nested % 2);
}
else {
return (angletot > 4.0f);
@@ -2000,7 +2000,7 @@ void fill_poly_v2i_n(
/* originally by Darel Rex Finley, 2007 */
int nodes, pixel_y, i, j, swap;
- int *node_x = MEM_mallocN(sizeof(*node_x) * (nr + 1), __func__);
+ int *node_x = MEM_mallocN(sizeof(*node_x) * (size_t)(nr + 1), __func__);
/* Loop through the rows of the image. */
for (pixel_y = ymin; pixel_y < ymax; pixel_y++) {
@@ -2376,7 +2376,7 @@ void barycentric_transform(float pt_tar[3], float const pt_src[3],
/* given an array with some invalid values this function interpolates valid values
* replacing the invalid ones */
-int interp_sparse_array(float *array, int const list_size, const float skipval)
+int interp_sparse_array(float *array, const int list_size, const float skipval)
{
int found_invalid = 0;
int found_valid = 0;
@@ -2400,11 +2400,11 @@ int interp_sparse_array(float *array, int const list_size, const float skipval)
float valid_last = skipval;
int valid_ofs = 0;
- float *array_up = MEM_callocN(sizeof(float) * list_size, "interp_sparse_array up");
- float *array_down = MEM_callocN(sizeof(float) * list_size, "interp_sparse_array up");
+ float *array_up = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
+ float *array_down = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
- int *ofs_tot_up = MEM_callocN(sizeof(int) * list_size, "interp_sparse_array tup");
- int *ofs_tot_down = MEM_callocN(sizeof(int) * list_size, "interp_sparse_array tdown");
+ int *ofs_tot_up = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tup");
+ int *ofs_tot_down = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tdown");
for (i = 0; i < list_size; i++) {
if (array[i] == skipval) {
@@ -2435,7 +2435,8 @@ int interp_sparse_array(float *array, int const list_size, const float skipval)
for (i = 0; i < list_size; i++) {
if (array[i] == skipval) {
if (array_up[i] != skipval && array_down[i] != skipval) {
- array[i] = ((array_up[i] * ofs_tot_down[i]) + (array_down[i] * ofs_tot_up[i])) / (float)(ofs_tot_down[i] + ofs_tot_up[i]);
+ array[i] = ((array_up[i] * (float)ofs_tot_down[i]) +
+ (array_down[i] * (float)ofs_tot_up[i])) / (float)(ofs_tot_down[i] + ofs_tot_up[i]);
}
else if (array_up[i] != skipval) {
array[i] = array_up[i];
@@ -2705,7 +2706,7 @@ void resolve_quad_uv_deriv(float r_uv[2], float r_deriv[2][2],
/* C = (p1-p) X (p1-p2) */
const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]);
- const double denom = a - 2 * b + fC;
+ double denom = a - 2 * b + fC;
/* clear outputs */
zero_v2(r_uv);
@@ -2729,7 +2730,7 @@ void resolve_quad_uv_deriv(float r_uv[2], float r_deriv[2][2],
const double denom_s = (1 - r_uv[0]) * (st0[0] - st3[0]) + r_uv[0] * (st1[0] - st2[0]);
const double denom_t = (1 - r_uv[0]) * (st0[1] - st3[1]) + r_uv[0] * (st1[1] - st2[1]);
int i = 0;
- double denom = denom_s;
+ denom = denom_s;
if (fabs(denom_s) < fabs(denom_t)) {
i = 1;
@@ -2742,7 +2743,6 @@ void resolve_quad_uv_deriv(float r_uv[2], float r_deriv[2][2],
if (r_deriv) {
float tmp1[2], tmp2[2], s[2], t[2];
- double denom;
/* clear outputs */
zero_v2(r_deriv[0]);
@@ -2755,14 +2755,14 @@ void resolve_quad_uv_deriv(float r_uv[2], float r_deriv[2][2],
sub_v2_v2v2(tmp2, st2, st1);
interp_v2_v2v2(t, tmp1, tmp2, r_uv[0]);
- denom = t[0]*s[1] - t[1]*s[0];
+ denom = t[0] * s[1] - t[1] * s[0];
if (!IS_ZERO(denom)) {
double inv_denom = 1.0 / denom;
- r_deriv[0][0] = (double)-t[1] * inv_denom;
- r_deriv[0][1] = (double) t[0] * inv_denom;
- r_deriv[1][0] = (double) s[1] * inv_denom;
- r_deriv[1][1] = (double)-s[0] * inv_denom;
+ r_deriv[0][0] = (float)((double)-t[1] * inv_denom);
+ r_deriv[0][1] = (float)((double) t[0] * inv_denom);
+ r_deriv[1][0] = (float)((double) s[1] * inv_denom);
+ r_deriv[1][1] = (float)((double)-s[0] * inv_denom);
}
}
}
@@ -3099,7 +3099,6 @@ void accumulate_vertex_normals_poly(float **vertnos, const float polyno[3],
/* accumulate angle weighted face normal */
{
const float *prev_edge = vdiffs[nverts - 1];
- int i;
for (i = 0; i < nverts; i++) {
const float *cur_edge = vdiffs[i];
@@ -3215,7 +3214,7 @@ void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight, fl
}
}
if (!weight || !rweight) {
- accu_weight = accu_rweight = list_size;
+ accu_weight = accu_rweight = (float)list_size;
}
mul_v3_fl(accu_com, 1.0f / accu_weight);
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index 1910b964d78..a5906dbdf6c 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -79,7 +79,7 @@ MINLINE void add_sh_shsh(float r[9], const float a[9], const float b[9])
r[i] = a[i] + b[i];
}
-MINLINE float dot_shsh(float a[9], float b[9])
+MINLINE float dot_shsh(const float a[9], const float b[9])
{
float r = 0.0f;
int i;
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index 35a763c5173..9af1c8677df 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -34,6 +34,8 @@
#include "BLI_math.h"
+#include "BLI_strict_flags.h"
+
/**************************************************************************
* INTERPOLATIONS
*
@@ -114,8 +116,8 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl
i = (int)floor(u);
j = (int)floor(v);
- a = u - i;
- b = v - j;
+ a = u - (float)i;
+ b = v - (float)j;
zero_v4(out);
@@ -130,7 +132,7 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl
for (n = -1; n <= 2; n++) {
x1 = i + n;
CLAMP(x1, 0, width - 1);
- wx = P(n - a);
+ wx = P((float)n - a);
for (m = -1; m <= 2; m++) {
float data[4];
@@ -223,18 +225,18 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl
}
else {
if (components == 1) {
- byte_output[0] = out[0] + 0.5f;
+ byte_output[0] = (unsigned char)(out[0] + 0.5f);
}
else if (components == 3) {
- byte_output[0] = out[0] + 0.5f;
- byte_output[1] = out[1] + 0.5f;
- byte_output[2] = out[2] + 0.5f;
+ byte_output[0] = (unsigned char)(out[0] + 0.5f);
+ byte_output[1] = (unsigned char)(out[1] + 0.5f);
+ byte_output[2] = (unsigned char)(out[2] + 0.5f);
}
else {
- byte_output[0] = out[0] + 0.5f;
- byte_output[1] = out[1] + 0.5f;
- byte_output[2] = out[2] + 0.5f;
- byte_output[3] = out[3] + 0.5f;
+ byte_output[0] = (unsigned char)(out[0] + 0.5f);
+ byte_output[1] = (unsigned char)(out[1] + 0.5f);
+ byte_output[2] = (unsigned char)(out[2] + 0.5f);
+ byte_output[3] = (unsigned char)(out[3] + 0.5f);
}
}
}
@@ -337,18 +339,18 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b);
if (components == 1) {
- byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f;
+ byte_output[0] = (unsigned char)(ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f);
}
else if (components == 3) {
- byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f;
- byte_output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f;
- byte_output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f;
+ byte_output[0] = (unsigned char)(ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f);
+ byte_output[1] = (unsigned char)(ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f);
+ byte_output[2] = (unsigned char)(ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f);
}
else {
- byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f;
- byte_output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f;
- byte_output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f;
- byte_output[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3] + 0.5f;
+ byte_output[0] = (unsigned char)(ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f);
+ byte_output[1] = (unsigned char)(ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f);
+ byte_output[2] = (unsigned char)(ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f);
+ byte_output[3] = (unsigned char)(ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3] + 0.5f);
}
}
}
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 5b1f924fd92..a4ea406ed43 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -31,6 +31,8 @@
#include <assert.h>
#include "BLI_math.h"
+#include "BLI_strict_flags.h"
+
/********************************* Init **************************************/
void zero_m3(float m[3][3])
@@ -115,17 +117,17 @@ void copy_m4_m3(float m1[4][4], float m2[3][3]) /* no clear */
void copy_m3_m3d(float R[3][3], double A[3][3])
{
/* Keep it stupid simple for better data flow in CPU. */
- R[0][0] = A[0][0];
- R[0][1] = A[0][1];
- R[0][2] = A[0][2];
+ R[0][0] = (float)A[0][0];
+ R[0][1] = (float)A[0][1];
+ R[0][2] = (float)A[0][2];
- R[1][0] = A[1][0];
- R[1][1] = A[1][1];
- R[1][2] = A[1][2];
+ R[1][0] = (float)A[1][0];
+ R[1][1] = (float)A[1][1];
+ R[1][2] = (float)A[1][2];
- R[2][0] = A[2][0];
- R[2][1] = A[2][1];
- R[2][2] = A[2][2];
+ R[2][0] = (float)A[2][0];
+ R[2][1] = (float)A[2][1];
+ R[2][2] = (float)A[2][2];
}
void swap_m3m3(float m1[3][3], float m2[3][3])
@@ -711,11 +713,11 @@ int invert_m4_m4(float inverse[4][4], float mat[4][4])
for (i = 0; i < 4; i++) {
/* Look for row with max pivot */
- max = fabs(tempmat[i][i]);
+ max = fabsf(tempmat[i][i]);
maxj = i;
for (j = i + 1; j < 4; j++) {
if (fabsf(tempmat[j][i]) > max) {
- max = fabs(tempmat[j][i]);
+ max = fabsf(tempmat[j][i]);
maxj = j;
}
}
@@ -1029,7 +1031,7 @@ bool is_orthonormal_m4(float m[4][4])
bool is_uniform_scaled_m3(float m[3][3])
{
- const float eps = 1e-7;
+ const float eps = 1e-7f;
float t[3][3];
float l1, l2, l3, l4, l5, l6;
@@ -1626,7 +1628,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
int m = 4;
int n = 4;
int maxiter = 200;
- int nu = min_ff(m, n);
+ int nu = min_ii(m, n);
float *work = work1;
float *e = work2;
@@ -1637,14 +1639,14 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
/* Reduce A to bidiagonal form, storing the diagonal elements
* in s and the super-diagonal elements in e. */
- int nct = min_ff(m - 1, n);
- int nrt = max_ff(0, min_ff(n - 2, m));
+ int nct = min_ii(m - 1, n);
+ int nrt = max_ii(0, min_ii(n - 2, m));
copy_m4_m4(A, A_);
zero_m4(U);
zero_v4(s);
- for (k = 0; k < max_ff(nct, nrt); k++) {
+ for (k = 0; k < max_ii(nct, nrt); k++) {
if (k < nct) {
/* Compute the transformation for the k-th column and
@@ -1748,7 +1750,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
/* Set up the final bidiagonal matrix or order p. */
- p = min_ff(n, m + 1);
+ p = min_ii(n, m + 1);
if (nct < n) {
s[nct] = A[nct][nct];
}
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 41535cf32b6..536b4d79385 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -27,11 +27,11 @@
* \ingroup bli
*/
-
-
#include <assert.h>
#include "BLI_math.h"
+#include "BLI_strict_flags.h"
+
/******************************** Quaternions ********************************/
/* used to test is a quat is not normalized (only used for debug prints) */
@@ -444,7 +444,7 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
/* rotate to axis */
if (axis > 2) {
copy_v3_v3(tvec, vec);
- axis -= 3;
+ axis = (short)(axis - 3);
}
else {
negate_v3_v3(tvec, vec);
@@ -1183,10 +1183,10 @@ void eulO_to_quat(float q[4], const float e[3], const short order)
a[j] = cj * ss + sj * cc;
a[k] = cj * cs - sj * sc;
- q[0] = cj * cc + sj * ss;
- q[1] = a[0];
- q[2] = a[1];
- q[3] = a[2];
+ q[0] = (float)(cj * cc + sj * ss);
+ q[1] = (float)(a[0]);
+ q[2] = (float)(a[1]);
+ q[3] = (float)(a[2]);
if (R->parity) q[j + 1] = -q[j + 1];
}
@@ -1230,15 +1230,15 @@ void eulO_to_mat3(float M[3][3], const float e[3], const short order)
sc = si * ch;
ss = si * sh;
- M[i][i] = cj * ch;
- M[j][i] = sj * sc - cs;
- M[k][i] = sj * cc + ss;
- M[i][j] = cj * sh;
- M[j][j] = sj * ss + cc;
- M[k][j] = sj * cs - sc;
- M[i][k] = -sj;
- M[j][k] = cj * si;
- M[k][k] = cj * ci;
+ M[i][i] = (float)(cj * ch);
+ M[j][i] = (float)(sj * sc - cs);
+ M[k][i] = (float)(sj * cc + ss);
+ M[i][j] = (float)(cj * sh);
+ M[j][j] = (float)(sj * ss + cc);
+ M[k][j] = (float)(sj * cs - sc);
+ M[i][k] = (float)(-sj);
+ M[j][k] = (float)(cj * si);
+ M[k][k] = (float)(cj * ci);
}
/* returns two euler calculation methods, so we can pick the best */
@@ -1256,17 +1256,17 @@ static void mat3_to_eulo2(float M[3][3], float e1[3], float e2[3], const short o
cy = sqrt(m[i][i] * m[i][i] + m[i][j] * m[i][j]);
if (cy > 16.0 * (double)FLT_EPSILON) {
- e1[i] = atan2(m[j][k], m[k][k]);
- e1[j] = atan2(-m[i][k], cy);
- e1[k] = atan2(m[i][j], m[i][i]);
+ e1[i] = atan2f(m[j][k], m[k][k]);
+ e1[j] = atan2f(-m[i][k], (float)cy);
+ e1[k] = atan2f(m[i][j], m[i][i]);
- e2[i] = atan2(-m[j][k], -m[k][k]);
- e2[j] = atan2(-m[i][k], -cy);
- e2[k] = atan2(-m[i][j], -m[i][i]);
+ e2[i] = atan2f(-m[j][k], -m[k][k]);
+ e2[j] = atan2f(-m[i][k], (float)-cy);
+ e2[k] = atan2f(-m[i][j], -m[i][i]);
}
else {
- e1[i] = atan2(-m[k][j], m[j][j]);
- e1[j] = atan2(-m[i][k], cy);
+ e1[i] = atan2f(-m[k][j], m[j][j]);
+ e1[j] = atan2f(-m[i][k], (float)cy);
e1[k] = 0;
copy_v3_v3(e2, e1);
@@ -1632,13 +1632,14 @@ void copy_dq_dq(DualQuat *dq1, const DualQuat *dq2)
void quat_apply_track(float quat[4], short axis, short upflag)
{
/* rotations are hard coded to match vec_to_quat */
+ const float sqrt_1_2 = (float)M_SQRT1_2;
const float quat_track[][4] = {
- {M_SQRT1_2, 0.0, -M_SQRT1_2, 0.0}, /* pos-y90 */
+ {sqrt_1_2, 0.0, -sqrt_1_2, 0.0}, /* pos-y90 */
{0.5, 0.5, 0.5, 0.5}, /* Quaternion((1,0,0), radians(90)) * Quaternion((0,1,0), radians(90)) */
- {M_SQRT1_2, 0.0, 0.0, M_SQRT1_2}, /* pos-z90 */
- {M_SQRT1_2, 0.0, M_SQRT1_2, 0.0}, /* neg-y90 */
+ {sqrt_1_2, 0.0, 0.0, sqrt_1_2}, /* pos-z90 */
+ {sqrt_1_2, 0.0, sqrt_1_2, 0.0}, /* neg-y90 */
{0.5, -0.5, -0.5, 0.5}, /* Quaternion((1,0,0), radians(-90)) * Quaternion((0,1,0), radians(-90)) */
- {0.0, M_SQRT1_2, M_SQRT1_2, 0.0} /* no rotation */
+ {0.0, sqrt_1_2, sqrt_1_2, 0.0} /* no rotation */
};
assert(axis >= 0 && axis <= 5);
@@ -1646,15 +1647,16 @@ void quat_apply_track(float quat[4], short axis, short upflag)
mul_qt_qtqt(quat, quat, quat_track[axis]);
- if (axis > 2)
- axis = axis - 3;
+ if (axis > 2) {
+ axis = (short)(axis - 3);
+ }
/* there are 2 possible up-axis for each axis used, the 'quat_track' applies so the first
* up axis is used X->Y, Y->X, Z->X, if this first up axis isn't used then rotate 90d
* the strange bit shift below just find the low axis {X:Y, Y:X, Z:X} */
if (upflag != (2 - axis) >> 1) {
- float q[4] = {M_SQRT1_2, 0.0, 0.0, 0.0}; /* assign 90d rotation axis */
- q[axis + 1] = ((axis == 1)) ? M_SQRT1_2 : -M_SQRT1_2; /* flip non Y axis */
+ float q[4] = {sqrt_1_2, 0.0, 0.0, 0.0}; /* assign 90d rotation axis */
+ q[axis + 1] = ((axis == 1)) ? sqrt_1_2 : -sqrt_1_2; /* flip non Y axis */
mul_qt_qtqt(quat, quat, q);
}
}
@@ -1835,7 +1837,7 @@ static int _axis_convert_lut[23][24] = {
// _axis_convert_num = {'X': 0, 'Y': 1, 'Z': 2, '-X': 3, '-Y': 4, '-Z': 5}
-MINLINE int _axis_signed(const int axis)
+BLI_INLINE int _axis_signed(const int axis)
{
return (axis < 3) ? axis : axis - 3;
}
@@ -1849,7 +1851,7 @@ int mat3_from_axis_conversion(int from_forward, int from_up, int to_forward, int
{
// from functools import reduce
int value;
- int i;
+ unsigned int i;
if (from_forward == to_forward && from_up == to_up) {
unit_m3(r_mat);
@@ -1870,8 +1872,8 @@ int mat3_from_axis_conversion(int from_forward, int from_up, int to_forward, int
(to_up << (3 * 3)));
for (i = 0; i < (sizeof(_axis_convert_matrix) / sizeof(*_axis_convert_matrix)); i++) {
- int j;
- for (j = 0; j < sizeof(*_axis_convert_lut) / sizeof(*_axis_convert_lut[0]); j++) {
+ unsigned int j;
+ for (j = 0; j < (sizeof(*_axis_convert_lut) / sizeof(*_axis_convert_lut[0])); j++) {
if (_axis_convert_lut[i][j] == value) {
copy_m3_m3(r_mat, _axis_convert_matrix[i]);
return true;
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index ba0394dbc66..48134cbf21d 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -27,10 +27,10 @@
* \ingroup bli
*/
-
-
#include "BLI_math.h"
+#include "BLI_strict_flags.h"
+
//******************************* Interpolation *******************************/
void interp_v2_v2v2(float target[2], const float a[2], const float b[2], const float t)
@@ -497,8 +497,8 @@ void ortho_basis_v3v3_v3(float v1[3], float v2[3], const float v[3])
*/
void rotate_normalized_v3_v3v3fl(float r[3], const float p[3], const float axis[3], const float angle)
{
- const float costheta = cos(angle);
- const float sintheta = sin(angle);
+ const float costheta = cosf(angle);
+ const float sintheta = sinf(angle);
/* double check they are normalized */
BLI_ASSERT_UNIT_V3(axis);
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 05be8bda709..45a0cb3f8e2 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -580,9 +580,9 @@ MINLINE void negate_v4_v4(float r[4], const float a[4])
/* could add more... */
MINLINE void negate_v3_short(short r[3])
{
- r[0] = -r[0];
- r[1] = -r[1];
- r[2] = -r[2];
+ r[0] = (short)-r[0];
+ r[1] = (short)-r[1];
+ r[2] = (short)-r[2];
}
MINLINE float dot_v2v2(const float a[2], const float b[2])
@@ -654,7 +654,7 @@ MINLINE float len_manhattan_v2(const float v[2])
MINLINE int len_manhattan_v2_int(const int v[2])
{
- return ABS(v[0]) + ABS(v[1]);
+ return abs(v[0]) + abs(v[1]);
}
MINLINE float len_manhattan_v3(const float v[3])