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:
authorJoshua Leung <aligorith@gmail.com>2017-12-05 14:54:39 +0300
committerJoshua Leung <aligorith@gmail.com>2017-12-05 14:54:39 +0300
commit5d96bc9c5a26d2b8372764e7ee7640674f6bf51b (patch)
treebdd0df3e7397505bc9ca236fc1ab9ed3328ee5b3 /source/blender/blenloader/intern/versioning_270.c
parent6ebf244aced249366a4215787f768fde99523069 (diff)
Version patching fixes for F-Curves (as required for fixes for T48988 and T52009)
* For the T48988 fix (i.e. separate Ease In/Out properties for Bendy Bones in Edit vs Pose modes), old animation data needed to be patched to use the new property names. This is needed to partially fix some of the issues in T53356 (though the Rigify code itself still needs to be patched). * For the T52009 fix, old files needed to have the frame_start and frame_end properties on the FModifier (base-class) updated to match that of the FMod_Stepped type-specific class. This wasn't done in the earlier commit since it wasn't worth going through all animation data just for the sake of updating these relatively-rare settings, but since we're doing it anyway now, it makes sense to include this here.
Diffstat (limited to 'source/blender/blenloader/intern/versioning_270.c')
-rw-r--r--source/blender/blenloader/intern/versioning_270.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 095f21a5b06..fa7bf0c7dee 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -62,6 +62,8 @@
#include "BKE_animsys.h"
#include "BKE_brush.h"
#include "BKE_colortools.h"
+#include "BKE_fcurve.h"
+#include "BKE_gpencil.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mask.h"
@@ -71,7 +73,6 @@
#include "BKE_sequencer.h"
#include "BKE_screen.h"
#include "BKE_tracking.h"
-#include "BKE_gpencil.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
@@ -285,6 +286,67 @@ static void do_versions_compositor_render_passes(bNodeTree *ntree)
}
}
+
+static char *replace_bbone_easing_rnapath(char *old_path)
+{
+ char *new_path = NULL;
+
+ /* NOTE: This will break paths for any bones/custom-properties
+ * which happen be named after the bbone property id's
+ */
+ if (strstr(old_path, "bbone_in"))
+ new_path = BLI_str_replaceN(old_path, "bbone_in", "bbone_easein");
+ else if (strstr(old_path, "bbone_out"))
+ new_path = BLI_str_replaceN(old_path, "bbone_out", "bbone_easeout");
+
+ if (new_path) {
+ MEM_freeN(old_path);
+ return new_path;
+ }
+ else {
+ return old_path;
+ }
+}
+
+static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), FCurve *fcu, void *UNUSED(user_data))
+{
+ /* F-Curve's path (for bbone_in/out) */
+ if (fcu->rna_path) {
+ fcu->rna_path = replace_bbone_easing_rnapath(fcu->rna_path);
+ }
+
+ /* Driver -> Driver Vars (for bbone_in/out) */
+ if (fcu->driver) {
+ for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
+ DRIVER_TARGETS_LOOPER(dvar)
+ {
+ if (dtar->rna_path) {
+ dtar->rna_path = replace_bbone_easing_rnapath(dtar->rna_path);
+ }
+ }
+ DRIVER_TARGETS_LOOPER_END;
+ }
+ }
+
+ /* FModifiers -> Stepped (for frame_start/end) */
+ if (fcu->modifiers.first) {
+ for (FModifier *fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
+ if (fcm->type == FMODIFIER_TYPE_STEPPED) {
+ FMod_Stepped *data = fcm->data;
+
+ /* Modifier doesn't work if the modifier's copy of start/end frame are both 0
+ * as those were only getting written to the fcm->data copy (T52009)
+ */
+ if ((fcm->sfra == fcm->efra) && (fcm->sfra == 0)) {
+ fcm->sfra = data->start_frame;
+ fcm->efra = data->end_frame;
+ }
+ }
+ }
+ }
+}
+
+
void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
{
if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
@@ -1721,4 +1783,10 @@ void do_versions_after_linking_270(Main *main)
}
} FOREACH_NODETREE_END
}
+
+ if (!MAIN_VERSION_ATLEAST(main, 279, 2)) {
+ /* B-Bones (bbone_in/out -> bbone_easein/out) + Stepped FMod Frame Start/End fix */
+ /* if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "bbone_easein")) */
+ BKE_fcurves_main_cb(main, do_version_bbone_easing_fcurve_fix, NULL);
+ }
}