2.5 - FollowPath Constraint + File Loading Bugfix

* Added a new option ('Fixed Position') for Follow Path constraint which allows you to constrain an object/bone to some fixed position along the curve. Unlike the default mode of operation, this doesn't depend on time unless you explicitly animate the offset percentage parameter associated with this.

* Made old (pre 2.5) files saved with armatures in pose mode load in pose mode again.
This commit is contained in:
2009-09-08 09:41:15 +00:00
parent b9816c98bc
commit 5ce8b1f704
5 changed files with 53 additions and 13 deletions

View File

@@ -121,9 +121,17 @@ class ConstraintButtonsPanel(bpy.types.Panel):
def FOLLOW_PATH(self, layout, con):
self.target_template(layout, con)
row = layout.row()
row.itemR(con, "curve_follow")
row.itemR(con, "offset")
split = layout.split()
col = split.column()
col.itemR(con, "curve_follow")
col = split.column()
col.itemR(con, "fixed_position")
if con.fixed_position:
col.itemR(con, "offset_percentage", text="Offset")
else:
col.itemR(con, "offset")
row = layout.row()
row.itemL(text="Forward:")

View File

@@ -1178,17 +1178,26 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
makeDispListCurveTypes(cob->scene, ct->tar, 0);
if (cu->path && cu->path->data) {
curvetime= bsystem_time(cob->scene, ct->tar, (float)ctime, 0.0) - data->offset;
#if 0 // XXX old animation system
if (calc_ipo_spec(cu->ipo, CU_SPEED, &curvetime)==0) {
curvetime /= cu->pathlen;
if ((data->followflag & FOLLOWPATH_STATIC) == 0) {
/* animated position along curve depending on time */
curvetime= bsystem_time(cob->scene, ct->tar, ctime, 0.0) - data->offset;
/* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
* but this will only work if it actually is animated...
*
* we firstly calculate the modulus of cu->ctime/cu->pathlen to clamp ctime within the 0.0 to 1.0 times pathlen
* range, then divide this (the modulus) by pathlen to get a value between 0.0 and 1.0
*/
curvetime= fmod(cu->ctime, cu->pathlen) / cu->pathlen;
CLAMP(curvetime, 0.0, 1.0);
}
#endif // XXX old animation system
else {
/* fixed position along curve */
curvetime= data->offset; // XXX might need a more sensible value
}
if ( where_on_path(ct->tar, curvetime, vec, dir) ) {
if (data->followflag) {
if (data->followflag & FOLLOWPATH_FOLLOW) {
vectoquat(dir, (short) data->trackflag, (short) data->upflag, quat);
Normalize(dir);

View File

@@ -9596,6 +9596,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) {
Scene *sce;
Object *ob;
for(sce = main->scene.first; sce; sce = sce->id.next) {
if(fd->fileflags & G_FILE_ENABLE_ALL_FRAMES)
@@ -9628,6 +9629,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
sce->gm.flag |= GAME_DISPLAY_LISTS;
}
for(ob = main->object.first; ob; ob = ob->id.next) {
if(ob->flag & 8192) // OB_POSEMODE = 8192
ob->mode |= OB_MODE_POSE;
}
}
/* put 2.50 compatibility code here until next subversion bump */

View File

@@ -64,7 +64,8 @@ typedef struct bConstraint {
float enforce; /* Amount of influence exherted by constraint (0.0-1.0) */
float headtail; /* Point along subtarget bone where the actual target is. 0=head (default for all), 1=tail*/
int pad;
struct Ipo *ipo; /* local influence ipo or driver */
struct Ipo *ipo; /* local influence ipo or driver */ // XXX depreceated for 2.5... old animation system hack
} bConstraint;
@@ -449,6 +450,10 @@ typedef enum B_CONSTRAINTCHANNEL_FLAG {
#define TRACK_nY 0x04
#define TRACK_nZ 0x05
/* FollowPath flags */
#define FOLLOWPATH_FOLLOW 0x01
#define FOLLOWPATH_STATIC 0x02
/* bTrackToConstraint->flags */
#define TARGET_Z_UP 0x01

View File

@@ -871,9 +871,15 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update");
prop= RNA_def_property(srna, "offset", PROP_INT, PROP_TIME);
RNA_def_property_range(prop, -300000.0, 300000.f);
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "Offset", "Offset from the position corresponding to the time frame.");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
prop= RNA_def_property(srna, "offset_percentage", PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_sdna(prop, NULL, "offset"); // XXX we might be better with another var or some hackery?
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Offset Percentage", "Percentage value defining target position along length of bone.");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
prop= RNA_def_property(srna, "forward", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "trackflag");
@@ -888,8 +894,14 @@ 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, "curve_follow", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "followflag", 1);
RNA_def_property_boolean_sdna(prop, NULL, "followflag", FOLLOWPATH_FOLLOW);
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, "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.");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
}