diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-27 13:44:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-27 13:44:56 +0400 |
commit | 13254cde8c7ca38af2dcec35efdb9f8f9b3bca46 (patch) | |
tree | a6d62e3b3948af458b5a8913293412393a540a96 /source/blender/blenlib | |
parent | 4035bf16e75acde1ef77d8a176edc95dbad70f35 (diff) |
Alternate mask spline feather offset calculation method: now there are 2 [Even | Smooth]
- Even preserves thickness but can give unsightly loops
- Smooth gives nicer shape but can give unsightly feather/spline mismatch for 'S' shapes created by beziers.
This is an example where smooth works much nicer.
http://www.graphicall.org/ftp/ideasman42/mask_compare.png
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector.c | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 8499a7f219c..eef8c9daaef 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -220,6 +220,9 @@ MINLINE void normal_float_to_short_v3(short r[3], const float n[3]); void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]); +void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist); +void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist); + /***************************** Array Functions *******************************/ /* attempted to follow fixed length vertex functions. names could be improved*/ double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size); diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 5cda1c0b81f..4196bab0474 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -451,6 +451,29 @@ void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]) if (max[2] < vec[2]) max[2] = vec[2]; } +/** ensure \a v1 is \a dist from \a v2 */ +void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist) +{ + if (!equals_v3v3(v2, v1)) { + float nor[3]; + + sub_v3_v3v3(nor, v1, v2); + normalize_v3(nor); + madd_v3_v3v3fl(v1, v2, nor, dist); + } +} + +void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist) +{ + if (!equals_v2v2(v2, v1)) { + float nor[2]; + + sub_v2_v2v2(nor, v1, v2); + normalize_v2(nor); + madd_v2_v2v2fl(v1, v2, nor, dist); + } +} + /***************************** Array Functions *******************************/ double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size) |