diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 3 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_math_matrix.h | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 64 | ||||
-rw-r--r-- | source/blender/collada/collada_internal.cpp | 3 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature_sketch.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 6 | ||||
-rw-r--r-- | source/blender/ikplugin/intern/iksolver_plugin.c | 3 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 6 |
9 files changed, 69 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index ad8276b902c..e1b21794f83 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4563,8 +4563,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, loc, nor, 0, 0, 0, 0); if (psys->part->rotmode == PART_ROT_VEL) { - copy_m3_m4(nmat, ob->imat); - transpose_m3(nmat); + transpose_m3_m4(nmat, ob->imat); mul_m3_v3(nmat, nor); normalize_v3(nor); diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index e58e42f3c2d..ee8b53037b0 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -144,7 +144,10 @@ void mul_v4d_m4v4d(double r[4], float M[4][4], double v[4]); /****************************** Linear Algebra *******************************/ void transpose_m3(float R[3][3]); +void transpose_m3_m3(float R[3][3], float A[3][3]); +void transpose_m3_m4(float R[3][3], float A[4][4]); void transpose_m4(float R[4][4]); +void transpose_m4_m4(float R[4][4], float A[4][4]); int compare_m4m4(float mat1[4][4], float mat2[4][4], float limit); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 115980cb3e6..293e90c8713 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -876,6 +876,37 @@ void transpose_m3(float mat[3][3]) mat[2][1] = t; } +void transpose_m3_m3(float rmat[3][3], float mat[3][3]) +{ + BLI_assert(rmat != mat); + + rmat[0][0] = mat[0][0]; + rmat[0][1] = mat[1][0]; + rmat[0][2] = mat[2][0]; + rmat[1][0] = mat[0][1]; + rmat[1][1] = mat[1][1]; + rmat[1][2] = mat[2][1]; + rmat[2][0] = mat[0][2]; + rmat[2][1] = mat[1][2]; + rmat[2][2] = mat[2][2]; +} + +/* seems obscure but in-fact a common operation */ +void transpose_m3_m4(float rmat[3][3], float mat[4][4]) +{ + BLI_assert(&rmat[0][0] != &mat[0][0]); + + rmat[0][0] = mat[0][0]; + rmat[0][1] = mat[1][0]; + rmat[0][2] = mat[2][0]; + rmat[1][0] = mat[0][1]; + rmat[1][1] = mat[1][1]; + rmat[1][2] = mat[2][1]; + rmat[2][0] = mat[0][2]; + rmat[2][1] = mat[1][2]; + rmat[2][2] = mat[2][2]; +} + void transpose_m4(float mat[4][4]) { float t; @@ -902,6 +933,28 @@ void transpose_m4(float mat[4][4]) mat[3][2] = t; } +void transpose_m4_m4(float rmat[4][4], float mat[4][4]) +{ + BLI_assert(rmat != mat); + + rmat[0][0] = mat[0][0]; + rmat[0][1] = mat[1][0]; + rmat[0][2] = mat[2][0]; + rmat[0][3] = mat[3][0]; + rmat[1][0] = mat[0][1]; + rmat[1][1] = mat[1][1]; + rmat[1][2] = mat[2][1]; + rmat[1][3] = mat[3][1]; + rmat[2][0] = mat[0][2]; + rmat[2][1] = mat[1][2]; + rmat[2][2] = mat[2][2]; + rmat[2][3] = mat[3][2]; + rmat[3][0] = mat[0][3]; + rmat[3][1] = mat[1][3]; + rmat[3][2] = mat[2][3]; + rmat[3][3] = mat[3][3]; +} + int compare_m4m4(float mat1[4][4], float mat2[4][4], float limit) { if (compare_v4v4(mat1[0], mat2[0], limit)) @@ -1145,8 +1198,7 @@ bool is_uniform_scaled_m3(float m[3][3]) float t[3][3]; float l1, l2, l3, l4, l5, l6; - copy_m3_m3(t, m); - transpose_m3(t); + transpose_m3_m3(t, m); l1 = len_squared_v3(m[0]); l2 = len_squared_v3(m[1]); @@ -1413,9 +1465,7 @@ void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3]) /* note: this is a workaround for negative matrix not working for rotation conversion, FIXME */ normalize_m3_m3(mat3_n, mat3); if (is_negative_m3(mat3)) { - negate_v3(mat3_n[0]); - negate_v3(mat3_n[1]); - negate_v3(mat3_n[2]); + negate_m3(mat3_n); } /* rotation */ @@ -1462,9 +1512,7 @@ void mat4_to_loc_quat(float loc[3], float quat[4], float wmat[4][4]) /* so scale doesn't interfere with rotation [#24291] */ /* note: this is a workaround for negative matrix not working for rotation conversion, FIXME */ if (is_negative_m3(mat3)) { - negate_v3(mat3_n[0]); - negate_v3(mat3_n[1]); - negate_v3(mat3_n[2]); + negate_m3(mat3_n); } mat3_to_quat(quat, mat3_n); diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index 567ee22b3d6..2aab9b6e7d3 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -94,8 +94,7 @@ void UnitConverter::dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math:: void UnitConverter::mat4_to_dae(float out[4][4], float in[4][4]) { - copy_m4_m4(out, in); - transpose_m4(out); + transpose_m4_m4(out, in); } void UnitConverter::mat4_to_dae_double(double out[4][4], float in[4][4]) diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index c9effe404da..737f901a055 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -403,9 +403,7 @@ static void sk_retargetStroke(bContext *C, SK_Stroke *stk) RigGraph *rg; invert_m4_m4(imat, obedit->obmat); - - copy_m3_m4(tmat, obedit->obmat); - transpose_m3(tmat); + transpose_m3_m4(tmat, obedit->obmat); arc = sk_strokeToArc(stk, imat, tmat); @@ -1358,9 +1356,7 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk) head = NULL; invert_m4_m4(invmat, obedit->obmat); - - copy_m3_m4(tmat, obedit->obmat); - transpose_m3(tmat); + transpose_m3_m4(tmat, obedit->obmat); for (i = 0; i < stk->nb_points; i++) { SK_Point *pt = stk->points + i; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index db04d3ccd66..f8f7bd1137e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2153,8 +2153,7 @@ static void calcDrawDMNormalScale(Object *ob, drawDMNormal_userData *data) invert_m3_m3(data->imat, obmat); /* transposed inverted matrix */ - copy_m3_m3(data->tmat, data->imat); - transpose_m3(data->tmat); + transpose_m3_m3(data->tmat, data->imat); } } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 8a3e8f19db4..47b20844294 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1543,8 +1543,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes float ray_start_local[3], ray_normal_local[3], local_scale, len_diff = TRANSFORM_DIST_MAX_RAY; invert_m4_m4(imat, obmat); - copy_m3_m4(timat, imat); - transpose_m3(timat); + transpose_m3_m4(timat, imat); copy_v3_v3(ray_start_local, ray_start); copy_v3_v3(ray_normal_local, ray_normal); @@ -2101,8 +2100,7 @@ static bool peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[4][4], invert_m4_m4(imat, obmat); - copy_m3_m4(timat, imat); - transpose_m3(timat); + transpose_m3_m4(timat, imat); copy_v3_v3(ray_start_local, ray_start); copy_v3_v3(ray_normal_local, ray_normal); diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index cd09b56b262..5da06ed91ec 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -307,8 +307,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) /* compute rest basis and its inverse */ copy_m3_m3(rest_basis, bone->bone_mat); - copy_m3_m3(irest_basis, bone->bone_mat); - transpose_m3(irest_basis); + transpose_m3_m3(irest_basis, bone->bone_mat); /* compute basis with rest_basis removed */ invert_m3_m3(iR_parmat, R_parmat); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index ef1478235d8..aefb2b7b0e8 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1427,8 +1427,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* 2.5 setup matrices */ mul_m4_m4m4(mat, re->viewmat, ob->obmat); invert_m4_m4(ob->imat, mat); /* need to be that way, for imat texture */ - copy_m3_m4(nmat, ob->imat); - transpose_m3(nmat); + transpose_m3_m4(nmat, ob->imat); if (psys->flag & PSYS_USE_IMAT) { /* psys->imat is the original emitter's inverse matrix, ob->obmat is the duplicated object's matrix */ @@ -2652,8 +2651,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) negative_scale = is_negative_m4(mat); /* local object -> world space transform for normals */ - copy_m4_m4(nmat, mat); - transpose_m4(nmat); + transpose_m4_m4(nmat, mat); invert_m4(nmat); /* material array */ |