Followup to rB8714ae09f894: better not have several RNA properties affect a single DNA one.

This commit is contained in:
Bastien Montagne 2014-04-28 13:20:37 +02:00
parent 2aa9d33404
commit 912151763d
5 changed files with 101 additions and 34 deletions

View File

@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 270
#define BLENDER_SUBVERSION 4
#define BLENDER_SUBVERSION 5
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
#define BLENDER_MINSUBVERSION 0

View 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;
}

View File

@ -79,6 +79,34 @@ static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
}
}
static void do_version_constraints_radians_degrees_270_5(ListBase *lb)
{
bConstraint *con;
for (con = lb->first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
bTransformConstraint *data = (bTransformConstraint *)con->data;
if (data->from == TRANS_ROTATION) {
copy_v3_v3(data->from_min_rot, data->from_min);
copy_v3_v3(data->from_max_rot, data->from_max);
}
else if (data->from == TRANS_SCALE) {
copy_v3_v3(data->from_min_scale, data->from_min);
copy_v3_v3(data->from_max_scale, data->from_max);
}
if (data->to == TRANS_ROTATION) {
copy_v3_v3(data->to_min_rot, data->to_min);
copy_v3_v3(data->to_max_rot, data->to_max);
}
else if (data->to == TRANS_SCALE) {
copy_v3_v3(data->to_min_scale, data->to_min);
copy_v3_v3(data->to_max_scale, data->to_max);
}
}
}
}
void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
{
@ -204,6 +232,23 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
if (!MAIN_VERSION_ATLEAST(main, 270, 5)) {
Object *ob;
/* Update Transform constraint (again :|). */
for (ob = main->object.first; ob; ob = ob->id.next) {
do_version_constraints_radians_degrees_270_5(&ob->constraints);
if (ob->pose) {
/* Bones constraints! */
bPoseChannel *pchan;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
do_version_constraints_radians_degrees_270_5(&pchan->constraints);
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "Material", "int", "mode2")) { /* will be replaced with version check when other new flag is added to mode2 */
Material *ma;

View File

@ -338,9 +338,18 @@ typedef struct bTransformConstraint {
float from_min[3]; /* from_min/max defines range of target transform */
float from_max[3]; /* to map on to to_min/max range. */
float to_min[3]; /* range of motion on owner caused by target */
float to_max[3];
float from_min_rot[3]; /* from_min/max defines range of target transform */
float from_max_rot[3]; /* to map on to to_min/max range. */
float to_min_rot[3]; /* range of motion on owner caused by target */
float to_max_rot[3];
float from_min_scale[3]; /* from_min/max defines range of target transform */
float from_max_scale[3]; /* to map on to to_min/max range. */
float to_min_scale[3]; /* range of motion on owner caused by target */
float to_max_scale[3];
} bTransformConstraint;
/* Pivot Constraint */

View File

@ -1719,146 +1719,146 @@ static void rna_def_constraint_transform(BlenderRNA *brna)
/* Rot */
prop = RNA_def_property(srna, "from_min_x_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "from_min[0]");
RNA_def_property_float_sdna(prop, NULL, "from_min_rot[0]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_min_y_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "from_min[1]");
RNA_def_property_float_sdna(prop, NULL, "from_min_rot[1]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_min_z_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "from_min[2]");
RNA_def_property_float_sdna(prop, NULL, "from_min_rot[2]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_max_x_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "from_max[0]");
RNA_def_property_float_sdna(prop, NULL, "from_max_rot[0]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_max_y_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "from_max[1]");
RNA_def_property_float_sdna(prop, NULL, "from_max_rot[1]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_max_z_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "from_max[2]");
RNA_def_property_float_sdna(prop, NULL, "from_max_rot[2]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_min_x_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "to_min[0]");
RNA_def_property_float_sdna(prop, NULL, "to_min_rot[0]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_min_y_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "to_min[1]");
RNA_def_property_float_sdna(prop, NULL, "to_min_rot[1]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_min_z_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "to_min[2]");
RNA_def_property_float_sdna(prop, NULL, "to_min_rot[2]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_max_x_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "to_max[0]");
RNA_def_property_float_sdna(prop, NULL, "to_max_rot[0]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_max_y_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "to_max[1]");
RNA_def_property_float_sdna(prop, NULL, "to_max_rot[1]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_max_z_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "to_max[2]");
RNA_def_property_float_sdna(prop, NULL, "to_max_rot[2]");
RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
/* Scale */
prop = RNA_def_property(srna, "from_min_x_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "from_min[0]");
RNA_def_property_float_sdna(prop, NULL, "from_min_scale[0]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_min_y_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "from_min[1]");
RNA_def_property_float_sdna(prop, NULL, "from_min_scale[1]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_min_z_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "from_min[2]");
RNA_def_property_float_sdna(prop, NULL, "from_min_scale[2]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_max_x_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "from_max[0]");
RNA_def_property_float_sdna(prop, NULL, "from_max_scale[0]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_max_y_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "from_max[1]");
RNA_def_property_float_sdna(prop, NULL, "from_max_scale[1]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "from_max_z_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "from_max[2]");
RNA_def_property_float_sdna(prop, NULL, "from_max_scale[2]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_min_x_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "to_min[0]");
RNA_def_property_float_sdna(prop, NULL, "to_min_scale[0]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_min_y_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "to_min[1]");
RNA_def_property_float_sdna(prop, NULL, "to_min_scale[1]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_min_z_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "to_min[2]");
RNA_def_property_float_sdna(prop, NULL, "to_min_scale[2]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_max_x_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "to_max[0]");
RNA_def_property_float_sdna(prop, NULL, "to_max_scale[0]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_max_y_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "to_max[1]");
RNA_def_property_float_sdna(prop, NULL, "to_max_scale[1]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "to_max_z_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "to_max[2]");
RNA_def_property_float_sdna(prop, NULL, "to_max_scale[2]");
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");