diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-12-26 00:44:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-12-26 00:46:48 +0300 |
commit | 53ec177b7f0d20865355468fda9a626176808635 (patch) | |
tree | a47d34530c37745832447c167acdfe9f0825f079 /source | |
parent | f84defa9c0373b7db4953b64aaa2f02673b28f69 (diff) |
optimize interp_weights_poly_v2, v3
use line_point_factor instead of length between vertices.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 148495c736c..3a0187584ff 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2714,11 +2714,10 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[ w[i_curr] = 1.0f; } else { - float len_curr = len_v3v3(co, v_curr); - float len_next = len_v3v3(co, v_next); - float edge_len = len_curr + len_next; - w[i_curr] = len_next / edge_len; - w[(i_curr + 1) % n] = len_curr / edge_len; + float fac = line_point_factor_v3(co, v_curr, v_next); + CLAMP(fac, 0.0f, 1.0f); + w[i_curr] = 1.0f - fac; + w[(i_curr + 1) % n] = fac; } } else { @@ -2787,11 +2786,10 @@ void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[ w[i_curr] = 1.0f; } else { - float len_curr = len_v2v2(co, v_curr); - float len_next = len_v2v2(co, v_next); - float edge_len = len_curr + len_next; - w[i_curr] = len_next / edge_len; - w[(i_curr + 1) % n] = len_curr / edge_len; + float fac = line_point_factor_v2(co, v_curr, v_next); + CLAMP(fac, 0.0f, 1.0f); + w[i_curr] = 1.0f - fac; + w[(i_curr + 1) % n] = fac; } } else { |