From 72735b104dc756617d26f751de9b12919d559829 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 4 Jan 2011 06:28:44 +0000 Subject: Fixing Grease Pencil typo noted while scanning through Mike Erwin's GSoC10 work. Cheers Mike for catching this! Also removing the use of sqrt() as noted in a "todo" comment there... --- source/blender/editors/gpencil/gpencil_paint.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/gpencil') diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index aa20bb2667f..11a15fd8afc 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -210,13 +210,17 @@ static short gp_stroke_filtermval (tGPsdata *p, int mval[2], int pmval[2]) if (p->gpd->sbuffer_size == 0) return 1; - /* check if mouse moved at least certain distance on both axes (best case) */ + /* check if mouse moved at least certain distance on both axes (best case) + * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand + */ else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) return 1; - /* check if the distance since the last point is significant enough */ - // future optimisation: sqrt here may be too slow? - else if (sqrt(dx*dx + dy*dy) > MIN_EUCLIDEAN_PX) + /* check if the distance since the last point is significant enough + * - prevents points being added too densely + * - distance here doesn't use sqrt to prevent slowness... we should still be safe from overflows though + */ + else if ((dx*dx + dy*dy) > MIN_EUCLIDEAN_PX*MIN_EUCLIDEAN_PX) return 1; /* mouse 'didn't move' */ @@ -415,7 +419,7 @@ static void gp_stroke_simplify (tGPsdata *p) return; /* don't simplify if less than 4 points in buffer */ - if ((num_points <= 2) || (old_points == NULL)) + if ((num_points <= 4) || (old_points == NULL)) return; /* clear buffer (but don't free mem yet) so that we can write to it -- cgit v1.2.3