Merging r58362 through r58463 from trunk into soc-2013-depsgraph_mt
[blender.git] / source / blender / blenkernel / intern / constraint.c
index 48ad3f513899d5e7ed0cbbc0578120963767cd93..8926ef0b599ff42d46bf3fc64be1c08f143f5038 100644 (file)
@@ -43,6 +43,8 @@
 #include "BLI_kdopbvh.h"
 #include "BLI_utildefines.h"
 
+#include "BLF_translation.h"
+
 #include "DNA_armature_types.h"
 #include "DNA_camera_types.h"
 #include "DNA_constraint_types.h"
@@ -67,6 +69,7 @@
 #include "BKE_bvhutils.h"
 #include "BKE_camera.h"
 #include "BKE_constraint.h"
+#include "BKE_curve.h"
 #include "BKE_displist.h"
 #include "BKE_deform.h"
 #include "BKE_DerivedMesh.h"    /* for geometry targets */
@@ -79,7 +82,7 @@
 #include "BKE_mesh.h"
 #include "BKE_shrinkwrap.h"
 #include "BKE_mesh.h"
-#include "BKE_tessmesh.h"
+#include "BKE_editmesh.h"
 #include "BKE_tracking.h"
 #include "BKE_movieclip.h"
 
 /* Find the first available, non-duplicate name for a given constraint */
 void BKE_unique_constraint_name(bConstraint *con, ListBase *list)
 {
-       BLI_uniquename(list, con, "Const", '.', offsetof(bConstraint, name), sizeof(con->name));
+       BLI_uniquename(list, con, DATA_("Const"), '.', offsetof(bConstraint, name), sizeof(con->name));
 }
 
 /* ----------------- Evaluation Loop Preparation --------------- */
@@ -130,8 +133,8 @@ bConstraintOb *BKE_constraints_make_evalob(Scene *scene, Object *ob, void *subda
                                unit_m4(cob->matrix);
                        
                        copy_m4_m4(cob->startmat, cob->matrix);
+                       break;
                }
-               break;
                case CONSTRAINT_OBTYPE_BONE:
                {
                        /* only set if we have valid bone, otherwise default */
@@ -150,15 +153,14 @@ bConstraintOb *BKE_constraints_make_evalob(Scene *scene, Object *ob, void *subda
                                }
                                
                                /* matrix in world-space */
-                               mult_m4_m4m4(cob->matrix, ob->obmat, cob->pchan->pose_mat);
+                               mul_m4_m4m4(cob->matrix, ob->obmat, cob->pchan->pose_mat);
                        }
                        else
                                unit_m4(cob->matrix);
                                
                        copy_m4_m4(cob->startmat, cob->matrix);
+                       break;
                }
-               break;
-                       
                default: /* other types not yet handled */
                        unit_m4(cob->matrix);
                        unit_m4(cob->startmat);
@@ -179,7 +181,7 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob)
        
        /* calculate delta of constraints evaluation */
        invert_m4_m4(imat, cob->startmat);
-       mult_m4_m4m4(delta, cob->matrix, imat);
+       mul_m4_m4m4(delta, cob->matrix, imat);
        
        /* copy matrices back to source */
        switch (cob->type) {
@@ -193,20 +195,20 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob)
                                /* copy inverse of delta back to owner */
                                invert_m4_m4(cob->ob->constinv, delta);
                        }
+                       break;
                }
-               break;
                case CONSTRAINT_OBTYPE_BONE:
                {
                        /* cob->ob or cob->pchan might not exist */
                        if (cob->ob && cob->pchan) {
                                /* copy new pose-matrix back to owner */
-                               mult_m4_m4m4(cob->pchan->pose_mat, cob->ob->imat, cob->matrix);
+                               mul_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);
                        }
+                       break;
                }
-               break;
        }
        
        /* free tempolary struct */
@@ -237,20 +239,20 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
                        {
                                /* world to pose */
                                invert_m4_m4(imat, ob->obmat);
-                               mult_m4_m4m4(mat, imat, mat);
+                               mul_m4_m4m4(mat, imat, mat);
                                
                                /* use pose-space as stepping stone for other spaces... */
                                if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) {
                                        /* call self with slightly different values */
                                        BKE_constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
                                }
+                               break;
                        }
-                       break;
                        case CONSTRAINT_SPACE_POSE: /* ---------- FROM POSESPACE ---------- */
                        {
                                /* pose to world */
                                if (to == CONSTRAINT_SPACE_WORLD) {
-                                       mult_m4_m4m4(mat, ob->obmat, mat);
+                                       mul_m4_m4m4(mat, ob->obmat, mat);
                                }
                                /* pose to local */
                                else if (to == CONSTRAINT_SPACE_LOCAL) {
@@ -262,11 +264,11 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
                                else if (to == CONSTRAINT_SPACE_PARLOCAL) {
                                        if (pchan->bone) {
                                                invert_m4_m4(imat, pchan->bone->arm_mat);
-                                               mult_m4_m4m4(mat, imat, mat);
+                                               mul_m4_m4m4(mat, imat, mat);
                                        }
                                }
+                               break;
                        }
-                       break;
                        case CONSTRAINT_SPACE_LOCAL: /* ------------ FROM LOCALSPACE --------- */
                        {
                                /* local to pose - do inverse procedure that was done for pose to local */
@@ -280,14 +282,14 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
                                        /* call self with slightly different values */
                                        BKE_constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
                                }
+                               break;
                        }
-                       break;
                        case CONSTRAINT_SPACE_PARLOCAL: /* -------------- FROM LOCAL WITH PARENT ---------- */
                        {
                                /* local + parent to pose */
                                if (pchan->bone) {
                                        copy_m4_m4(diff_mat, pchan->bone->arm_mat);
-                                       mult_m4_m4m4(mat, mat, diff_mat);
+                                       mul_m4_m4m4(mat, mat, diff_mat);
                                }
                                
                                /* use pose-space as stepping stone for other spaces */
@@ -295,8 +297,8 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
                                        /* call self with slightly different values */
                                        BKE_constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
                                }
+                               break;
                        }
-                       break;
                }
        }
        else {
@@ -305,9 +307,9 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
                        /* check if object has a parent */
                        if (ob->parent) {
                                /* 'subtract' parent's effects from owner */
-                               mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
+                               mul_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
                                invert_m4_m4(imat, diff_mat);
-                               mult_m4_m4m4(mat, imat, mat);
+                               mul_m4_m4m4(mat, imat, mat);
                        }
                        else {
                                /* Local space in this case will have to be defined as local to the owner's 
@@ -318,15 +320,15 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
                                zero_v3(diff_mat[3]);
                                
                                invert_m4_m4(imat, diff_mat);
-                               mult_m4_m4m4(mat, imat, mat);
+                               mul_m4_m4m4(mat, imat, mat);
                        }
                }
                else if (from == CONSTRAINT_SPACE_LOCAL && to == CONSTRAINT_SPACE_WORLD) {
                        /* check that object has a parent - otherwise this won't work */
                        if (ob->parent) {
                                /* 'add' parent's effect back to owner */
-                               mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
-                               mult_m4_m4m4(mat, diff_mat, mat);
+                               mul_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
+                               mul_m4_m4m4(mat, diff_mat, mat);
                        }
                        else {
                                /* Local space in this case will have to be defined as local to the owner's 
@@ -336,7 +338,7 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
                                normalize_m4(diff_mat);
                                zero_v3(diff_mat[3]);
                                
-                               mult_m4_m4m4(mat, diff_mat, mat);
+                               mul_m4_m4m4(mat, diff_mat, mat);
                        }
                }
        }
@@ -348,7 +350,7 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
 static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[4][4])
 {
        DerivedMesh *dm = NULL;
-       BMEditMesh *em = BMEdit_FromObject(ob);
+       BMEditMesh *em = BKE_editmesh_from_object(ob);
        float vec[3] = {0.0f, 0.0f, 0.0f};
        float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3];
        float imat[3][3], tmat[3][3];
@@ -378,29 +380,31 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
        if (dm) {
                MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
                int numVerts = dm->getNumVerts(dm);
-               int i, count = 0;
+               int i;
                float co[3], nor[3];
                
                /* check that dvert is a valid pointers (just in case) */
                if (dvert) {
                        MDeformVert *dv = dvert;
+                       float weightsum = 0.0f;
+
                        /* get the average of all verts with that are in the vertex-group */
                        for (i = 0; i < numVerts; i++, dv++) {
                                MDeformWeight *dw = defvert_find_index(dv, defgroup);
-                               if (dw && dw->weight != 0.0f) {
+
+                               if (dw && dw->weight > 0.0f) {
                                        dm->getVertCo(dm, i, co);
                                        dm->getVertNo(dm, i, nor);
-                                       add_v3_v3(vec, co);
-                                       add_v3_v3(normal, nor);
-                                       count++;
-                                       
+                                       madd_v3_v3fl(vec, co, dw->weight);
+                                       madd_v3_v3fl(normal, nor, dw->weight);
+                                       weightsum += dw->weight;
                                }
                        }
 
                        /* calculate averages of normal and coordinates */
-                       if (count > 0) {
-                               mul_v3_fl(vec, 1.0f / count);
-                               mul_v3_fl(normal, 1.0f / count);
+                       if (weightsum > 0) {
+                               mul_v3_fl(vec, 1.0f / weightsum);
+                               mul_v3_fl(normal, 1.0f / weightsum);
                        }
                        
                        
@@ -445,7 +449,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m
 {
        Lattice *lt = (Lattice *)ob->data;
        
-       DispList *dl = BKE_displist_find(&ob->disp, DL_VERTS);
+       DispList *dl = ob->curve_cache ? BKE_displist_find(&ob->curve_cache->disp, DL_VERTS) : NULL;
        float *co = dl ? dl->verts : NULL;
        BPoint *bp = lt->def;
        
@@ -530,7 +534,7 @@ static void constraint_target_to_mat4(Object *ob, const char *substring, float m
                         */
                        if (headtail < 0.000001f) {
                                /* skip length interpolation if set to head */
-                               mult_m4_m4m4(mat, ob->obmat, pchan->pose_mat);
+                               mul_m4_m4m4(mat, ob->obmat, pchan->pose_mat);
                        }
                        else {
                                float tempmat[4][4], loc[3];
@@ -542,7 +546,7 @@ static void constraint_target_to_mat4(Object *ob, const char *substring, float m
                                copy_m4_m4(tempmat, pchan->pose_mat);
                                copy_v3_v3(tempmat[3], loc);
                                
-                               mult_m4_m4m4(mat, ob->obmat, tempmat);
+                               mul_m4_m4m4(mat, ob->obmat, tempmat);
                        }
                }
                else
@@ -753,12 +757,12 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
                        /* multiply target (parent matrix) by offset (parent inverse) to get 
                         * the effect of the parent that will be exerted on the owner
                         */
-                       mult_m4_m4m4(parmat, ct->matrix, data->invmat);
+                       mul_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)
                         */
-                       mult_m4_m4m4(cob->matrix, parmat, cob->matrix);
+                       mul_m4_m4m4(cob->matrix, parmat, cob->matrix);
                }
                else {
                        float invmat[4][4], tempmat[4][4];
@@ -795,13 +799,13 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
                        /* multiply target (parent matrix) by offset (parent inverse) to get 
                         * the effect of the parent that will be exerted on the owner
                         */
-                       mult_m4_m4m4(parmat, ct->matrix, invmat);
+                       mul_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);
-                       mult_m4_m4m4(cob->matrix, parmat, tempmat);
+                       mul_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
@@ -817,7 +821,7 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
 static bConstraintTypeInfo CTI_CHILDOF = {
        CONSTRAINT_TYPE_CHILDOF, /* type */
        sizeof(bChildOfConstraint), /* size */
-       "ChildOf", /* name */
+       "Child Of", /* name */
        "bChildOfConstraint", /* struct name */
        NULL, /* free data */
        childof_id_looper, /* id looper */
@@ -992,7 +996,7 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
 static bConstraintTypeInfo CTI_TRACKTO = {
        CONSTRAINT_TYPE_TRACKTO, /* type */
        sizeof(bTrackToConstraint), /* size */
-       "TrackTo", /* name */
+       "Track To", /* name */
        "bTrackToConstraint", /* struct name */
        NULL, /* free data */
        trackto_id_looper, /* id looper */
@@ -1160,10 +1164,10 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
                 */
                
                /* only happens on reload file, but violates depsgraph still... fix! */
-               if (cu->path == NULL || cu->path->data == NULL)
+               if (ct->tar->curve_cache == NULL || ct->tar->curve_cache->path == NULL || ct->tar->curve_cache->path->data == NULL)
                        BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
                
-               if (cu->path && cu->path->data) {
+               if (ct->tar->curve_cache->path && ct->tar->curve_cache->path->data) {
                        float quat[4];
                        if ((data->followflag & FOLLOWPATH_STATIC) == 0) {
                                /* animated position along curve depending on time */
@@ -1202,8 +1206,8 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
                                        vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag);
                                        
                                        normalize_v3(dir);
-                                       q[0] = (float)cos(0.5 * vec[3]);
-                                       x1 = (float)sin(0.5 * vec[3]);
+                                       q[0] = cosf(0.5 * vec[3]);
+                                       x1 = sinf(0.5 * vec[3]);
                                        q[1] = -x1 * dir[0];
                                        q[2] = -x1 * dir[1];
                                        q[3] = -x1 * dir[2];
@@ -1218,7 +1222,7 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
                                if (data->followflag & FOLLOWPATH_RADIUS) {
                                        float tmat[4][4], rmat[4][4];
                                        scale_m4_fl(tmat, radius);
-                                       mult_m4_m4m4(rmat, tmat, totmat);
+                                       mul_m4_m4m4(rmat, tmat, totmat);
                                        copy_m4_m4(totmat, rmat);
                                }
                                
@@ -1930,10 +1934,8 @@ static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTa
        if (VALID_CONS_TARGET(ct)) {
                /* special exception for curves - depsgraph issues */
                if (ct->tar->type == OB_CURVE) {
-                       Curve *cu = ct->tar->data;
-                       
                        /* this check is to make sure curve objects get updated on file load correctly.*/
-                       if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */
+                       if (ct->tar->curve_cache == NULL || ct->tar->curve_cache->path == NULL || ct->tar->curve_cache->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */
                                BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
                }
                
@@ -2138,7 +2140,7 @@ static void actcon_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBa
                 * function has already taken care of everything else.
                 */
                copy_m4_m4(temp, cob->matrix);
-               mult_m4_m4m4(cob->matrix, temp, ct->matrix);
+               mul_m4_m4m4(cob->matrix, temp, ct->matrix);
        }
 }
 
@@ -2231,8 +2233,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                        
                                                /* the z axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
+                                               break;
                                        }
-                                       break;
                                        case TRACK_Z: /* LOCK X TRACK Z */
                                        {
                                                /* Projection of Vector on the plane */
@@ -2245,8 +2247,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                        
                                                /* the z axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
+                                               break;
                                        }
-                                       break;
                                        case TRACK_nY: /* LOCK X TRACK -Y */
                                        {
                                                /* Projection of Vector on the plane */
@@ -2260,8 +2262,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                        
                                                /* the z axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
+                                               break;
                                        }
-                                       break;
                                        case TRACK_nZ: /* LOCK X TRACK -Z */
                                        {
                                                /* Projection of Vector on the plane */
@@ -2275,16 +2277,16 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                                
                                                /* the z axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
+                                               break;
                                        }
-                                       break;
                                        default:
                                        {
                                                unit_m3(totmat);
+                                               break;
                                        }
-                                       break;
                                }
+                               break;
                        }
-                       break;
                        case LOCK_Y: /* LOCK Y */
                        {
                                switch (data->trackflag) {
@@ -2300,8 +2302,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
 
                                                /* the z axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
+                                               break;
                                        }
-                                       break;
                                        case TRACK_Z: /* LOCK Y TRACK Z */
                                        {
                                                /* Projection of Vector on the plane */
@@ -2314,8 +2316,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                        
                                                /* the z axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
+                                               break;
                                        }
-                                       break;
                                        case TRACK_nX: /* LOCK Y TRACK -X */
                                        {
                                                /* Projection of Vector on the plane */
@@ -2329,8 +2331,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                        
                                                /* the z axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
+                                               break;
                                        }
-                                       break;
                                        case TRACK_nZ: /* LOCK Y TRACK -Z */
                                        {
                                                /* Projection of Vector on the plane */
@@ -2344,16 +2346,16 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                        
                                                /* the z axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
+                                               break;
                                        }
-                                       break;
                                        default:
                                        {
                                                unit_m3(totmat);
+                                               break;
                                        }
-                                       break;
                                }
+                               break;
                        }
-                       break;
                        case LOCK_Z: /* LOCK Z */
                        {
                                switch (data->trackflag) {
@@ -2369,8 +2371,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                        
                                                /* the x axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
+                                               break;
                                        }
-                                       break;
                                        case TRACK_Y: /* LOCK Z TRACK Y */
                                        {
                                                /* Projection of Vector on the plane */
@@ -2383,8 +2385,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                                
                                                /* the x axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
+                                               break;
                                        }
-                                       break;
                                        case TRACK_nX: /* LOCK Z TRACK -X */
                                        {
                                                /* Projection of Vector on the plane */
@@ -2398,8 +2400,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                        
                                                /* the x axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
+                                               break;
                                        }
-                                       break;
                                        case TRACK_nY: /* LOCK Z TRACK -Y */
                                        {
                                                /* Projection of Vector on the plane */
@@ -2413,21 +2415,21 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                                
                                                /* the x axis gets mapped onto a third orthogonal vector */
                                                cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
+                                               break;
                                        }
-                                       break;
                                        default:
                                        {
                                                unit_m3(totmat);
+                                               break;
                                        }
-                                       break;
                                }
+                               break;
                        }
-                       break;
                        default:
                        {
                                unit_m3(totmat);
+                               break;
                        }
-                       break;
                }
                /* Block to keep matrix heading */
                copy_m3_m4(tmpmat, cob->matrix);
@@ -2515,7 +2517,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
        
        /* only evaluate if there is a target */
        if (VALID_CONS_TARGET(ct)) {
-               float dvec[3], dist = 0.0f, sfac = 1.0f;
+               float dvec[3], dist, sfac = 1.0f;
                short clamp_surf = 0;
                
                /* calculate our current distance from the target */
@@ -2824,7 +2826,7 @@ static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ
                if (data->flag & MINMAX_USEROT) {
                        /* take rotation of target into account by doing the transaction in target's localspace */
                        invert_m4_m4(imat, tarmat);
-                       mult_m4_m4m4(tmat, imat, obmat);
+                       mul_m4_m4m4(tmat, imat, obmat);
                        copy_m4_m4(obmat, tmat);
                        unit_m4(tarmat);
                }
@@ -2877,7 +2879,7 @@ static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ
                        }
                        if (data->flag & MINMAX_USEROT) {
                                /* get out of localspace */
-                               mult_m4_m4m4(tmat, ct->matrix, obmat);
+                               mul_m4_m4m4(tmat, ct->matrix, obmat);
                                copy_m4_m4(cob->matrix, tmat);
                        }
                        else {
@@ -3004,14 +3006,12 @@ static void clampto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
 static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
 {
        if (VALID_CONS_TARGET(ct)) {
-               Curve *cu = ct->tar->data;
-               
                /* note: when creating constraints that follow path, the curve gets the CU_PATH set now,
                 *              currently for paths to work it needs to go through the bevlist/displist system (ton) 
                 */
                
                /* only happens on reload file, but violates depsgraph still... fix! */
-               if (cu->path == NULL || cu->path->data == NULL)
+               if (ct->tar->curve_cache == NULL || ct->tar->curve_cache->path == NULL || ct->tar->curve_cache->path->data == NULL)
                        BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
        }
        
@@ -3029,7 +3029,6 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
        
        /* only evaluate if there is a target and it is a curve */
        if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_CURVE)) {
-               Curve *cu = data->tar->data;
                float obmat[4][4], ownLoc[3];
                float curveMin[3], curveMax[3];
                float targetMatrix[4][4] = MAT4_UNITY;
@@ -3042,7 +3041,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
                BKE_object_minmax(ct->tar, curveMin, curveMax, TRUE);
                
                /* get targetmatrix */
-               if (cu->path && cu->path->data) {
+               if (data->tar->curve_cache &&  data->tar->curve_cache->path && data->tar->curve_cache->path->data) {
                        float vec[4], dir[3], totmat[4][4];
                        float curvetime;
                        short clamp_axis;
@@ -3255,15 +3254,16 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                        case 1: /* rotation */
                                for (i = 0; i < 3; i++) {
                                        float tmin, tmax;
+                                       float val;
                                        
                                        tmin = data->to_min[i];
                                        tmax = data->to_max[i];
                                        
                                        /* all values here should be in degrees */
-                                       eul[i] = tmin + (sval[(int)data->map[i]] * (tmax - tmin));
+                                       val = tmin + (sval[(int)data->map[i]] * (tmax - tmin));
                                        
-                                       /* now convert final value back to radians */
-                                       eul[i] = DEG2RADF(eul[i]);
+                                       /* now convert final value back to radians, and add to original rotation (so that it can still be rotated) */
+                                       eul[i] += DEG2RADF(val);
                                }
                                break;
                        default: /* location */
@@ -3644,14 +3644,12 @@ static void splineik_flush_tars(bConstraint *con, ListBase *list, short nocopy)
 static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
 {
        if (VALID_CONS_TARGET(ct)) {
-               Curve *cu = ct->tar->data;
-               
                /* note: when creating constraints that follow path, the curve gets the CU_PATH set now,
                 *              currently for paths to work it needs to go through the bevlist/displist system (ton) 
                 */
                
                /* only happens on reload file, but violates depsgraph still... fix! */
-               if (cu->path == NULL || cu->path->data == NULL)
+               if (ct->tar->curve_cache == NULL || ct->tar->curve_cache->path == NULL || ct->tar->curve_cache->path->data == NULL)
                        BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
        }
        
@@ -3874,7 +3872,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
                        else {
                                BKE_tracking_get_camera_object_matrix(cob->scene, camob, mat);
 
-                               mult_m4_m4m4(cob->matrix, obmat, mat);
+                               mul_m4_m4m4(cob->matrix, obmat, mat);
                                translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
                        }
                }
@@ -3960,7 +3958,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
 
                                copy_m4_m4(rmat, camob->obmat);
                                zero_v3(rmat[3]);
-                               mult_m4_m4m4(cob->matrix, cob->matrix, rmat);
+                               mul_m4_m4m4(cob->matrix, cob->matrix, rmat);
 
                                copy_v3_v3(cob->matrix[3], disp);
                        }
@@ -3981,7 +3979,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]);
-                               mult_m4_m4m4(cob->matrix, cob->matrix, rmat);
+                               mul_m4_m4m4(cob->matrix, cob->matrix, rmat);
 
                                copy_v3_v3(cob->matrix[3], disp);
                        }
@@ -4072,7 +4070,7 @@ static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
 
                copy_m4_m4(obmat, cob->matrix);
 
-               mult_m4_m4m4(cob->matrix, obmat, mat);
+               mul_m4_m4m4(cob->matrix, obmat, mat);
        }
 }
 
@@ -4138,7 +4136,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
                        BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, framenr, mat);
 
                        invert_m4_m4(camimat, cammat);
-                       mult_m4_m4m4(parmat, cammat, data->invmat);
+                       mul_m4_m4m4(parmat, cammat, data->invmat);
 
                        copy_m4_m4(cammat, camob->obmat);
                        copy_m4_m4(obmat, cob->matrix);
@@ -4353,12 +4351,12 @@ static bConstraint *add_new_constraint_internal(const char *name, short type)
                        cti->new_data(con->data);
                
                /* if no name is provided, use the type of the constraint as the name */
-               newName = (name && name[0]) ? name : cti->name;
+               newName = (name && name[0]) ? name : DATA_(cti->name);
        }
        else {
                /* if no name is provided, use the generic "Const" name */
                /* NOTE: any constraint type that gets here really shouldn't get added... */
-               newName = (name && name[0]) ? name : "Const";
+               newName = (name && name[0]) ? name : DATA_("Const");
        }
        
        /* copy the name */
@@ -4409,8 +4407,8 @@ static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const ch
                                con->ownspace = CONSTRAINT_SPACE_POSE;
                                con->flag |= CONSTRAINT_SPACEONCE;
                        }
+                       break;
                }
-               break;
        }
        
        return con;
@@ -4635,8 +4633,8 @@ void BKE_get_constraint_target_matrix(Scene *scene, bConstraint *con, int index,
                                        unit_m4(cob->matrix);
                                        unit_m4(cob->startmat);
                                }
+                               break;
                        }
-                       break;
                        case CONSTRAINT_OBTYPE_BONE: /* this may occur in some cases */
                        {
                                cob->ob = NULL; /* this might not work at all :/ */
@@ -4649,8 +4647,8 @@ void BKE_get_constraint_target_matrix(Scene *scene, bConstraint *con, int index,
                                        unit_m4(cob->matrix);
                                        unit_m4(cob->startmat);
                                }
+                               break;
                        }
-                       break;
                }
                
                /* get targets - we only need the first one though (and there should only be one) */
@@ -4707,7 +4705,7 @@ void BKE_get_constraint_targets_for_solving(bConstraint *con, bConstraintOb *cob
 /* ---------- Evaluation ----------- */
 
 /* This function is called whenever constraints need to be evaluated. Currently, all
- * constraints that can be evaluated are everytime this gets run.
+ * constraints that can be evaluated are every time this gets run.
  *
  * BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and 
  * after running this function, to sort out cob