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:
authorHallam Roberts <MysteryPancake>2022-03-11 18:14:05 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-03-11 20:27:58 +0300
commit3da84d8b086bd2d09beb5bdb89ba6beddf1e1dd6 (patch)
tree698e6793ba776716a256abf10ed4b1623ade15eb /source/blender/blenlib/intern
parent62a0984d7290cbd6fd3acfa79d53765f97f93b0a (diff)
Cleanup: use M_PI_2 and M_PI_4 where possible
The constant M_PI_4 is added to GLSL to ensure it works there too. Differential Revision: https://developer.blender.org/D14288
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c8
-rw-r--r--source/blender/blenlib/intern/math_vector.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 90a91cbe26f..bb6bc0db00d 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -95,10 +95,10 @@ MINLINE float saacos(float fac)
MINLINE float saasin(float fac)
{
if (UNLIKELY(fac <= -1.0f)) {
- return (float)-M_PI / 2.0f;
+ return (float)-M_PI_2;
}
else if (UNLIKELY(fac >= 1.0f)) {
- return (float)M_PI / 2.0f;
+ return (float)M_PI_2;
}
else {
return asinf(fac);
@@ -131,10 +131,10 @@ MINLINE float saacosf(float fac)
MINLINE float saasinf(float fac)
{
if (UNLIKELY(fac <= -1.0f)) {
- return (float)-M_PI / 2.0f;
+ return (float)-M_PI_2;
}
else if (UNLIKELY(fac >= 1.0f)) {
- return (float)M_PI / 2.0f;
+ return (float)M_PI_2;
}
else {
return asinf(fac);
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index e71b1150d8f..da6a6dff16f 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -289,7 +289,7 @@ void mid_v3_v3v3_angle_weighted(float r[3], const float a[3], const float b[3])
BLI_ASSERT_UNIT_V3(b);
add_v3_v3v3(r, a, b);
- angle = ((float)(1.0 / (M_PI / 2.0)) *
+ angle = ((float)M_2_PI *
/* normally we would only multiply by 2,
* but instead of an angle make this 0-1 factor */
2.0f) *
@@ -305,7 +305,7 @@ void mid_v3_angle_weighted(float r[3])
/* double check they are normalized */
BLI_assert(len_squared_v3(r) <= 1.0f + FLT_EPSILON);
- angle = ((float)(1.0 / (M_PI / 2.0)) *
+ angle = ((float)M_2_PI *
/* normally we would only multiply by 2,
* but instead of an angle make this 0-1 factor */
2.0f) *