From a1a0ebbf490fd36d893ad5b0a37e099f3d035eac Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 2 Feb 2014 01:36:40 +1100 Subject: Code cleanup: use length squared where possible --- source/blender/editors/space_clip/clip_draw.c | 9 ++++----- source/blender/editors/space_clip/tracking_ops.c | 9 +++++---- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'source/blender/editors/space_clip') diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 983858ac568..aee6e2cda93 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -769,12 +769,12 @@ static float get_shortest_pattern_side(MovieTrackingMarker *marker) next = (i + 1) % 4; - cur_len = len_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]); + cur_len = len_squared_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]); len = min_ff(cur_len, len); } - return len; + return sqrtf(len); } static void draw_marker_slide_square(float x, float y, float dx, float dy, int outline, float px[2]) @@ -1031,8 +1031,7 @@ static void getArrowEndPoint(const int width, const int height, const float zoom direction[0] *= width; direction[1] *= height; - max_length = len_v2(direction); - normalize_v2(direction); + max_length = normalize_v2(direction); mul_v2_fl(direction, min_ff(32.0f / zoom, max_length)); direction[0] /= width; direction[1] /= height; @@ -1461,7 +1460,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie sub_v2_v2(vec, npos); - if (len_v2(vec) < 3.0f) + if (len_squared_v2(vec) < (3.0f * 3.0f)) glColor3f(0.0f, 1.0f, 0.0f); else glColor3f(1.0f, 0.0f, 0.0f); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 59cfe88e8c9..2e63e00dc28 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -546,10 +546,11 @@ static int get_mouse_pattern_corner(SpaceClip *sc, MovieTrackingMarker *marker, next = (i + 1) % 4; - cur_len = len_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]); + cur_len = len_squared_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]); len = min_ff(cur_len, len); } + len = sqrtf(len); dx = 12.0f / width / sc->zoom; dy = 12.0f / height / sc->zoom; @@ -913,7 +914,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, const wmEvent *event) sub_v2_v2(start, data->old_pos); - if (len_v2(start) > 0.0f) { + if (len_squared_v2(start) != 0.0f) { float mval[2]; if (data->accurate) { @@ -986,7 +987,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_clip_point_stable_pos(sc, ar, mval[0], mval[1], &end[0], &end[1]); sub_v2_v2(end, data->old_pos); - if (len_v2(start) > 0.0f) { + if (len_squared_v2(start) != 0.0f) { scale = len_v2(end) / len_v2(start); if (scale < 0.0f) { @@ -2207,7 +2208,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb sub_v3_v3(vec, obmat[3]); } - if (len_v2(vec) < 1e-3f) + if (len_squared_v2(vec) < (1e-3f * 1e-3f)) return; unit_m4(mat); -- cgit v1.2.3