[Bf-blender-cvs] [a91c4ac] master: Ignore user-preferences when inserting keys from Python

Campbell Barton noreply at git.blender.org
Mon Apr 28 23:35:16 CEST 2014


Commit: a91c4ac99fd4d766834a42ace4a670dfa824813b
Author: Campbell Barton
Date:   Tue Apr 29 07:34:09 2014 +1000
https://developer.blender.org/rBa91c4ac99fd4d766834a42ace4a670dfa824813b

Ignore user-preferences when inserting keys from Python

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

M	source/blender/editors/animation/keyframing.c
M	source/blender/makesdna/DNA_anim_types.h
M	source/blender/makesrna/intern/rna_fcurve.c
M	source/blender/python/intern/bpy_rna_anim.c

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

diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 9008d33..8a02aed 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -396,11 +396,18 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag)
 	beztr.vec[2][0] = x + 1.0f;
 	beztr.vec[2][1] = y;
 	beztr.f1 = beztr.f2 = beztr.f3 = SELECT;
-	beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */
-	//BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
 
-	/* use default interpolation mode, with exceptions for int/discrete values */
-	beztr.ipo = U.ipo_new;
+	if (flag & INSERTKEY_NO_USERPREF) {
+		beztr.h1 = beztr.h2 = HD_AUTO_ANIM;
+		beztr.ipo = BEZT_IPO_BEZ;
+	}
+	else {
+		beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */
+		//BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
+
+		/* use default interpolation mode, with exceptions for int/discrete values */
+		beztr.ipo = U.ipo_new;
+	}
 
 	if (fcu->flag & FCURVE_DISCRETE_VALUES)
 		beztr.ipo = BEZT_IPO_CONST;
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 8c04c41..390233a 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -791,7 +791,8 @@ typedef enum eInsertKeyFlags {
 	INSERTKEY_FAST 		= (1<<2),	/* don't recalculate handles,etc. after adding key */
 	INSERTKEY_FASTR		= (1<<3),	/* don't realloc mem (or increase count, as array has already been set out) */
 	INSERTKEY_REPLACE 	= (1<<4),	/* only replace an existing keyframe (this overrides INSERTKEY_NEEDED) */
-	INSERTKEY_XYZ2RGB	= (1<<5)	/* transform F-Curves should have XYZ->RGB color mode */
+	INSERTKEY_XYZ2RGB	= (1<<5),	/* transform F-Curves should have XYZ->RGB color mode */
+	INSERTKEY_NO_USERPREF	= (1 << 6),	/* ignore user-prefs (needed for predictable API use) */
 } eInsertKeyFlags;
 
 /* ************************************************ */
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index bf07aae..00caa3b 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -738,7 +738,7 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl
 
 static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
 {
-	int index = insert_vert_fcurve(fcu, frame, value, flag);
+	int index = insert_vert_fcurve(fcu, frame, value, flag | INSERTKEY_NO_USERPREF);
 	return ((fcu->bezt) && (index >= 0)) ? (fcu->bezt + index) : NULL;
 }
 
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 3320043..ed51ba5 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -168,8 +168,13 @@ static int pyrna_struct_keyframe_parse(
 		*cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
 
 	/* flag may be null (no option currently for remove keyframes e.g.). */
-	if (pyoptions && options && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) == -1))
-		return -1;
+	if (options) {
+		if (pyoptions && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) == -1)) {
+			return -1;
+		}
+
+		*options |= INSERTKEY_NO_USERPREF;
+	}
 
 	return 0; /* success */
 }




More information about the Bf-blender-cvs mailing list