[Bf-blender-cvs] [5d96bc9c5a2] master: Version patching fixes for F-Curves (as required for fixes for T48988 and T52009)

Joshua Leung noreply at git.blender.org
Tue Dec 5 13:00:05 CET 2017


Commit: 5d96bc9c5a26d2b8372764e7ee7640674f6bf51b
Author: Joshua Leung
Date:   Wed Dec 6 00:54:39 2017 +1300
Branches: master
https://developer.blender.org/rB5d96bc9c5a26d2b8372764e7ee7640674f6bf51b

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.

===================================================================

M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenloader/intern/versioning_270.c

===================================================================

diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 5aa13cad61d..6107bb1e32e 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1047,8 +1047,9 @@ static void nlastrips_apply_all_curves_cb(ID *id, ListBase *strips, AllFCurvesCb
 }
 
 /* Helper for BKE_fcurves_main_cb() - Dispatch wrapped operator to all F-Curves */
-static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, AllFCurvesCbWrapper *wrapper)
+static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, void *wrapper_data)
 {
+	AllFCurvesCbWrapper *wrapper = wrapper_data;
 	NlaTrack *nlt;
 	
 	if (adt->action) {
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);
+	}
 }



More information about the Bf-blender-cvs mailing list