Followup to rB8714ae09f894: better not have several RNA properties affect a single...
[blender.git] / source / blender / blenkernel / intern / constraint.c
index b55520a4c42a8477422c3bb77099717e2714ab72..d2ae005bc82bd857f33833aa16a7fc17f1e883c4 100644 (file)
@@ -3206,6 +3206,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
        
        /* only evaluate if there is a target */
        if (VALID_CONS_TARGET(ct)) {
+               float *from_min, *from_max, *to_min, *to_max;
                float loc[3], eul[3], size[3];
                float dvec[3], sval[3];
                int i;
@@ -3223,13 +3224,19 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                                         */
                                        negate_v3(dvec);
                                }
+                               from_min = data->from_min_scale;
+                               from_max = data->from_max_scale;
                                break;
                        case TRANS_ROTATION:
                                mat4_to_eulO(dvec, cob->rotOrder, ct->matrix);
+                               from_min = data->from_min_rot;
+                               from_max = data->from_max_rot;
                                break;
                        case TRANS_LOCATION:
                        default:
                                copy_v3_v3(dvec, ct->matrix[3]);
+                               from_min = data->from_min;
+                               from_max = data->from_max;
                                break;
                }
                
@@ -3241,8 +3248,8 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                /* determine where in range current transforms lie */
                if (data->expo) {
                        for (i = 0; i < 3; i++) {
-                               if (data->from_max[i] - data->from_min[i])
-                                       sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
+                               if (from_max[i] - from_min[i])
+                                       sval[i] = (dvec[i] - from_min[i]) / (from_max[i] - from_min[i]);
                                else
                                        sval[i] = 0.0f;
                        }
@@ -3250,9 +3257,9 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                else {
                        /* clamp transforms out of range */
                        for (i = 0; i < 3; i++) {
-                               CLAMP(dvec[i], data->from_min[i], data->from_max[i]);
-                               if (data->from_max[i] - data->from_min[i])
-                                       sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
+                               CLAMP(dvec[i], from_min[i], from_max[i]);
+                               if (from_max[i] - from_min[i])
+                                       sval[i] = (dvec[i] - from_min[i]) / (from_max[i] - from_min[i]);
                                else
                                        sval[i] = 0.0f;
                        }
@@ -3262,22 +3269,28 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
                /* apply transforms */
                switch (data->to) {
                        case TRANS_SCALE:
+                               to_min = data->to_min_scale;
+                               to_max = data->to_max_scale;
                                for (i = 0; i < 3; i++) {
                                        /* multiply with original scale (so that it can still be scaled) */
-                                       size[i] *= data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]));
+                                       size[i] *= to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i]));
                                }
                                break;
                        case TRANS_ROTATION:
+                               to_min = data->to_min_rot;
+                               to_max = data->to_max_rot;
                                for (i = 0; i < 3; i++) {
                                        /* add to original rotation (so that it can still be rotated) */
-                                       eul[i] += data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]));
+                                       eul[i] += to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i]));
                                }
                                break;
                        case TRANS_LOCATION:
                        default:
+                               to_min = data->to_min;
+                               to_max = data->to_max;
                                for (i = 0; i < 3; i++) {
                                        /* add to original location (so that it can still be moved) */
-                                       loc[i] += (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i])));
+                                       loc[i] += (to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i])));
                                }
                                break;
                }