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>2010-11-17 15:02:36 +0300
committerJoshua Leung <aligorith@gmail.com>2010-11-17 15:02:36 +0300
commitf7137610390804b8016240bc6401540a912e2495 (patch)
treebc0409baecb7a837e93d5794e0bfd1128b5f7584 /source/blender/blenkernel/intern/fcurve.c
parent91217f117f739dc93381a4542094141f46639be3 (diff)
Keyframing Operators: Improved Error Messages
* Keyframing operators now use the reports system for displaying all its error messages. - The benefit of this is that users no longer need to check the console for error messages if keyframing fails. - Unfortunately, reports are not currently viewable in any space/view in Blender, so... * Added a temporary operator (UI_OT_reports_to_textblock), which can be accessed in the UI from the button which appears in place of the icon when more than one report exists. This dumps the current list of reports to a textblock "Recent Reports", from which they can be viewed. This isn't really nice, but at least we now have a way to view these again, which makes debugging some things a pain. * Bugfix #24606 - when trying to add keyframes to F-Curves with F-Modifiers already which alter the curve significantly enough that the keyframes will have no effect, there are now warnings which aim to alleviate any confusion.
Diffstat (limited to 'source/blender/blenkernel/intern/fcurve.c')
-rw-r--r--source/blender/blenkernel/intern/fcurve.c103
1 files changed, 93 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 75029af4b10..2f886d8ab43 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -163,7 +163,7 @@ void copy_fcurves (ListBase *dst, ListBase *src)
}
}
-/* --------------------- Finding -------------------------- */
+/* ----------------- Finding F-Curves -------------------------- */
/* high level function to get an fcurve from C without having the rna */
FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name, int index)
@@ -298,36 +298,36 @@ int list_find_data_fcurves (ListBase *dst, ListBase *src, const char *dataPrefix
return matches;
}
-FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven)
+FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven)
{
FCurve *fcu= NULL;
*driven= 0;
/* there must be some RNA-pointer + property combon */
- if(prop && ptr->id.data && RNA_property_animateable(ptr, prop)) {
+ if (prop && ptr->id.data && RNA_property_animateable(ptr, prop)) {
AnimData *adt= BKE_animdata_from_id(ptr->id.data);
char *path;
- if(adt) {
- if((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
+ if (adt) {
+ if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
/* XXX this function call can become a performance bottleneck */
path= RNA_path_from_ID_to_property(ptr, prop);
- if(path) {
+ if (path) {
/* animation takes priority over drivers */
- if(adt->action && adt->action->curves.first)
+ if (adt->action && adt->action->curves.first)
fcu= list_find_fcurve(&adt->action->curves, path, rnaindex);
/* if not animated, check if driven */
- if(!fcu && (adt->drivers.first)) {
+ if (!fcu && (adt->drivers.first)) {
fcu= list_find_fcurve(&adt->drivers, path, rnaindex);
- if(fcu)
+ if (fcu)
*driven= 1;
}
- if(fcu && action)
+ if (fcu && action)
*action= adt->action;
MEM_freeN(path);
@@ -339,6 +339,8 @@ FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction
return fcu;
}
+/* ----------------- Finding Keyframes/Extents -------------------------- */
+
/* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */
#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
@@ -520,6 +522,87 @@ void calc_fcurve_range (FCurve *fcu, float *start, float *end)
}
}
+/* ----------------- Status Checks -------------------------- */
+
+/* Are keyframes on F-Curve of any use?
+ * Usability of keyframes refers to whether they should be displayed,
+ * and also whether they will have any influence on the final result.
+ */
+short fcurve_are_keyframes_usable (FCurve *fcu)
+{
+ /* F-Curve must exist */
+ if (fcu == NULL)
+ return 0;
+
+ /* F-Curve must not have samples - samples are mutually exclusive of keyframes */
+ if (fcu->fpt)
+ return 0;
+
+ /* if it has modifiers, none of these should "drastically" alter the curve */
+ if (fcu->modifiers.first) {
+ FModifier *fcm;
+
+ /* check modifiers from last to first, as last will be more influential */
+ // TODO: optionally, only check modifier if it is the active one...
+ for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) {
+ /* ignore if muted/disabled */
+ if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED))
+ continue;
+
+ /* type checks */
+ switch (fcm->type) {
+ /* clearly harmless - do nothing */
+ case FMODIFIER_TYPE_CYCLES:
+ case FMODIFIER_TYPE_STEPPED:
+ case FMODIFIER_TYPE_NOISE:
+ break;
+
+ /* sometimes harmful - depending on whether they're "additive" or not */
+ case FMODIFIER_TYPE_GENERATOR:
+ {
+ FMod_Generator *data = (FMod_Generator *)fcm->data;
+
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ return 0;
+ }
+ break;
+ case FMODIFIER_TYPE_FN_GENERATOR:
+ {
+ FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data;
+
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ return 0;
+ }
+ break;
+
+ /* always harmful - cannot allow */
+ default:
+ return 0;
+ }
+ }
+ }
+
+ /* keyframes are usable */
+ return 1;
+}
+
+/* Can keyframes be added to F-Curve?
+ * Keyframes can only be added if they are already visible
+ */
+short fcurve_is_keyframable (FCurve *fcu)
+{
+ /* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on final result) */
+ if (fcurve_are_keyframes_usable(fcu) == 0)
+ return 0;
+
+ /* F-Curve must currently be editable too */
+ if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) )
+ return 0;
+
+ /* F-Curve is keyframable */
+ return 1;
+}
+
/* ***************************** Keyframe Column Tools ********************************* */
/* add a BezTriple to a column */