diff options
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 6885a5aa351..4455e72cf45 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -148,6 +148,7 @@ MINLINE void negate_v3_short(short r[3]); MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT; MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT; +MINLINE float dot_v3v3v3(const float p[3], const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT; MINLINE float dot_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT; MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index da9d5bd3f49..6b6a3113e0b 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -621,6 +621,18 @@ MINLINE float dot_v3v3(const float a[3], const float b[3]) return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } +MINLINE float dot_v3v3v3(const float p[3], const float a[3], const float b[3]) +{ + float vec1[3], vec2[3]; + + sub_v3_v3v3(vec1, a, p); + sub_v3_v3v3(vec2, b, p); + if (is_zero_v3(vec1) || is_zero_v3(vec2)) { + return 0.0f; + } + return dot_v3v3(vec1, vec2); +} + MINLINE float dot_v4v4(const float a[4], const float b[4]) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; |