diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-26 10:12:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-26 10:12:49 +0400 |
commit | 29df776b89691cc44b6d88afd5956a64aba88058 (patch) | |
tree | 858ed9eff812b2a72ef710d47f10f1d9c82b7ba7 /source/blender/blenlib | |
parent | 501649a806db6b1175694254f4be3fe249f90163 (diff) |
optimization: call one bmesh operator for rotate (not 3).
added pivot_m4() utility function since rotating about an arbitrary point is handy.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_matrix.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 723122d7814..1d877be67bd 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -175,7 +175,7 @@ void mat4_to_size(float r[3], float M[4][4]); void translate_m4(float mat[4][4], float tx, float ty, float tz); void rotate_m4(float mat[4][4], const char axis, const float angle); void rotate_m2(float mat[2][2], const float angle); - +void pivot_m4(float mat[4][4], const float pivot[3]); void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3]); void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wmat[4][4]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 312805e23f6..3f635f97ec0 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1374,6 +1374,21 @@ void rotate_m2(float mat[2][2], const float angle) mat[1][0] = -mat[0][1]; } +/* scale or rotate around a non zero pivot */ +void pivot_m4(float mat[4][4], const float pivot[3]) +{ + float tmat[4][4]; + + unit_m4(tmat); + + copy_v3_v3(tmat[3], pivot); + mul_m4_m4m4(mat, tmat, mat); + + /* invert the matrix */ + negate_v3(tmat[3]); + mul_m4_m4m4(mat, mat, tmat); +} + void blend_m3_m3m3(float out[3][3], float dst[3][3], float src[3][3], const float srcweight) { float srot[3][3], drot[3][3]; |