Bugfix #20940: Offset always resets to 1 in follow path constraint

Made the 'Offset Factor' setting use a separate variable from the 'Offset' setting in the DNA stuff. While we could get away with this sort of thing in the past, it turns out that with the Datablocks viewer these days, settings sharing an internal var but with different ranges/behaviour doesn't work well anymore, since later instances override earlier ones.
This commit is contained in:
Joshua Leung 2010-02-03 09:05:31 +00:00
parent 742ef3b4cc
commit 53596fc6b8
3 changed files with 10 additions and 7 deletions

@ -1206,7 +1206,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
}
else {
/* fixed position along curve */
curvetime= data->offset; // XXX might need a more sensible value
curvetime= data->offset_fac;
}
if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius) ) {

@ -257,11 +257,15 @@ typedef struct bDampTrackConstraint {
/* Follow Path constraints */
typedef struct bFollowPathConstraint {
Object *tar; /* Must be path object */
float offset; /* Offset in time on the path (in frame) */
Object *tar; /* Must be path object */
float offset; /* Offset in time on the path (in frames), when NOT using 'fixed position' */
float offset_fac; /* Parametric offset factor defining position along path, when using 'fixed position' */
int followflag;
int trackflag;
int upflag;
short trackflag;
short upflag;
} bFollowPathConstraint;
/* Stretch to constraint */

@ -1045,7 +1045,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
prop= RNA_def_property(srna, "offset_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "offset"); // XXX we might be better with another var or some hackery?
RNA_def_property_float_sdna(prop, NULL, "offset_fac");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Offset Factor", "Percentage value defining target position along length of bone.");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
@ -1067,7 +1067,6 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Follow Curve", "Object will follow the heading and banking of the curve.");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
// TODO: do we need to do some special trickery to get offset sane for this?
prop= RNA_def_property(srna, "use_fixed_position", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "followflag", FOLLOWPATH_STATIC);
RNA_def_property_ui_text(prop, "Fixed Position", "Object will stay locked to a single point somewhere along the length of the curve regardless of time.");