From 9d8a9cacc309063b27f1d0535b2ab8d7ea10c233 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 10 Feb 2017 18:10:26 +0100 Subject: De-duplicate min/max calculation in F-Curve normalization --- source/blender/editors/animation/anim_draw.c | 36 +++++++++++----------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'source/blender/editors/animation/anim_draw.c') diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 33e44d73894..0a0952870c3 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -308,6 +308,7 @@ 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; BezTriple *bezt; int i; float max_coord = -FLT_MAX; @@ -318,29 +319,20 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo return 1.0f; } - if (PRVRANGEON) { - for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { - if (IN_RANGE_INCL(bezt->vec[1][0], scene->r.psfra, scene->r.pefra)) { - max_coord = max_ff(max_coord, bezt->vec[0][1]); - max_coord = max_ff(max_coord, bezt->vec[1][1]); - max_coord = max_ff(max_coord, bezt->vec[2][1]); - - min_coord = min_ff(min_coord, bezt->vec[0][1]); - min_coord = min_ff(min_coord, bezt->vec[1][1]); - min_coord = min_ff(min_coord, bezt->vec[2][1]); - } - } - } - else { - for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { - max_coord = max_ff(max_coord, bezt->vec[0][1]); - max_coord = max_ff(max_coord, bezt->vec[1][1]); - max_coord = max_ff(max_coord, bezt->vec[2][1]); - - min_coord = min_ff(min_coord, bezt->vec[0][1]); - min_coord = min_ff(min_coord, bezt->vec[1][1]); - min_coord = min_ff(min_coord, bezt->vec[2][1]); + 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; } + max_coord = max_ff(max_coord, bezt->vec[0][1]); + max_coord = max_ff(max_coord, bezt->vec[1][1]); + max_coord = max_ff(max_coord, bezt->vec[2][1]); + + min_coord = min_ff(min_coord, bezt->vec[0][1]); + min_coord = min_ff(min_coord, bezt->vec[1][1]); + min_coord = min_ff(min_coord, bezt->vec[2][1]); } if (max_coord > min_coord) { -- cgit v1.2.3 From 9148ce9f3c245c3a9c10857f69e9d338c5593d3d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 13 Feb 2017 10:00:46 +0100 Subject: F-Curve normalization: Do proper curve min/max instead of handle min/max Would be cool to find some way to cache the results. --- source/blender/editors/animation/anim_draw.c | 74 +++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/animation/anim_draw.c') diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 0a0952870c3..a4ba95420c1 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -46,6 +46,8 @@ #include "BLI_dlrbTree.h" #include "BKE_context.h" +#include "BKE_curve.h" +#include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_nla.h" #include "BKE_mask.h" @@ -309,7 +311,7 @@ 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; - BezTriple *bezt; + const BezTriple *bezt; int i; float max_coord = -FLT_MAX; float min_coord = FLT_MAX; @@ -326,13 +328,71 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo { continue; } - max_coord = max_ff(max_coord, bezt->vec[0][1]); - max_coord = max_ff(max_coord, bezt->vec[1][1]); - max_coord = max_ff(max_coord, bezt->vec[2][1]); - min_coord = min_ff(min_coord, bezt->vec[0][1]); - min_coord = min_ff(min_coord, bezt->vec[1][1]); - min_coord = min_ff(min_coord, bezt->vec[2][1]); + 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 (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. + */ + 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) { + 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 { + 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); + + 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]); + } + } + } + } } if (max_coord > min_coord) { -- cgit v1.2.3 From 3e628eefa9f55fac7b0faaec4fd4392c2de6b20e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 15 Feb 2017 16:19:05 +0100 Subject: Motion blur investigation feature This commit adds a way to debug Cycles motion blur issues which are usually happening due to something crazy happening in between of frames. Biggest trouble was that artists had no clue about what's happening in subframes before they render. This is at least inefficient workflow when dealing with motion blur shots with complex animation. Now there is an option in Time Line Editor which could be found in View -> Show Subframe. This option will expose current frame with it's subframe to the time line editor header and it'll allow scrubbing with a subframe precision in time line editor. Please note that none of the tools in Blender are aware of subframe, so they'll likely be using current integer frame still. This is something we don't consider a bug for now, the whole purpose for now is to give a tool for investigation. Eventually we'll likely tweak all tools to be aware of subframe. Hopefully now we can finish the movie here in the studio.. --- source/blender/editors/animation/anim_draw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/animation/anim_draw.c') diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index a4ba95420c1..98900812bb2 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -117,7 +117,8 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) /* Draw a light green line to indicate current frame */ UI_ThemeColor(TH_CFRAME); - const float x = (float)(scene->r.cfra * scene->r.framelen); + const float time = scene->r.cfra + scene->r.subframe; + const float x = (float)(time * scene->r.framelen); glLineWidth((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0); -- cgit v1.2.3