diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-14 12:44:35 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-14 12:44:35 +0400 |
commit | f2074949e7a3dbf3a1dc5b51a0a3eee0eee9aada (patch) | |
tree | 1912a8eb416499bdba69f0955515b3d905c52024 /source/blender/editors/space_clip/tracking_select.c | |
parent | 8d496b3bf2c58a0a161c20c987f414953a6d1e87 (diff) |
code cleanup: reduce calling sqrt() when distances are only calculated for comparison use dist_squared_to_line_segment_v2().
Diffstat (limited to 'source/blender/editors/space_clip/tracking_select.c')
-rw-r--r-- | source/blender/editors/space_clip/tracking_select.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index ea3d1226937..5a79e832ebe 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -161,12 +161,12 @@ static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2]) float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]}; float v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]}; - d1 = dist_to_line_segment_v2(p, v1, v2); - d2 = dist_to_line_segment_v2(p, v2, v3); - d3 = dist_to_line_segment_v2(p, v3, v4); - d4 = dist_to_line_segment_v2(p, v4, v1); + d1 = dist_squared_to_line_segment_v2(p, v1, v2); + d2 = dist_squared_to_line_segment_v2(p, v2, v3); + d3 = dist_squared_to_line_segment_v2(p, v3, v4); + d4 = dist_squared_to_line_segment_v2(p, v4, v1); - return MIN4(d1, d2, d3, d4); + return sqrtf(MIN4(d1, d2, d3, d4)); } static float dist_to_crns(float co[2], float pos[2], float crns[4][2]) @@ -176,12 +176,12 @@ static float dist_to_crns(float co[2], float pos[2], float crns[4][2]) float *v1 = crns[0], *v2 = crns[1]; float *v3 = crns[2], *v4 = crns[3]; - d1 = dist_to_line_segment_v2(p, v1, v2); - d2 = dist_to_line_segment_v2(p, v2, v3); - d3 = dist_to_line_segment_v2(p, v3, v4); - d4 = dist_to_line_segment_v2(p, v4, v1); + d1 = dist_squared_to_line_segment_v2(p, v1, v2); + d2 = dist_squared_to_line_segment_v2(p, v2, v3); + d3 = dist_squared_to_line_segment_v2(p, v3, v4); + d4 = dist_squared_to_line_segment_v2(p, v4, v1); - return MIN4(d1, d2, d3, d4); + return sqrtf(MIN4(d1, d2, d3, d4)); } static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbase, float co[2]) |