diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2019-08-01 18:05:53 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2019-08-01 18:05:53 +0300 |
commit | 03bbd5f9dedf7b3dfea7119c172c61f0b50ae28c (patch) | |
tree | 79ab34e79af6a700c6f73f331e4ee4e253ab3751 /source/blender/editors/animation | |
parent | 2204bfcf9e1c3a38e60830bd97775dd72158f4d6 (diff) | |
parent | 49b2162309da6abf66764d41d9fc4c45ad01936c (diff) |
Merge branch 'master' into temp-gpencil-drw-engine
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r-- | source/blender/editors/animation/anim_channels_defines.c | 14 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_channels_edit.c | 7 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_draw.c | 43 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_filter.c | 1 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_ipo_utils.c | 2 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_markers.c | 12 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 80 | ||||
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 2 |
8 files changed, 49 insertions, 112 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 7a7769ccc90..3d7178a4114 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4340,7 +4340,6 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi AnimData *adt = BKE_animdata_from_id(id); FCurve *fcu = (FCurve *)fcu_poin; - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4356,7 +4355,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi /* Get NLA context for value remapping */ NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( - &nla_cache, depsgraph, &id_ptr, adt, (float)CFRA); + &nla_cache, &id_ptr, adt, (float)CFRA, false); /* get current frame and apply NLA-mapping to it (if applicable) */ cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); @@ -4373,7 +4372,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi /* insert a keyframe for this F-Curve */ done = insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); + reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); if (done) { if (adt->action != NULL) { @@ -4395,7 +4394,6 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi KeyBlock *kb = (KeyBlock *)kb_poin; char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4411,7 +4409,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi /* Get NLA context for value remapping */ NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( - &nla_cache, depsgraph, &id_ptr, key->adt, (float)CFRA); + &nla_cache, &id_ptr, key->adt, (float)CFRA, false); /* get current frame and apply NLA-mapping to it (if applicable) */ cfra = BKE_nla_tweakedit_remap(key->adt, (float)CFRA, NLATIME_CONVERT_UNMAP); @@ -4433,7 +4431,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi /* insert a keyframe for this F-Curve */ done = insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); + reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); if (done) { WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -4460,7 +4458,6 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, PropertyRNA *prop; int index; - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4485,8 +4482,7 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, } /* insert a keyframe for this F-Curve */ - done = insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag); + done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag); if (done) { WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index b93d52a1b2d..7e913014a87 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1705,7 +1705,7 @@ static void ANIM_OT_channels_ungroup(wmOperatorType *ot) /* ******************** Delete Channel Operator *********************** */ -static void update_dependencies_on_delete(bAnimListElem *ale) +static void tag_update_animation_element(bAnimListElem *ale) { ID *id = ale->id; AnimData *adt = BKE_animdata_from_id(id); @@ -1801,7 +1801,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* try to free F-Curve */ ANIM_fcurve_delete_from_animdata(&ac, adt, fcu); - update_dependencies_on_delete(ale); + tag_update_animation_element(ale); break; } case ANIMTYPE_NLACURVE: { @@ -1823,7 +1823,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* unlink and free the F-Curve */ BLI_remlink(&strip->fcurves, fcu); free_fcurve(fcu); - update_dependencies_on_delete(ale); + tag_update_animation_element(ale); break; } case ANIMTYPE_GPLAYER: { @@ -1967,6 +1967,7 @@ static void setflag_anim_channels(bAnimContext *ac, /* set the setting in the appropriate way */ ANIM_channel_setting_set(ac, ale, setting, mode); + tag_update_animation_element(ale); /* if flush status... */ if (flush) { diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 61bf7f95340..7ab50afe3a1 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -422,23 +422,16 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo } else { const BezTriple *prev_bezt = bezt - 1; - if (prev_bezt->ipo == BEZT_IPO_CONST) { - /* Constant interpolation: previous CV value is used up - * to the current keyframe. - */ - max_coord = max_ff(max_coord, bezt->vec[1][1]); - min_coord = min_ff(min_coord, bezt->vec[1][1]); - } - else if (prev_bezt->ipo == BEZT_IPO_LIN) { - /* Linear interpolation: min/max using both previous and - * and current CV. + 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 if (prev_bezt->ipo == BEZT_IPO_BEZ) { + else { const int resol = fcu->driver ? 32 : min_ii((int)(5.0f * len_v2v2(bezt->vec[1], prev_bezt->vec[1])), @@ -448,30 +441,12 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo min_coord = min_ff(min_coord, prev_bezt->vec[1][1]); } else { - 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]; - - 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); - + float step_size = (bezt->vec[1][0] - prev_bezt->vec[1][0]) / resol; 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]); + 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); } } } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 2d16ce30d31..625a52fc800 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -412,7 +412,6 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) if (scene) { ac->markers = ED_context_get_markers(C); } - ac->depsgraph = CTX_data_depsgraph(C); ac->view_layer = CTX_data_view_layer(C); ac->obact = (ac->view_layer->basact) ? ac->view_layer->basact->object : NULL; ac->sa = sa; diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index f5bd7a47248..fad9a1a8e49 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -238,6 +238,6 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3]) /* value is fixed at 1.0f, otherwise we cannot clearly see the curves... */ hsv[2] = 1.0f; - /* finally, conver this to RGB colors */ + /* finally, convert this to RGB colors */ hsv_to_rgb_v(hsv, out); } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 2bbb8e5888c..ded59466370 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -470,7 +470,7 @@ static void draw_marker_line_if_necessary(TimeMarker *marker, int flag, int xpos } static void draw_marker( - const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int flag, int region_height) + const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int flag, int region_height) { GPU_blend(true); GPU_blend_set_func_separate( @@ -484,7 +484,9 @@ static void draw_marker( GPU_blend(false); float name_y = UI_DPI_FAC * 18; - if (marker->flag & SELECT) { + /* Give an offset to the marker name when selected, + * or when near the current frame (5 frames range, starting from the current one). */ + if ((marker->flag & SELECT) || (IN_RANGE_INCL(marker->frame, cfra, cfra - 4))) { name_y += UI_DPI_FAC * 10; } draw_marker_name(fstyle, marker, xpos, name_y); @@ -547,6 +549,7 @@ void ED_markers_draw(const bContext *C, int flag) ARegion *ar = CTX_wm_region(C); View2D *v2d = UI_view2d_fromcontext(C); + int cfra = CTX_data_scene(C)->r.cfra; rctf markers_region_rect; get_marker_region_rect(v2d, &markers_region_rect); @@ -564,17 +567,18 @@ void ED_markers_draw(const bContext *C, int flag) const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; + /* Separate loops in order to draw selected markers on top */ for (TimeMarker *marker = markers->first; marker; marker = marker->next) { if ((marker->flag & SELECT) == 0) { if (marker_is_in_frame_range(marker, clip_frame_range)) { - draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); + draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy); } } } for (TimeMarker *marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { if (marker_is_in_frame_range(marker, clip_frame_range)) { - draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); + draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy); } } } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 2e7ed7eae34..de6e4c2fd0d 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -721,23 +721,12 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) /* ------------------ RNA Data-Access Functions ------------------ */ /* Try to read value using RNA-properties obtained already */ -static float *setting_get_rna_values(Depsgraph *depsgraph, - PointerRNA *ptr, - PropertyRNA *prop, - const bool get_evaluated, - float *buffer, - int buffer_size, - int *r_count) +static float *setting_get_rna_values( + PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count) { BLI_assert(buffer_size >= 1); float *values = buffer; - PointerRNA ptr_eval; - - if (get_evaluated) { - DEG_get_evaluated_rna_pointer(depsgraph, ptr, &ptr_eval); - ptr = &ptr_eval; - } if (RNA_property_array_check(prop)) { int length = *r_count = RNA_property_array_length(ptr, prop); @@ -977,12 +966,8 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) * In the event that it is not possible to perform visual keying, try to fall-back * to using the default method. Assumes that all data it has been passed is valid. */ -static float *visualkey_get_values(Depsgraph *depsgraph, - PointerRNA *ptr, - PropertyRNA *prop, - float *buffer, - int buffer_size, - int *r_count) +static float *visualkey_get_values( + PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count) { BLI_assert(buffer_size >= 4); @@ -999,27 +984,21 @@ static float *visualkey_get_values(Depsgraph *depsgraph, */ if (ptr->type == &RNA_Object) { Object *ob = (Object *)ptr->data; - const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - /* Loc code is specific... */ if (strstr(identifier, "location")) { - copy_v3_v3(buffer, ob_eval->obmat[3]); + copy_v3_v3(buffer, ob->obmat[3]); *r_count = 3; return buffer; } - copy_m4_m4(tmat, ob_eval->obmat); - rotmode = ob_eval->rotmode; + copy_m4_m4(tmat, ob->obmat); + rotmode = ob->rotmode; } else if (ptr->type == &RNA_PoseBone) { - Object *ob = (Object *)ptr->id.data; bPoseChannel *pchan = (bPoseChannel *)ptr->data; - const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name); - - BKE_armature_mat_pose_to_bone(pchan_eval, pchan_eval->pose_mat, tmat); - rotmode = pchan_eval->rotmode; + BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, tmat); + rotmode = pchan->rotmode; /* Loc code is specific... */ if (strstr(identifier, "location")) { @@ -1032,7 +1011,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph, } } else { - return setting_get_rna_values(depsgraph, ptr, prop, true, buffer, buffer_size, r_count); + return setting_get_rna_values(ptr, prop, buffer, buffer_size, r_count); } /* Rot/Scale code are common! */ @@ -1066,7 +1045,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph, } /* as the function hasn't returned yet, read value from system in the default way */ - return setting_get_rna_values(depsgraph, ptr, prop, true, buffer, buffer_size, r_count); + return setting_get_rna_values(ptr, prop, buffer, buffer_size, r_count); } /* ------------------------- Insert Key API ------------------------- */ @@ -1075,8 +1054,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph, * Retrieve current property values to keyframe, * possibly applying NLA correction when necessary. */ -static float *get_keyframe_values(Depsgraph *depsgraph, - ReportList *reports, +static float *get_keyframe_values(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, int index, @@ -1094,11 +1072,11 @@ static float *get_keyframe_values(Depsgraph *depsgraph, * it works by keyframing using a value extracted from the final matrix * instead of using the kt system to extract a value. */ - values = visualkey_get_values(depsgraph, &ptr, prop, buffer, buffer_size, r_count); + values = visualkey_get_values(&ptr, prop, buffer, buffer_size, r_count); } else { /* read value from system */ - values = setting_get_rna_values(depsgraph, &ptr, prop, false, buffer, buffer_size, r_count); + values = setting_get_rna_values(&ptr, prop, buffer, buffer_size, r_count); } /* adjust the value for NLA factors */ @@ -1207,8 +1185,7 @@ static bool insert_keyframe_value(ReportList *reports, * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, * and extra keyframe filtering. */ -bool insert_keyframe_direct(Depsgraph *depsgraph, - ReportList *reports, +bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, @@ -1261,8 +1238,7 @@ bool insert_keyframe_direct(Depsgraph *depsgraph, int value_count; int index = fcu->array_index; - float *values = get_keyframe_values(depsgraph, - reports, + float *values = get_keyframe_values(reports, ptr, prop, index, @@ -1347,7 +1323,6 @@ static bool insert_keyframe_fcurve_value(Main *bmain, * index of -1 keys all array indices */ short insert_keyframe(Main *bmain, - Depsgraph *depsgraph, ReportList *reports, ID *id, bAction *act, @@ -1405,7 +1380,7 @@ short insert_keyframe(Main *bmain, if (adt && adt->action == act) { /* Get NLA context for value remapping. */ nla_context = BKE_animsys_get_nla_keyframing_context( - nla_cache ? nla_cache : &tmp_nla_cache, depsgraph, &id_ptr, adt, cfra); + nla_cache ? nla_cache : &tmp_nla_cache, &id_ptr, adt, cfra, false); /* Apply NLA-mapping to frame. */ cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); @@ -1416,8 +1391,7 @@ short insert_keyframe(Main *bmain, int value_count; bool force_all; - float *values = get_keyframe_values(depsgraph, - reports, + float *values = get_keyframe_values(reports, ptr, prop, array_index, @@ -2373,7 +2347,6 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot) static int insert_key_button_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -2407,7 +2380,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) if (fcu) { success = insert_keyframe_direct( - depsgraph, op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0); + op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0); } else { BKE_report(op->reports, @@ -2423,15 +2396,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) fcu = rna_get_fcurve_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special); if (fcu && driven) { - success = insert_keyframe_direct(depsgraph, - op->reports, - ptr, - prop, - fcu, - cfra, - ts->keyframe_type, - NULL, - INSERTKEY_DRIVER); + success = insert_keyframe_direct( + op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, INSERTKEY_DRIVER); } } else { @@ -2468,7 +2434,6 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) } success = insert_keyframe(bmain, - depsgraph, op->reports, ptr.id.data, NULL, @@ -2794,8 +2759,7 @@ bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float fra float buffer[RNA_MAX_ARRAY_LENGTH]; int count, index = fcu->array_index; - float *values = setting_get_rna_values( - NULL, &ptr, prop, false, buffer, RNA_MAX_ARRAY_LENGTH, &count); + float *values = setting_get_rna_values(&ptr, prop, buffer, RNA_MAX_ARRAY_LENGTH, &count); float fcurve_val = calculate_fcurve(&anim_rna, fcu, frame); float cur_val = (index >= 0 && index < count) ? values[index] : 0.0f; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 0cb83c79c85..ccd0fc54611 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -1030,7 +1030,6 @@ static short keyingset_apply_keying_flags(const short base_flags, int ANIM_apply_keyingset( bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ReportList *reports = CTX_wm_reports(C); @@ -1125,7 +1124,6 @@ int ANIM_apply_keyingset( /* action to take depends on mode */ if (mode == MODIFYKEY_MODE_INSERT) { success += insert_keyframe(bmain, - depsgraph, reports, ksp->id, act, |