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:
authorCampbell Barton <ideasman42@gmail.com>2014-02-01 18:36:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-01 19:24:48 +0400
commita1a0ebbf490fd36d893ad5b0a37e099f3d035eac (patch)
treeb77aa5ecaa83b233c804598563a56ed33b49be5a /source/blender/editors/space_clip
parent798e684c7c4d8b7c0c31a5f892ae43189e8d1b8c (diff)
Code cleanup: use length squared where possible
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r--source/blender/editors/space_clip/clip_draw.c9
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c9
2 files changed, 9 insertions, 9 deletions
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);