diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-09 19:39:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-09 19:39:24 +0400 |
commit | 2433404e4b90581fe65c8259e58baeee14259638 (patch) | |
tree | ae18da5ef1eebbe12869bf72b8575f570295daa1 /source/blender/blenlib | |
parent | 85f15bb0ed1ee74a86c7877877fc99579bd5605c (diff) |
add inline function mul_project_m4_v3_zfac() to get the z-depth value from a vector & mat4x4
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 9 |
3 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 42a6b90f738..5476978513e 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -108,6 +108,7 @@ MINLINE void mul_v3_v3(float r[3], const float a[3]); MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]); MINLINE void mul_v4_fl(float r[4], float f); MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f); +MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]); 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]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 69ece9b9ed0..f116c9b8443 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -367,9 +367,7 @@ void mul_mat3_m4_v3(float mat[4][4], float vec[3]) void mul_project_m4_v3(float mat[4][4], float vec[3]) { - const float w = (mat[0][3] * vec[0]) + - (mat[1][3] * vec[1]) + - (mat[2][3] * vec[2]) + mat[3][3]; + const float w = mul_project_m4_v3_zfac(mat, vec); mul_m4_v3(mat, vec); vec[0] /= w; diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 48e7de43a86..c8e8ff9602b 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -398,6 +398,15 @@ MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f) r[3] = a[3] * f; } +/* note: could add a matrix inline */ +MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]) +{ + return (mat[0][3] * co[0]) + + (mat[1][3] * co[1]) + + (mat[2][3] * co[2]) + mat[3][3]; +} + + MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f) { r[0] += a[0] * f; |