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_double3.hh3
-rw-r--r--source/blender/blenlib/BLI_float2.hh3
-rw-r--r--source/blender/blenlib/BLI_float3.hh3
-rw-r--r--source/blender/blenlib/BLI_mpq2.hh3
4 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_double3.hh b/source/blender/blenlib/BLI_double3.hh
index 0d60148e1de..5f7b0f330b9 100644
--- a/source/blender/blenlib/BLI_double3.hh
+++ b/source/blender/blenlib/BLI_double3.hh
@@ -221,7 +221,8 @@ inline double distance(const double3 &a, const double3 &b)
inline double distance_squared(const double3 &a, const double3 &b)
{
- return dot(a, b);
+ const double3 diff = a - b;
+ return dot(diff, diff);
}
inline double3 lerp(const double3 &a, const double3 &b, double t)
diff --git a/source/blender/blenlib/BLI_float2.hh b/source/blender/blenlib/BLI_float2.hh
index 40cbc272102..77173aaa0d2 100644
--- a/source/blender/blenlib/BLI_float2.hh
+++ b/source/blender/blenlib/BLI_float2.hh
@@ -168,7 +168,8 @@ inline float distance(const float2 &a, const float2 &b)
inline float distance_squared(const float2 &a, const float2 &b)
{
- return dot(a, b);
+ const float2 diff = a - b;
+ return dot(diff, diff);
}
} // namespace blender::math
diff --git a/source/blender/blenlib/BLI_float3.hh b/source/blender/blenlib/BLI_float3.hh
index dcbc462cab4..2f78be2bc35 100644
--- a/source/blender/blenlib/BLI_float3.hh
+++ b/source/blender/blenlib/BLI_float3.hh
@@ -231,7 +231,8 @@ inline float distance(const float3 &a, const float3 &b)
inline float distance_squared(const float3 &a, const float3 &b)
{
- return dot(a, b);
+ const float3 diff = a - b;
+ return dot(diff, diff);
}
inline float3 lerp(const float3 &a, const float3 &b, float t)
diff --git a/source/blender/blenlib/BLI_mpq2.hh b/source/blender/blenlib/BLI_mpq2.hh
index de88bd82890..a5b9698b2f2 100644
--- a/source/blender/blenlib/BLI_mpq2.hh
+++ b/source/blender/blenlib/BLI_mpq2.hh
@@ -175,7 +175,8 @@ inline mpq_class distance(const mpq2 &a, const mpq2 &b)
inline mpq_class distance_squared(const mpq2 &a, const mpq2 &b)
{
- return dot(a, b);
+ const mpq2 diff = a - b;
+ return dot(diff, diff);
}
} // namespace blender::math