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:
Diffstat (limited to 'source/blender/makesrna/intern/rna_fcurve.c')
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c107
1 files changed, 70 insertions, 37 deletions
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 63405e08f69..69e15482bbb 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -53,7 +53,7 @@ EnumPropertyItem fmodifier_type_items[] = {
{FMODIFIER_TYPE_CYCLES, "CYCLES", 0, "Cycles", ""},
{FMODIFIER_TYPE_NOISE, "NOISE", 0, "Noise", ""},
{FMODIFIER_TYPE_FILTER, "FILTER", 0, "Filter", ""},
- {FMODIFIER_TYPE_PYTHON, "PYTHON", 0, "Python", ""},
+ //{FMODIFIER_TYPE_PYTHON, "PYTHON", 0, "Python", ""}, // FIXME: not implemented yet!
{FMODIFIER_TYPE_LIMITS, "LIMITS", 0, "Limits", ""},
{FMODIFIER_TYPE_STEPPED, "STEPPED", 0, "Stepped Interpolation", ""},
{0, NULL, 0, NULL, NULL}};
@@ -62,6 +62,7 @@ EnumPropertyItem beztriple_keyframe_type_items[] = {
{BEZT_KEYTYPE_KEYFRAME, "KEYFRAME", 0, "Keyframe", ""},
{BEZT_KEYTYPE_BREAKDOWN, "BREAKDOWN", 0, "Breakdown", ""},
{BEZT_KEYTYPE_EXTREME, "EXTREME", 0, "Extreme", ""},
+ {BEZT_KEYTYPE_JITTER, "JITTER", 0, "Jitter", ""},
{0, NULL, 0, NULL, NULL}};
#ifdef RNA_RUNTIME
@@ -111,7 +112,7 @@ static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA
// TODO: this really needs an update guard...
DAG_scene_sort(bmain, scene);
- DAG_id_flush_update(id, OB_RECALC_OB|OB_RECALC_DATA);
+ DAG_id_tag_update(id, OB_RECALC_OB|OB_RECALC_DATA);
WM_main_add_notifier(NC_SCENE|ND_FRAME, scene);
}
@@ -334,19 +335,36 @@ static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
{
- AnimData *adt= BKE_animdata_from_id(ptr->id.data);
- bAction *act= (adt) ? adt->action : NULL;
+ ID *pid = (ID *)ptr->id.data;
+ ID *vid = (ID *)value.id.data;
FCurve *fcu= ptr->data;
-
- /* same ID? */
- if (value.data && (ptr->id.data != value.id.data)) {
+ bAction *act = NULL;
+
+ /* get action */
+ if (ELEM(NULL, pid, vid)) {
+ printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n", pid, vid);
+ return;
+ }
+ else if (value.data && (pid != vid)) {
/* id's differ, cant do this, should raise an error */
+ printf("ERROR: ID's differ - ptr=%p vs value=%p \n", pid, vid);
return;
}
+
+ if (GS(pid->name)==ID_AC && GS(vid->name)==ID_AC) {
+ /* the ID given is the action already - usually when F-Curve is obtained from an action's pointer */
+ act = (bAction *)pid;
+ }
+ else {
+ /* the ID given is the owner of the F-Curve (for drivers) */
+ AnimData *adt = BKE_animdata_from_id(ptr->id.data);
+ act = (adt)? adt->action : NULL;
+ }
+
/* already belongs to group? */
if (fcu->grp == value.data) {
/* nothing to do */
- printf("ERROR: F-Curve already belongs to the group\n");
+ printf("ERROR: F-Curve already belongs to this group\n");
return;
}
@@ -357,18 +375,16 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
/* can't change the grouping of F-Curve when it doesn't belong to an action */
printf("ERROR: cannot assign F-Curve to group, since F-Curve is not attached to any ID\n");
return;
- }
-
- /* try to remove F-Curve from action (including from any existing groups)
- * - if after this op it is still attached to something, then it is a driver
- * not an animation curve as we thought, and we should exit
- */
- action_groups_remove_channel(act, fcu);
- if (fcu->next) {
- /* F-Curve is not one that exists in the action, since the above op couldn't remove it from the list */
+ }
+ /* make sure F-Curve exists in this action first, otherwise we could still have been tricked */
+ else if (BLI_findindex(&act->curves, fcu) == -1) {
+ printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name);
return;
}
+ /* try to remove F-Curve from action (including from any existing groups) */
+ action_groups_remove_channel(act, fcu);
+
/* add the F-Curve back to the action now in the right place */
// TODO: make the api function handle the case where there isn't any group to assign to
if (value.data) {
@@ -531,25 +547,34 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl
*max= MAXFRAMEF;
}
-static BezTriple *rna_FKeyframe_points_add(FCurve *fcu, float frame, float value, int do_replace, int do_needed, int do_fast)
+static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
{
- int index;
- int flag= 0;
-
- if(do_replace) flag |= INSERTKEY_REPLACE;
- if(do_needed) flag |= INSERTKEY_NEEDED;
- if(do_fast) flag |= INSERTKEY_FAST;
+ int index= insert_vert_fcurve(fcu, frame, value, flag);
+ return ((fcu->bezt) && (index >= 0))? (fcu->bezt + index) : NULL;
+}
+static void rna_FKeyframe_points_add(FCurve *fcu, int tot)
+{
+ if(tot > 0) {
+ if(fcu->totvert) {
+ BezTriple *nbezt= MEM_callocN(sizeof(BezTriple) * (fcu->totvert + tot), "rna_FKeyframe_points_add");
+ memcpy(nbezt, fcu->bezt, sizeof(BezTriple) * fcu->totvert);
+ MEM_freeN(fcu->bezt);
+ fcu->bezt= nbezt;
+ }
+ else {
+ fcu->bezt= MEM_callocN(sizeof(BezTriple) * tot, "rna_FKeyframe_points_add");
+ }
- index= insert_vert_fcurve(fcu, frame, value, flag);
- return index >= 0 ? fcu->bezt + index : NULL;
+ fcu->totvert += tot;
+ }
}
static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast)
{
int index= (int)(bezt - fcu->bezt);
if (index < 0 || index >= fcu->totvert) {
- BKE_report(reports, RPT_ERROR, "bezier not in fcurve.");
+ BKE_report(reports, RPT_ERROR, "Keyframe not in F-Curve.");
return;
}
@@ -747,8 +772,8 @@ static void rna_def_fmodifier_cycles(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Before Mode", "Cycling mode to use before first keyframe");
RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
- prop= RNA_def_property(srna, "cycles_before", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "before_cycles");
+ prop= RNA_def_property(srna, "cycles_before", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "before_cycles");
RNA_def_property_ui_text(prop, "Before Cycles", "Maximum number of cycles to allow before first keyframe. (0 = infinite)");
RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
@@ -759,8 +784,8 @@ static void rna_def_fmodifier_cycles(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "After Mode", "Cycling mode to use after last keyframe");
RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
- prop= RNA_def_property(srna, "cycles_after", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "after_cycles");
+ prop= RNA_def_property(srna, "cycles_after", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "after_cycles");
RNA_def_property_ui_text(prop, "After Cycles", "Maximum number of cycles to allow after last keyframe. (0 = infinite)");
RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
}
@@ -1308,25 +1333,32 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
FunctionRNA *func;
PropertyRNA *parm;
+ static EnumPropertyItem keyframe_flag_items[] = {
+ {INSERTKEY_REPLACE, "REPLACE", 0, "Replace", "Don't add any new keyframes, but just replace existing ones"},
+ {INSERTKEY_NEEDED, "NEEDED", 0, "Needed", "Only adds keyframes that are needed"},
+ {INSERTKEY_FAST, "FAST", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time"},
+ {0, NULL, 0, NULL, NULL}};
+
RNA_def_property_srna(cprop, "FCurveKeyframePoints");
srna= RNA_def_struct(brna, "FCurveKeyframePoints", NULL);
RNA_def_struct_sdna(srna, "FCurve");
RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points");
- func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
+ func= RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert");
RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
parm= RNA_def_float(func, "frame", 0.0f, -FLT_MAX, FLT_MAX, "", "X Value of this keyframe point", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "", "Y Value of this keyframe point", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);
- /* optional */
- parm= RNA_def_boolean(func, "replace", 0, "Replace", "Replace existing keyframes");
- parm= RNA_def_boolean(func, "needed", 0, "Needed", "Only adds keyframes that are needed");
- parm= RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time");
+
+ RNA_def_enum_flag(func, "options", keyframe_flag_items, 0, "", "Keyframe options.");
parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
RNA_def_function_return(func, parm);
+ func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
+ RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
+ RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
func= RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
RNA_def_function_ui_description(func, "Remove keyframe from an fcurve.");
@@ -1334,7 +1366,7 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove.");
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
/* optional */
- parm= RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating the curve each time");
+ RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating the curve each time");
}
static void rna_def_fcurve(BlenderRNA *brna)
@@ -1395,6 +1427,7 @@ static void rna_def_fcurve(BlenderRNA *brna)
prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 3);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor");
RNA_def_property_update(prop, NC_ANIMATION, NULL);