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:
authorBastien Montagne <montagne29@wanadoo.fr>2013-08-23 19:17:54 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-08-23 19:17:54 +0400
commit25ca7622386a1cb74b1745f1038fd71cd498a17c (patch)
treebccc6de59645a2376075c90efd1b21f894a49880 /source/blender
parent09ff49755fc84a0dd4214099a0dd47facba83288 (diff)
Fix [#36538] Discontinuity (Euler) Filter - never ends - (deadlock?)
Code could enter in an infinite loop when curve value was an odd multiple of PI (i.e. 180°)... Current code was also factorized and got rid of fabs calls! ;)
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/space_graph/graph_edit.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 9d22d6fcc95..68a0a1799c1 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1676,7 +1676,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
/* FIXME: there are more complicated methods that will be needed to fix more cases than just some */
for (f = 0; f < 3; f++) {
FCurve *fcu = euf->fcurves[f];
- BezTriple *bezt, *prev = NULL;
+ BezTriple *bezt, *prev;
unsigned int i;
/* skip if not enough vets to do a decent analysis of... */
@@ -1684,29 +1684,19 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
continue;
/* prev follows bezt, bezt = "current" point to be fixed */
- for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, prev = bezt, bezt++) {
- /* our method depends on determining a "difference" from the previous vert */
- if (prev == NULL)
- continue;
+ /* our method depends on determining a "difference" from the previous vert */
+ for (i = 1, prev = fcu->bezt, bezt = fcu->bezt + 1; i < fcu->totvert; i++, prev = bezt++) {
+ const float sign = (prev->vec[1][1] > bezt->vec[1][1]) ? 1.0f : -1.0f;
/* > 180 degree flip? */
- if (fabs(prev->vec[1][1] - bezt->vec[1][1]) >= M_PI) {
+ if ((sign * (prev->vec[1][1] - bezt->vec[1][1])) >= (float)M_PI) {
/* 360 degrees to add/subtract frame value until difference is acceptably small that there's no more flip */
- const float fac = 2.0f * (float)M_PI;
+ const float fac = sign * 2.0f * (float)M_PI;
- if (prev->vec[1][1] > bezt->vec[1][1]) {
- while (fabsf(bezt->vec[1][1] - prev->vec[1][1]) >= (float)M_PI) {
- bezt->vec[0][1] += fac;
- bezt->vec[1][1] += fac;
- bezt->vec[2][1] += fac;
- }
- }
- else { /* if (prev->vec[1][1] < bezt->vec[1][1]) */
- while (fabsf(bezt->vec[1][1] - prev->vec[1][1]) >= (float)M_PI) {
- bezt->vec[0][1] -= fac;
- bezt->vec[1][1] -= fac;
- bezt->vec[2][1] -= fac;
- }
+ while ((sign * (prev->vec[1][1] - bezt->vec[1][1])) >= (float)M_PI) {
+ bezt->vec[0][1] += fac;
+ bezt->vec[1][1] += fac;
+ bezt->vec[2][1] += fac;
}
}
}