Math lib: matrix multiplication order fix for two functions that were
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 16 Dec 2011 19:53:12 +0000 (19:53 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 16 Dec 2011 19:53:12 +0000 (19:53 +0000)
inconsistent with similar functions & math notation:

mul_m4_m4m4(R, B, A) => mult_m4_m4m4(R, A, B)
mul_m3_m3m4(R, B, A) => mult_m3_m3m4(R, A, B)

For branch maintainers, it should be relatively simple to fix things manually,
it's also possible run this script after merging to do automatic replacement:
http://www.pasteall.org/27459/python

66 files changed:
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenlib/BLI_math_matrix.h
source/blender/blenlib/intern/math_matrix.c
source/blender/blenlib/intern/math_rotation.c
source/blender/collada/AnimationExporter.cpp
source/blender/collada/AnimationImporter.cpp
source/blender/collada/ArmatureExporter.cpp
source/blender/collada/ArmatureImporter.cpp
source/blender/collada/DocumentImporter.cpp
source/blender/collada/TransformReader.cpp
source/blender/collada/TransformWriter.cpp
source/blender/collada/collada_utils.cpp
source/blender/editors/armature/editarmature.c
source/blender/editors/curve/editcurve.c
source/blender/editors/mesh/editmesh_lib.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_hook.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_manipulator.c
source/blender/gpu/intern/gpu_material.c
source/blender/ikplugin/intern/iksolver_plugin.c
source/blender/ikplugin/intern/itasc_plugin.cpp
source/blender/makesrna/intern/rna_object.c
source/blender/modifiers/intern/MOD_array.c
source/blender/modifiers/intern/MOD_boolean_util.c
source/blender/modifiers/intern/MOD_cast.c
source/blender/modifiers/intern/MOD_hook.c
source/blender/modifiers/intern/MOD_meshdeform.c
source/blender/modifiers/intern/MOD_mirror.c
source/blender/modifiers/intern/MOD_screw.c
source/blender/modifiers/intern/MOD_uvproject.c
source/blender/modifiers/intern/MOD_warp.c
source/blender/modifiers/intern/MOD_wave.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/pointdensity.c
source/blender/render/intern/source/render_texture.c
source/blender/render/intern/source/shadbuf.c
source/blender/render/intern/source/shadeinput.c
source/blender/render/intern/source/strand.c
source/blender/render/intern/source/volumetric.c
source/blender/render/intern/source/zbuf.c
source/gameengine/Converter/BL_ArmatureChannel.cpp

index 0cd8845..bb8022c 100644 (file)
@@ -726,10 +726,10 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
                        if(!is_zero_v3(group->dupli_ofs)) {
                                copy_m4_m4(tmat, go->ob->obmat);
                                sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs);
-                               mul_m4_m4m4(mat, tmat, ob->obmat);
+                               mult_m4_m4m4(mat, ob->obmat, tmat);
                        }
                        else {
-                               mul_m4_m4m4(mat, go->ob->obmat, ob->obmat);
+                               mult_m4_m4m4(mat, ob->obmat, go->ob->obmat);
                        }
                        
                        dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
@@ -955,7 +955,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
                                           when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
                                        */
                                        if(par_space_mat)
-                                               mul_m4_m4m4(vdd.obmat, ob->obmat, par_space_mat);
+                                               mult_m4_m4m4(vdd.obmat, par_space_mat, ob->obmat);
                                        else
                                                copy_m4_m4(vdd.obmat, ob->obmat);
 
@@ -1084,7 +1084,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                           when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
                                        */
                                        if(par_space_mat)
-                                               mul_m4_m4m4(ob__obmat, ob->obmat, par_space_mat);
+                                               mult_m4_m4m4(ob__obmat, par_space_mat, ob->obmat);
                                        else
                                                copy_m4_m4(ob__obmat, ob->obmat);
                                        
@@ -1396,15 +1396,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                        if(!is_zero_v3(part->dup_group->dupli_ofs)) {
                                                copy_m4_m4(tmat, oblist[b]->obmat);
                                                sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs);
-                                               mul_m4_m4m4(tmat, tmat, pamat);
+                                               mult_m4_m4m4(tmat, pamat, tmat);
                                        }
                                        else {
-                                               mul_m4_m4m4(tmat, oblist[b]->obmat, pamat);
+                                               mult_m4_m4m4(tmat, pamat, oblist[b]->obmat);
                                        }
 
                                        mul_mat3_m4_fl(tmat, size*scale);
                                        if(par_space_mat)
-                                               mul_m4_m4m4(mat, tmat, par_space_mat);
+                                               mult_m4_m4m4(mat, par_space_mat, tmat);
                                        else
                                                copy_m4_m4(mat, tmat);
 
@@ -1435,15 +1435,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                 * remove the real emitter's transformation before 2nd order duplication.
                                 */
                                if(par_space_mat && GS(id->name) != ID_GR)
-                                       mul_m4_m4m4(mat, pamat, psys->imat);
+                                       mult_m4_m4m4(mat, psys->imat, pamat);
                                else
                                        copy_m4_m4(mat, pamat);
 
-                               mul_m4_m4m4(tmat, obmat, mat);
+                               mult_m4_m4m4(tmat, mat, obmat);
                                mul_mat3_m4_fl(tmat, size*scale);
 
                                if(par_space_mat)
-                                       mul_m4_m4m4(mat, tmat, par_space_mat);
+                                       mult_m4_m4m4(mat, par_space_mat, tmat);
                                else
                                        copy_m4_m4(mat, tmat);
 
index 4035db3..ae04b77 100644 (file)
@@ -505,9 +505,9 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
                if(prev->bone->segments==1) {
                        /* find the previous roll to interpolate */
                        if(rest)
-                               mul_m4_m4m4(difmat, prev->bone->arm_mat, imat);
+                               mult_m4_m4m4(difmat, imat, prev->bone->arm_mat);
                        else
-                               mul_m4_m4m4(difmat, prev->pose_mat, imat);
+                               mult_m4_m4m4(difmat, imat, prev->pose_mat);
                        copy_m3_m4(result, difmat);                             // the desired rotation at beginning of next bone
                        
                        vec_roll_to_mat3(h1, 0.0f, mat3);                       // the result of vec_roll without roll
@@ -538,9 +538,9 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
                
                /* find the next roll to interpolate as well */
                if(rest)
-                       mul_m4_m4m4(difmat, next->bone->arm_mat, imat);
+                       mult_m4_m4m4(difmat, imat, next->bone->arm_mat);
                else
-                       mul_m4_m4m4(difmat, next->pose_mat, imat);
+                       mult_m4_m4m4(difmat, imat, next->pose_mat);
                copy_m3_m4(result, difmat);                             // the desired rotation at beginning of next bone
                
                vec_roll_to_mat3(h2, 0.0f, mat3);                       // the result of vec_roll without roll
@@ -837,7 +837,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
        
        invert_m4_m4(obinv, target->obmat);
        copy_m4_m4(premat, target->obmat);
-       mul_m4_m4m4(postmat, armOb->obmat, obinv);
+       mult_m4_m4m4(postmat, obinv, armOb->obmat);
        invert_m4_m4(premat, postmat);
 
        /* bone defmats are already in the channels, chan_mat */
@@ -1103,7 +1103,7 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4])
        invert_m4_m4(obmat, ob->obmat);
        
        /* multiply given matrix by object's-inverse to find pose-space matrix */
-       mul_m4_m4m4(outmat, obmat, inmat);
+       mult_m4_m4m4(outmat, inmat, obmat);
 }
 
 /* Convert Wolrd-Space Location to Pose-Space Location
@@ -1174,7 +1174,7 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm
         * This should leave behind the effects of restpose + 
         * parenting + constraints
         */
-       mul_m4_m4m4(pc_posemat, inv_trans, pose_mat);
+       mult_m4_m4m4(pc_posemat, pose_mat, inv_trans);
        
        /* get the inverse of the leftovers so that we can remove 
         * that component from the supplied matrix
@@ -1182,7 +1182,7 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm
        invert_m4_m4(inv_posemat, pc_posemat);
        
        /* get the new matrix */
-       mul_m4_m4m4(outmat, inmat, inv_posemat);
+       mult_m4_m4m4(outmat, inv_posemat, inmat);
 }
 
 /* Convert Pose-Space Location to Bone-Space Location
@@ -1237,7 +1237,7 @@ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float
        float imat[4][4];
        
        invert_m4_m4(imat, arm_mat);
-       mul_m4_m4m4(delta_mat, pose_mat, imat);
+       mult_m4_m4m4(delta_mat, imat, pose_mat);
 }
 
 /* **************** Rotation Mode Conversions ****************************** */
@@ -1410,7 +1410,7 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
                offs_bone[3][1]+= prevbone->length;
                
                /* Compose the matrix for this bone  */
-               mul_m4_m4m4(bone->arm_mat, offs_bone, prevbone->arm_mat);
+               mult_m4_m4m4(bone->arm_mat, prevbone->arm_mat, offs_bone);
        }
        else {
                copy_m4_m3(bone->arm_mat, bone->bone_mat);
@@ -2310,7 +2310,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
                        /* extract the scale of the parent matrix */
                        mat4_to_size(tscale, parchan->pose_mat);
                        size_to_mat4(tsmat, tscale);
-                       mul_m4_m4m4(tmat, tmat, tsmat);
+                       mult_m4_m4m4(tmat, tsmat, tmat);
 
                        mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
                }
@@ -2344,7 +2344,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
                }
        }
        else {
-               mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
+               mult_m4_m4m4(pchan->pose_mat, bone->arm_mat, pchan->chan_mat);
 
                /* optional location without arm_mat rotation */
                if(bone->flag & BONE_NO_LOCAL_LOCATION)
@@ -2466,7 +2466,7 @@ void where_is_pose (Scene *scene, Object *ob)
        for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
                if(pchan->bone) {
                        invert_m4_m4(imat, pchan->bone->arm_mat);
-                       mul_m4_m4m4(pchan->chan_mat, imat, pchan->pose_mat);
+                       mult_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
                }
        }
 }
index 2bd973d..f55ceab 100644 (file)
@@ -159,7 +159,7 @@ float object_camera_dof_distance(Object *ob)
                copy_m4_m4(obmat, ob->obmat);
                normalize_m4(obmat);
                invert_m4_m4(imat, obmat);
-               mul_m4_m4m4(mat, cam->dof_ob->obmat, imat);
+               mult_m4_m4m4(mat, imat, cam->dof_ob->obmat);
                return fabsf(mat[3][2]);
        }
        return cam->YF_dofdist;
index 87a50b8..927a98c 100644 (file)
@@ -153,7 +153,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata,
                                }
                                
                                /* matrix in world-space */
-                               mul_m4_m4m4(cob->matrix, cob->pchan->pose_mat, ob->obmat);
+                               mult_m4_m4m4(cob->matrix, ob->obmat, cob->pchan->pose_mat);
                        }
                        else
                                unit_m4(cob->matrix);
@@ -182,7 +182,7 @@ void constraints_clear_evalob (bConstraintOb *cob)
        
        /* calculate delta of constraints evaluation */
        invert_m4_m4(imat, cob->startmat);
-       mul_m4_m4m4(delta, imat, cob->matrix);
+       mult_m4_m4m4(delta, cob->matrix, imat);
        
        /* copy matrices back to source */
        switch (cob->type) {
@@ -203,7 +203,7 @@ void constraints_clear_evalob (bConstraintOb *cob)
                        /* cob->ob or cob->pchan might not exist */
                        if (cob->ob && cob->pchan) {
                                /* copy new pose-matrix back to owner */
-                               mul_m4_m4m4(cob->pchan->pose_mat, cob->matrix, cob->ob->imat);
+                               mult_m4_m4m4(cob->pchan->pose_mat, cob->ob->imat, cob->matrix);
                                
                                /* copy inverse of delta back to owner */
                                invert_m4_m4(cob->pchan->constinv, delta);
@@ -242,7 +242,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                /* world to pose */
                                invert_m4_m4(imat, ob->obmat);
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(mat, tempmat, imat);
+                               mult_m4_m4m4(mat, imat, tempmat);
                                
                                /* use pose-space as stepping stone for other spaces... */
                                if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) {
@@ -256,7 +256,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                /* pose to world */
                                if (to == CONSTRAINT_SPACE_WORLD) {
                                        copy_m4_m4(tempmat, mat);
-                                       mul_m4_m4m4(mat, tempmat, ob->obmat);
+                                       mult_m4_m4m4(mat, ob->obmat, tempmat);
                                }
                                /* pose to local */
                                else if (to == CONSTRAINT_SPACE_LOCAL) {
@@ -281,12 +281,12 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                                                offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
                                                                mul_m4_v3(pchan->parent->pose_mat, tmat[3]);
                                                                
-                                                               mul_m4_m4m4(diff_mat, offs_bone, tmat);
+                                                               mult_m4_m4m4(diff_mat, tmat, offs_bone);
                                                                invert_m4_m4(imat, diff_mat);
                                                        }
                                                        else {
                                                                /* pose_mat = par_pose_mat * bone_mat * chan_mat */
-                                                               mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat);
+                                                               mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone);
                                                                invert_m4_m4(imat, diff_mat);
                                                        }
                                                }
@@ -296,7 +296,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                                }
                                                
                                                copy_m4_m4(tempmat, mat);
-                                               mul_m4_m4m4(mat, tempmat, imat);
+                                               mult_m4_m4m4(mat, imat, tempmat);
                                        }
                                }
                                /* pose to local with parent */
@@ -304,7 +304,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                        if (pchan->bone) {
                                                invert_m4_m4(imat, pchan->bone->arm_mat);
                                                copy_m4_m4(tempmat, mat);
-                                               mul_m4_m4m4(mat, tempmat, imat);
+                                               mult_m4_m4m4(mat, imat, tempmat);
                                        }
                                }
                        }
@@ -334,22 +334,22 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                                        zero_v3(offs_bone[3]);
                                                        mul_m4_v3(pchan->parent->pose_mat, tmat[3]);
                                                        
-                                                       mul_m4_m4m4(diff_mat, offs_bone, tmat);
+                                                       mult_m4_m4m4(diff_mat, tmat, offs_bone);
                                                        copy_m4_m4(tempmat, mat);
-                                                       mul_m4_m4m4(mat, tempmat, diff_mat);
+                                                       mult_m4_m4m4(mat, diff_mat, tempmat);
                                                }
                                                else {
                                                        /* pose_mat = par_pose_mat * bone_mat * chan_mat */
-                                                       mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat);
+                                                       mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone);
                                                        copy_m4_m4(tempmat, mat);
-                                                       mul_m4_m4m4(mat, tempmat, diff_mat);
+                                                       mult_m4_m4m4(mat, diff_mat, tempmat);
                                                }
                                        }
                                        else {
                                                copy_m4_m4(diff_mat, pchan->bone->arm_mat);
                                                
                                                copy_m4_m4(tempmat, mat);
-                                               mul_m4_m4m4(mat, tempmat, diff_mat);
+                                               mult_m4_m4m4(mat, diff_mat, tempmat);
                                        }
                                }
                                
@@ -366,7 +366,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                if (pchan->bone) {                                      
                                        copy_m4_m4(diff_mat, pchan->bone->arm_mat);
                                        copy_m4_m4(tempmat, mat);
-                                       mul_m4_m4m4(mat, diff_mat, tempmat);
+                                       mult_m4_m4m4(mat, tempmat, diff_mat);
                                }
                                
                                /* use pose-space as stepping stone for other spaces */
@@ -384,10 +384,10 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                        /* check if object has a parent */
                        if (ob->parent) {
                                /* 'subtract' parent's effects from owner */
-                               mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
+                               mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
                                invert_m4_m4(imat, diff_mat);
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(mat, tempmat, imat);
+                               mult_m4_m4m4(mat, imat, tempmat);
                        }
                        else {
                                /* Local space in this case will have to be defined as local to the owner's 
@@ -399,7 +399,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                
                                invert_m4_m4(imat, diff_mat);
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(mat, tempmat, imat);
+                               mult_m4_m4m4(mat, imat, tempmat);
                        }
                }
                else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) {
@@ -407,8 +407,8 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                        if (ob->parent) {
                                /* 'add' parent's effect back to owner */
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
-                               mul_m4_m4m4(mat, tempmat, diff_mat);
+                               mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
+                               mult_m4_m4m4(mat, diff_mat, tempmat);
                        }
                        else {
                                /* Local space in this case will have to be defined as local to the owner's 
@@ -419,7 +419,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                zero_v3(diff_mat[3]);
                                
                                copy_m4_m4(tempmat, mat);
-                               mul_m4_m4m4(mat, tempmat, diff_mat);
+                               mult_m4_m4m4(mat, diff_mat, tempmat);
                        }
                }
        }
@@ -612,7 +612,7 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float
                         */
                        if (headtail < 0.000001f) {
                                /* skip length interpolation if set to head */
-                               mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat);
+                               mult_m4_m4m4(mat, ob->obmat, pchan->pose_mat);
                        }
                        else {
                                float tempmat[4][4], loc[3];
@@ -624,7 +624,7 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float
                                copy_m4_m4(tempmat, pchan->pose_mat);   
                                copy_v3_v3(tempmat[3], loc);
                                
-                               mul_m4_m4m4(mat, tempmat, ob->obmat);
+                               mult_m4_m4m4(mat, ob->obmat, tempmat);
                        }
                } 
                else
@@ -836,12 +836,12 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
                        /* multiply target (parent matrix) by offset (parent inverse) to get 
                         * the effect of the parent that will be exherted on the owner
                         */
-                       mul_m4_m4m4(parmat, data->invmat, ct->matrix);
+                       mult_m4_m4m4(parmat, ct->matrix, data->invmat);
                        
                        /* now multiply the parent matrix by the owner matrix to get the 
                         * the effect of this constraint (i.e.  owner is 'parented' to parent)
                         */
-                       mul_m4_m4m4(cob->matrix, cob->matrix, parmat);
+                       mult_m4_m4m4(cob->matrix, parmat, cob->matrix);
                }
                else {
                        float invmat[4][4], tempmat[4][4];
@@ -878,13 +878,13 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
                        /* multiply target (parent matrix) by offset (parent inverse) to get 
                         * the effect of the parent that will be exherted on the owner
                         */
-                       mul_m4_m4m4(parmat, invmat, ct->matrix);
+                       mult_m4_m4m4(parmat, ct->matrix, invmat);
                        
                        /* now multiply the parent matrix by the owner matrix to get the 
                         * the effect of this constraint (i.e.  owner is 'parented' to parent)
                         */
                        copy_m4_m4(tempmat, cob->matrix);
-                       mul_m4_m4m4(cob->matrix, tempmat, parmat);
+                       mult_m4_m4m4(cob->matrix, parmat, tempmat);
 
                        /* without this, changes to scale and rotation can change location
                         * of a parentless bone or a disconnected bone. Even though its set
@@ -1294,7 +1294,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
                                if (data->followflag & FOLLOWPATH_RADIUS) {
                                        float tmat[4][4], rmat[4][4];
                                        scale_m4_fl(tmat, radius);
-                                       mul_m4_m4m4(rmat, totmat, tmat);
+                                       mult_m4_m4m4(rmat, tmat, totmat);
                                        copy_m4_m4(totmat, rmat);
                                }
                                
@@ -2237,7 +2237,7 @@ static void actcon_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListB
                 * function has already taken care of everything else.
                 */
                copy_m4_m4(temp, cob->matrix);
-               mul_m4_m4m4(cob->matrix, ct->matrix, temp);
+               mult_m4_m4m4(cob->matrix, temp, ct->matrix);
        }
 }
 
@@ -2928,7 +2928,7 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar
                if (data->flag & MINMAX_USEROT) {
                        /* take rotation of target into account by doing the transaction in target's localspace */
                        invert_m4_m4(imat, tarmat);
-                       mul_m4_m4m4(tmat, obmat, imat);
+                       mult_m4_m4m4(tmat, imat, obmat);
                        copy_m4_m4(obmat, tmat);
                        unit_m4(tarmat);
                }
@@ -2981,7 +2981,7 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar
                        }
                        if (data->flag & MINMAX_USEROT) {
                                /* get out of localspace */
-                               mul_m4_m4m4(tmat, obmat, ct->matrix);
+                               mult_m4_m4m4(tmat, ct->matrix, obmat);
                                copy_m4_m4(cob->matrix, tmat);
                        } 
                        else {                  
@@ -4020,7 +4020,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
                                        
                                        copy_m4_m4(rmat, camob->obmat);
                                        zero_v3(rmat[3]);
-                                       mul_m4_m4m4(cob->matrix, rmat, cob->matrix);
+                                       mult_m4_m4m4(cob->matrix, cob->matrix, rmat);
                                        
                                        copy_v3_v3(cob->matrix[3], disp);
                                }
@@ -4039,7 +4039,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
                                        /* apply camera rotation so Z-axis would be co-linear */
                                        copy_m4_m4(rmat, camob->obmat);
                                        zero_v3(rmat[3]);
-                                       mul_m4_m4m4(cob->matrix, rmat, cob->matrix);
+                                       mult_m4_m4m4(cob->matrix, cob->matrix, rmat);
                                        
                                        copy_v3_v3(cob->matrix[3], disp);
                                }
@@ -4096,7 +4096,7 @@ static void camerasolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBas
                BKE_tracking_get_interpolated_camera(&clip->tracking, scene->r.cfra, mat);
                
                copy_m4_m4(obmat, cob->matrix);
-               mul_m4_m4m4(cob->matrix, mat, obmat);
+               mult_m4_m4m4(cob->matrix, obmat, mat);
        }
 }
 
index d01e3de..b9947c5 100644 (file)
@@ -1283,7 +1283,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
                }
                else {
                        /* worldspace matrix */
-                       mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat);
+                       mult_m4_m4m4(mat, ob->obmat, pchan->pose_mat);
                }
        }
        else {
index fe07662..4c30789 100644 (file)
@@ -316,7 +316,7 @@ void init_latt_deform(Object *oblatt, Object *ob)
        else {
                /* in deformspace, calc matrix */
                invert_m4_m4(imat, oblatt->obmat);
-               mul_m4_m4m4(lt->latmat, ob->obmat, imat);
+               mult_m4_m4m4(lt->latmat, imat, ob->obmat);
        
                /* back: put in deform array */
                invert_m4_m4(imat, lt->latmat);
@@ -470,7 +470,7 @@ typedef struct {
 static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc)
 {
        invert_m4_m4(ob->imat, ob->obmat);
-       mul_m4_m4m4(cd->objectspace, par->obmat, ob->imat);
+       mult_m4_m4m4(cd->objectspace, ob->imat, par->obmat);
        invert_m4_m4(cd->curvespace, cd->objectspace);
        copy_m3_m4(cd->objectspace3, cd->objectspace);
        
index 0883ec1..57fc747 100644 (file)
@@ -1679,7 +1679,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
                                        temp2[3][1]= ml->y;
                                        temp2[3][2]= ml->z;
 
-                                       mul_m4_m4m4(temp1, temp3, temp2);
+                                       mult_m4_m4m4(temp1, temp2, temp3);
                                
                                        /* make a copy because of duplicates */
                                        mainb[a]= new_pgn_element(sizeof(MetaElem));
@@ -1691,9 +1691,9 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
                                        
                                        /* mat is the matrix to transform from mball into the basis-mball */
                                        invert_m4_m4(obinv, obmat);
-                                       mul_m4_m4m4(temp2, bob->obmat, obinv);
+                                       mult_m4_m4m4(temp2, obinv, bob->obmat);
                                        /* MetaBall transformation */
-                                       mul_m4_m4m4(mat, temp1, temp2);
+                                       mult_m4_m4m4(mat, temp2, temp1);
 
                                        invert_m4_m4(imat,mat);                         
 
index 29494f0..28c1aac 100644 (file)
@@ -1363,7 +1363,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
         *   this is closer to making a copy of the object - in-place. */
        if(gob) {
                ob->rotmode= target->rotmode;
-               mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat);
+               mult_m4_m4m4(ob->obmat, gob->obmat, target->obmat);
                if(gob->dup_group) { /* should always be true */
                        float tvec[3];
                        copy_v3_v3(tvec, gob->dup_group->dupli_ofs);
@@ -1589,9 +1589,9 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const
 
        if(use_parent && ob->parent) {
                float rmat[4][4], diff_mat[4][4], imat[4][4];
-               mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
+               mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
                invert_m4_m4(imat, diff_mat);
-               mul_m4_m4m4(rmat, mat, imat); /* get the parent relative matrix */
+               mult_m4_m4m4(rmat, imat, mat); /* get the parent relative matrix */
                object_apply_mat4(ob, rmat, use_compat, FALSE);
                
                /* same as below, use rmat rather than mat */
@@ -1715,7 +1715,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
                if(cu->flag & CU_PATH_RADIUS) {
                        float tmat[4][4], rmat[4][4];
                        scale_m4_fl(tmat, radius);
-                       mul_m4_m4m4(rmat, mat, tmat);
+                       mult_m4_m4m4(rmat, tmat, mat);
                        copy_m4_m4(mat, rmat);
                }
 
@@ -2520,7 +2520,7 @@ void object_handle_update(Scene *scene, Object *ob)
                                if(ob->proxy_from->proxy_group) {/* transform proxy into group space */
                                        Object *obg= ob->proxy_from->proxy_group;
                                        invert_m4_m4(obg->imat, obg->obmat);
-                                       mul_m4_m4m4(ob->obmat, ob->proxy_from->obmat, obg->imat);
+                                       mult_m4_m4m4(ob->obmat, obg->imat, ob->proxy_from->obmat);
                                        if(obg->dup_group) { /* should always be true */
                                                add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs);
                                        }
index 000df5e..a3e13b4 100644 (file)
@@ -709,8 +709,8 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
        psys->childcachebufs.first = psys->childcachebufs.last = NULL;
 
        copy_m4_m4(data->winmat, winmat);
-       mul_m4_m4m4(data->viewmat, ob->obmat, viewmat);
-       mul_m4_m4m4(data->mat, data->viewmat, winmat);
+       mult_m4_m4m4(data->viewmat, viewmat, ob->obmat);
+       mult_m4_m4m4(data->mat, winmat, data->viewmat);
        data->winx= winx;
        data->winy= winy;
 
@@ -3374,7 +3374,7 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa
 
        psys_mat_hair_to_object(ob, dm, from, pa, facemat);
 
-       mul_m4_m4m4(hairmat, facemat, ob->obmat);
+       mult_m4_m4m4(hairmat, ob->obmat, facemat);
 }
 
 /************************************************/
index e2b0e82..828ecb2 100644 (file)
@@ -1484,7 +1484,7 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M
                        }
 
                        if(origin_set)
-                               mul_m4_m4m4(mat, mat, imat);
+                               mult_m4_m4m4(mat, imat, mat);
 
                        copy_m4_m4(reconstructed[reconstruction->camnr].mat, mat);
                        reconstructed[reconstruction->camnr].framenr= a;
@@ -1914,7 +1914,7 @@ void BKE_tracking_projection_matrix(MovieTracking *tracking, int framenr, int wi
                float imat[4][4];
 
                invert_m4_m4(imat, camera->mat);
-               mul_m4_m4m4(mat, imat, winmat);
+               mult_m4_m4m4(mat, winmat, imat);
        } else copy_m4_m4(mat, winmat);
 }
 
index 008d2ad..4d3a4df 100644 (file)
@@ -68,10 +68,12 @@ void sub_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]);
 void sub_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
 
 void mul_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]);
-void mul_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
 void mul_m4_m3m4(float R[4][4], float A[3][3], float B[4][4]);
 void mul_m4_m4m3(float R[4][4], float A[4][4], float B[3][3]);
-void mul_m3_m3m4(float R[3][3], float A[3][3], float B[4][4]);
+/* note: the A,B arguments are reversed compared to previous mul_m4_m4m4
+   function, for consistency with above functions & math notation. */
+void mult_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]);
+void mult_m3_m3m4(float R[3][3], float A[4][4], float B[3][3]);
 
 void mul_serie_m3(float R[3][3],
        float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3],
index 37cb49f..ee9cbaf 100644 (file)
@@ -142,7 +142,7 @@ void swap_m4m4(float m1[][4], float m2[][4])
 
 /******************************** Arithmetic *********************************/
 
-void mul_m4_m4m4(float m1[][4], float m2_[][4], float m3_[][4])
+void mult_m4_m4m4(float m1[][4], float m3_[][4], float m2_[][4])
 {
        float m2[4][4], m3[4][4];
 
@@ -209,7 +209,7 @@ void mul_m4_m4m3(float (*m1)[4], float (*m3)[4], float (*m2)[3])
 }
 
 /* m1 = m2 * m3, ignore the elements on the 4th row/column of m3*/
-void mul_m3_m3m4(float m1[][3], float m2[][3], float m3[][4])
+void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3])
 {
        /* m1[i][j] = m2[i][k] * m3[k][j] */
        m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] +m2[0][2] * m3[2][0];
@@ -280,19 +280,19 @@ void mul_serie_m4(float answ[][4], float m1[][4],
        
        if(m1==NULL || m2==NULL) return;
        
-       mul_m4_m4m4(answ, m2, m1);
+       mult_m4_m4m4(answ, m1, m2);
        if(m3) {
-               mul_m4_m4m4(temp, m3, answ);
+               mult_m4_m4m4(temp, answ, m3);
                if(m4) {
-                       mul_m4_m4m4(answ, m4, temp);
+                       mult_m4_m4m4(answ, temp, m4);
                        if(m5) {
-                               mul_m4_m4m4(temp, m5, answ);
+                               mult_m4_m4m4(temp, answ, m5);
                                if(m6) {
-                                       mul_m4_m4m4(answ, m6, temp);
+                                       mult_m4_m4m4(answ, temp, m6);
                                        if(m7) {
-                                               mul_m4_m4m4(temp, m7, answ);
+                                               mult_m4_m4m4(temp, answ, m7);
                                                if(m8) {
-                                                       mul_m4_m4m4(answ, m8, temp);
+                                                       mult_m4_m4m4(answ, temp, m8);
                                                }
                                                else copy_m4_m4(answ, temp);
                                        }
index e466479..5596b6f 100644 (file)
@@ -1433,7 +1433,7 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
 
        /* split scaling and rotation, there is probably a faster way to do
           this, it's done like this now to correctly get negative scaling */
-       mul_m4_m4m4(baseRS, basemat, mat);
+       mult_m4_m4m4(baseRS, mat, basemat);
        mat4_to_size(scale,baseRS);
 
        copy_v3_v3(dscale, scale);
@@ -1452,10 +1452,10 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
                copy_v3_v3(baseR[3], baseRS[3]);
 
                invert_m4_m4(baseinv, basemat);
-               mul_m4_m4m4(R, baseinv, baseR);
+               mult_m4_m4m4(R, baseR, baseinv);
 
                invert_m4_m4(baseRinv, baseR);
-               mul_m4_m4m4(S, baseRS, baseRinv);
+               mult_m4_m4m4(S, baseRinv, baseRS);
 
                /* set scaling part */
                mul_serie_m4(dq->scale, basemat, S, baseinv, NULL, NULL, NULL, NULL, NULL);
index 7bd70e9..7b57ed2 100644 (file)
@@ -767,7 +767,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames , Ob
                // compute bone local mat
                if (bone->parent) {
                        invert_m4_m4(ipar, parchan->pose_mat);
-                       mul_m4_m4m4(mat, pchan->pose_mat, ipar);
+                       mult_m4_m4m4(mat, ipar, pchan->pose_mat);
                }
                else
                        copy_m4_m4(mat, pchan->pose_mat);
@@ -1274,7 +1274,7 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i
                // compute bone local mat
                if (bone->parent) {
                        invert_m4_m4(ipar, parchan->pose_mat);
-                       mul_m4_m4m4(mat, pchan->pose_mat, ipar);
+                       mult_m4_m4m4(mat, ipar, pchan->pose_mat);
                }
                else
                        copy_m4_m4(mat, pchan->pose_mat);
index 9b4e476..c47e024 100644 (file)
@@ -723,7 +723,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
 
                        // calc M
                        calc_joint_parent_mat_rest(par, NULL, root, node);
-                       mul_m4_m4m4(temp, matfra, par);
+                       mult_m4_m4m4(temp, par, matfra);
 
                        // evaluate_joint_world_transform_at_frame(temp, NULL, , node, fra);
 
@@ -1276,7 +1276,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
 
                        // calc M
                        calc_joint_parent_mat_rest(par, NULL, root, node);
-                       mul_m4_m4m4(temp, matfra, par);
+                       mult_m4_m4m4(temp, par, matfra);
 
                        // evaluate_joint_world_transform_at_frame(temp, NULL, , node, fra);
 
@@ -1434,7 +1434,7 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::
                float temp[4][4];
                copy_m4_m4(temp, mat);
 
-               mul_m4_m4m4(mat, m, temp);
+               mult_m4_m4m4(mat, temp, m);
        }
 }
 
@@ -1597,7 +1597,7 @@ void AnimationImporter::get_joint_rest_mat(float mat[4][4], COLLADAFW::Node *roo
 
                calc_joint_parent_mat_rest(par, NULL, root, node);
                get_node_mat(m, node, NULL, NULL);
-               mul_m4_m4m4(mat, m, par);
+               mult_m4_m4m4(mat, par, m);
        }
 }
 
@@ -1616,7 +1616,7 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], float par[4]
                if (par) {
                        float temp[4][4];
                        get_node_mat(temp, node, NULL, NULL);
-                       mul_m4_m4m4(m, temp, par);
+                       mult_m4_m4m4(m, par, temp);
                }
                else {
                        get_node_mat(m, node, NULL, NULL);
@@ -1656,7 +1656,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No
                        float temp[4][4], ipar[4][4];
                        invert_m4_m4(ipar, par_job->obmat);
                        copy_m4_m4(temp, mat);
-                       mul_m4_m4m4(mat, temp, ipar);
+                       mult_m4_m4m4(mat, ipar, temp);
                }
 
                TransformBase::decompose(mat, job->loc, NULL, job->quat, job->size);
@@ -1689,7 +1689,7 @@ bool AnimationImporter::evaluate_joint_world_transform_at_frame(float mat[4][4],
        if (par) {
                float temp[4][4];
                evaluate_transform_at_frame(temp, node, node == end ? fra : 0.0f);
-               mul_m4_m4m4(m, temp, par);
+               mult_m4_m4m4(m, par, temp);
        }
        else {
                evaluate_transform_at_frame(m, node, node == end ? fra : 0.0f);
index df786c3..fcfc197 100644 (file)
@@ -218,11 +218,11 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
 
                float invpar[4][4];
                invert_m4_m4(invpar, parchan->pose_mat);
-               mul_m4_m4m4(mat, pchan->pose_mat, invpar);
+               mult_m4_m4m4(mat, invpar, pchan->pose_mat);
        }
        else {
                // get world-space from armature-space
-               mul_m4_m4m4(mat, pchan->pose_mat, ob_arm->obmat);
+               mult_m4_m4m4(mat, ob_arm->obmat, pchan->pose_mat);
        }
 
        TransformWriter::add_node_transform(node, mat,NULL );
@@ -374,7 +374,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
                        float inv_bind_mat[4][4];
 
                        // make world-space matrix, arm_mat is armature-space
-                       mul_m4_m4m4(world, pchan->bone->arm_mat, ob_arm->obmat);
+                       mult_m4_m4m4(world, ob_arm->obmat, pchan->bone->arm_mat);
                        
                        invert_m4_m4(mat, world);
                        converter.mat4_to_dae(inv_bind_mat, mat);
index bababf8..4bc0c18 100644 (file)
@@ -99,7 +99,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
 
        // get world-space
        if (parent){
-               mul_m4_m4m4(mat, obmat, parent_mat);
+               mult_m4_m4m4(mat, parent_mat, obmat);
 
        }
        else {
@@ -185,7 +185,7 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
 
                // get world-space
                if (parent)
-                       mul_m4_m4m4(mat, obmat, parent_mat);
+                       mult_m4_m4m4(mat, parent_mat, obmat);
                else
                        copy_m4_m4(mat, obmat);
 
@@ -584,17 +584,17 @@ void ArmatureImporter::set_pose ( Object * ob_arm ,  COLLADAFW::Node * root_node
 
        // get world-space
        if (parentname){
-               mul_m4_m4m4(mat, obmat, parent_mat);
+               mult_m4_m4m4(mat, parent_mat, obmat);
                bPoseChannel *parchan = get_pose_channel(ob_arm->pose, parentname);
 
-               mul_m4_m4m4(pchan->pose_mat, mat , parchan->pose_mat);
+               mult_m4_m4m4(pchan->pose_mat, parchan->pose_mat, mat );
 
        }
        else {
                copy_m4_m4(mat, obmat);
                float invObmat[4][4];
                invert_m4_m4(invObmat, ob_arm->obmat);
-               mul_m4_m4m4(pchan->pose_mat, mat, invObmat);
+               mult_m4_m4m4(pchan->pose_mat, invObmat, mat);
        }
 
        mat4_to_axis_angle(ax,&angle,mat);
index 267aa92..05b2b3b 100644 (file)
@@ -335,7 +335,7 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
                                }
                        }
                        // calc new matrix and apply
-                       mul_m4_m4m4(obn->obmat, mat, obn->obmat);
+                       mult_m4_m4m4(obn->obmat, obn->obmat, mat);
                        object_apply_mat4(obn, obn->obmat, 0, 0);
                }
        }
index 2604939..a73d524 100644 (file)
@@ -63,7 +63,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m
                        }
 
                copy_m4_m4(copy, mat);
-               mul_m4_m4m4(mat, cur, copy);
+               mult_m4_m4m4(mat, copy, cur);
 
                if (animation_map) {
                        // AnimationList that drives this Transformation
index 2b4864e..379a061 100644 (file)
@@ -40,7 +40,7 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[][4],
        if (parent_mat) {
                float invpar[4][4];
                invert_m4_m4(invpar, parent_mat);
-               mul_m4_m4m4(local, mat, invpar);
+               mult_m4_m4m4(local, invpar, mat);
        }
        else {
                copy_m4_m4(local, mat);
@@ -77,7 +77,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob)
                // calculate local mat
 
                invert_m4_m4(imat, ob->parent->obmat);
-               mul_m4_m4m4(mat, tmat, imat);
+               mult_m4_m4m4(mat, imat, tmat);
 
                // done
 
index 6a82446..c3aa735 100644 (file)
@@ -89,7 +89,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
                where_is_object(sce, par);
 
                // move child obmat into world space
-               mul_m4_m4m4(mat, ob->obmat, par->obmat);
+               mult_m4_m4m4(mat, par->obmat, ob->obmat);
                copy_m4_m4(ob->obmat, mat);
        }
        
index 6dbb08e..48f3f78 100644 (file)
@@ -936,7 +936,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
                        
                        /* Find the difference matrix */
                        invert_m4_m4(oimat, ob->obmat);
-                       mul_m4_m4m4(mat, base->object->obmat, oimat);
+                       mult_m4_m4m4(mat, oimat, base->object->obmat);
                        
                        /* Copy bones and posechannels from the object to the edit armature */
                        for (pchan=opose->chanbase.first; pchan; pchan=pchann) {
@@ -972,7 +972,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
                                        
                                        /* Find the roll */
                                        invert_m4_m4(imat, premat);
-                                       mul_m4_m4m4(difmat, postmat, imat);
+                                       mult_m4_m4m4(difmat, imat, postmat);
                                        
                                        curbone->roll -= (float)atan2(difmat[2][0], difmat[2][2]);
                                }
index a679fa3..762564c 100644 (file)
@@ -6056,7 +6056,7 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
                        
                                if(cu->nurb.first) {
                                        /* watch it: switch order here really goes wrong */
-                                       mul_m4_m4m4(cmat, base->object->obmat, imat);
+                                       mult_m4_m4m4(cmat, imat, base->object->obmat);
                                        
                                        nu= cu->nurb.first;
                                        while(nu) {
index 845cc29..5e8105d 100644 (file)
@@ -1316,7 +1316,7 @@ static short extrudeflag_edge(Object *obedit, EditMesh *em, short UNUSED(flag),
                                if (mmd->mirror_ob) {
                                        float imtx[4][4];
                                        invert_m4_m4(imtx, mmd->mirror_ob->obmat);
-                                       mul_m4_m4m4(mtx, obedit->obmat, imtx);
+                                       mult_m4_m4m4(mtx, imtx, obedit->obmat);
                                }
 
                                for (eed= em->edges.first; eed; eed= eed->next) {
@@ -1603,7 +1603,7 @@ short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor, int
                                if (mmd->mirror_ob) {
                                        float imtx[4][4];
                                        invert_m4_m4(imtx, mmd->mirror_ob->obmat);
-                                       mul_m4_m4m4(mtx, obedit->obmat, imtx);
+                                       mult_m4_m4m4(mtx, imtx, obedit->obmat);
                                }
 
                                for (eed= em->edges.first; eed; eed= eed->next) {
index 2e5fc51..37d3d5b 100644 (file)
@@ -7246,7 +7246,7 @@ static int sort_faces_exec(bContext *C, wmOperator *op)
                float cur[3];
                
                if (event == 1)
-                       mul_m4_m4m4(mat, OBACT->obmat, rv3d->viewmat); /* apply the view matrix to the object matrix */
+                       mult_m4_m4m4(mat, rv3d->viewmat, OBACT->obmat); /* apply the view matrix to the object matrix */
                else if (event == 2) { /* sort from cursor */
                        if( v3d && v3d->localvd ) {
                                VECCOPY(cur, v3d->cursor);
index 1022d24..dd82f05 100644 (file)
@@ -327,7 +327,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
                                /* if this is the object we're merging into, no need to do anything */
                                if(base->object != ob) {
                                        /* watch this: switch matmul order really goes wrong */
-                                       mul_m4_m4m4(cmat, base->object->obmat, imat);
+                                       mult_m4_m4m4(cmat, imat, base->object->obmat);
                                        
                                        /* transform vertex coordinates into new space */
                                        for(a=0, mv=mvert; a < me->totvert; a++, mv++) {
index 2a45a7d..796ca01 100644 (file)
@@ -747,7 +747,7 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op)
                 * the effect of the constraint
                 */
                invert_m4_m4(imat, pchan->pose_mat);
-               mul_m4_m4m4(tmat, imat, pmat);
+               mult_m4_m4m4(tmat, pmat, imat);
                invert_m4_m4(data->invmat, tmat);
                
                /* 5. restore constraints */
index 773974d..7bb91c1 100644 (file)
@@ -646,7 +646,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op)
                        float imat[4][4], mat[4][4];
                        
                        /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
-                       mul_m4_m4m4(mat, pchan->pose_mat, hmd->object->obmat);
+                       mult_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
                        
                        invert_m4_m4(imat, mat);
                        mul_serie_m4(hmd->parentinv, imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
index 060cae4..3aefe5f 100644 (file)
@@ -3087,8 +3087,8 @@ static void project_paint_begin(ProjPaintState *ps)
                        }
 
                        /* same as view3d_get_object_project_mat */
-                       mul_m4_m4m4(vmat, ps->ob->obmat, viewmat);
-                       mul_m4_m4m4(ps->projectMat, vmat, winmat);
+                       mult_m4_m4m4(vmat, viewmat, ps->ob->obmat);
+                       mult_m4_m4m4(ps->projectMat, winmat, vmat);
                }
 
 
index 5706633..a5da593 100644 (file)
@@ -1930,7 +1930,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
        }
 
        /* imat for normals */
-       mul_m4_m4m4(mat, ob->obmat, wpd->vc.rv3d->viewmat);
+       mult_m4_m4m4(mat, wpd->vc.rv3d->viewmat, ob->obmat);
        invert_m4_m4(imat, mat);
        copy_m3_m4(wpd->wpimat, imat);
        
@@ -1980,7 +1980,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        view3d_operator_needs_opengl(C);
                
        /* load projection matrix */
-       mul_m4_m4m4(mat, ob->obmat, vc->rv3d->persmat);
+       mult_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
 
        pressure = RNA_float_get(itemptr, "pressure");
        RNA_float_get_array(itemptr, "mouse", mval);
@@ -2361,7 +2361,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent
        copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface);
        
        /* some old cruft to sort out later */
-       mul_m4_m4m4(mat, ob->obmat, vpd->vc.rv3d->viewmat);
+       mult_m4_m4m4(mat, vpd->vc.rv3d->viewmat, ob->obmat);
        invert_m4_m4(imat, mat);
        copy_m3_m4(vpd->vpimat, imat);
 
@@ -2423,7 +2423,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        view3d_operator_needs_opengl(C);
                        
        /* load projection matrix */
-       mul_m4_m4m4(mat, ob->obmat, vc->rv3d->persmat);
+       mult_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
 
        mval[0]-= vc->ar->winrct.xmin;
        mval[1]-= vc->ar->winrct.ymin;
index b84fea2..4cd95dc 100644 (file)
@@ -2121,7 +2121,7 @@ static void do_clay_tubes_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
        copy_v3_v3(mat[3], ss->cache->location);  mat[3][3] = 1;
        normalize_m4(mat);
        scale_m4_fl(scale, ss->cache->radius);
-       mul_m4_m4m4(tmat, scale, mat);
+       mult_m4_m4m4(tmat, mat, scale);
        invert_m4_m4(mat, tmat);
 
        #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
index b0e7f1b..8a11c88 100644 (file)
@@ -2005,7 +2005,7 @@ static void set_axis(Scene *scene,  Object *ob, MovieTrackingTrack *track, char
        invert_m4(mat);
 
        object_to_mat4(ob, obmat);
-       mul_m4_m4m4(mat, obmat, mat);
+       mult_m4_m4m4(mat, mat, obmat);
        object_apply_mat4(ob, mat, 0, 0);
 }
 
@@ -2073,14 +2073,14 @@ static int set_floor_exec(bContext *C, wmOperator *op)
        invert_m4(mat);
 
        object_to_mat4(parent, obmat);
-       mul_m4_m4m4(mat, obmat, mat);
-       mul_m4_m4m4(newmat, mat, rot);
+       mult_m4_m4m4(mat, mat, obmat);
+       mult_m4_m4m4(newmat, rot, mat);
        object_apply_mat4(parent, newmat, 0, 0);
 
        /* make camera have positive z-coordinate */
        if(parent->loc[2]<0) {
                invert_m4(rot);
-               mul_m4_m4m4(newmat, mat, rot);
+               mult_m4_m4m4(newmat, rot, mat);
                object_apply_mat4(parent, newmat, 0, 0);
        }
 
index b3eba86..273336b 100644 (file)
@@ -4020,7 +4020,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
        if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) {
                float mat[4][4];
-               mul_m4_m4m4(mat, psys->imat, ob->obmat);
+               mult_m4_m4m4(mat, ob->obmat, psys->imat);
                glMultMatrixf(mat);
        }
 
index c493e4a..cac5d85 100644 (file)
@@ -204,8 +204,8 @@ ARegion *ED_view3d_context_region_unlock(bContext *C)
 void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d)
 {
        /* local viewmat and persmat, to calculate projections */
-       mul_m4_m4m4(rv3d->viewmatob, ob->obmat, rv3d->viewmat);
-       mul_m4_m4m4(rv3d->persmatob, ob->obmat, rv3d->persmat);
+       mult_m4_m4m4(rv3d->viewmatob, rv3d->viewmat, ob->obmat);
+       mult_m4_m4m4(rv3d->persmatob, rv3d->persmat, ob->obmat);
 
        /* initializes object space clipping, speeds up clip tests */
        ED_view3d_local_clipping(rv3d, ob->obmat);
index 3f97978..80b7522 100644 (file)
@@ -1993,7 +1993,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
        setwinmatrixview3d(ar, v3d, NULL);      /* 0= no pick rect */
        setviewmatrixview3d(scene, v3d, rv3d);  /* note: calls where_is_object for camera... */
 
-       mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+       mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
        invert_m4_m4(rv3d->persinv, rv3d->persmat);
        invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
 
@@ -2028,7 +2028,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *))
        setwinmatrixview3d(ar, v3d, NULL);      /* 0= no pick rect */
        setviewmatrixview3d(scene, v3d, rv3d);  /* note: calls where_is_object for camera... */
        
-       mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+       mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
        invert_m4_m4(rv3d->persinv, rv3d->persmat);
        invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
        
@@ -2219,7 +2219,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
                copy_m4_m4(rv3d.winmat, winmat);
                copy_m4_m4(rv3d.viewmat, viewmat);
                invert_m4_m4(rv3d.viewinv, rv3d.viewmat);
-               mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat);
+               mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
                invert_m4_m4(rv3d.persinv, rv3d.viewinv);
 
                ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat);
@@ -2301,7 +2301,7 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar,
                setviewmatrixview3d(scene, v3d, rv3d);  /* note: calls where_is_object for camera... */
        
        /* update utilitity matrices */
-       mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+       mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
        invert_m4_m4(rv3d->persinv, rv3d->persmat);
        invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
 
@@ -2555,7 +2555,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w
                v3d.lens= params.lens;
        }
 
-       mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat);
+       mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
        invert_m4_m4(rv3d.persinv, rv3d.viewinv);
 
        return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag, err_out);
index 6d2a745..fa970f7 100644 (file)
@@ -116,9 +116,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d)
                        ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
 
                        invert_m4_m4(v3d->camera->imat, v3d->camera->obmat);
-                       mul_m4_m4m4(diff_mat, v3d->camera->imat, view_mat);
+                       mult_m4_m4m4(diff_mat, view_mat, v3d->camera->imat);
 
-                       mul_m4_m4m4(parent_mat, root_parent->obmat, diff_mat);
+                       mult_m4_m4m4(parent_mat, diff_mat, root_parent->obmat);
 
                        object_tfm_protected_backup(root_parent, &obtfm);
                        object_apply_mat4(root_parent, parent_mat, TRUE, FALSE);
index 0cdb7a1..981d467 100644 (file)
@@ -663,8 +663,8 @@ static void move_camera(bContext* C, RegionView3D* rv3d, FlyInfo* fly, int orien
                ED_view3d_to_m4(prev_view_mat, fly->rv3d->ofs, fly->rv3d->viewquat, fly->rv3d->dist);
                invert_m4_m4(prev_view_imat, prev_view_mat);
                ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
-               mul_m4_m4m4(diff_mat, prev_view_imat, view_mat);
-               mul_m4_m4m4(parent_mat, fly->root_parent->obmat, diff_mat);
+               mult_m4_m4m4(diff_mat, view_mat, prev_view_imat);
+               mult_m4_m4m4(parent_mat, diff_mat, fly->root_parent->obmat);
                object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE);
 
                // where_is_object(scene, fly->root_parent);
index 33f7acf..1be19f1 100644 (file)
@@ -141,7 +141,7 @@ void view3d_get_transformation(ARegion *ar, RegionView3D *rv3d, Object *ob, bglM
        int i, j;
 
        if (ob) {
-               mul_m4_m4m4(cpy, ob->obmat, rv3d->viewmat);
+               mult_m4_m4m4(cpy, rv3d->viewmat, ob->obmat);
        } else {
                copy_m4_m4(cpy, rv3d->viewmat);
        }
index 89f859d..4d98afc 100644 (file)
@@ -740,8 +740,8 @@ void ED_view3d_ob_project_mat_get(RegionView3D *rv3d, Object *ob, float pmat[4][
 {
        float vmat[4][4];
        
-       mul_m4_m4m4(vmat, ob->obmat, rv3d->viewmat);
-       mul_m4_m4m4(pmat, vmat, rv3d->winmat);
+       mult_m4_m4m4(vmat, rv3d->viewmat, ob->obmat);
+       mult_m4_m4m4(pmat, rv3d->winmat, vmat);
 }
 
 #if 0
@@ -809,7 +809,7 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb)
        if(bb==NULL) return 1;
        if(bb->flag & OB_BB_DISABLED) return 1;
        
-       mul_m4_m4m4(mat, obmat, rv3d->persmat);
+       mult_m4_m4m4(mat, rv3d->persmat, obmat);
        
        for(a=0; a<8; a++) {
                copy_v3_v3(vec, bb->vec[a]);
@@ -1196,7 +1196,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
        }
        
        setwinmatrixview3d(ar, v3d, &rect);
-       mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->viewmat, vc->rv3d->winmat);
+       mult_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
        
        if(v3d->drawtype > OB_WIRE) {
                v3d->zbuf= TRUE;
@@ -1274,7 +1274,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
        
        G.f &= ~G_PICKSEL;
        setwinmatrixview3d(ar, v3d, NULL);
-       mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->viewmat, vc->rv3d->winmat);
+       mult_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
        
        if(v3d->drawtype > OB_WIRE) {
                v3d->zbuf= 0;
index 802e6cd..fd74458 100644 (file)
@@ -441,14 +441,14 @@ static short apply_targetless_ik(Object *ob)
                                                offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
                                                mul_m4_v3(parchan->parent->pose_mat, rmat[3]);
 
-                                               mul_m4_m4m4(tmat, offs_bone, rmat);
+                                               mult_m4_m4m4(tmat, rmat, offs_bone);
                                        }
                                        else if(parchan->bone->flag & BONE_NO_SCALE) {
-                                               mul_m4_m4m4(tmat, offs_bone, parchan->parent->pose_mat);
+                                               mult_m4_m4m4(tmat, parchan->parent->pose_mat, offs_bone);
                                                normalize_m4(tmat);
                                        }
                                        else
-                                               mul_m4_m4m4(tmat, offs_bone, parchan->parent->pose_mat);
+                                               mult_m4_m4m4(tmat, parchan->parent->pose_mat, offs_bone);
 
                                        invert_m4_m4(imat, tmat);
                                }
@@ -459,7 +459,7 @@ static short apply_targetless_ik(Object *ob)
                                        invert_m4_m4(imat, tmat);
                                }
                                /* result matrix */
-                               mul_m4_m4m4(rmat, parchan->pose_mat, imat);
+                               mult_m4_m4m4(rmat, imat, parchan->pose_mat);
 
                                /* apply and decompose, doesn't work for constraints or non-uniform scale well */
                                {
index d085795..e7e1ee4 100644 (file)
@@ -171,7 +171,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
                                                float obinv[4][4];
                                                
                                                invert_m4_m4(obinv, mmd->mirror_ob->obmat);
-                                               mul_m4_m4m4(mtx, ob->obmat, obinv);
+                                               mult_m4_m4m4(mtx, obinv, ob->obmat);
                                                invert_m4_m4(imtx, mtx);
                                        }
                                        
index 63495d5..5578ea7 100644 (file)
@@ -1564,7 +1564,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
        rect.ymax= mval[1]+hotspot;
 
        setwinmatrixview3d(ar, v3d, &rect);
-       mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+       mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
 
        glSelectBuffer( 64, buffer);
        glRenderMode(GL_SELECT);
@@ -1586,7 +1586,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
 
        G.f &= ~G_PICKSEL;
        setwinmatrixview3d(ar, v3d, NULL);
-       mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
+       mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
 
        if(hits==1) return buffer[3];
        else if(hits>1) {
index 4b991a3..250ea51 100644 (file)
@@ -321,9 +321,9 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float v
                        }
 
                        if(material->dynproperty & DYN_LAMP_IMAT)
-                               mul_m4_m4m4(lamp->dynimat, viewinv, lamp->imat);
+                               mult_m4_m4m4(lamp->dynimat, lamp->imat, viewinv);
                        if(material->dynproperty & DYN_LAMP_PERSMAT)
-                               mul_m4_m4m4(lamp->dynpersmat, viewinv, lamp->persmat);
+                               mult_m4_m4m4(lamp->dynpersmat, lamp->persmat, viewinv);
                }
 
                GPU_pass_update_uniforms(material->pass);
@@ -1671,7 +1671,7 @@ void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize
        normalize_v3(lamp->viewmat[2]);
 
        /* makeshadowbuf */
-       mul_m4_m4m4(persmat, lamp->viewmat, lamp->winmat);
+       mult_m4_m4m4(persmat, lamp->winmat, lamp->viewmat);
 
        /* opengl depth buffer is range 0.0..1.0 instead of -1.0..1.0 in blender */
        unit_m4(rangemat);
@@ -1682,7 +1682,7 @@ void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize
        rangemat[3][1] = 0.5f;
        rangemat[3][2] = 0.5f;
 
-       mul_m4_m4m4(lamp->persmat, persmat, rangemat);
+       mult_m4_m4m4(lamp->persmat, rangemat, persmat);
 
        /* opengl */
        glDisable(GL_SCISSOR_TEST);
index eb3695e..34656da 100644 (file)
@@ -199,7 +199,7 @@ static void make_dmats(bPoseChannel *pchan)
        if (pchan->parent) {
                float iR_parmat[4][4];
                invert_m4_m4(iR_parmat, pchan->parent->pose_mat);
-               mul_m4_m4m4(pchan->chan_mat,  pchan->pose_mat, iR_parmat);      // delta mat
+               mult_m4_m4m4(pchan->chan_mat, iR_parmat,  pchan->pose_mat);     // delta mat
        }
        else copy_m4_m4(pchan->chan_mat, pchan->pose_mat);
 }
@@ -216,7 +216,7 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[][3])   // nr = t
        if (pchan->parent)
                mul_serie_m4(pchan->pose_mat, pchan->parent->pose_mat, pchan->chan_mat, ikmat, NULL, NULL, NULL, NULL, NULL);
        else 
-               mul_m4_m4m4(pchan->pose_mat, ikmat, pchan->chan_mat);
+               mult_m4_m4m4(pchan->pose_mat, pchan->chan_mat, ikmat);
 
        /* calculate head */
        copy_v3_v3(pchan->pose_head, pchan->pose_mat[3]);
@@ -356,7 +356,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
                unit_m4(rootmat);
        copy_v3_v3(rootmat[3], pchan->pose_head);
        
-       mul_m4_m4m4(imat, rootmat, ob->obmat);
+       mult_m4_m4m4(imat, ob->obmat, rootmat);
        invert_m4_m4(goalinv, imat);
        
        for (target=tree->targets.first; target; target=target->next) {
@@ -371,7 +371,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
                get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
                
                /* and set and transform goal */
-               mul_m4_m4m4(goal, rootmat, goalinv);
+               mult_m4_m4m4(goal, goalinv, rootmat);
                
                copy_v3_v3(goalpos, goal[3]);
                copy_m3_m4(goalrot, goal);
@@ -385,7 +385,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
                                break;
                        }
                        else {
-                               mul_m4_m4m4(goal, rootmat, goalinv);
+                               mult_m4_m4m4(goal, goalinv, rootmat);
                                copy_v3_v3(polepos, goal[3]);
                                poleconstrain= 1;
 
index f4720b7..f605441 100644 (file)
@@ -570,7 +570,7 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram
                        mul_serie_m4(restmat, target->owner->obmat, chanmat, target->eeRest, NULL, NULL, NULL, NULL, NULL);
                } 
                else {
-                       mul_m4_m4m4(restmat, target->eeRest, target->owner->obmat);
+                       mult_m4_m4m4(restmat, target->owner->obmat, target->eeRest);
                }
                // blend the target
                blend_m4_m4m4(tarmat, restmat, tarmat, constraint->enforce);
@@ -597,7 +597,7 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame&
                // save the base as a frame too so that we can compute deformation
                // after simulation
                ikscene->baseFrame.setValue(&chanmat[0][0]);
-               mul_m4_m4m4(rootmat, chanmat, ikscene->blArmature->obmat);
+               mult_m4_m4m4(rootmat, ikscene->blArmature->obmat, chanmat);
        } 
        else {
                copy_m4_m4(rootmat, ikscene->blArmature->obmat);
@@ -622,11 +622,11 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame&
                // get polar target matrix in world space
                get_constraint_target_matrix(ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
                // convert to armature space
-               mul_m4_m4m4(polemat, mat, imat);
+               mult_m4_m4m4(polemat, imat, mat);
                // get the target in world space (was computed before as target object are defined before base object)
                iktarget->target->getPose().getValue(mat[0]);
                // convert to armature space
-               mul_m4_m4m4(goalmat, mat, imat);
+               mult_m4_m4m4(goalmat, imat, mat);
                // take position of target, polar target, end effector, in armature space
                KDL::Vector goalpos(goalmat[3]);
                KDL::Vector polepos(polemat[3]);
@@ -1003,7 +1003,7 @@ static void convert_pose(IK_Scene *ikscene)
                        copy_m4_m4(bmat, bone->arm_mat);
                }
                invert_m4_m4(rmat, bmat);
-               mul_m4_m4m4(bmat, pchan->pose_mat, rmat);
+               mult_m4_m4m4(bmat, rmat, pchan->pose_mat);
                normalize_m4(bmat);
                boneRot.setValue(bmat[0]);
                GetJointRotation(boneRot, ikchan->jointType, rot);
@@ -1419,7 +1419,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan)
                copy_m4_m4(mat, pchan->bone->arm_mat);
                copy_v3_v3(mat[3], pchan->bone->arm_tail);
                // get the rest pose relative to the armature base
-               mul_m4_m4m4(iktarget->eeRest, mat, invBaseFrame);
+               mult_m4_m4m4(iktarget->eeRest, invBaseFrame, mat);
                iktarget->eeBlend = (!ikscene->polarConstraint && condata->type==CONSTRAINT_IK_COPYPOSE) ? true : false;
                // use target_callback to make sure the initPose includes enforce coefficient
                target_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, iktarget);
index f920cfb..9109c8f 100644 (file)
@@ -174,7 +174,7 @@ static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
        if(ob->parent) {
                float invmat[4][4]; /* for inverse of parent's matrix */
                invert_m4_m4(invmat, ob->parent->obmat);
-               mul_m4_m4m4((float(*)[4])values, ob->obmat, invmat);
+               mult_m4_m4m4((float(*)[4])values, invmat, ob->obmat);
        }
        else {
                copy_m4_m4((float(*)[4])values, ob->obmat);
@@ -191,7 +191,7 @@ static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
        if(ob->parent) {
                float invmat[4][4];
                invert_m4_m4(invmat, ob->parentinv);
-               mul_m4_m4m4(ob->obmat, (float(*)[4])values, invmat);
+               mult_m4_m4m4(ob->obmat, invmat, (float(*)[4])values);
        }
        else {
                copy_m4_m4(ob->obmat, (float(*)[4])values);
index ce052b2..4602600 100644 (file)
@@ -338,7 +338,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
        unit_m4(final_offset);
 
        for(j=0; j < count - 1; j++) {
-               mul_m4_m4m4(tmp_mat, final_offset, offset);
+               mult_m4_m4m4(tmp_mat, offset, final_offset);
                copy_m4_m4(final_offset, tmp_mat);
        }
 
@@ -679,7 +679,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
                cap_medge = end_cap->getEdgeArray(end_cap);
                cap_mface = end_cap->getFaceArray(end_cap);
 
-               mul_m4_m4m4(endoffset, final_offset, offset);
+               mult_m4_m4m4(endoffset, offset, final_offset);
 
                vert_map = MEM_callocN(sizeof(*vert_map) * capVerts,
                "arrayModifier_doArray vert_map");
index 8435011..afd16b4 100644 (file)
@@ -474,7 +474,7 @@ static DerivedMesh *NewBooleanDerivedMesh_intern(
        // we need to compute the inverse transform from global to ob (inv_mat),
        // and the transform from ob to ob_select for use in interpolation (map_mat)
        invert_m4_m4(inv_mat, ob->obmat);
-       mul_m4_m4m4(map_mat, ob_select->obmat, inv_mat);
+       mult_m4_m4m4(map_mat, inv_mat, ob_select->obmat);
        invert_m4_m4(inv_mat, ob_select->obmat);
 
        {
index e481f69..16d57a2 100644 (file)
@@ -159,7 +159,7 @@ static void sphere_do(
        if (ctrl_ob) {
                if(flag & MOD_CAST_USE_OB_TRANSFORM) {
                        invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat);
-                       mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat);
+                       mult_m4_m4m4(mat, ctrl_ob->imat, ob->obmat);
                        invert_m4_m4(imat, mat);
                }
 
@@ -331,7 +331,7 @@ static void cuboid_do(
        if (ctrl_ob) {
                if(flag & MOD_CAST_USE_OB_TRANSFORM) {
                        invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat);
-                       mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat);
+                       mult_m4_m4m4(mat, ctrl_ob->imat, ob->obmat);
                        invert_m4_m4(imat, mat);
                }
 
index 9948a1a..f5e4ebf 100644 (file)
@@ -157,7 +157,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm,
        /* get world-space matrix of target, corrected for the space the verts are in */
        if (hmd->subtarget[0] && pchan) {
                /* bone target if there's a matching pose-channel */
-               mul_m4_m4m4(dmat, pchan->pose_mat, hmd->object->obmat);
+               mult_m4_m4m4(dmat, hmd->object->obmat, pchan->pose_mat);
        }
        else {
                /* just object target */
index bcbb6c6..e6e2c0f 100644 (file)
@@ -223,8 +223,8 @@ static void meshdeformModifier_do(
 
        /* compute matrices to go in and out of cage object space */
        invert_m4_m4(imat, mmd->object->obmat);
-       mul_m4_m4m4(cagemat, ob->obmat, imat);
-       mul_m4_m4m4(cmat, cagemat, mmd->bindmat);
+       mult_m4_m4m4(cagemat, imat, ob->obmat);
+       mult_m4_m4m4(cmat, mmd->bindmat, cagemat);
        invert_m4_m4(iobmat, cmat);
        copy_m3_m4(icagemat, iobmat);
 
index 5336cb0..c72a76f 100644 (file)
@@ -129,7 +129,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
                float obinv[4][4];
                
                invert_m4_m4(obinv, mmd->mirror_ob->obmat);
-               mul_m4_m4m4(mtx, ob->obmat, obinv);
+               mult_m4_m4m4(mtx, obinv, ob->obmat);
                invert_m4_m4(imtx, mtx);
        }
 
index 5dc233c..0867a4b 100644 (file)
@@ -197,7 +197,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                /* calc the matrix relative to the axis object */
                invert_m4_m4(mtx_tmp_a, ob->obmat);
                copy_m4_m4(mtx_tx_inv, ltmd->ob_axis->obmat);
-               mul_m4_m4m4(mtx_tx, mtx_tx_inv, mtx_tmp_a);
+               mult_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv);
 
                /* calc the axis vec */
                mul_mat3_m4_v3(mtx_tx, axis_vec); /* only rotation component */
index 584aa6d..af61c80 100644 (file)
@@ -222,11 +222,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
                                if(cam->type == CAM_PERSP) {
                                        float perspmat[4][4];
                                        perspective_m4( perspmat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
-                                       mul_m4_m4m4(tmpmat, projectors[i].projmat, perspmat);
+                                       mult_m4_m4m4(tmpmat, perspmat, projectors[i].projmat);
                                } else { /* if(cam->type == CAM_ORTHO) */
                                        float orthomat[4][4];
                                        orthographic_m4( orthomat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
-                                       mul_m4_m4m4(tmpmat, projectors[i].projmat, orthomat);
+                                       mult_m4_m4m4(tmpmat, orthomat, projectors[i].projmat);
                                }
                        }
                } else {
@@ -250,7 +250,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
                        }
                }
                
-               mul_m4_m4m4(projectors[i].projmat, tmpmat, offsetmat);
+               mult_m4_m4m4(projectors[i].projmat, offsetmat, tmpmat);
 
                /* calculate worldspace projector normal (for best projector test) */
                projectors[i].normal[0] = 0;
index 8422916..41702a7 100644 (file)
@@ -197,11 +197,11 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
 
        invert_m4_m4(obinv, ob->obmat);
 
-       mul_m4_m4m4(mat_from, wmd->object_from->obmat, obinv);
-       mul_m4_m4m4(mat_to, wmd->object_to->obmat, obinv);
+       mult_m4_m4m4(mat_from, obinv, wmd->object_from->obmat);
+       mult_m4_m4m4(mat_to, obinv, wmd->object_to->obmat);
 
        invert_m4_m4(tmat, mat_from); // swap?
-       mul_m4_m4m4(mat_final, mat_to, tmat);
+       mult_m4_m4m4(mat_final, tmat, mat_to);
 
        invert_m4_m4(mat_from_inv, mat_from);
 
index 80dd0c0..398a078 100644 (file)
@@ -279,7 +279,7 @@ static void waveModifier_do(WaveModifierData *md,
                float mat[4][4];
                /* get the control object's location in local coordinates */
                invert_m4_m4(ob->imat, ob->obmat);
-               mul_m4_m4m4(mat, wmd->objectcenter->obmat, ob->imat);
+               mult_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat);
 
                wmd->startx = mat[3][0];
                wmd->starty = mat[3][1];
index d396522..78f2fe6 100644 (file)
@@ -1690,14 +1690,14 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
        }
        
 /* 2.5 setup matrices */
-       mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+       mult_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);
 
        if(psys->flag & PSYS_USE_IMAT) {
                /* psys->imat is the original emitter's inverse matrix, ob->obmat is the duplicated object's matrix */
-               mul_m4_m4m4(duplimat, psys->imat, ob->obmat);
+               mult_m4_m4m4(duplimat, ob->obmat, psys->imat);
                use_duplimat = 1;
        }
 
@@ -2134,7 +2134,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int
        float vec[3], hasize, mat[4][4], imat[3][3];
        int a, ok, seed= ma->seed1;
 
-       mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+       mult_m4_m4m4(mat, re->viewmat, ob->obmat);
        copy_m3_m4(imat, ob->imat);
 
        re->flag |= R_HALO;
@@ -2429,7 +2429,7 @@ static void init_render_mball(Render *re, ObjectRen *obr)
        if (ob!=find_basis_mball(re->scene, ob))
                return;
 
-       mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+       mult_m4_m4m4(mat, re->viewmat, ob->obmat);
        invert_m4_m4(ob->imat, mat);
        copy_m3_m4(imat, ob->imat);
 
@@ -2802,7 +2802,7 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset)
        nu= cu->nurb.first;
        if(nu==0) return;
 
-       mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+       mult_m4_m4m4(mat, re->viewmat, ob->obmat);
        invert_m4_m4(ob->imat, mat);
 
        /* material array */
@@ -2871,7 +2871,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
        dl= disp.first;
        if(dl==NULL) return;
        
-       mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+       mult_m4_m4m4(mat, re->viewmat, ob->obmat);
        invert_m4_m4(ob->imat, mat);
 
        /* material array */
@@ -3256,7 +3256,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
 
        me= ob->data;
 
-       mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+       mult_m4_m4m4(mat, re->viewmat, ob->obmat);
        invert_m4_m4(ob->imat, mat);
        copy_m3_m4(imat, ob->imat);
        negative_scale= is_negative_m4(mat);
@@ -3599,7 +3599,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4])
        /* matrix: combination of inverse view and lampmat */
        /* calculate again: the ortho-render has no correct viewinv */
        invert_m4_m4(viewinv, re->viewmat);
-       mul_m4_m4m4(shb->viewmat, viewinv, shb->winmat);
+       mult_m4_m4m4(shb->viewmat, shb->winmat, viewinv);
        
        /* projection */
        shb->d= lar->clipsta;
@@ -3677,7 +3677,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
        BLI_addtail(&re->lampren, lar);
        go->lampren= lar;
 
-       mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+       mult_m4_m4m4(mat, re->viewmat, ob->obmat);
        invert_m4_m4(ob->imat, mat);
 
        copy_m3_m4(lar->mat, mat);
@@ -4372,7 +4372,7 @@ static void find_dupli_instances(Render *re, ObjectRen *obr)
        float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3];
        int first = 1;
 
-       mul_m4_m4m4(obmat, obr->obmat, re->viewmat);
+       mult_m4_m4m4(obmat, re->viewmat, obr->obmat);
        invert_m4_m4(imat, obmat);
 
        /* for objects instanced by dupliverts/faces/particles, we go over the
@@ -4385,7 +4385,7 @@ static void find_dupli_instances(Render *re, ObjectRen *obr)
                        /* compute difference between object matrix and
                         * object matrix with dupli transform, in viewspace */
                        copy_m4_m4(obimat, obi->mat);
-                       mul_m4_m4m4(obi->mat, imat, obimat);
+                       mult_m4_m4m4(obi->mat, obimat, imat);
 
                        copy_m3_m4(nmat, obi->mat);
                        invert_m3_m3(obi->nmat, nmat);
@@ -4407,7 +4407,7 @@ static void assign_dupligroup_dupli(Render *re, ObjectInstanceRen *obi, ObjectRe
 {
        float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3];
 
-       mul_m4_m4m4(obmat, obr->obmat, re->viewmat);
+       mult_m4_m4m4(obmat, re->viewmat, obr->obmat);
        invert_m4_m4(imat, obmat);
 
        obi->obr= obr;
@@ -4415,7 +4415,7 @@ static void assign_dupligroup_dupli(Render *re, ObjectInstanceRen *obi, ObjectRe
        /* compute difference between object matrix and
         * object matrix with dupli transform, in viewspace */
        copy_m4_m4(obimat, obi->mat);
-       mul_m4_m4m4(obi->mat, imat, obimat);
+       mult_m4_m4m4(obi->mat, obimat, imat);
 
        copy_m3_m4(nmat, obi->mat);
        invert_m3_m3(obi->nmat, nmat);
@@ -4612,7 +4612,7 @@ static void init_render_object(Render *re, Object *ob, Object *par, DupliObject
        else if(render_object_type(ob->type))
                add_render_object(re, ob, par, dob, timeoffset);
        else {
-               mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+               mult_m4_m4m4(mat, re->viewmat, ob->obmat);
                invert_m4_m4(ob->imat, mat);
        }
        
@@ -4858,7 +4858,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
        * See bug: [#28744] - campbell */
        for(ob= re->main->object.first; ob; ob= ob->id.next) {
                /* imat objects has to be done here, since displace can have texture using Object map-input */
-               mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+               mult_m4_m4m4(mat, re->viewmat, ob->obmat);
                invert_m4_m4(ob->imat_ren, mat);
                copy_m4_m4(ob->imat, ob->imat_ren);
                /* each object should only be rendered once */
@@ -4930,7 +4930,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
                                                 * this is a duplivert/face/particle, or it is a non-animated object in
                                                 * a dupligroup that has already been created before */
                                                if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) {
-                                                       mul_m4_m4m4(mat, dob->mat, re->viewmat);
+                                                       mult_m4_m4m4(mat, re->viewmat, dob->mat);
                                                        obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat, obd->lay);
 
                                                        /* fill in instance variables for texturing */
@@ -4957,7 +4957,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
                                                for(psys=obd->particlesystem.first; psys; psys=psys->next) {
                                                        if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, psysindex))) {
                                                                if(obi == NULL)
-                                                                       mul_m4_m4m4(mat, dob->mat, re->viewmat);
+                                                                       mult_m4_m4m4(mat, re->viewmat, dob->mat);
                                                                obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, psysindex++, mat, obd->lay);
 
                                                                set_dupli_tex_mat(re, obi, dob);
@@ -5312,7 +5312,7 @@ static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen
                int a;
 
                if(obi->flag & R_TRANSFORMED)
-                       mul_m4_m4m4(winmat, obi->mat, re->winmat);
+                       mult_m4_m4m4(winmat, re->winmat, obi->mat);
                else
                        copy_m4_m4(winmat, re->winmat);
 
@@ -5349,7 +5349,7 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve
        int a, *face, *index;
 
        if(obi->flag & R_TRANSFORMED)
-               mul_m4_m4m4(winmat, obi->mat, re->winmat);
+               mult_m4_m4m4(winmat, re->winmat, obi->mat);
        else
                copy_m4_m4(winmat, re->winmat);
 
@@ -5443,7 +5443,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float *
        velarray = fss->meshVelocities;
 
        if(obi->flag & R_TRANSFORMED)
-               mul_m4_m4m4(winmat, obi->mat, re->winmat);
+               mult_m4_m4m4(winmat, re->winmat, obi->mat);
        else
                copy_m4_m4(winmat, re->winmat);
        
@@ -5533,7 +5533,7 @@ static void copy_dbase_object_vectors(Render *re, ListBase *lb)
                        vec= obilb->vectors= MEM_mallocN(2*sizeof(float)*totvector, "vector array");
 
                        if(obi->flag & R_TRANSFORMED)
-                               mul_m4_m4m4(winmat, obi->mat, re->winmat);
+                               mult_m4_m4m4(winmat, re->winmat, obi->mat);
                        else
                                copy_m4_m4(winmat, re->winmat);
 
@@ -5861,7 +5861,7 @@ void RE_make_sticky(Scene *scene, View3D *v3d)
                                        CD_CALLOC, NULL, me->totvert);
                                
                                where_is_object(scene, ob);
-                               mul_m4_m4m4(mat, ob->obmat, re->viewmat);
+                               mult_m4_m4m4(mat, re->viewmat, ob->obmat);
                                
                                ms= me->msticky;
                                for(a=0; a<me->totvert; a++, ms++, mvert++) {
index 3512ffa..a45bb63 100644 (file)
@@ -263,7 +263,7 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode)
                /* append or set matrix depending on dupli */
                if(obi->flag & R_DUPLI_TRANSFORMED) {
                        copy_m4_m4(tmpmat, obi->mat);
-                       mul_m4_m4m4(obi->mat, tmpmat, tmat);
+                       mult_m4_m4m4(obi->mat, tmat, tmpmat);
                }
                else if(mode==1)
                        copy_m4_m4(obi->mat, tmat);
@@ -312,10 +312,10 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode)
                if(lar->shb) {
                        if(mode==1) {
                                invert_m4_m4(pmat, mat);
-                               mul_m4_m4m4(smat, pmat, lar->shb->viewmat);
-                               mul_m4_m4m4(lar->shb->persmat, smat, lar->shb->winmat);
+                               mult_m4_m4m4(smat, lar->shb->viewmat, pmat);
+                               mult_m4_m4m4(lar->shb->persmat, lar->shb->winmat, smat);
                        }
-                       else mul_m4_m4m4(lar->shb->persmat, lar->shb->viewmat, lar->shb->winmat);
+                       else mult_m4_m4m4(lar->shb->persmat, lar->shb->winmat, lar->shb->viewmat);
                }
        }
        
@@ -393,7 +393,7 @@ static void env_set_imats(Render *re)
        
        base= re->scene->base.first;
        while(base) {
-               mul_m4_m4m4(mat, base->object->obmat, re->viewmat);
+               mult_m4_m4m4(mat, re->viewmat, base->object->obmat);
                invert_m4_m4(base->object->imat, mat);
                
                base= base->next;
@@ -422,7 +422,7 @@ static void render_envmap(Render *re, EnvMap *env)
        normalize_m4(orthmat);
        
        /* need imat later for texture imat */
-       mul_m4_m4m4(mat, orthmat, re->viewmat);
+       mult_m4_m4m4(mat, re->viewmat, orthmat);
        invert_m4_m4(tmat, mat);
        copy_m3_m4(env->obimat, tmat);
 
@@ -441,7 +441,7 @@ static void render_envmap(Render *re, EnvMap *env)
                copy_m4_m4(envre->viewinv, tmat);
                
                /* we have to correct for the already rotated vertexcoords */
-               mul_m4_m4m4(tmat, oldviewinv, envre->viewmat);
+               mult_m4_m4m4(tmat, envre->viewmat, oldviewinv);
                invert_m4_m4(env->imat, tmat);
                
                env_rotate_scene(envre, tmat, 1);
@@ -528,7 +528,7 @@ void make_envmaps(Render *re)
                                                        normalize_m4(orthmat);
                                                        
                                                        /* need imat later for texture imat */
-                                                       mul_m4_m4m4(mat, orthmat, re->viewmat);
+                                                       mult_m4_m4m4(mat, re->viewmat, orthmat);
                                                        invert_m4_m4(tmat, mat);
                                                        copy_m3_m4(env->obimat, tmat);
                                                }
index 5b81ea8..ae37487 100644 (file)
@@ -116,7 +116,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
        /* init everything */
        if (!psys || !ob || !pd) return;
 
-       mul_m4_m4m4(obview, re->viewinv, ob->obmat);
+       mult_m4_m4m4(obview, ob->obmat, re->viewinv);
        
        /* Just to create a valid rendering context for particles */
        psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, 0);
index 202c7dc..883684c 100644 (file)
@@ -2087,7 +2087,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
                if( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) {
                        // TODO: these calculations happen for every pixel!
                        //      -> move to shi->obi
-                       mul_m4_m4m4(tmp, shi->obr->ob->obmat, R.viewmat);
+                       mult_m4_m4m4(tmp, R.viewmat, shi->obr->ob->obmat);
                        copy_m3_m4(obj2view, tmp); // use only upper left 3x3 matrix
                        invert_m3_m3(view2obj, obj2view);
                
index 8cb7009..c14a768 100644 (file)
@@ -640,7 +640,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
                obr= obi->obr;
 
                if(obi->flag & R_TRANSFORMED)
-                       mul_m4_m4m4(obviewmat, obi->mat, viewmat);
+                       mult_m4_m4m4(obviewmat, viewmat, obi->mat);
                else
                        copy_m4_m4(obviewmat, viewmat);
 
@@ -777,7 +777,7 @@ void makeshadowbuf(Render *re, LampRen *lar)
        wsize= shb->pixsize*(shb->size/2.0f);
        
        perspective_m4( shb->winmat,-wsize, wsize, -wsize, wsize, shb->d, shb->clipend);
-       mul_m4_m4m4(shb->persmat, shb->viewmat, shb->winmat);
+       mult_m4_m4m4(shb->persmat, shb->winmat, shb->viewmat);
 
        if(ELEM3(lar->buftype, LA_SHADBUF_REGULAR, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) {
                shb->totbuf= lar->buffers;
@@ -1987,7 +1987,7 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root)
                obr= obi->obr;
 
                if(obi->flag & R_TRANSFORMED)
-                       mul_m4_m4m4(winmat, obi->mat, shb->persmat);
+                       mult_m4_m4m4(winmat, shb->persmat, obi->mat);
                else
                        copy_m4_m4(winmat, shb->persmat);
 
index dd02674..580a09d 100644 (file)
@@ -1268,7 +1268,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
 
                                zbuf_make_winmat(&R, winmat);
                                if(shi->obi->flag & R_TRANSFORMED)
-                                       mul_m4_m4m4(obwinmat, obi->mat, winmat);
+                                       mult_m4_m4m4(obwinmat, winmat, obi->mat);
                                else
                                        copy_m4_m4(obwinmat, winmat);
 
index 633c7ca..4fc3bb7 100644 (file)
@@ -848,7 +848,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa
 
                /* compute matrix and try clipping whole object */
                if(obi->flag & R_TRANSFORMED)
-                       mul_m4_m4m4(obwinmat, obi->mat, winmat);
+                       mult_m4_m4m4(obwinmat, winmat, obi->mat);
                else
                        copy_m4_m4(obwinmat, winmat);
 
index 4b18942..a46ef38 100644 (file)
@@ -245,7 +245,7 @@ static float metadensity(Object* ob, const float co[3])
        
        /* transform co to meta-element */
        float tco[3] = {co[0], co[1], co[2]};
-       mul_m4_m4m4(mat, ob->obmat, R.viewmat);
+       mult_m4_m4m4(mat, R.viewmat, ob->obmat);
        invert_m4_m4(imat, mat);
        mul_m4_v3(imat, tco);
        
index 8b38399..8efe23c 100644 (file)
@@ -1819,7 +1819,7 @@ void zbuf_make_winmat(Render *re, float winmat[][4])
                panomat[2][0]= -re->panosi;
                panomat[2][2]= re->panoco;
 
-               mul_m4_m4m4(winmat, panomat, re->winmat);
+               mult_m4_m4m4(winmat, re->winmat, panomat);
        }
        else
                copy_m4_m4(winmat, re->winmat);
@@ -2138,7 +2138,7 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*,
                                continue;
                        
                        if(obi->flag & R_TRANSFORMED)
-                               mul_m4_m4m4(obwinmat, obi->mat, winmat);
+                               mult_m4_m4m4(obwinmat, winmat, obi->mat);
                        else
                                copy_m4_m4(obwinmat, winmat);
 
@@ -2318,7 +2318,7 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int
                        continue;
 
                if(obi->flag & R_TRANSFORMED)
-                       mul_m4_m4m4(obwinmat, obi->mat, winmat);
+                       mult_m4_m4m4(obwinmat, winmat, obi->mat);
                else
                        copy_m4_m4(obwinmat, winmat);
 
@@ -2557,7 +2557,7 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo
                        continue;
 
                if(obi->flag & R_TRANSFORMED)
-                       mul_m4_m4m4(obwinmat, obi->mat, winmat);
+                       mult_m4_m4m4(obwinmat, winmat, obi->mat);
                else
                        copy_m4_m4(obwinmat, winmat);
 
@@ -3300,7 +3300,7 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase *
                        continue;
 
                if(obi->flag & R_TRANSFORMED)
-                       mul_m4_m4m4(obwinmat, obi->mat, winmat);
+                       mult_m4_m4m4(obwinmat, winmat, obi->mat);
                else
                        copy_m4_m4(obwinmat, winmat);
 
index c463068..80a9db4 100644 (file)
@@ -215,7 +215,7 @@ PyObject* BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const str
        normalize_m3(pose_mat);
        if (pchan->parent) {
                // bone has a parent, compute the rest pose of the bone taking actual pose of parent
-               mul_m3_m3m4(rest_mat, pchan->bone->bone_mat, pchan->parent->pose_mat);
+               mult_m3_m3m4(rest_mat, pchan->parent->pose_mat, pchan->bone->bone_mat);
                normalize_m3(rest_mat);
        } else {
                // otherwise, the bone matrix in armature space is the rest pose