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:
authorCampbell Barton <ideasman42@gmail.com>2010-11-22 13:39:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-11-22 13:39:28 +0300
commitf781780cc043bc26f70c89d1292215f0491d30dc (patch)
tree38925182938b35a3821c6e906693b1aeff8e138f /source/blender/blenlib/intern/math_matrix.c
parent77dff3f9863638a5a95a1ee7e6fc2b0e9b3b8357 (diff)
- blend_m3_m3m3 and blend_m4_m4m4 now support matrices with negative scales.
- python/mathutils api matrix.lerp(other, factor) - new function mat3_to_rot_size(), like mat4_to_loc_rot_size but with no location.
Diffstat (limited to 'source/blender/blenlib/intern/math_matrix.c')
-rw-r--r--source/blender/blenlib/intern/math_matrix.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index d2bd7a0a2b1..154eb746e5c 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -976,17 +976,15 @@ float mat4_to_scale(float mat[][4])
return mat3_to_scale(tmat);
}
-void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wmat[][4])
+
+void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3])
{
- float mat3[3][3]; /* wmat -> 3x3 */
- float mat3_n[3][3]; /* wmat -> normalized, 3x3 */
- float imat3_n[3][3]; /* wmat -> normalized & inverted, 3x3 */
- /* location */
- copy_v3_v3(loc, wmat[3]);
+ float mat3_n[3][3]; /* mat3 -> normalized, 3x3 */
+ float imat3_n[3][3]; /* mat3 -> normalized & inverted, 3x3 */
/* rotation & scale are linked, we need to create the mat's
* for these together since they are related. */
- copy_m3_m4(mat3, wmat);
+
/* so scale doesnt interfear with rotation [#24291] */
/* note: this is a workaround for negative matrix not working for rotation conversion, FIXME */
normalize_m3_m3(mat3_n, mat3);
@@ -1010,6 +1008,17 @@ void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wm
size[2]= mat3[2][2];
}
+void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wmat[][4])
+{
+ float mat3[3][3]; /* wmat -> 3x3 */
+
+ copy_m3_m4(mat3, wmat);
+ mat3_to_rot_size(rot, size, mat3);
+
+ /* location */
+ copy_v3_v3(loc, wmat[3]);
+}
+
void scale_m3_fl(float m[][3], float scale)
{
m[0][0]= m[1][1]= m[2][2]= scale;
@@ -1075,18 +1084,19 @@ void rotate_m4(float mat[][4], const char axis, const float angle)
}
}
-void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], float srcweight)
+void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], const float srcweight)
{
+ float srot[3][3], drot[3][3];
float squat[4], dquat[4], fquat[4];
float ssize[3], dsize[3], fsize[3];
float rmat[3][3], smat[3][3];
- mat3_to_quat(dquat,dst);
- mat3_to_size(dsize,dst);
+ mat3_to_rot_size(drot, dsize, dst);
+ mat3_to_rot_size(srot, ssize, src);
+
+ mat3_to_quat(dquat, drot);
+ mat3_to_quat(squat, srot);
- mat3_to_quat(squat,src);
- mat3_to_size(ssize,src);
-
/* do blending */
interp_qt_qtqt(fquat, dquat, squat, srcweight);
interp_v3_v3v3(fsize, dsize, ssize, srcweight);
@@ -1097,20 +1107,19 @@ void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], float srcweig
mul_m3_m3m3(out, rmat, smat);
}
-void blend_m4_m4m4(float out[][4], float dst[][4], float src[][4], float srcweight)
+void blend_m4_m4m4(float out[][4], float dst[][4], float src[][4], const float srcweight)
{
+ float sloc[3], dloc[3], floc[3];
+ float srot[3][3], drot[3][3];
float squat[4], dquat[4], fquat[4];
float ssize[3], dsize[3], fsize[3];
- float sloc[3], dloc[3], floc[3];
-
- mat4_to_quat(dquat,dst);
- mat4_to_size(dsize,dst);
- copy_v3_v3(dloc, dst[3]);
- mat4_to_quat(squat,src);
- mat4_to_size(ssize,src);
- copy_v3_v3(sloc, src[3]);
-
+ mat4_to_loc_rot_size(dloc, drot, dsize, dst);
+ mat4_to_loc_rot_size(sloc, srot, ssize, src);
+
+ mat3_to_quat(dquat, drot);
+ mat3_to_quat(squat, srot);
+
/* do blending */
interp_v3_v3v3(floc, dloc, sloc, srcweight);
interp_qt_qtqt(fquat, dquat, squat, srcweight);