Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-25 20:51:21 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-25 20:51:21 +0300
commit905a238075ca9660fbf41476c373c3723e8b7e0a (patch)
treede3de9b29d08071bce8d8871f593e75202e65c65 /source/blender/blenloader/intern/readfile.c
parentc74440f198da9dbafcf563e0ecaa505d0d7834b5 (diff)
Fix for radians-degrees version patch, more testing should have gone
into this before committing: * Subversion was not increased, meaning that conversion would be applied even on files saved with the new version. * Drivers were not converted. * FCurve generator modifiers were not converted. This seems to cover all cases we found for Durian, if another conversion is needed for this, be sure to increase the subversion number and do it in a separate if() test, otherwise files will break.
Diffstat (limited to 'source/blender/blenloader/intern/readfile.c')
-rw-r--r--source/blender/blenloader/intern/readfile.c158
1 files changed, 86 insertions, 72 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 492321d9ed9..30a5b647fe1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6459,28 +6459,43 @@ static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype)
}
}
-static void do_version_fcurve_radians_degrees_250(FCurve *fcu)
+static void do_version_fcurves_radians_degrees_250(ListBase *lb, char *propname)
{
+ FCurve *fcu;
+ FModifier *fcm;
int i;
- if (fcu->bezt) {
- for (i=0; i<fcu->totvert; i++) {
- BezTriple *bt = fcu->bezt+i;
-
- bt->vec[0][1] *= 180.0/M_PI;
- bt->vec[1][1] *= 180.0/M_PI;
- bt->vec[2][1] *= 180.0/M_PI;
- }
- }
- else if (fcu->fpt) {
- for (i=0; i<fcu->totvert; i++) {
- FPoint *fpt = fcu->fpt+i;
+ for (fcu=lb->first; fcu; fcu=fcu->next) {
+ if (strstr(fcu->rna_path, propname)) {
+ if (fcu->bezt) {
+ for (i=0; i<fcu->totvert; i++) {
+ BezTriple *bt = fcu->bezt+i;
+
+ bt->vec[0][1] *= 180.0/M_PI;
+ bt->vec[1][1] *= 180.0/M_PI;
+ bt->vec[2][1] *= 180.0/M_PI;
+ }
+ }
+ else if (fcu->fpt) {
+ for (i=0; i<fcu->totvert; i++) {
+ FPoint *fpt = fcu->fpt+i;
+
+ fpt->vec[1] *= 180.0/M_PI;
+ }
+ }
- fpt->vec[1] *= 180.0/M_PI;
+ for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
+ if (fcm->type == FMODIFIER_TYPE_GENERATOR) {
+ FMod_Generator *data= (FMod_Generator *)fcm->data;
+
+ for (i=0; i<data->arraysize; i++)
+ data->coefficients[i] *= 180/M_PI;
+ }
+ }
+
+ fcu->flag |= FCURVE_ROTATION_DEGREES;
}
}
-
- fcu->flag |= FCURVE_ROTATION_DEGREES;
}
static void do_versions(FileData *fd, Library *lib, Main *main)
@@ -10536,69 +10551,68 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* put 2.50 compatibility code here until next subversion bump */
- if (1) {
- {
- /* still missing:
- - Pose channel IK (min x/y/z, max x/y/z)
- */
- bAction *act;
- Object *ob;
-
- float rads_per_deg = M_PI / 180.0;
-
- /* convert degrees to radians for internal use */
- for (ob=main->object.first; ob; ob=ob->id.next) {
- AnimData *adt = BKE_animdata_from_id((ID *)ob);
- bConstraint *con;
-
- for (con=ob->constraints.first; con; con=con->next) {
-
- if(con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) {
- bRigidBodyJointConstraint *data = con->data;
- data->axX *= rads_per_deg;
- data->axY *= rads_per_deg;
- data->axZ *= rads_per_deg;
- }
- else if(con->type==CONSTRAINT_TYPE_KINEMATIC) {
- bKinematicConstraint *data = con->data;
- data->poleangle *= rads_per_deg;
- }
- else if(con->type==CONSTRAINT_TYPE_ROTLIMIT) {
- bRotLimitConstraint *data = con->data;
- FCurve *fcu;
-
- /* do it here, slightly less chance of getting a false positive */
- for (fcu=adt->action->curves.first; fcu; fcu=fcu->next) {
- if (strstr(fcu->rna_path, "minimum_x"))
- do_version_fcurve_radians_degrees_250(fcu);
- }
-
- data->xmin *= rads_per_deg;
- data->xmax *= rads_per_deg;
- data->ymin *= rads_per_deg;
- data->ymax *= rads_per_deg;
- data->zmin *= rads_per_deg;
- data->zmax *= rads_per_deg;
+ if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) {
+ /* still missing: - Pose channel IK (min x/y/z, max x/y/z)
+ NOTE: if you do more conversion, be sure to do it outside of this and
+ increase subversion again, otherwise it will not be correct */
+ bAction *act;
+ Object *ob;
+
+ float rads_per_deg = M_PI / 180.0;
+
+ /* convert degrees to radians for internal use */
+ for (ob=main->object.first; ob; ob=ob->id.next) {
+ AnimData *adt = BKE_animdata_from_id((ID *)ob);
+ bConstraint *con;
- }
- }
+ if(adt) {
+ do_version_fcurves_radians_degrees_250(&adt->drivers, "rotation_euler");
+ do_version_fcurves_radians_degrees_250(&adt->drivers, "delta_rotation_euler");
+ do_version_fcurves_radians_degrees_250(&adt->drivers, "pole_angle");
}
- /* convert fcurve values to be stored in degrees */
- for (act = main->action.first; act; act=act->id.next) {
- FCurve *fcu;
+ for (con=ob->constraints.first; con; con=con->next) {
- /* convert over named properties with PROP_UNIT_ROTATION time of this change */
- for (fcu=act->curves.first; fcu; fcu=fcu->next) {
- if (strstr(fcu->rna_path, "rotation_euler"))
- do_version_fcurve_radians_degrees_250(fcu);
- else if (strstr(fcu->rna_path, "delta_rotation_euler"))
- do_version_fcurve_radians_degrees_250(fcu);
- else if (strstr(fcu->rna_path, "pole_angle"))
- do_version_fcurve_radians_degrees_250(fcu);
+ if(con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) {
+ bRigidBodyJointConstraint *data = con->data;
+ data->axX *= rads_per_deg;
+ data->axY *= rads_per_deg;
+ data->axZ *= rads_per_deg;
+ }
+ else if(con->type==CONSTRAINT_TYPE_KINEMATIC) {
+ bKinematicConstraint *data = con->data;
+ data->poleangle *= rads_per_deg;
+ }
+ else if(con->type==CONSTRAINT_TYPE_ROTLIMIT) {
+ bRotLimitConstraint *data = con->data;
+
+ if(adt) {
+ do_version_fcurves_radians_degrees_250(&adt->action->curves, "minimum_x");
+ do_version_fcurves_radians_degrees_250(&adt->action->curves, "minimum_y");
+ do_version_fcurves_radians_degrees_250(&adt->action->curves, "minimum_z");
+ do_version_fcurves_radians_degrees_250(&adt->action->curves, "maximum_x");
+ do_version_fcurves_radians_degrees_250(&adt->action->curves, "maximum_y");
+ do_version_fcurves_radians_degrees_250(&adt->action->curves, "maximum_z");
+ }
+
+ data->xmin *= rads_per_deg;
+ data->xmax *= rads_per_deg;
+ data->ymin *= rads_per_deg;
+ data->ymax *= rads_per_deg;
+ data->zmin *= rads_per_deg;
+ data->zmax *= rads_per_deg;
+
}
}
}
+
+ /* convert fcurve values to be stored in degrees */
+ for (act = main->action.first; act; act=act->id.next) {
+ /* convert over named properties with PROP_UNIT_ROTATION time of this change */
+ do_version_fcurves_radians_degrees_250(&act->curves, "rotation_euler");
+ do_version_fcurves_radians_degrees_250(&act->curves, "delta_rotation_euler");
+ do_version_fcurves_radians_degrees_250(&act->curves, "pole_angle");
+ }
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */