[Bf-blender-cvs] [ca737350a84] temp-graph-select-changes: Refactor how we communicate handle precedence to curve calculation
Julian Eisel
noreply at git.blender.org
Thu Oct 31 14:00:05 CET 2019
Commit: ca737350a8460871bc92ad2b44279f7a44b93a5e
Author: Julian Eisel
Date: Thu Oct 31 13:58:41 2019 +0100
Branches: temp-graph-select-changes
https://developer.blender.org/rBca737350a8460871bc92ad2b44279f7a44b93a5e
Refactor how we communicate handle precedence to curve calculation
Use already set flag, much less hacky this way (even though it required
additional changes).
===================================================================
M source/blender/blenkernel/BKE_curve.h
M source/blender/blenkernel/BKE_fcurve.h
M source/blender/blenkernel/intern/curve.c
M source/blender/blenkernel/intern/fcurve.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
===================================================================
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 6d88e9f97b0..1c0c8143e31 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -242,6 +242,12 @@ void BKE_nurb_handle_calc(struct BezTriple *bezt,
struct BezTriple *next,
const bool is_fcurve,
const char smoothing);
+void BKE_nurb_handle_calc_ex(struct BezTriple *bezt,
+ struct BezTriple *prev,
+ struct BezTriple *next,
+ const int handle_sel_flag,
+ const bool is_fcurve,
+ const char smoothing);
void BKE_nurb_handle_calc_simple(struct Nurb *nu, struct BezTriple *bezt);
void BKE_nurb_handle_calc_simple_auto(struct Nurb *nu, struct BezTriple *bezt);
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 164cfc4a265..80e13d66107 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -328,6 +328,7 @@ eFCU_Cycle_Type BKE_fcurve_get_cycle_type(struct FCurve *fcu);
/* -------- Curve Sanity -------- */
void calchandles_fcurve(struct FCurve *fcu);
+void calchandles_fcurve_ex(struct FCurve *fcu, int handle_sel_flag);
void testhandles_fcurve(struct FCurve *fcu, const int sel_flag, const bool use_handle);
void sort_time_fcurve(struct FCurve *fcu);
short test_time_fcurve(struct FCurve *fcu);
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 85c3d249d88..39c7cf9b44e 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -3201,6 +3201,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
static void calchandleNurb_intern(BezTriple *bezt,
const BezTriple *prev,
const BezTriple *next,
+ int handle_sel_flag,
bool is_fcurve,
bool skip_align,
char fcurve_smoothing)
@@ -3402,9 +3403,8 @@ static void calchandleNurb_intern(BezTriple *bezt,
len_ratio = len_a / len_b;
- 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 (bezt->f1 & handle_sel_flag) { /* 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]);
@@ -3444,7 +3444,7 @@ static void calchandleNurb_intern(BezTriple *bezt,
#undef p2_h2
}
-static void calchandlesNurb_intern(Nurb *nu, bool skip_align)
+static void calchandlesNurb_intern(Nurb *nu, int handle_sel_flag, bool skip_align)
{
BezTriple *bezt, *prev, *next;
int a;
@@ -3467,7 +3467,7 @@ static void calchandlesNurb_intern(Nurb *nu, bool skip_align)
next = bezt + 1;
while (a--) {
- calchandleNurb_intern(bezt, prev, next, 0, skip_align, 0);
+ calchandleNurb_intern(bezt, prev, next, handle_sel_flag, 0, skip_align, 0);
prev = bezt;
if (a == 1) {
if (nu->flagu & CU_NURB_CYCLIC) {
@@ -4043,12 +4043,22 @@ void BKE_nurb_handle_smooth_fcurve(BezTriple *bezt, int total, bool cycle)
void BKE_nurb_handle_calc(
BezTriple *bezt, BezTriple *prev, BezTriple *next, const bool is_fcurve, const char smoothing)
{
- calchandleNurb_intern(bezt, prev, next, is_fcurve, false, smoothing);
+ calchandleNurb_intern(bezt, prev, next, SELECT, is_fcurve, false, smoothing);
+}
+
+void BKE_nurb_handle_calc_ex(BezTriple *bezt,
+ BezTriple *prev,
+ BezTriple *next,
+ const int handle_sel_flag,
+ const bool is_fcurve,
+ const char smoothing)
+{
+ calchandleNurb_intern(bezt, prev, next, handle_sel_flag, is_fcurve, false, smoothing);
}
void BKE_nurb_handles_calc(Nurb *nu) /* first, if needed, set handle flags */
{
- calchandlesNurb_intern(nu, false);
+ calchandlesNurb_intern(nu, SELECT, false);
}
/**
@@ -4644,7 +4654,7 @@ void BKE_curve_nurbs_vert_coords_apply_with_mat4(ListBase *lb,
}
}
- calchandlesNurb_intern(nu, true);
+ calchandlesNurb_intern(nu, SELECT, true);
}
}
@@ -4682,7 +4692,7 @@ void BKE_curve_nurbs_vert_coords_apply(ListBase *lb,
}
}
- calchandlesNurb_intern(nu, true);
+ calchandlesNurb_intern(nu, SELECT, true);
}
}
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 4eea46259b6..89b835f2700 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1039,7 +1039,7 @@ static BezTriple *cycle_offset_triple(
/* This function recalculates the handles of an F-Curve
* If the BezTriples have been rearranged, sort them first before using this.
*/
-void calchandles_fcurve(FCurve *fcu)
+void calchandles_fcurve_ex(FCurve *fcu, int handle_sel_flag)
{
BezTriple *bezt, *prev, *next;
int a = fcu->totvert;
@@ -1075,7 +1075,7 @@ void calchandles_fcurve(FCurve *fcu)
}
/* calculate auto-handles */
- BKE_nurb_handle_calc(bezt, prev, next, true, fcu->auto_smoothing);
+ BKE_nurb_handle_calc_ex(bezt, prev, next, handle_sel_flag, true, fcu->auto_smoothing);
/* for automatic ease in and out */
if (BEZT_IS_AUTOH(bezt) && !cycle) {
@@ -1120,6 +1120,10 @@ void calchandles_fcurve(FCurve *fcu)
BKE_nurb_handle_smooth_fcurve(fcu->bezt, fcu->totvert, cycle);
}
}
+void calchandles_fcurve(FCurve *fcu)
+{
+ calchandles_fcurve_ex(fcu, SELECT);
+}
void testhandles_fcurve(FCurve *fcu, const int sel_flag, const bool use_handle)
{
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 3bfa3abaeab..69a5cadaff3 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -218,7 +218,6 @@ typedef struct TransData2D {
typedef struct TransDataCurveHandleFlags {
char ih1, ih2;
char *h1, *h2;
- char *f1, *f2, *f3;
} TransDataCurveHandleFlags;
/** Used for sequencer transform. */
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index aab967ffeb2..39b26f39669 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -694,19 +694,12 @@ 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;
}
@@ -1241,18 +1234,11 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve
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;
}
}
}
diff --git a/source/blender/editors/transform/transform_convert_graph.c b/source/blender/editors/transform/transform_convert_graph.c
index 610f2bed81a..3753ca133d1 100644
--- a/source/blender/editors/transform/transform_convert_graph.c
+++ b/source/blender/editors/transform/transform_convert_graph.c
@@ -510,10 +510,6 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
unit_scale,
offset);
bezt->f3 |= BEZT_FLAG_TEMP_TAG;
-
- if (!sel_left && !sel_key) {
- bezt->f3 |= BEZT_FLAG_PRECEDENCE;
- }
}
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 6e88c4dc7e4..932644370d3 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -448,7 +448,7 @@ static void recalcData_graphedit(TransInfo *t)
dosort++;
}
else {
- calchandles_fcurve(fcu);
+ calchandles_fcurve_ex(fcu, BEZT_FLAG_TEMP_TAG);
}
/* set refresh tags for objects using this animation,
@@ -1900,10 +1900,6 @@ void postTrans(bContext *C, TransInfo *t)
TransData *td = tc->data;
for (int a = 0; a < tc->data_len; a++, td++) {
if (td->flag & TD_BEZTRIPLE) {
- *td->hdata->f1 &= ~BEZT_FLAG_PRECEDENCE;
- *td->hdata->f2 &= ~BEZT_FLAG_PRECEDENCE;
- *td->hdata->f3 &= ~BEZT_FLAG_PRECEDENCE;
-
MEM_freeN(td->hdata);
}
}
@@ -2001,10 +1997,6 @@ static void restoreElement(TransData *td)
if (td->flag & TD_BEZTRIPLE) {
*(td->hdata->h1) = td->hdata->ih1;
*(td->hdata->h2) = td->hdata->ih2;
-
- *(td->hdata->f1) &= ~BEZT_FLAG_PRECEDENCE;
- *(td->hdata->f2) &= ~BEZT_FLAG_PRECEDENCE;
- *(td->hdata->f3) &= ~BEZT_FLAG_PRECEDENCE;
}
}
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/mak
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list