Commit 8a28c073 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

app/core/gimpcoords-interpolate.c applied patch from Alexia Death that

2009-02-14  Sven Neumann  <sven@gimp.org>

	* app/core/gimpcoords-interpolate.c
	* app/display/gimpdisplayshell-coords.c: applied patch from 
Alexia
	Death that fixes issues with the new stroke direction code
	(bug #520078).


svn path=/trunk/; revision=28030
parent be83d344
2009-02-14 Sven Neumann <sven@gimp.org>
* app/core/gimpcoords-interpolate.c
* app/display/gimpdisplayshell-coords.c: applied patch from Alexia
Death that fixes issues with the new stroke direction code
(bug #520078).
2009-02-14 Sven Neumann <sven@gimp.org> 2009-02-14 Sven Neumann <sven@gimp.org>
Bug 472644 Rotate with clipping crops the whole layer Bug 472644 Rotate with clipping crops the whole layer
......
...@@ -228,6 +228,8 @@ gimp_coords_interpolate_catmull (const GimpCoords catmul_pt1, ...@@ -228,6 +228,8 @@ gimp_coords_interpolate_catmull (const GimpCoords catmul_pt1,
{ {
gdouble delta_x, delta_y; gdouble delta_x, delta_y;
gdouble distance; gdouble distance;
gdouble dir_step;
gdouble delta_dir;
gint num_points; gint num_points;
gint n; gint n;
...@@ -236,8 +238,8 @@ gimp_coords_interpolate_catmull (const GimpCoords catmul_pt1, ...@@ -236,8 +238,8 @@ gimp_coords_interpolate_catmull (const GimpCoords catmul_pt1,
GimpCoords end_coords; GimpCoords end_coords;
GimpCoords future_coords; GimpCoords future_coords;
delta_x = catmul_pt3.x - catmul_pt2.x; delta_x = catmul_pt3.x - catmul_pt2.x;
delta_y = catmul_pt3.y - catmul_pt2.y; delta_y = catmul_pt3.y - catmul_pt2.y;
/* Catmull-Rom interpolation requires 4 points. /* Catmull-Rom interpolation requires 4 points.
* Two endpoints plus one more at each end. * Two endpoints plus one more at each end.
...@@ -252,50 +254,56 @@ gimp_coords_interpolate_catmull (const GimpCoords catmul_pt1, ...@@ -252,50 +254,56 @@ gimp_coords_interpolate_catmull (const GimpCoords catmul_pt1,
num_points = distance / precision; num_points = distance / precision;
for (n = 1; n <=num_points; n++) delta_dir = end_coords.direction - start_coords.direction;
if (delta_dir <= -0.5)
delta_dir += 1.0;
else if (delta_dir >= 0.5)
delta_dir -= 1.0;
dir_step = delta_dir / num_points;
for (n = 1; n <= num_points; n++)
{ {
GimpCoords res_coords; GimpCoords coords;
GimpCoords last_coords;
gdouble velocity; gdouble velocity;
gdouble delta_x;
gdouble delta_y;
gdouble p = (gdouble) n / num_points; gdouble p = (gdouble) n / num_points;
res_coords.x = coords.x =
gimp_coords_get_catmull_spline_point (p, gimp_coords_get_catmull_spline_point (p,
past_coords.x, past_coords.x,
start_coords.x, start_coords.x,
end_coords.x, end_coords.x,
future_coords.x); future_coords.x);
res_coords.y = coords.y =
gimp_coords_get_catmull_spline_point (p, gimp_coords_get_catmull_spline_point (p,
past_coords.y, past_coords.y,
start_coords.y, start_coords.y,
end_coords.y, end_coords.y,
future_coords.y); future_coords.y);
res_coords.pressure = coords.pressure =
gimp_coords_get_catmull_spline_point (p, gimp_coords_get_catmull_spline_point (p,
past_coords.pressure, past_coords.pressure,
start_coords.pressure, start_coords.pressure,
end_coords.pressure, end_coords.pressure,
future_coords.pressure); future_coords.pressure);
res_coords.xtilt = coords.xtilt =
gimp_coords_get_catmull_spline_point (p, gimp_coords_get_catmull_spline_point (p,
past_coords.xtilt, past_coords.xtilt,
start_coords.xtilt, start_coords.xtilt,
end_coords.xtilt, end_coords.xtilt,
future_coords.xtilt); future_coords.xtilt);
res_coords.ytilt = coords.ytilt =
gimp_coords_get_catmull_spline_point (p, gimp_coords_get_catmull_spline_point (p,
past_coords.ytilt, past_coords.ytilt,
start_coords.ytilt, start_coords.ytilt,
end_coords.ytilt, end_coords.ytilt,
future_coords.ytilt); future_coords.ytilt);
res_coords.wheel = coords.wheel =
gimp_coords_get_catmull_spline_point (p, gimp_coords_get_catmull_spline_point (p,
past_coords.wheel, past_coords.wheel,
start_coords.wheel, start_coords.wheel,
...@@ -307,29 +315,14 @@ gimp_coords_interpolate_catmull (const GimpCoords catmul_pt1, ...@@ -307,29 +315,14 @@ gimp_coords_interpolate_catmull (const GimpCoords catmul_pt1,
start_coords.velocity, start_coords.velocity,
end_coords.velocity, end_coords.velocity,
future_coords.velocity); future_coords.velocity);
res_coords.velocity = CLAMP (velocity, 0.0, 1.0); coords.velocity = CLAMP (velocity, 0.0, 1.0);
if (n > 1) coords.direction = start_coords.direction + dir_step * n;
last_coords = g_array_index (*ret_coords, GimpCoords, n - 2);
else
last_coords = start_coords;
delta_x = last_coords.x - res_coords.x; while (coords.direction > 1.0)
delta_y = last_coords.y - res_coords.y; coords.direction -= 1.0;
if (delta_x == 0)
{
res_coords.direction = last_coords.direction;
}
else
{
res_coords.direction = atan ((- delta_y) / delta_x) / (2 * G_PI);
if (delta_x < 0.0)
res_coords.direction = res_coords.direction + 0.5;
}
g_array_append_val (*ret_coords, res_coords); g_array_append_val (*ret_coords, coords);
if (ret_params) if (ret_params)
g_array_append_val (*ret_params, p); g_array_append_val (*ret_params, p);
......
...@@ -219,11 +219,13 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell, ...@@ -219,11 +219,13 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
gdouble inertia_factor, gdouble inertia_factor,
guint32 time) guint32 time)
{ {
gdouble delta_time = 0.001; gdouble delta_time = 0.001;
gdouble delta_x = 0.0; gdouble delta_x = 0.0;
gdouble delta_y = 0.0; gdouble delta_y = 0.0;
gdouble distance = 1.0; gdouble dir_delta_x = 0.0;
gboolean event_fill = (inertia_factor > 0); gdouble dir_delta_y = 0.0;
gdouble distance = 1.0;
gboolean event_fill = (inertia_factor > 0);
/* Smoothing causes problems with cursor tracking /* Smoothing causes problems with cursor tracking
* when zoomed above screen resolution so we need to supress it. * when zoomed above screen resolution so we need to supress it.
...@@ -291,26 +293,74 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell, ...@@ -291,26 +293,74 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
/* Speed needs upper limit */ /* Speed needs upper limit */
coords->velocity = MIN (coords->velocity, 1.0); coords->velocity = MIN (coords->velocity, 1.0);
} }
if ((fabs (delta_x) > 1.5) && (fabs (delta_y) > 1.5))
{
dir_delta_x = delta_x;
dir_delta_y = delta_y;
}
else
{
gint x = 3;
while (((fabs (dir_delta_x) < 1.5) ||
(fabs (dir_delta_y) < 1.5)) && (x >= 0))
{
const GimpCoords old_event = g_array_index (shell->event_history,
GimpCoords, x);
if (delta_x == 0.0) dir_delta_x = old_event.x - coords->x;
dir_delta_y = old_event.y - coords->y;
x--;
}
}
if (dir_delta_x == 0.0)
{ {
coords->direction = shell->last_coords.direction; if (dir_delta_y >= 0.0)
coords->direction = 0.5;
else if (dir_delta_y < 0.0)
coords->direction = 0.0;
else coords->direction = shell->last_coords.direction;
} }
else else
{ {
coords->direction = atan ((- 1.0 * delta_y) / delta_x) / (2 * G_PI); coords->direction = atan ((- 1.0 * dir_delta_y) /
if (delta_x < 0.0) dir_delta_x) / (2 * G_PI);
if (dir_delta_x > 0.0)
coords->direction = coords->direction + 0.5; coords->direction = coords->direction + 0.5;
} }
delta_dir = coords->direction - shell->last_coords.direction; while (coords->direction > 1.0)
coords->direction -= 1.0;
while (coords->direction < 0.0)
coords->direction += 1.0;
delta_dir = coords->direction - shell->last_coords.direction;
if ((fabs (delta_dir) > 0.5) && (delta_dir < 0.0))
{
coords->direction = (0.5 * coords->direction +
0.5 * (shell->last_coords.direction - 1.0));
}
else if ((fabs (delta_dir) > 0.5) && (delta_dir > 0.0))
{
coords->direction = (0.5 * coords->direction +
0.5 * (shell->last_coords.direction + 1.0));
}
else
{
coords->direction = (0.5 * coords->direction +
0.5 * shell->last_coords.direction);
}
while (coords->direction > 1.0)
coords->direction -= 1.0;
if ((fabs (delta_dir) > 0.5) && (delta_dir < 0.0)) while (coords->direction < 0.0)
coords->direction = 0.3 * coords->direction + 0.7 * (shell->last_coords.direction - 1.0); coords->direction += 1.0;
else if ((fabs (delta_dir) > 0.5) && (delta_dir > 0.0))
coords->direction = 0.3 * coords->direction + 0.7 * (shell->last_coords.direction + 1.0);
else
coords->direction = 0.3 * coords->direction + 0.7 * shell->last_coords.direction;
/* High speed -> less smooth*/ /* High speed -> less smooth*/
inertia_factor *= (1 - coords->velocity); inertia_factor *= (1 - coords->velocity);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment