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:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-10-29 22:10:48 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-10-29 22:10:48 +0400
commitf6e504cee9f85867554f5a0ab89b52a66c0f257e (patch)
tree5fb69d2976ae845f908840b1d28fd81dfcaa8b2d
parent8bdbbca4858ab143661f371cc302092759e29408 (diff)
Make anim system safer for threading
Remove usages of ANIM_unit_mapping_apply_fcurve in favor of runtime scale factor apply. There're still calls to ANIM_nla_mapping_apply_fcurve are hanging around, they're the next t be cleaned up!
-rw-r--r--source/blender/editors/animation/anim_draw.c72
-rw-r--r--source/blender/editors/include/ED_anim_api.h3
-rw-r--r--source/blender/editors/space_graph/graph_draw.c56
-rw-r--r--source/blender/editors/space_graph/graph_edit.c50
-rw-r--r--source/blender/editors/space_graph/graph_select.c45
-rw-r--r--source/blender/editors/transform/transform_conversions.c26
-rw-r--r--source/blender/editors/transform/transform_generics.c8
7 files changed, 89 insertions, 171 deletions
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 9e8800fd91e..4a8557a2b1f 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -389,76 +389,4 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest
return 1.0f;
}
-/* ----------------------- */
-
-/* helper function for ANIM_unit_mapping_apply_fcurve -> mapping callback for unit mapping */
-static short bezt_unit_mapping_apply(KeyframeEditData *ked, BezTriple *bezt)
-{
- /* mapping factor is stored in f1, flags are stored in i1 */
- const bool only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS) != 0;
- const bool sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS) != 0;
- const bool skip_knot = (ked->i1 & ANIM_UNITCONV_SKIPKNOTS) != 0;
- float fac = ked->f1;
-
- /* adjust BezTriple handles only if allowed to */
- if (only_keys == false) {
- if ((sel_vs == false) || (bezt->f1 & SELECT))
- bezt->vec[0][1] *= fac;
- if ((sel_vs == false) || (bezt->f3 & SELECT))
- bezt->vec[2][1] *= fac;
- }
-
- if (skip_knot == false) {
- if ((sel_vs == false) || (bezt->f2 & SELECT))
- bezt->vec[1][1] *= fac;
- }
-
- return 0;
-}
-
-/* Apply/Unapply units conversions to keyframes */
-void ANIM_unit_mapping_apply_fcurve(Scene *scene, ID *id, FCurve *fcu, short flag)
-{
- KeyframeEditData ked;
- KeyframeEditFunc sel_cb;
- float fac;
-
- /* abort if rendering - we may get some race condition issues... */
- if (G.is_rendering) return;
-
- /* calculate mapping factor, and abort if nothing to change */
- fac = ANIM_unit_mapping_get_factor(scene, id, fcu, (flag & ANIM_UNITCONV_RESTORE));
- if (fac == 1.0f)
- return;
-
- /* init edit data
- * - mapping factor is stored in f1
- * - flags are stored in 'i1'
- */
- memset(&ked, 0, sizeof(KeyframeEditData));
- ked.f1 = (float)fac;
- ked.i1 = (int)flag;
-
- /* only selected? */
- if (flag & ANIM_UNITCONV_ONLYSEL)
- sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
- else
- sel_cb = NULL;
-
- /* apply to F-Curve */
- ANIM_fcurve_keyframes_loop(&ked, fcu, sel_cb, bezt_unit_mapping_apply, NULL);
-
- // FIXME: loop here for samples should be generalised
- // TODO: only sel?
- if (fcu->fpt) {
- FPoint *fpt;
- unsigned int i;
-
- for (i = 0, fpt = fcu->fpt; i < fcu->totvert; i++, fpt++) {
- /* apply unit mapping */
- fpt->vec[1] *= fac;
- }
- }
-}
-
/* *************************************************** */
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 61f9cec15d9..d23c57273ec 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -564,9 +564,6 @@ typedef enum eAnimUnitConv_Flags {
/* Get unit conversion factor for given ID + F-Curve */
float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FCurve *fcu, short restore);
-/* Apply/Unapply units conversions to keyframes */
-void ANIM_unit_mapping_apply_fcurve(struct Scene *scene, struct ID *id, struct FCurve *fcu, short flag);
-
/* ------------- Utility macros ----------------------- */
/* provide access to Keyframe Type info in BezTriple
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 23c39a5e99a..ba619fd9c77 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -206,7 +206,7 @@ static void draw_fcurve_handle_control(float x, float y, float xscale, float ysc
}
/* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
-static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only)
+static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only, float units_scale)
{
BezTriple *bezt = fcu->bezt;
BezTriple *prevbezt = NULL;
@@ -216,6 +216,9 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2
/* get view settings */
hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
UI_view2d_getscale(v2d, &xscale, &yscale);
+
+ /* Compensate OGL scale sued for unit mapping, so circle will be circle, not ellipse */
+ yscale *= units_scale;
/* set handle color */
if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT);
@@ -271,7 +274,7 @@ static void set_fcurve_vertex_color(FCurve *fcu, short sel)
}
-static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only)
+static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only, float units_scale)
{
View2D *v2d = &ar->v2d;
@@ -287,10 +290,10 @@ static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short
/* draw the two handles first (if they're shown, the curve doesn't have just a single keyframe, and the curve is being edited) */
if (do_handles) {
set_fcurve_vertex_color(fcu, 0);
- draw_fcurve_vertices_handles(fcu, sipo, v2d, 0, sel_handle_only);
+ draw_fcurve_vertices_handles(fcu, sipo, v2d, 0, sel_handle_only, units_scale);
set_fcurve_vertex_color(fcu, 1);
- draw_fcurve_vertices_handles(fcu, sipo, v2d, 1, sel_handle_only);
+ draw_fcurve_vertices_handles(fcu, sipo, v2d, 1, sel_handle_only, units_scale);
}
/* draw keyframes over the handles */
@@ -547,11 +550,14 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
FPoint *fpt = prevfpt + 1;
float fac, v[2];
int b = fcu->totvert - 1;
-
- glBegin(GL_LINE_STRIP);
-
+ float unit_scale;
+
/* apply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, 0);
+ glPushMatrix();
+ unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0);
+ glScalef(1.0f, unit_scale, 1.0f);
+
+ glBegin(GL_LINE_STRIP);
/* extrapolate to left? - left-side of view comes before first keyframe? */
if (prevfpt->vec[0] > v2d->cur.xmin) {
@@ -611,10 +617,8 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
glVertex2fv(v);
}
- /* unapply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, ANIM_UNITCONV_RESTORE);
-
glEnd();
+ glPopMatrix();
}
/* helper func - draw one repeat of an F-Curve */
@@ -627,11 +631,14 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
float fac = 0.0f;
int b = fcu->totvert - 1;
int resol;
-
- glBegin(GL_LINE_STRIP);
-
+ float unit_scale;
+
/* apply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, 0);
+ glPushMatrix();
+ unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0);
+ glScalef(1.0f, unit_scale, 1.0f);
+
+ glBegin(GL_LINE_STRIP);
/* extrapolate to left? */
if (prevbezt->vec[1][0] > v2d->cur.xmin) {
@@ -766,10 +773,8 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
glVertex2fv(v1);
}
- /* unapply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, ANIM_UNITCONV_RESTORE);
-
glEnd();
+ glPopMatrix();
}
/* Debugging -------------------------------- */
@@ -1014,9 +1019,11 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
}
}
else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
- /* apply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, fcu, 0);
-
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
+
+ glPushMatrix();
+ glScalef(1.0f, unit_scale, 1.0f);
+
if (fcu->bezt) {
int do_handles = draw_fcurve_handles_check(sipo, fcu);
@@ -1027,15 +1034,14 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
glDisable(GL_BLEND);
}
- draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY));
+ draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY), unit_scale);
}
else {
/* samples: only draw two indicators at either end as indicators */
draw_fcurve_samples(sipo, ar, fcu);
}
-
- /* unapply unit mapping */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, fcu, ANIM_UNITCONV_RESTORE);
+
+ glPopMatrix();
}
}
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 274c06bf871..c8e07dbda68 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1787,20 +1787,23 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS);
-
+ KeyframeEditData current_ked;
+ float unit_scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS);
+
+ memset(&current_ked, 0, sizeof(current_ked));
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
- ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
+ ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
- ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
-
- /* unapply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | ANIM_UNITCONV_ONLYKEYS);
+ ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
+
+ ked.f1 += current_ked.f1;
+ ked.i1 += current_ked.i1;
+ ked.f2 += current_ked.f2 / unit_scale;
+ ked.i2 += current_ked.i2;
}
BLI_freelistN(&anim_data);
@@ -1865,6 +1868,7 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
KeyframeEditData ked;
KeyframeEditFunc edit_cb;
+ float cursor_value = 0.0f;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
@@ -1881,16 +1885,16 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
}
else if (mode == GRAPHKEYS_SNAP_VALUE) {
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
- ked.f1 = (sipo) ? sipo->cursorVal : 0.0f;
+ cursor_value = (sipo) ? sipo->cursorVal : 0.0f;
}
/* snap keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0);
-
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, 0);
+
+ ked.f1 = cursor_value / unit_scale;
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
@@ -1898,9 +1902,6 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
}
else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE);
}
BLI_freelistN(&anim_data);
@@ -1977,7 +1978,8 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
KeyframeEditData ked;
KeyframeEditFunc edit_cb;
-
+ float cursor_value;
+
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_mirror(mode);
@@ -2000,7 +2002,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
}
else if (mode == GRAPHKEYS_MIRROR_VALUE) {
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
- ked.f1 = (sipo) ? sipo->cursorVal : 0.0f;
+ cursor_value = (sipo) ? sipo->cursorVal : 0.0f;
}
/* filter data */
@@ -2010,10 +2012,11 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
/* mirror keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS);
+
/* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS);
-
+ ked.f1 = cursor_value * unit_scale;
+
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
@@ -2021,9 +2024,6 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
}
else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
-
- /* unapply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS | ANIM_UNITCONV_RESTORE);
}
BLI_freelistN(&anim_data);
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 4bb5e1b11d4..ce036bec380 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -227,7 +227,7 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor
KeyframeEditData ked;
KeyframeEditFunc ok_cb, select_cb;
View2D *v2d = &ac->ar->v2d;
- rctf rectf;
+ rctf rectf, scaled_rectf;
/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
@@ -243,7 +243,7 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor
/* init editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
- ked.data = &rectf;
+ ked.data = &scaled_rectf;
/* treat handles separately? */
if (incl_handles) {
@@ -252,21 +252,24 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor
}
else
mapping_flag = ANIM_UNITCONV_ONLYKEYS;
-
+
/* loop over data, doing border select */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, mapping_flag);
-
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
+
/* apply NLA mapping to all the keyframes, since it's easier than trying to
* guess when a callback might use something different
*/
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0);
-
+
+ scaled_rectf.xmin = rectf.xmin;
+ scaled_rectf.xmax = rectf.xmax;
+ scaled_rectf.ymin = rectf.ymin / unit_scale;
+ scaled_rectf.ymax = rectf.ymax / unit_scale;
+
/* set horizontal range (if applicable)
* NOTE: these values are only used for x-range and y-range but not region
* (which uses ked.data, i.e. rectf)
@@ -296,9 +299,6 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor
/* un-apply NLA mapping from all the keyframes */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0);
-
- /* unapply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | mapping_flag);
}
/* cleanup */
@@ -936,7 +936,7 @@ static int fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt)
/* check if the given vertex is within bounds or not */
// TODO: should we return if we hit something?
-static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2])
+static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2], float unit_scale)
{
/* Keyframes or Samples? */
if (bezt) {
@@ -947,7 +947,7 @@ static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fc
* needed to access the relevant vertex coordinates in the 3x3
* 'vec' matrix
*/
- UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1], &screen_co[0], &screen_co[1]);
+ UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale, &screen_co[0], &screen_co[1]);
/* check if distance from mouse cursor to vert in screen space is within tolerance */
// XXX: inlined distance calculation, since we cannot do this on ints using the math lib...
@@ -996,7 +996,7 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
View2D *v2d = &ac->ar->v2d;
-
+
/* get curves to search through
* - if the option to only show keyframes that belong to selected F-Curves is enabled,
* include the 'only selected' flag...
@@ -1009,32 +1009,30 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
- /* apply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0);
-
+ float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
+
/* apply NLA mapping to all the keyframes */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
-
+
if (fcu->bezt) {
BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL;
int i;
for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) {
/* keyframe */
- nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_KEY, mval);
+ nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_KEY, mval, unit_scale);
/* handles - only do them if they're visible */
if (fcurve_handle_sel_check(sipo, bezt1) && (fcu->totvert > 1)) {
/* first handle only visible if previous segment had handles */
if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
- nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_LEFT, mval);
+ nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_LEFT, mval, unit_scale);
}
/* second handle only visible if this segment is bezier */
if (bezt1->ipo == BEZT_IPO_BEZ) {
- nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_RIGHT, mval);
+ nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_RIGHT, mval, unit_scale);
}
}
}
@@ -1047,9 +1045,6 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
/* un-apply NLA mapping from all the keyframes */
if (adt)
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
-
- /* unapply unit corrections */
- ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE);
}
/* free channels */
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 28d31b09ad2..41d04c85f44 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -3835,7 +3835,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
short intvals = (fcu->flag & FCURVE_INT_VALUES);
-
+ float unit_scale;
+ float scaled_mtx[3][3], scaled_smtx[3][3];
+
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
@@ -3848,8 +3850,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (fcu->bezt == NULL)
continue;
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, anim_map_flag);
-
+ unit_scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, ale->key_data, anim_map_flag);
+
+ copy_m3_m3(scaled_mtx, mtx);
+ copy_m3_m3(scaled_smtx, smtx);
+ mul_v3_fl(scaled_mtx[1], 1.0f / unit_scale);
+ mul_v3_fl(scaled_smtx[1], unit_scale);
+
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
@@ -3866,7 +3873,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (!ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE) || !(sel2)) {
if (sel1) {
hdata = initTransDataCurveHandles(td, bezt);
- bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, mtx, smtx);
+ bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, scaled_mtx, scaled_smtx);
}
else {
/* h1 = 0; */ /* UNUSED */
@@ -3875,7 +3882,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (sel3) {
if (hdata == NULL)
hdata = initTransDataCurveHandles(td, bezt);
- bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx);
+ bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, scaled_mtx, scaled_smtx);
}
else {
/* h2 = 0; */ /* UNUSED */
@@ -3897,7 +3904,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
hdata = initTransDataCurveHandles(td, bezt);
}
- bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals, mtx, smtx);
+ bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals, scaled_mtx, scaled_smtx);
}
/* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...):
@@ -3919,13 +3926,6 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
/* Sets handles based on the selection */
testhandles_fcurve(fcu, use_handle);
-
- /* even though transform values are written back right after during transform,
- * using individual center's with rotation means the center point wont
- * be touched again see: [#34303] */
- if (use_local_center) {
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, anim_map_flag | ANIM_UNITCONV_RESTORE);
- }
}
/* cleanup temp list */
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 33eca0d6b89..422060c48e6 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -381,9 +381,6 @@ static void recalcData_graphedit(TransInfo *t)
bAnimListElem *ale;
int dosort = 0;
- const bool use_local_center = checkUseLocalCenter_GraphEdit(t);
-
-
/* initialize relevant anim-context 'context' data from TransInfo data */
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
scene = ac.scene = t->scene;
@@ -411,11 +408,6 @@ static void recalcData_graphedit(TransInfo *t)
if (!fcu_test_selected(fcu))
continue;
- ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data,
- ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS | ANIM_UNITCONV_RESTORE |
- (use_local_center ? ANIM_UNITCONV_SKIPKNOTS : 0));
-
-
/* watch it: if the time is wrong: do not correct handles yet */
if (test_time_fcurve(fcu))
dosort++;