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>2012-08-14 12:44:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-14 12:44:35 +0400
commitf2074949e7a3dbf3a1dc5b51a0a3eee0eee9aada (patch)
tree1912a8eb416499bdba69f0955515b3d905c52024 /source/blender/blenkernel/intern/dynamicpaint.c
parent8d496b3bf2c58a0a161c20c987f414953a6d1e87 (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/blenkernel/intern/dynamicpaint.c')
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 8122f9bf617..0daf06c6305 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1997,7 +1997,10 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
/* Get closest edge to that subpixel on UV map */
{
- float pixel[2], dist, t_dist;
+ float pixel[2];
+ /* distances only used for comparison */
+ float dist_squared, t_dist_squared;
+
int i, uindex[3], edge1_index, edge2_index,
e1_index, e2_index, target_face;
float closest_point[2], lambda, dir_vec[2];
@@ -2019,17 +2022,17 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
/*
* Find closest edge to that pixel
*/
- /* Dist to first edge */
+ /* Dist to first edge */
e1_index = cPoint->v1; e2_index = cPoint->v2; edge1_index = uindex[0]; edge2_index = uindex[1];
- dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[edge1_index], tface[cPoint->face_index].uv[edge2_index]);
+ dist_squared = dist_squared_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[edge1_index], tface[cPoint->face_index].uv[edge2_index]);
- /* Dist to second edge */
- t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[1]], tface[cPoint->face_index].uv[uindex[2]]);
- if (t_dist < dist) { e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist = t_dist; }
+ /* Dist to second edge */
+ t_dist_squared = dist_squared_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[1]], tface[cPoint->face_index].uv[uindex[2]]);
+ if (t_dist_squared < dist_squared) { e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist_squared = t_dist_squared; }
- /* Dist to third edge */
- t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[2]], tface[cPoint->face_index].uv[uindex[0]]);
- if (t_dist < dist) { e1_index = cPoint->v3; e2_index = cPoint->v1; edge1_index = uindex[2]; edge2_index = uindex[0]; dist = t_dist; }
+ /* Dist to third edge */
+ t_dist_squared = dist_squared_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[2]], tface[cPoint->face_index].uv[uindex[0]]);
+ if (t_dist_squared < dist_squared) { e1_index = cPoint->v3; e2_index = cPoint->v1; edge1_index = uindex[2]; edge2_index = uindex[0]; dist_squared = t_dist_squared; }
/*