diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-04-20 02:52:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-04-20 02:53:40 +0300 |
commit | dbf1257b14582d5c6cabbed01ef1bf89860106fd (patch) | |
tree | 257526e39019988ca2f3c34a8fe9e1a2af57e1c5 /source/blender/blenlib/intern/scanfill.c | |
parent | 38442ae2dc7ff9fe656b715e0ac92c465dccc7ee (diff) |
Minor optimization for scanfill
Replace angle with with cosine calculation.
Diffstat (limited to 'source/blender/blenlib/intern/scanfill.c')
-rw-r--r-- | source/blender/blenlib/intern/scanfill.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 8a96daeeb91..e913499ba2b 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -602,7 +602,7 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl else { /* test rest of vertices */ ScanFillVertLink *best_sc = NULL; - float best_angle = 3.14f; + float angle_best_cos = -1.0f; float miny; bool firsttime = false; @@ -633,21 +633,18 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl best_sc = sc1; } else { - float angle; - /* prevent angle calc for the simple cases only 1 vertex is found */ if (firsttime == false) { - best_angle = angle_v2v2v2(v2->xy, v1->xy, best_sc->vert->xy); + angle_best_cos = cos_v2v2v2(v2->xy, v1->xy, best_sc->vert->xy); firsttime = true; } - angle = angle_v2v2v2(v2->xy, v1->xy, sc1->vert->xy); - if (angle < best_angle) { + const float angle_test_cos = cos_v2v2v2(v2->xy, v1->xy, sc1->vert->xy); + if (angle_test_cos > angle_best_cos) { best_sc = sc1; - best_angle = angle; + angle_best_cos = angle_test_cos; } } - } } } |