diff options
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r-- | source/blender/editors/animation/anim_channels_defines.c | 10 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_channels_edit.c | 163 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_draw.c | 230 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_filter.c | 41 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_markers.c | 17 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_motion_paths.c | 4 | ||||
-rw-r--r-- | source/blender/editors/animation/drivers.c | 12 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_edit.c | 8 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_general.c | 6 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_keylist.cc | 4 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 6 | ||||
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 16 |
13 files changed, 317 insertions, 202 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index b7562073ee7..3a82143cfdf 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -85,7 +85,7 @@ #define ANIM_CHAN_NAME_SIZE 256 /* get the pointer used for some flag */ -#define GET_ACF_FLAG_PTR(ptr, type) ((*(type) = sizeof((ptr))), &(ptr)) +#define GET_ACF_FLAG_PTR(ptr, type) ((*(type) = sizeof(ptr)), &(ptr)) /* *********************************************** */ /* Generic Functions (Type independent) */ @@ -4937,7 +4937,7 @@ static void draw_setting_widget(bAnimContext *ac, tooltip = TIP_("Grease Pencil layer is visible in the viewport"); } else { - tooltip = TIP_("Channels are visible in Graph Editor for editing"); + tooltip = TIP_("Toggle visibility of Channels in Graph Editor for editing"); } break; @@ -4993,7 +4993,7 @@ static void draw_setting_widget(bAnimContext *ac, } else if (ale->type == ANIMTYPE_GPLAYER) { tooltip = TIP_( - "Shows all keyframes during animation playback and enabled all frames for editing " + "Show all keyframes during animation playback and enable all frames for editing " "(uncheck to use only the current keyframe during animation playback and editing)"); } else { @@ -5353,8 +5353,8 @@ void ANIM_channel_draw_widgets(const bContext *C, * and wouldn't be able to auto-keyframe. * - Slider should start before the toggles (if they're visible) * to keep a clean line down the side. - * - Sliders are always drawn in Shapekey mode now. Prior to this - * the SACTION_SLIDERS flag would be set when changing into Shapekey mode. + * - Sliders are always drawn in Shape-key mode now. Prior to this + * the SACTION_SLIDERS flag would be set when changing into shape-key mode. */ if (((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 06a62b7a9de..e86e1f16e54 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -31,6 +31,7 @@ #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_gpencil.h" +#include "BKE_layer.h" #include "BKE_lib_id.h" #include "BKE_mask.h" #include "BKE_nla.h" @@ -53,10 +54,9 @@ #include "WM_api.h" #include "WM_types.h" -/* ************************************************************************** */ -/* CHANNELS API - Exposed API */ - -/* -------------------------- Selection ------------------------------------- */ +/* -------------------------------------------------------------------- */ +/** \name Public Channel Selection API + * \{ */ void ANIM_set_active_channel(bAnimContext *ac, void *data, @@ -462,7 +462,11 @@ void ANIM_anim_channels_select_toggle(bAnimContext *ac) ANIM_animdata_freelist(&anim_data); } -/* ---------------------------- Graph Editor ------------------------------------- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Public Graph Editor API + * \{ */ /* Copy a certain channel setting to parents of the modified channel. */ static void anim_flush_channel_setting_up(bAnimContext *ac, @@ -626,7 +630,11 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, anim_flush_channel_setting_down(ac, setting, mode, match, matchLevel); } -/* -------------------------- F-Curves ------------------------------------- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Public F-Curves API + * \{ */ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *fcu) { @@ -698,10 +706,11 @@ bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt) return false; } -/* ************************************************************************** */ -/* OPERATORS */ +/** \} */ -/* ****************** Operator Utilities ********************************** */ +/* -------------------------------------------------------------------- */ +/** \name Operator Utilities + * \{ */ /* poll callback for being in an Animation Editor channels list region */ static bool animedit_poll_channels_active(bContext *C) @@ -747,7 +756,11 @@ static bool animedit_poll_channels_nla_tweakmode_off(bContext *C) return true; } -/* ****************** Rearrange Channels Operator ******************* */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Move (Rearrange) Channels Operator + * \{ */ /* constants for channel rearranging */ /* WARNING: don't change existing ones without modifying rearrange func accordingly */ @@ -1580,7 +1593,11 @@ static void ANIM_OT_channels_move(wmOperatorType *ot) ""); } -/* ******************** Group Channel Operator ************************ */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Group Channel Operator + * \{ */ static bool animchannels_grouping_poll(bContext *C) { @@ -1738,7 +1755,11 @@ static void ANIM_OT_channels_group(wmOperatorType *ot) // RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); } -/* ----------------------------------------------------------- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Ungroup Channels Operator + * \{ */ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1804,7 +1825,11 @@ static void ANIM_OT_channels_ungroup(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ******************** Delete Channel Operator *********************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Delete Channel Operator + * \{ */ static void tag_update_animation_element(bAnimListElem *ale) { @@ -1975,7 +2000,11 @@ static void ANIM_OT_channels_delete(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ********************** Set Flags Operator *********************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Set/Toggle Channel Flags Operator Utilities + * \{ */ /* defines for setting animation-channel flags */ static const EnumPropertyItem prop_animchannel_setflag_types[] = { @@ -2222,7 +2251,11 @@ static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN); /* internal hack - don't expose */ } -/* ********************** Expand Channels Operator *********************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Expand Channels Operator + * \{ */ static int animchannels_expand_exec(bContext *C, wmOperator *op) { @@ -2267,7 +2300,11 @@ static void ANIM_OT_channels_expand(wmOperatorType *ot) ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)"); } -/* ********************** Collapse Channels Operator *********************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Collapse Channels Operator + * \{ */ static int animchannels_collapse_exec(bContext *C, wmOperator *op) { @@ -2312,17 +2349,22 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot) ot->srna, "all", true, "All", "Collapse all channels (not just selected ones)"); } -/* ************ Remove All "Empty" AnimData Blocks Operator ********* */ -/* We define "empty" AnimData blocks here as those which have all 3 of criteria: - * 1) No active action OR that active actions are empty - * Assuming that all legitimate entries will have an action, - * and that empty actions - * 2) No NLA Tracks + NLA Strips - * Assuming that users haven't set up any of these as "placeholders" - * for convenience sake, and that most that exist were either unintentional - * or are no longer wanted - * 3) No drivers - */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Remove All "Empty" AnimData Blocks Operator + * + * We define "empty" AnimData blocks here as those which have all 3 of criteria: + * + * 1) No active action OR that active actions are empty + * Assuming that all legitimate entries will have an action, + * and that empty actions + * 2) No NLA Tracks + NLA Strips + * Assuming that users haven't set up any of these as "placeholders" + * for convenience sake, and that most that exist were either unintentional + * or are no longer wanted + * 3) No drivers + * \{ */ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -2421,7 +2463,11 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ******************* Reenable Disabled Operator ******************* */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Re-enable Disabled Operator + * \{ */ static bool animchannels_enable_poll(bContext *C) { @@ -2488,7 +2534,7 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) /* identifiers */ ot->name = "Revive Disabled F-Curves"; ot->idname = "ANIM_OT_channels_fcurves_enable"; - ot->description = "Clears 'disabled' tag from all F-Curves to get broken F-Curves working again"; + ot->description = "Clear 'disabled' tag from all F-Curves to get broken F-Curves working again"; /* api callbacks */ ot->exec = animchannels_enable_exec; @@ -2498,7 +2544,11 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ****************** Select Filter Textbox Operator ******************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Filter Text-box Operator + * \{ */ /* XXX: make this generic? */ static bool animchannels_select_filter_poll(bContext *C) @@ -2571,7 +2621,11 @@ static void ANIM_OT_channels_select_filter(wmOperatorType *ot) ot->poll = animchannels_select_filter_poll; } -/* ********************** Select All Operator *********************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select All Operator + * \{ */ static int animchannels_selectall_exec(bContext *C, wmOperator *op) { @@ -2626,7 +2680,11 @@ static void ANIM_OT_channels_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } -/* ******************** Box Select Operator *********************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Box Select Operator + * \{ */ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectmode) { @@ -2704,8 +2762,6 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm ANIM_animdata_freelist(&anim_data); } -/* ------------------- */ - static int animchannels_box_select_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -2764,8 +2820,13 @@ static void ANIM_OT_channels_select_box(wmOperatorType *ot) WM_operator_properties_gesture_box_select(ot); } -/* ******************* Rename Operator ***************************** */ -/* Allow renaming some channels by clicking on them */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Rename Channel Operator + * + * Allow renaming some channels by clicking on them. + * \{ */ static bool rename_anim_channels(bAnimContext *ac, int channel_index) { @@ -2922,7 +2983,12 @@ static void ANIM_OT_channels_rename(wmOperatorType *ot) ot->poll = animedit_poll_channels_active; } -/* ******************** Mouse-Click Operator *********************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Channel Keyframes Operator (Internal Logic) + * \{ */ + /* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */ static int click_select_channel_scene(bAnimListElem *ale, @@ -2953,6 +3019,7 @@ static int click_select_channel_object(bContext *C, bAnimListElem *ale, const short /* eEditKeyframes_Select or -1 */ selectmode) { + Scene *scene = ac->scene; ViewLayer *view_layer = ac->view_layer; Base *base = (Base *)ale->data; Object *ob = base->object; @@ -2971,11 +3038,10 @@ static int click_select_channel_object(bContext *C, } } else { - Base *b; - /* deselect all */ + BKE_view_layer_synced_ensure(scene, view_layer); /* TODO: should this deselect all other types of channels too? */ - for (b = view_layer->object_bases.first; b; b = b->next) { + LISTBASE_FOREACH (Base *, b, BKE_view_layer_object_bases_get(view_layer)) { ED_object_base_select(b, BA_DESELECT); if (b->object->adt) { b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); @@ -3365,9 +3431,13 @@ static int mouse_anim_channels(bContext *C, return notifierFlags; } -/* ------------------- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Channel Keyframes Operator + * \{ */ -/* handle clicking */ +/** Handle picking logic. */ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bAnimContext ac; @@ -3553,8 +3623,11 @@ static void ANIM_OT_channel_select_keys(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -/* ************************************************************************** */ -/* Operator Registration */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Operator Registration + * \{ */ void ED_operatortypes_animchannels(void) { @@ -3595,4 +3668,4 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) WM_keymap_ensure(keyconf, "Animation Channels", 0, 0); } -/* ************************************************************************** */ +/** \} */ diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 06a0077df9b..329bc2b46eb 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -329,6 +329,121 @@ short ANIM_get_normalization_flags(bAnimContext *ac) return 0; } +static void fcurve_scene_coord_range_get(Scene *scene, + FCurve *fcu, + float *r_min_coord, + float *r_max_coord) +{ + float min_coord = FLT_MAX; + float max_coord = -FLT_MAX; + const bool use_preview_only = PRVRANGEON; + + if (fcu->bezt || fcu->fpt) { + int start = 0; + int end = fcu->totvert; + + if (use_preview_only) { + start = scene->r.psfra; + end = min_ii(scene->r.pefra + 1, fcu->totvert); + } + + if (fcu->bezt) { + const BezTriple *bezt = fcu->bezt + start; + for (int i = start; i < end; i++, bezt++) { + + if (i == 0) { + /* We ignore extrapolation flags and handle here, and use the + * control point position only. so we normalize "interesting" + * part of the curve. + * + * Here we handle left extrapolation. + */ + max_coord = max_ff(max_coord, bezt->vec[1][1]); + min_coord = min_ff(min_coord, bezt->vec[1][1]); + } + else { + const BezTriple *prev_bezt = bezt - 1; + if (!ELEM(prev_bezt->ipo, BEZT_IPO_BEZ, BEZT_IPO_BACK, BEZT_IPO_ELASTIC)) { + /* The points on the curve will lie inside the start and end points. + * Calculate min/max using both previous and current CV. + */ + max_coord = max_ff(max_coord, bezt->vec[1][1]); + min_coord = min_ff(min_coord, bezt->vec[1][1]); + max_coord = max_ff(max_coord, prev_bezt->vec[1][1]); + min_coord = min_ff(min_coord, prev_bezt->vec[1][1]); + } + else { + const int resol = fcu->driver ? + 32 : + min_ii((int)(5.0f * len_v2v2(bezt->vec[1], prev_bezt->vec[1])), + 32); + if (resol < 2) { + max_coord = max_ff(max_coord, prev_bezt->vec[1][1]); + min_coord = min_ff(min_coord, prev_bezt->vec[1][1]); + } + else { + if (!ELEM(prev_bezt->ipo, BEZT_IPO_BACK, BEZT_IPO_ELASTIC)) { + /* Calculate min/max using bezier forward differencing. */ + float data[120]; + float v1[2], v2[2], v3[2], v4[2]; + + v1[0] = prev_bezt->vec[1][0]; + v1[1] = prev_bezt->vec[1][1]; + v2[0] = prev_bezt->vec[2][0]; + v2[1] = prev_bezt->vec[2][1]; + + v3[0] = bezt->vec[0][0]; + v3[1] = bezt->vec[0][1]; + v4[0] = bezt->vec[1][0]; + v4[1] = bezt->vec[1][1]; + + BKE_fcurve_correct_bezpart(v1, v2, v3, v4); + + BKE_curve_forward_diff_bezier( + v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float[3])); + BKE_curve_forward_diff_bezier( + v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float[3])); + + for (int j = 0; j <= resol; ++j) { + const float *fp = &data[j * 3]; + max_coord = max_ff(max_coord, fp[1]); + min_coord = min_ff(min_coord, fp[1]); + } + } + else { + /* Calculate min/max using full fcurve evaluation. + * [slower than bezier forward differencing but evaluates Back/Elastic + * interpolation as well]. */ + float step_size = (bezt->vec[1][0] - prev_bezt->vec[1][0]) / resol; + for (int j = 0; j <= resol; j++) { + float eval_time = prev_bezt->vec[1][0] + step_size * j; + float eval_value = evaluate_fcurve_only_curve(fcu, eval_time); + max_coord = max_ff(max_coord, eval_value); + min_coord = min_ff(min_coord, eval_value); + } + } + } + } + } + } + } + else if (fcu->fpt) { + const FPoint *fpt = fcu->fpt + start; + for (int i = start; i < end; ++i, ++fpt) { + min_coord = min_ff(min_coord, fpt->vec[1]); + max_coord = max_ff(max_coord, fpt->vec[1]); + } + } + } + + if (r_min_coord) { + *r_min_coord = min_coord; + } + if (r_max_coord) { + *r_max_coord = max_coord; + } +} + static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, float *r_offset) { float factor = 1.0f, offset = 0.0f; @@ -366,112 +481,23 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo } fcu->prev_norm_factor = 1.0f; - if (fcu->bezt) { - const bool use_preview_only = PRVRANGEON; - const BezTriple *bezt; - int i; - float max_coord = -FLT_MAX; - float min_coord = FLT_MAX; - float range; - - if (fcu->totvert < 1) { - return 1.0f; - } - - for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { - if (use_preview_only && !IN_RANGE_INCL(bezt->vec[1][0], scene->r.psfra, scene->r.pefra)) { - continue; - } - - if (i == 0) { - /* We ignore extrapolation flags and handle here, and use the - * control point position only. so we normalize "interesting" - * part of the curve. - * - * Here we handle left extrapolation. - */ - max_coord = max_ff(max_coord, bezt->vec[1][1]); - min_coord = min_ff(min_coord, bezt->vec[1][1]); - } - else { - const BezTriple *prev_bezt = bezt - 1; - if (!ELEM(prev_bezt->ipo, BEZT_IPO_BEZ, BEZT_IPO_BACK, BEZT_IPO_ELASTIC)) { - /* The points on the curve will lie inside the start and end points. - * Calculate min/max using both previous and current CV. - */ - max_coord = max_ff(max_coord, bezt->vec[1][1]); - min_coord = min_ff(min_coord, bezt->vec[1][1]); - max_coord = max_ff(max_coord, prev_bezt->vec[1][1]); - min_coord = min_ff(min_coord, prev_bezt->vec[1][1]); - } - else { - const int resol = fcu->driver ? - 32 : - min_ii((int)(5.0f * len_v2v2(bezt->vec[1], prev_bezt->vec[1])), - 32); - if (resol < 2) { - max_coord = max_ff(max_coord, prev_bezt->vec[1][1]); - min_coord = min_ff(min_coord, prev_bezt->vec[1][1]); - } - else { - if (!ELEM(prev_bezt->ipo, BEZT_IPO_BACK, BEZT_IPO_ELASTIC)) { - /* Calculate min/max using bezier forward differencing. */ - float data[120]; - float v1[2], v2[2], v3[2], v4[2]; - - v1[0] = prev_bezt->vec[1][0]; - v1[1] = prev_bezt->vec[1][1]; - v2[0] = prev_bezt->vec[2][0]; - v2[1] = prev_bezt->vec[2][1]; - - v3[0] = bezt->vec[0][0]; - v3[1] = bezt->vec[0][1]; - v4[0] = bezt->vec[1][0]; - v4[1] = bezt->vec[1][1]; - - BKE_fcurve_correct_bezpart(v1, v2, v3, v4); - - BKE_curve_forward_diff_bezier( - v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float[3])); - BKE_curve_forward_diff_bezier( - v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float[3])); - - for (int j = 0; j <= resol; ++j) { - const float *fp = &data[j * 3]; - max_coord = max_ff(max_coord, fp[1]); - min_coord = min_ff(min_coord, fp[1]); - } - } - else { - /* Calculate min/max using full fcurve evaluation. - * [slower than bezier forward differencing but evaluates Back/Elastic interpolation - * as well]. */ - float step_size = (bezt->vec[1][0] - prev_bezt->vec[1][0]) / resol; - for (int j = 0; j <= resol; j++) { - float eval_time = prev_bezt->vec[1][0] + step_size * j; - float eval_value = evaluate_fcurve_only_curve(fcu, eval_time); - max_coord = max_ff(max_coord, eval_value); - min_coord = min_ff(min_coord, eval_value); - } - } - } - } - } - } + float max_coord = -FLT_MAX; + float min_coord = FLT_MAX; + fcurve_scene_coord_range_get(scene, fcu, &min_coord, &max_coord); - if (max_coord > min_coord) { - range = max_coord - min_coord; - if (range > FLT_EPSILON) { - factor = 2.0f / range; - } - offset = -min_coord - range / 2.0f; - } - else if (max_coord == min_coord) { - factor = 1.0f; - offset = -min_coord; + if (max_coord > min_coord) { + const float range = max_coord - min_coord; + if (range > FLT_EPSILON) { + factor = 2.0f / range; } + offset = -min_coord - range / 2.0f; + } + else if (max_coord == min_coord) { + factor = 1.0f; + offset = -min_coord; } + BLI_assert(factor != 0.0f); if (r_offset) { *r_offset = offset; diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 6dc11292a3a..3a04873588d 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -118,10 +118,12 @@ static void animedit_get_yscale_factor(bAnimContext *ac) /* NOTE: there's a similar function in key.c #BKE_key_from_object. */ static Key *actedit_get_shapekeys(bAnimContext *ac) { + Scene *scene = ac->scene; ViewLayer *view_layer = ac->view_layer; Object *ob; Key *key; + BKE_view_layer_synced_ensure(scene, view_layer); ob = BKE_view_layer_active_object_get(view_layer); if (ob == NULL) { return NULL; @@ -393,12 +395,13 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) /* get useful default context settings from context */ ac->bmain = bmain; ac->scene = scene; + ac->view_layer = CTX_data_view_layer(C); if (scene) { ac->markers = ED_context_get_markers(C); + BKE_view_layer_synced_ensure(ac->scene, ac->view_layer); } - ac->view_layer = CTX_data_view_layer(C); ac->depsgraph = CTX_data_depsgraph_pointer(C); - ac->obact = (ac->view_layer->basact) ? ac->view_layer->basact->object : NULL; + ac->obact = BKE_view_layer_active_object_get(ac->view_layer); ac->area = area; ac->region = region; ac->sl = sl; @@ -414,6 +417,11 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) return ANIM_animdata_context_getdata(ac); } +bool ANIM_animdata_can_have_greasepencil(const eAnimCont_Types type) +{ + return ELEM(type, ANIMCONT_GPENCIL, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE); +} + /* ************************************************************ */ /* Blender Data <-- Filter --> Channels to be operated on */ @@ -1119,7 +1127,7 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id /* Check for selected nodes. */ if (fcu->rna_path && - (BLI_str_quoted_substr(fcu->rna_path, "nodes[", node_name, sizeof(node_name)))) { + BLI_str_quoted_substr(fcu->rna_path, "nodes[", node_name, sizeof(node_name))) { /* Get strip name, and check if this strip is selected. */ node = nodeFindNodebyName(ntree, node_name); @@ -1338,7 +1346,7 @@ static size_t animfilter_fcurves(ListBase *anim_data, * Back to step 2 :) */ for (fcu = first; - ((fcu = animfilter_fcurve_next(ads, fcu, fcurve_type, filter_mode, owner, owner_id))); + (fcu = animfilter_fcurve_next(ads, fcu, fcurve_type, filter_mode, owner, owner_id)); fcu = fcu->next) { if (UNLIKELY(fcurve_type == ANIMTYPE_NLACURVE)) { /* NLA Control Curve - Basically the same as normal F-Curves, @@ -1599,7 +1607,7 @@ static size_t animfilter_nla_controls( /* add control curves from each NLA strip... */ /* NOTE: ANIMTYPE_FCURVES are created here, to avoid duplicating the code needed */ - BEGIN_ANIMFILTER_SUBCHANNELS (((adt->flag & ADT_NLA_SKEYS_COLLAPSED) == 0)) { + BEGIN_ANIMFILTER_SUBCHANNELS ((adt->flag & ADT_NLA_SKEYS_COLLAPSED) == 0) { NlaTrack *nlt; NlaStrip *strip; @@ -1846,8 +1854,8 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, bDopeSheet *ads = ac->ads; size_t items = 0; + Scene *scene = ac->scene; ViewLayer *view_layer = (ViewLayer *)ac->view_layer; - Base *base; /* Include all annotation datablocks. */ if (((ads->filterflag & ADS_FILTER_ONLYSEL) == 0) || @@ -1859,7 +1867,8 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, } } /* Objects in the scene */ - for (base = view_layer->object_bases.first; base; base = base->next) { + BKE_view_layer_synced_ensure(scene, view_layer); + LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { /* Only consider this object if it has got some GP data (saving on all the other tests) */ if (base->object && (base->object->type == OB_GPENCIL)) { Object *ob = base->object; @@ -1888,7 +1897,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, } /* check selection and object type filters */ - if ((ads->filterflag & ADS_FILTER_ONLYSEL) && !((base->flag & BASE_SELECTED))) { + if ((ads->filterflag & ADS_FILTER_ONLYSEL) && !(base->flag & BASE_SELECTED)) { /* only selected should be shown */ continue; } @@ -3170,16 +3179,19 @@ static int ds_base_sorting_cmp(const void *base1_ptr, const void *base2_ptr) /* Get a sorted list of all the bases - for inclusion in dopesheet (when drawing channels) */ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, + const Scene *scene, ViewLayer *view_layer, int filter_mode, size_t *r_usable_bases) { /* Create an array with space for all the bases, but only containing the usable ones */ - size_t tot_bases = BLI_listbase_count(&view_layer->object_bases); + BKE_view_layer_synced_ensure(scene, view_layer); + ListBase *object_bases = BKE_view_layer_object_bases_get(view_layer); + size_t tot_bases = BLI_listbase_count(object_bases); size_t num_bases = 0; Base **sorted_bases = MEM_mallocN(sizeof(Base *) * tot_bases, "Dopesheet Usable Sorted Bases"); - LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { + LISTBASE_FOREACH (Base *, base, object_bases) { if (animdata_filter_base_is_ok(ads, base, OB_MODE_OBJECT, filter_mode)) { sorted_bases[num_bases++] = base; } @@ -3249,14 +3261,17 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, * - Don't do this if this behavior has been turned off (i.e. due to it being too slow) * - Don't do this if there's just a single object */ + BKE_view_layer_synced_ensure(scene, view_layer); + ListBase *object_bases = BKE_view_layer_object_bases_get(view_layer); if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && !(ads->flag & ADS_FLAG_NO_DB_SORT) && - (view_layer->object_bases.first != view_layer->object_bases.last)) { + (object_bases->first != object_bases->last)) { /* Filter list of bases (i.e. objects), sort them, then add their contents normally... */ /* TODO: Cache the old sorted order - if the set of bases hasn't changed, don't re-sort... */ Base **sorted_bases; size_t num_bases; - sorted_bases = animdata_filter_ds_sorted_bases(ads, view_layer, filter_mode, &num_bases); + sorted_bases = animdata_filter_ds_sorted_bases( + ads, scene, view_layer, filter_mode, &num_bases); if (sorted_bases) { /* Add the necessary channels for these bases... */ for (size_t i = 0; i < num_bases; i++) { @@ -3275,7 +3290,7 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, */ Object *obact = BKE_view_layer_active_object_get(view_layer); const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT; - LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { + LISTBASE_FOREACH (Base *, base, object_bases) { if (animdata_filter_base_is_ok(ads, base, object_mode, filter_mode)) { /* since we're still here, this object should be usable */ items += animdata_filter_dopesheet_ob(ac, anim_data, ads, base, filter_mode); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index f1562fac7ee..94746837259 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1110,7 +1110,7 @@ static void MARKER_OT_move(wmOperatorType *ot) RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX); PropertyRNA *prop = RNA_def_boolean( ot->srna, "tweak", 0, "Tweak", "Operator has been activated using a click-drag event"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); + RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); } /** \} */ @@ -1255,14 +1255,14 @@ static int select_timeline_marker_frame(ListBase *markers, deselect_markers(markers); } - LISTBASE_CIRCULAR_FORWARD_BEGIN (markers, marker, marker_cycle_selected) { + LISTBASE_CIRCULAR_FORWARD_BEGIN (TimeMarker *, markers, marker, marker_cycle_selected) { /* this way a not-extend select will always give 1 selected marker */ if (marker->frame == frame) { marker->flag ^= SELECT; break; } } - LISTBASE_CIRCULAR_FORWARD_END(markers, marker, marker_cycle_selected); + LISTBASE_CIRCULAR_FORWARD_END(TimeMarker *, markers, marker, marker_cycle_selected); } return ret_val; @@ -1281,7 +1281,7 @@ static void select_marker_camera_switch( int sel = 0; if (!extend) { - BKE_view_layer_base_deselect_all(view_layer); + BKE_view_layer_base_deselect_all(scene, view_layer); } for (marker = markers->first; marker; marker = marker->next) { @@ -1291,6 +1291,7 @@ static void select_marker_camera_switch( } } + BKE_view_layer_synced_ensure(scene, view_layer); for (marker = markers->first; marker; marker = marker->next) { if (marker->camera) { if (marker->frame == cfra) { @@ -1378,7 +1379,7 @@ static void MARKER_OT_select(wmOperatorType *ot) ot->modal = WM_generic_select_modal; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_UNDO; WM_operator_properties_generic_select(ot); prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); @@ -1478,7 +1479,7 @@ static void MARKER_OT_select_box(wmOperatorType *ot) ot->poll = ed_markers_poll_markers_exist; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_UNDO; /* properties */ WM_operator_properties_gesture_box(ot); @@ -1602,8 +1603,8 @@ static void MARKER_OT_select_leftright(wmOperatorType *ot) /* rna storage */ RNA_def_enum( - ot->srna, "mode", prop_markers_select_leftright_modes, MARKERS_LRSEL_LEFT, "mode", "Mode"); - RNA_def_boolean(ot->srna, "extend", false, "extend", "Extend"); + ot->srna, "mode", prop_markers_select_leftright_modes, MARKERS_LRSEL_LEFT, "Mode", ""); + RNA_def_boolean(ot->srna, "extend", false, "Extend Select", ""); } /** \} */ diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c index 23c1d68b4d6..4a83bb4c800 100644 --- a/source/blender/editors/animation/anim_motion_paths.c +++ b/source/blender/editors/animation/anim_motion_paths.c @@ -161,11 +161,11 @@ static void motionpaths_calc_bake_targets(ListBase *targets, int cframe) } /* Result must be in world-space. */ - mul_m4_v3(ob_eval->obmat, mpv->co); + mul_m4_v3(ob_eval->object_to_world, mpv->co); } else { /* World-space object location. */ - copy_v3_v3(mpv->co, ob_eval->obmat[3]); + copy_v3_v3(mpv->co, ob_eval->object_to_world[3]); } float mframe = (float)(cframe); diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 63794caf5a7..f899e41149d 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -322,8 +322,8 @@ int ANIM_add_driver_with_target(ReportList *reports, * then use the first one */ { /* Use the shorter of the two (to avoid out of bounds access) */ - int dst_len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr, prop) : 1; - int src_len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr2, prop2) : 1; + int dst_len = RNA_property_array_check(prop) ? RNA_property_array_length(&ptr, prop) : 1; + int src_len = RNA_property_array_check(prop) ? RNA_property_array_length(&ptr2, prop2) : 1; int len = MIN2(dst_len, src_len); @@ -347,7 +347,7 @@ int ANIM_add_driver_with_target(ReportList *reports, case CREATEDRIVER_MAPPING_1_N: /* 1-N - Specified target index for all */ default: { - int len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr, prop) : 1; + int len = RNA_property_array_check(prop) ? RNA_property_array_length(&ptr, prop) : 1; for (int i = 0; i < len; i++) { done_tot += add_driver_with_target(reports, @@ -1126,7 +1126,7 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) ot->name = "Remove Driver"; ot->idname = "ANIM_OT_driver_button_remove"; ot->description = - "Remove the driver(s) for the property(s) connected represented by the highlighted button"; + "Remove the driver(s) for the connected property(s) represented by the highlighted button"; /* callbacks */ ot->exec = remove_driver_button_exec; @@ -1163,7 +1163,7 @@ void ANIM_OT_driver_button_edit(wmOperatorType *ot) ot->name = "Edit Driver"; ot->idname = "ANIM_OT_driver_button_edit"; ot->description = - "Edit the drivers for the property connected represented by the highlighted button"; + "Edit the drivers for the connected property represented by the highlighted button"; /* callbacks */ ot->exec = edit_driver_button_exec; @@ -1257,7 +1257,7 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot) /* identifiers */ ot->name = "Paste Driver"; ot->idname = "ANIM_OT_paste_driver_button"; - ot->description = "Paste the driver in the copy/paste buffer for the highlighted button"; + ot->description = "Paste the driver in the clipboard to the highlighted button"; /* callbacks */ ot->exec = paste_driver_button_exec; diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 786204a52ed..6df9dc1e86d 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -608,7 +608,7 @@ static AnimKeylistDrawListElem *ed_keylist_draw_list_add_elem( return draw_elem; } -/* *************************** Channel Drawing Funcs *************************** */ +/* *************************** Channel Drawing Functions *************************** */ void draw_summary_channel(struct AnimKeylistDrawList *draw_list, bAnimContext *ac, diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 2a94c5db439..7bb104045c3 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -497,7 +497,7 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) if (ked && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) { \ /* Only act on visible items, so check handle visibility state. */ \ const bool handles_visible = ((ked->iterflags & KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE) ? \ - (BEZT_ISSEL_ANY(bezt)) : \ + BEZT_ISSEL_ANY(bezt) : \ true); \ if (handles_visible) { \ if (check(0)) { \ @@ -809,7 +809,7 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt) static short snap_bezier_nearest(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) { - bezt->vec[1][0] = (float)(floorf(bezt->vec[1][0] + 0.5f)); + bezt->vec[1][0] = (float)floorf(bezt->vec[1][0] + 0.5f); } return 0; } @@ -1494,7 +1494,7 @@ static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt) { /* Only act on visible items, so check handle visibility state. */ const bool handles_visible = ked && ((ked->iterflags & KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE) ? - (BEZT_ISSEL_ANY(bezt)) : + BEZT_ISSEL_ANY(bezt) : true); /* if we've got info on what to select, use it, otherwise select all */ @@ -1520,7 +1520,7 @@ static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt) { /* Only act on visible items, so check handle visibility state. */ const bool handles_visible = ked && ((ked->iterflags & KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE) ? - (BEZT_ISSEL_ANY(bezt)) : + BEZT_ISSEL_ANY(bezt) : true); /* if we've got info on what to deselect, use it, otherwise deselect all */ diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 40f0ac59b01..fbe65d6917e 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -151,7 +151,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo * if there is a considerable distance between the points, and also if the * current is further away than the next one is to the previous. */ - if (beztn && (IS_EQT(cur[0], next[0], thresh)) && (IS_EQT(next[1], prev[1], thresh) == 0)) { + if (beztn && IS_EQT(cur[0], next[0], thresh) && (IS_EQT(next[1], prev[1], thresh) == 0)) { /* only add if current is further away from previous */ if (cur[1] > next[1]) { if (IS_EQT(cur[1], prev[1], thresh) == 0) { @@ -654,8 +654,8 @@ void sample_fcurve(FCurve *fcu) * keyframes while sampling will affect the outcome... * - only start sampling+adding from index=1, so that we don't overwrite original keyframe */ - range = (int)(ceil(end->vec[1][0] - start->vec[1][0])); - sfra = (int)(floor(start->vec[1][0])); + range = (int)ceil(end->vec[1][0] - start->vec[1][0]); + sfra = (int)floor(start->vec[1][0]); if (range) { value_cache = MEM_callocN(sizeof(TempFrameValCache) * range, "IcuFrameValCache"); diff --git a/source/blender/editors/animation/keyframes_keylist.cc b/source/blender/editors/animation/keyframes_keylist.cc index da266dd4253..9b3cabb6c79 100644 --- a/source/blender/editors/animation/keyframes_keylist.cc +++ b/source/blender/editors/animation/keyframes_keylist.cc @@ -1110,7 +1110,7 @@ void gpencil_to_keylist(bDopeSheet *ads, bGPdata *gpd, AnimKeylist *keylist, con } } -void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, AnimKeylist *keylist) +void gpl_to_keylist(bDopeSheet * /*ads*/, bGPDlayer *gpl, AnimKeylist *keylist) { if (gpl && keylist) { ED_keylist_reset_last_accessed(keylist); @@ -1124,7 +1124,7 @@ void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, AnimKeylist *keylis } } -void mask_to_keylist(bDopeSheet *UNUSED(ads), MaskLayer *masklay, AnimKeylist *keylist) +void mask_to_keylist(bDopeSheet * /*ads*/, MaskLayer *masklay, AnimKeylist *keylist) { if (masklay && keylist) { ED_keylist_reset_last_accessed(keylist); diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index acf53541843..96a9604a6f5 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1044,12 +1044,12 @@ static float *visualkey_get_values( Object *ob = ptr->data; /* Loc code is specific... */ if (strstr(identifier, "location")) { - copy_v3_v3(buffer, ob->obmat[3]); + copy_v3_v3(buffer, ob->object_to_world[3]); *r_count = 3; return buffer; } - copy_m4_m4(tmat, ob->obmat); + copy_m4_m4(tmat, ob->object_to_world); rotmode = ob->rotmode; } else if (ptr->type == &RNA_PoseBone) { @@ -1180,7 +1180,7 @@ static float *get_keyframe_values(ReportList *reports, { float *values; - if ((flag & INSERTKEY_MATRIX) && (visualkey_can_use(&ptr, prop))) { + if ((flag & INSERTKEY_MATRIX) && visualkey_can_use(&ptr, prop)) { /* visual-keying is only available for object and pchan datablocks, as * it works by keyframing using a value extracted from the final matrix * instead of using the kt system to extract a value. diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index e6bcb404bcb..3448ba1c017 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -120,7 +120,7 @@ void ANIM_OT_keying_set_add(wmOperatorType *ot) /* identifiers */ ot->name = "Add Empty Keying Set"; ot->idname = "ANIM_OT_keying_set_add"; - ot->description = "Add a new (empty) Keying Set to the active Scene"; + ot->description = "Add a new (empty) keying set to the active Scene"; /* callbacks */ ot->exec = add_default_keyingset_exec; @@ -168,7 +168,7 @@ void ANIM_OT_keying_set_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Active Keying Set"; ot->idname = "ANIM_OT_keying_set_remove"; - ot->description = "Remove the active Keying Set"; + ot->description = "Remove the active keying set"; /* callbacks */ ot->exec = remove_active_keyingset_exec; @@ -211,7 +211,7 @@ void ANIM_OT_keying_set_path_add(wmOperatorType *ot) /* identifiers */ ot->name = "Add Empty Keying Set Path"; ot->idname = "ANIM_OT_keying_set_path_add"; - ot->description = "Add empty path to active Keying Set"; + ot->description = "Add empty path to active keying set"; /* callbacks */ ot->exec = add_empty_ks_path_exec; @@ -254,7 +254,7 @@ void ANIM_OT_keying_set_path_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Active Keying Set Path"; ot->idname = "ANIM_OT_keying_set_path_remove"; - ot->description = "Remove active Path from active Keying Set"; + ot->description = "Remove active Path from active keying set"; /* callbacks */ ot->exec = remove_active_ks_path_exec; @@ -429,7 +429,7 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); /* show warning */ - BKE_report(op->reports, RPT_INFO, "Property removed from Keying Set"); + BKE_report(op->reports, RPT_INFO, "Property removed from keying set"); } return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; @@ -491,7 +491,7 @@ void ANIM_OT_keying_set_active_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Active Keying Set"; ot->idname = "ANIM_OT_keying_set_active_set"; - ot->description = "Select a new keying set as the active one"; + ot->description = "Set a new active keying set"; /* callbacks */ ot->invoke = keyingset_active_menu_invoke; @@ -589,7 +589,7 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) /* find relevant builtin KeyingSets which use this, and remove them */ /* TODO: this isn't done now, since unregister is really only used at the moment when we - * reload the scripts, which kindof defeats the purpose of "builtin"? */ + * reload the scripts, which kind of defeats the purpose of "builtin"? */ for (ks = builtin_keyingsets.first; ks; ks = ksn) { ksn = ks->next; @@ -888,7 +888,7 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) /* TODO: check for missing callbacks! */ /* check if it can be used in the current context */ - return (ksi->poll(ksi, C)); + return ksi->poll(ksi, C); } return true; |