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/editors/space_graph
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/editors/space_graph')
-rw-r--r--source/blender/editors/space_graph/graph_draw.c2
-rw-r--r--source/blender/editors/space_graph/graph_edit.c43
-rw-r--r--source/blender/editors/space_graph/graph_utils.c69
3 files changed, 38 insertions, 76 deletions
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 01a8ba4797c..1f92f32cc88 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -899,7 +899,7 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri
* - if the option to only show controls if the F-Curve is selected is enabled, we must obey this
*/
if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) {
- if (fcurve_needs_draw_fmodifier_controls(fcu, fcm)) {
+ if (fcurve_are_keyframes_usable(fcu) == 0) {
/* only draw controls if this is the active modifier */
if ((fcu->flag & FCURVE_ACTIVE) && (fcm)) {
switch (fcm->type) {
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index e1d1e4194d5..35307a78e65 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -406,6 +406,7 @@ static void insert_graph_keys(bAnimContext *ac, short mode)
bAnimListElem *ale;
int filter;
+ ReportList *reports = ac->reports;
Scene *scene= ac->scene;
float cfra= (float)CFRA;
short flag = 0;
@@ -432,7 +433,7 @@ static void insert_graph_keys(bAnimContext *ac, short mode)
/* if there's an id */
if (ale->id)
- insert_keyframe(ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
+ insert_keyframe(reports, ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
else
insert_vert_fcurve(fcu, cfra, fcu->curval, 0);
}
@@ -507,19 +508,33 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
}
fcu = ale->data;
- /* get frame and value from props */
- frame= RNA_float_get(op->ptr, "frame");
- val= RNA_float_get(op->ptr, "value");
-
- /* apply inverse NLA-mapping to frame to get correct time in un-scaled action */
- adt= ANIM_nla_mapping_get(&ac, ale);
- frame= BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP);
-
- /* apply inverse unit-mapping to value to get correct value for F-Curves */
- val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, 1);
-
- /* insert keyframe on the specified frame + value */
- insert_vert_fcurve(fcu, frame, val, 0);
+ /* when there are F-Modifiers on the curve, only allow adding
+ * keyframes if these will be visible after doing so...
+ */
+ if (fcurve_is_keyframable(fcu)) {
+ /* get frame and value from props */
+ frame= RNA_float_get(op->ptr, "frame");
+ val= RNA_float_get(op->ptr, "value");
+
+ /* apply inverse NLA-mapping to frame to get correct time in un-scaled action */
+ adt= ANIM_nla_mapping_get(&ac, ale);
+ frame= BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP);
+
+ /* apply inverse unit-mapping to value to get correct value for F-Curves */
+ val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, 1);
+
+ /* insert keyframe on the specified frame + value */
+ insert_vert_fcurve(fcu, frame, val, 0);
+ }
+ else {
+ /* warn about why this can't happen */
+ if (fcu->fpt)
+ BKE_report(op->reports, RPT_ERROR, "Keyframes cannot be added to sampled F-Curves");
+ else if (fcu->flag & FCURVE_PROTECTED)
+ BKE_report(op->reports, RPT_ERROR, "Active F-Curve is not editable");
+ else
+ BKE_report(op->reports, RPT_ERROR, "Remove F-Modifiers from F-Curve to add keyframes");
+ }
/* free temp data */
MEM_freeN(ale);
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index 927149a268d..417d92782cc 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -87,57 +87,6 @@ bAnimListElem *get_active_fcurve_channel (bAnimContext *ac)
/* ************************************************************** */
/* Operator Polling Callbacks */
-/* check if any FModifiers to draw controls for - fcm is 'active' modifier
- * used for the polling callbacks + also for drawing
- */
-// TODO: restructure these tests
-// TODO: maybe for now, just allow editing always for now...
-short fcurve_needs_draw_fmodifier_controls (FCurve *fcu, FModifier *fcm)
-{
- /* don't draw if there aren't any modifiers at all */
- if (fcu->modifiers.first == NULL)
- return 0;
-
- /* if only one modifier
- * - don't draw if it is muted or disabled
- * - set it as the active one if no active one is present
- */
- if (fcu->modifiers.first == fcu->modifiers.last) {
- fcm= fcu->modifiers.first;
- if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED))
- return 0;
- }
-
- /* if there's an active modifier - don't draw if it doesn't drastically
- * alter the curve...
- */
- if (fcm) {
- switch (fcm->type) {
- /* clearly harmless */
- case FMODIFIER_TYPE_CYCLES:
- return 0;
- case FMODIFIER_TYPE_STEPPED:
- return 0;
-
- /* borderline... */
- case FMODIFIER_TYPE_NOISE:
- return 0;
- }
- }
-
- /* if only active modifier - don't draw if it is muted or disabled */
- if (fcm) {
- if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED))
- return 0;
- }
-
- /* if we're still here, this means that there are modifiers with controls to be drawn */
- // FIXME: what happens if all the modifiers were muted/disabled
- return 1;
-}
-
-/* ------------------- */
-
/* Check if there are any visible keyframes (for selection tools) */
int graphop_visible_keyframes_poll (bContext *C)
{
@@ -167,7 +116,6 @@ int graphop_visible_keyframes_poll (bContext *C)
for (ale = anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->data;
- FModifier *fcm;
/* visible curves for selection must fulfull the following criteria:
* - it has bezier keyframes
@@ -176,10 +124,10 @@ int graphop_visible_keyframes_poll (bContext *C)
*/
if (fcu->bezt == NULL)
continue;
- fcm= find_active_fmodifier(&fcu->modifiers);
-
- found= (fcurve_needs_draw_fmodifier_controls(fcu, fcm) == 0);
- if (found) break;
+ if (fcurve_are_keyframes_usable(fcu)) {
+ found = 1;
+ break;
+ }
}
/* cleanup and return findings */
@@ -216,7 +164,6 @@ int graphop_editable_keyframes_poll (bContext *C)
for (ale = anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->data;
- FModifier *fcm;
/* editable curves must fulfull the following criteria:
* - it has bezier keyframes
@@ -226,10 +173,10 @@ int graphop_editable_keyframes_poll (bContext *C)
*/
if (fcu->bezt == NULL)
continue;
- fcm= find_active_fmodifier(&fcu->modifiers);
-
- found= (fcurve_needs_draw_fmodifier_controls(fcu, fcm) == 0);
- if (found) break;
+ if (fcurve_is_keyframable(fcu)) {
+ found = 1;
+ break;
+ }
}
/* cleanup and return findings */