gimp r26232 - in trunk: . app/core app/display app/paint app/xcf
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26232 - in trunk: . app/core app/display app/paint app/xcf
- Date: Fri, 18 Jul 2008 11:56:05 +0000 (UTC)
Author: neo
Date: Fri Jul 18 11:56:05 2008
New Revision: 26232
URL: http://svn.gnome.org/viewvc/gimp?rev=26232&view=rev
Log:
2008-07-18 Sven Neumann <sven gimp org>
* app/core/core-types.h: removed delta_time, delta_x, delta_y,
distance and random from the GimpCoords struct. These don't need
to be kept here and they can't be properly interpolated.
* app/core/gimpcoords.c: changed accordingly.
* app/xcf/xcf-load.c (xcf_load_vector): the size of the
GimpCoords
struct changed.
* app/display/gimpdisplayshell.[ch] (struct _GimpDisplayShell):
added some members to store values from the last event that are
needed in gimp_display_shell_eval_event() and which are not any
longer part of GimpCoords.
* app/display/gimpdisplayshell-coords.c
(gimp_display_shell_eval_event): changed accordingly.
* app/paint/gimppaintoptions.c: calculate a random number when
one
is needed.
* app/paint/gimpbrushcore.c (gimp_brush_core_interpolate):
GimpCoords doesn't have a "random" field any longer.
Modified:
trunk/ChangeLog
trunk/app/core/core-types.h
trunk/app/core/gimpcoords.c
trunk/app/display/gimpdisplayshell-coords.c
trunk/app/display/gimpdisplayshell.c
trunk/app/display/gimpdisplayshell.h
trunk/app/paint/gimpbrushcore.c
trunk/app/paint/gimppaintoptions.c
trunk/app/xcf/xcf-load.c
Modified: trunk/app/core/core-types.h
==============================================================================
--- trunk/app/core/core-types.h (original)
+++ trunk/app/core/core-types.h Fri Jul 18 11:56:05 2008
@@ -52,9 +52,7 @@
GIMP_COORDS_DEFAULT_TILT, \
GIMP_COORDS_DEFAULT_TILT, \
GIMP_COORDS_DEFAULT_WHEEL, \
- 0.0, 0.0, 0.0, 0.0, \
- GIMP_COORDS_DEFAULT_VELOCITY, \
- 0.0 }
+ GIMP_COORDS_DEFAULT_VELOCITY }
/* base classes */
@@ -204,12 +202,7 @@
gdouble xtilt;
gdouble ytilt;
gdouble wheel;
- gdouble delta_time;
- gdouble delta_x;
- gdouble delta_y;
- gdouble distance;
gdouble velocity;
- gdouble random;
};
Modified: trunk/app/core/gimpcoords.c
==============================================================================
--- trunk/app/core/gimpcoords.c (original)
+++ trunk/app/core/gimpcoords.c Fri Jul 18 11:56:05 2008
@@ -44,33 +44,23 @@
{
if (b)
{
- ret_val->x = amul * a->x + bmul * b->x;
- ret_val->y = amul * a->y + bmul * b->y;
- ret_val->pressure = amul * a->pressure + bmul * b->pressure;
- ret_val->xtilt = amul * a->xtilt + bmul * b->xtilt;
- ret_val->ytilt = amul * a->ytilt + bmul * b->ytilt;
- ret_val->wheel = amul * a->wheel + bmul * b->wheel;
- ret_val->delta_time = amul * a->delta_time + bmul * b->delta_time;
- ret_val->delta_x = amul * a->delta_x + bmul * b->delta_x;
- ret_val->delta_y = amul * a->delta_y + bmul * b->delta_y;
- ret_val->distance = amul * a->distance + bmul * b->distance;
- ret_val->velocity = amul * a->velocity + bmul * b->velocity;
- ret_val->random = amul * a->random + bmul * b->random;
+ ret_val->x = amul * a->x + bmul * b->x;
+ ret_val->y = amul * a->y + bmul * b->y;
+ ret_val->pressure = amul * a->pressure + bmul * b->pressure;
+ ret_val->xtilt = amul * a->xtilt + bmul * b->xtilt;
+ ret_val->ytilt = amul * a->ytilt + bmul * b->ytilt;
+ ret_val->wheel = amul * a->wheel + bmul * b->wheel;
+ ret_val->velocity = amul * a->velocity + bmul * b->velocity;
}
else
{
- ret_val->x = amul * a->x;
- ret_val->y = amul * a->y;
- ret_val->pressure = amul * a->pressure;
- ret_val->xtilt = amul * a->xtilt;
- ret_val->ytilt = amul * a->ytilt;
- ret_val->wheel = amul * a->wheel;
- ret_val->delta_time = amul * a->delta_time;
- ret_val->delta_x = amul * a->delta_x;
- ret_val->delta_y = amul * a->delta_y;
- ret_val->distance = amul * a->distance;
- ret_val->velocity = amul * a->velocity;
- ret_val->random = amul * a->random;
+ ret_val->x = amul * a->x;
+ ret_val->y = amul * a->y;
+ ret_val->pressure = amul * a->pressure;
+ ret_val->xtilt = amul * a->xtilt;
+ ret_val->ytilt = amul * a->ytilt;
+ ret_val->wheel = amul * a->wheel;
+ ret_val->velocity = amul * a->velocity;
}
}
Modified: trunk/app/display/gimpdisplayshell-coords.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-coords.c (original)
+++ trunk/app/display/gimpdisplayshell-coords.c Fri Jul 18 11:56:05 2008
@@ -213,6 +213,11 @@
gdouble inertia_factor,
guint32 time)
{
+ gdouble delta_time = 0.001;
+ gdouble delta_x = 0.0;
+ gdouble delta_y = 0.0;
+ gdouble distance = 1.0;
+
/* Smoothing causes problems with cursor tracking
* when zoomed above screen resolution so we need to supress it.
*/
@@ -221,22 +226,21 @@
inertia_factor = 0.0;
}
- if (shell->last_disp_motion_time == 0)
+ if (shell->last_motion_time == 0)
{
/* First pair is invalid to do any velocity calculation,
- * so we apply constant values.
+ * so we apply a constant value.
*/
- coords->velocity = 1.0;
- coords->delta_time = 0.001;
- coords->distance = 1;
+ coords->velocity = 1.0;
}
else
{
- gdouble dx = coords->delta_x = shell->last_coords.x - coords->x;
- gdouble dy = coords->delta_y = shell->last_coords.y - coords->y;
gdouble filter;
gdouble dist;
+ delta_x = shell->last_coords.x - coords->x;
+ delta_y = shell->last_coords.y - coords->y;
+
#define SMOOTH_FACTOR 0.3
/* Events with distances less than the screen resolution are not
@@ -244,20 +248,18 @@
*/
filter = MIN (1 / shell->scale_x, 1 / shell->scale_y) / 2.0;
- if (fabs (dx) < filter && fabs (dy) < filter)
+ if (fabs (delta_x) < filter && fabs (delta_y) < filter)
return FALSE;
- coords->delta_time = time - shell->last_disp_motion_time;
- coords->delta_time = (shell->last_coords.delta_time * (1 - SMOOTH_FACTOR)
- + coords->delta_time * SMOOTH_FACTOR);
- coords->distance = dist = sqrt (SQR (dx) + SQR (dy));
+ delta_time = (shell->last_motion_delta_time * (1 - SMOOTH_FACTOR)
+ + (time - shell->last_motion_time) * SMOOTH_FACTOR);
- coords->random = g_random_double_range (0.0, 1.0);
+ distance = dist = sqrt (SQR (delta_x) + SQR (delta_y));
/* If even smoothed time resolution does not allow to guess for speed,
* use last velocity.
*/
- if ((coords->delta_time == 0))
+ if (delta_time == 0)
{
coords->velocity = shell->last_coords.velocity;
}
@@ -266,14 +268,13 @@
/* We need to calculate the velocity in screen coordinates
* for human interaction
*/
- gdouble screen_distance = (coords->distance *
+ gdouble screen_distance = (distance *
MIN (shell->scale_x, shell->scale_y));
/* Calculate raw valocity */
- coords->velocity = ((screen_distance / (gdouble) coords->delta_time) /
- VELOCITY_UNIT);
+ coords->velocity = ((screen_distance / delta_time) / VELOCITY_UNIT);
- /* Adding velocity dependent smooth, feels better in tools this way. */
+ /* Adding velocity dependent smoothing, feels better in tools. */
coords->velocity = (shell->last_coords.velocity *
(1 - MIN (SMOOTH_FACTOR, coords->velocity)) +
coords->velocity *
@@ -282,10 +283,11 @@
/* Speed needs upper limit */
coords->velocity = MIN (coords->velocity, 1.0);
}
+
/* High speed -> less smooth*/
inertia_factor *= (1 - coords->velocity);
- if (inertia_factor > 0 && coords->distance > 0)
+ if (inertia_factor > 0 && distance > 0)
{
/* Apply smoothing to X and Y. */
@@ -301,23 +303,21 @@
gdouble new_x;
gdouble new_y;
- sin_new = coords->delta_x / coords->distance;
- sin_old = shell->last_coords.delta_x / shell->last_coords.distance;
+ sin_new = delta_x / distance;
+ sin_old = shell->last_motion_delta_x / shell->last_motion_distance;
sin_avg = sin (asin (sin_old) * inertia_factor +
asin (sin_new) * (1 - inertia_factor));
- cos_new = coords->delta_y / coords->distance;
- cos_old = shell->last_coords.delta_y / shell->last_coords.distance;
+ cos_new = delta_y / distance;
+ cos_old = shell->last_motion_delta_y / shell->last_motion_distance;
cos_avg = cos (acos (cos_old) * inertia_factor +
acos (cos_new) * (1 - inertia_factor));
- coords->delta_x = sin_avg * coords->distance;
- coords->delta_y = cos_avg * coords->distance;
+ delta_x = sin_avg * distance;
+ delta_y = cos_avg * distance;
- new_x =
- (shell->last_coords.x - coords->delta_x) * 0.5 + coords->x * 0.5;
- new_y =
- (shell->last_coords.y - coords->delta_y) * 0.5 + coords->y * 0.5;
+ new_x = (shell->last_coords.x - delta_x) * 0.5 + coords->x * 0.5;
+ new_y = (shell->last_coords.y - delta_y) * 0.5 + coords->y * 0.5;
cur_deviation = SQR (coords->x - new_x) + SQR (coords->y - new_y);
@@ -333,18 +333,17 @@
coords->x = new_x;
coords->y = new_y;
- coords->delta_x = shell->last_coords.x - coords->x;
- coords->delta_y = shell->last_coords.y - coords->y;
+ delta_x = shell->last_coords.x - coords->x;
+ delta_y = shell->last_coords.y - coords->y;
/* Recalculate distance */
- coords->distance = sqrt (SQR (coords->delta_x) +
- SQR (coords->delta_y));
+ distance = sqrt (SQR (delta_x) + SQR (delta_y));
}
#ifdef VERBOSE
g_printerr ("DIST: %f, DT:%f, Vel:%f, Press:%f,smooth_dd:%f, sf %f\n",
- coords->distance,
- coords->delta_time,
+ distance,
+ delta_time,
shell->last_coords.velocity,
coords->pressure,
coords->distance - dist,
@@ -352,8 +351,13 @@
#endif
}
- shell->last_coords = *coords;
- shell->last_disp_motion_time = time;
+ shell->last_coords = *coords;
+
+ shell->last_motion_time = time;
+ shell->last_motion_delta_time = delta_time;
+ shell->last_motion_delta_x = delta_x;
+ shell->last_motion_delta_y = delta_y;
+ shell->last_motion_distance = distance;
return TRUE;
}
Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c (original)
+++ trunk/app/display/gimpdisplayshell.c Fri Jul 18 11:56:05 2008
@@ -337,6 +337,12 @@
shell->scroll_start_x = 0;
shell->scroll_start_y = 0;
shell->button_press_before_focus = FALSE;
+
+ shell->last_motion_time = 0;
+ shell->last_motion_delta_x = 0.0;
+ shell->last_motion_delta_y = 0.0;
+ shell->last_motion_distance = 0.0;
+ shell->last_motion_delta_time = 0.0;
shell->highlight = NULL;
shell->mask = NULL;
Modified: trunk/app/display/gimpdisplayshell.h
==============================================================================
--- trunk/app/display/gimpdisplayshell.h (original)
+++ trunk/app/display/gimpdisplayshell.h Fri Jul 18 11:56:05 2008
@@ -180,8 +180,13 @@
gint scroll_start_x;
gint scroll_start_y;
gboolean button_press_before_focus;
- guint32 last_disp_motion_time; /* previous time of a forwarded motion event */
+
+ guint32 last_motion_time; /* previous time of a forwarded motion event */
guint32 last_read_motion_time;
+ gdouble last_motion_delta_time;
+ gdouble last_motion_delta_x;
+ gdouble last_motion_delta_y;
+ gdouble last_motion_distance;
GdkRectangle *highlight; /* in image coordinates, can be NULL */
GimpDrawable *mask;
Modified: trunk/app/paint/gimpbrushcore.c
==============================================================================
--- trunk/app/paint/gimpbrushcore.c (original)
+++ trunk/app/paint/gimpbrushcore.c Fri Jul 18 11:56:05 2008
@@ -635,7 +635,6 @@
p * delta_wheel);
paint_core->cur_coords.velocity = (paint_core->last_coords.velocity +
p * delta_velocity);
- paint_core->cur_coords.random = g_random_double_range (0.0, 1.0);
if (core->jitter > 0.0)
{
Modified: trunk/app/paint/gimppaintoptions.c
==============================================================================
--- trunk/app/paint/gimppaintoptions.c (original)
+++ trunk/app/paint/gimppaintoptions.c Fri Jul 18 11:56:05 2008
@@ -1002,7 +1002,7 @@
velocity = GIMP_PAINT_VELOCITY_SCALE * (1 - coords->velocity);
if (paint_options->random_options->opacity)
- random = coords->random;
+ random = g_random_double_range (0.0, 1.0);
opacity = gimp_paint_options_get_dynamics_mix (pressure,
paint_options->pressure_options->prescale,
@@ -1048,11 +1048,11 @@
if (paint_options->random_options->size)
{
- random = 1.0 - coords->random;
+ random = 1.0 - g_random_double_range (0.0, 1.0);
}
else if (paint_options->random_options->inverse_size)
{
- random = coords->random;
+ random = g_random_double_range (0.0, 1.0);
}
scale = gimp_paint_options_get_dynamics_mix (pressure,
@@ -1098,7 +1098,7 @@
velocity = GIMP_PAINT_VELOCITY_SCALE * (1 - coords->velocity);
if (paint_options->random_options->rate)
- random = coords->random;
+ random = g_random_double_range (0.0, 1.0);
rate = gimp_paint_options_get_dynamics_mix (pressure,
paint_options->pressure_options->prescale,
@@ -1136,7 +1136,7 @@
velocity = GIMP_PAINT_VELOCITY_SCALE * coords->velocity;
if (paint_options->random_options->color)
- random = coords->random;
+ random = g_random_double_range (0.0, 1.0);
color = gimp_paint_options_get_dynamics_mix (pressure,
paint_options->pressure_options->prescale,
@@ -1173,7 +1173,7 @@
velocity = GIMP_PAINT_VELOCITY_SCALE * (1 - coords->velocity);
if (paint_options->random_options->hardness)
- random = coords->random;
+ random = g_random_double_range (0.0, 1.0);
hardness = gimp_paint_options_get_dynamics_mix (pressure,
paint_options->pressure_options->prescale,
Modified: trunk/app/xcf/xcf-load.c
==============================================================================
--- trunk/app/xcf/xcf-load.c (original)
+++ trunk/app/xcf/xcf-load.c Fri Jul 18 11:56:05 2008
@@ -1735,7 +1735,7 @@
guint32 num_axes;
guint32 num_control_points;
guint32 type;
- gfloat coords[6] = GIMP_COORDS_DEFAULT_VALUES;
+ gfloat coords[7] = GIMP_COORDS_DEFAULT_VALUES;
GimpStroke *stroke;
gint j;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]