[Bf-blender-cvs] [1ee7405a988] temp-graph-select-changes: Only move selected handles on the dragged side
Julian Eisel
noreply at git.blender.org
Wed Oct 30 18:02:06 CET 2019
Commit: 1ee7405a98817fcf8d061932d0c6a0c7fd20f7ff
Author: Julian Eisel
Date: Wed Oct 30 17:58:06 2019 +0100
Branches: temp-graph-select-changes
https://developer.blender.org/rB1ee7405a98817fcf8d061932d0c6a0c7fd20f7ff
Only move selected handles on the dragged side
E.g. when dragging a right handle, only move selected right handles,
keep keys and left handles untouch.
This is a bit hacky and feels fragile, since the transform operator
doesn't act just on the selection anymore. I plan to get some testing
before pushing this into master though.
===================================================================
M source/blender/blenkernel/intern/curve.c
M source/blender/editors/space_graph/graph_select.c
M source/blender/editors/space_graph/space_graph.c
M source/blender/editors/transform/transform.c
M source/blender/editors/transform/transform.h
M source/blender/editors/transform/transform_convert.c
M source/blender/editors/transform/transform_convert_graph.c
M source/blender/editors/transform/transform_generics.c
M source/blender/makesdna/DNA_curve_types.h
M source/blender/makesdna/DNA_space_types.h
===================================================================
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index d81d250a305..7154afb4e09 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -3402,8 +3402,9 @@ static void calchandleNurb_intern(BezTriple *bezt,
len_ratio = len_a / len_b;
- if (bezt->f1 & SELECT) { /* order of calculation */
- if (ELEM(bezt->h2, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) { /* aligned */
+ if ((bezt->f1 & SELECT) && (!(bezt->f3 & SELECT) || !(bezt->f3 & BEZT_FLAG_PRECEDENCE) ||
+ (bezt->f1 & BEZT_FLAG_PRECEDENCE))) { /* order of calculation */
+ if (ELEM(bezt->h2, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) { /* aligned */
if (len_a > eps) {
len = 1.0f / len_ratio;
p2_h2[0] = p2[0] + len * (p2[0] - p2_h1[0]);
@@ -3601,7 +3602,8 @@ static bool tridiagonal_solve_with_limits(
float target = h[i] > hmax[i] ? hmax[i] : hmin[i];
- /* heuristically only lock handles that go in the right direction if there are such ones */
+ /* heuristically only lock handles that go in the right direction if there are such ones
+ */
if (target != 0.0f || all) {
/* mark item locked */
is_locked[i] = 1;
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index c25c8022595..a0442213e3c 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -1436,6 +1436,9 @@ static int mouse_graph_keys(bAnimContext *ac,
wait_to_deselect_others = false;
}
+ sipo->runtime.flag &= ~(SIPO_RUNTIME_FLAG_TWEAK_HANDLES_LEFT |
+ SIPO_RUNTIME_FLAG_TWEAK_HANDLES_RIGHT);
+
const bool already_selected =
nvi && (((nvi->hpoint == NEAREST_HANDLE_KEY) && (nvi->bezt->f2 & SELECT)) ||
((nvi->hpoint == NEAREST_HANDLE_LEFT) && (nvi->bezt->f1 & SELECT)) ||
@@ -1552,6 +1555,13 @@ static int mouse_graph_keys(bAnimContext *ac,
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nvi->fcu, nvi->ctype);
}
+ if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
+ sipo->runtime.flag |= SIPO_RUNTIME_FLAG_TWEAK_HANDLES_LEFT;
+ }
+ else if (nvi->hpoint == NEAREST_HANDLE_RIGHT) {
+ sipo->runtime.flag |= SIPO_RUNTIME_FLAG_TWEAK_HANDLES_RIGHT;
+ }
+
/* free temp sample data for filtering */
MEM_freeN(nvi);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 91e5ab61dd9..19a11fd50e9 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -794,6 +794,9 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
ED_area_tag_redraw(sa);
}
+ sipo->runtime.flag &= ~(SIPO_RUNTIME_FLAG_TWEAK_HANDLES_LEFT |
+ SIPO_RUNTIME_FLAG_TWEAK_HANDLES_RIGHT);
+
/* init/adjust F-Curve colors */
graph_refresh_fcurve_colors(C);
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 9f53c38c403..239fd63b7d9 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2359,6 +2359,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* Needed to translate tweak events to mouse buttons. */
t->launch_event = event ? WM_userdef_event_type_from_keymap_type(event->type) : -1;
+ t->is_launch_event_tweak = event ? ISTWEAK(event->type) : false;
/* XXX Remove this when wm_operator_call_internal doesn't use window->eventstate
* (which can have type = 0) */
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index c437714956a..3bfa3abaeab 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -213,10 +213,12 @@ typedef struct TransData2D {
float ih1[2], ih2[2];
} TransData2D;
-/** Used to store 2 handles for each #TransData in case the other handle wasn't selected. */
+/** Used to store 2 handles for each #TransData in case the other handle wasn't selected. Also to
+ * unset temporary flags. */
typedef struct TransDataCurveHandleFlags {
char ih1, ih2;
char *h1, *h2;
+ char *f1, *f2, *f3;
} TransDataCurveHandleFlags;
/** Used for sequencer transform. */
@@ -631,6 +633,9 @@ typedef struct TransInfo {
/*************** NEW STUFF *********************/
/** event type used to launch transform. */
short launch_event;
+ /** Is the actual launch event a tweak event? (launch_event above is set to the corresponding
+ * mouse button then.) */
+ bool is_launch_event_tweak;
struct {
/** Orientation type when when we're not constrained.
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 64ad8b2091e..18a85f235ac 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -694,12 +694,19 @@ void calc_distanceCurveVerts(TransData *head, TransData *tail)
TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTriple *bezt)
{
TransDataCurveHandleFlags *hdata;
+
td->flag |= TD_BEZTRIPLE;
hdata = td->hdata = MEM_mallocN(sizeof(TransDataCurveHandleFlags), "CuHandle Data");
+
hdata->ih1 = bezt->h1;
hdata->h1 = &bezt->h1;
hdata->ih2 = bezt->h2; /* in case the second is not selected */
hdata->h2 = &bezt->h2;
+
+ hdata->f1 = &bezt->f1;
+ hdata->f2 = &bezt->f2;
+ hdata->f3 = &bezt->f3;
+
return hdata;
}
@@ -1090,7 +1097,7 @@ typedef struct BeztMap {
/* This function converts an FCurve's BezTriple array to a BeztMap array
* NOTE: this allocates memory that will need to get freed later
*/
-static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert, const short UNUSED(use_handle))
+static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert)
{
BezTriple *bezt = bezts;
BezTriple *prevbezt = NULL;
@@ -1118,7 +1125,7 @@ static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert, const short UNUS
}
/* This function copies the code of sort_time_ipocurve, but acts on BeztMap structs instead */
-static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(use_handle))
+static void sort_time_beztmaps(BeztMap *bezms, int totvert)
{
BeztMap *bezm;
int i, ok = 1;
@@ -1163,8 +1170,7 @@ static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(u
}
/* This function firstly adjusts the pointers that the transdata has to each BezTriple */
-static void beztmap_to_data(
- TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert, const short UNUSED(use_handle))
+static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert)
{
BezTriple *bezts = fcu->bezt;
BeztMap *bezm;
@@ -1235,11 +1241,18 @@ static void beztmap_to_data(
if (bezm->swapHs == 1) {
td->hdata->h1 = &(bezts + bezm->newIndex)->h2;
td->hdata->h2 = &(bezts + bezm->newIndex)->h1;
+
+ td->hdata->f1 = &(bezts + bezm->newIndex)->f3;
+ td->hdata->f3 = &(bezts + bezm->newIndex)->f1;
}
else {
td->hdata->h1 = &(bezts + bezm->newIndex)->h1;
td->hdata->h2 = &(bezts + bezm->newIndex)->h2;
+
+ td->hdata->f1 = &(bezts + bezm->newIndex)->f1;
+ td->hdata->f3 = &(bezts + bezm->newIndex)->f3;
}
+ td->hdata->f2 = &(bezts + bezm->newIndex)->f2;
}
}
}
@@ -1259,7 +1272,13 @@ void remake_graph_transdata(TransInfo *t, ListBase *anim_data)
{
SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
bAnimListElem *ale;
- const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0;
+ const bool use_handle =
+#if 1
+ false;
+ UNUSED_VARS(sipo);
+#else
+ (sipo->flag & SIPO_NOHANDLES) == 0;
+#endif
/* sort and reassign verts */
for (ale = anim_data->first; ale; ale = ale->next) {
@@ -1270,9 +1289,9 @@ void remake_graph_transdata(TransInfo *t, ListBase *anim_data)
/* adjust transform-data pointers */
/* note, none of these functions use 'use_handle', it could be removed */
- bezm = bezt_to_beztmaps(fcu->bezt, fcu->totvert, use_handle);
- sort_time_beztmaps(bezm, fcu->totvert, use_handle);
- beztmap_to_data(t, fcu, bezm, fcu->totvert, use_handle);
+ bezm = bezt_to_beztmaps(fcu->bezt, fcu->totvert);
+ sort_time_beztmaps(bezm, fcu->totvert);
+ beztmap_to_data(t, fcu, bezm, fcu->totvert);
/* free mapping stuff */
MEM_freeN(bezm);
@@ -2074,7 +2093,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else if (t->spacetype == SPACE_GRAPH) {
SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
bAnimContext ac;
- const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0;
+ const bool use_handle =
+#if 1
+ false;
+#else
+ (sipo->flag & SIPO_NOHANDLES) == 0;
+#endif
/* initialize relevant anim-context 'context' data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
diff --git a/source/blender/editors/transform/transform_convert_graph.c b/source/blender/editors/transform/transform_convert_graph.c
index d936aab752a..ebe53c383f8 100644
--- a/source/blender/editors/transform/transform_convert_graph.c
+++ b/source/blender/editors/transform/transform_convert_graph.c
@@ -1,4 +1,4 @@
-/*
+/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -158,21 +158,51 @@ static bool graph_edit_use_local_center(TransInfo *t)
return ((t->around == V3D_AROUND_LOCAL_ORIGINS) && (graph_edit_is_translation_mode(t) == false));
}
+/**
+ * Get the effective selection of a triple for transform, i.e. return which vertices should be
+ * affected by transform.
+ */
+static void graph_bezt_get_transform_selection(const TransInfo *t,
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list