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-06-05 16:09:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-05 16:09:24 +0400
commit49cc9c7502dcbdc60b4d0e7df7fe3e304e622010 (patch)
tree5bdc8a86c27df1c1b96a1af290858ead3785c82a /source/blender
parentaca2e6a739efdfe8c37dbfe182d5c4557c12ae5e (diff)
code cleanup: mask feather weight - add in checks for u==1 or u==0
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/mask.c66
1 files changed, 38 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 5f6bd862fc2..26e0f14e08b 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -780,47 +780,57 @@ void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u,
float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, float u)
{
MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point);
-
BezTriple *bezt = &point->bezt, *bezt_next;
- float cur_u, cur_w, next_u, next_w, fac;
- int i;
bezt_next = mask_spline_point_next_bezt(spline, points_array, point);
- if (!bezt_next)
+ if (!bezt_next) {
return bezt->weight;
+ }
+ else if (u <= 0.0) {
+ return bezt->weight;
+ }
+ else if (u >= 1.0f) {
+ return bezt_next->weight;
+ }
+ else {
+ float cur_u, cur_w, next_u, next_w, fac;
+ int i;
- for (i = 0; i < point->tot_uw + 1; i++) {
+ for (i = 0; i < point->tot_uw + 1; i++) {
- if (i == 0) {
- cur_u = 0.0f;
- cur_w = bezt->weight;
- }
- else {
- cur_u = point->uw[i - 1].u;
- cur_w = point->uw[i - 1].w;
+ if (i == 0) {
+ cur_u = 0.0f;
+ cur_w = bezt->weight;
+ }
+ else {
+ cur_u = point->uw[i - 1].u;
+ cur_w = point->uw[i - 1].w;
+ }
+
+ if (i == point->tot_uw) {
+ next_u = 1.0f;
+ next_w = bezt_next->weight;
+ }
+ else {
+ next_u = point->uw[i].u;
+ next_w = point->uw[i].w;
+ }
+
+ if (u >= cur_u && u <= next_u) {
+ break;
+ }
}
- if (i == point->tot_uw) {
- next_u = 1.0f;
- next_w = bezt_next->weight;
+ fac = (u - cur_u) / (next_u - cur_u);
+
+ if (spline->weight_interp == MASK_SPLINE_INTERP_EASE) {
+ return cur_w + (next_w - cur_w) * (3.0f * fac * fac - 2.0f * fac * fac * fac);
}
else {
- next_u = point->uw[i].u;
- next_w = point->uw[i].w;
- }
-
- if (u >= cur_u && u <= next_u) {
- break;
+ return (1.0f - fac) * cur_w + fac * next_w;
}
}
-
- fac = (u - cur_u) / (next_u - cur_u);
-
- if (spline->weight_interp == MASK_SPLINE_INTERP_EASE)
- return cur_w + (next_w - cur_w) * (3.0f * fac * fac - 2.0f * fac * fac * fac);
- else
- return (1.0f - fac) * cur_w + fac * next_w;
}
MaskSplinePointUW *BKE_mask_point_sort_uw(MaskSplinePoint *point, MaskSplinePointUW *uw)