[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47462] trunk/blender/source/blender: mask point slide now accounts for scaled bezier weights,
Campbell Barton
ideasman42 at gmail.com
Tue Jun 5 14:51:24 CEST 2012
Revision: 47462
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47462
Author: campbellbarton
Date: 2012-06-05 12:51:11 +0000 (Tue, 05 Jun 2012)
Log Message:
-----------
mask point slide now accounts for scaled bezier weights,
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_mask.h
trunk/blender/source/blender/blenkernel/intern/mask.c
trunk/blender/source/blender/editors/mask/mask_ops.c
Modified: trunk/blender/source/blender/blenkernel/BKE_mask.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_mask.h 2012-06-05 12:33:20 UTC (rev 47461)
+++ trunk/blender/source/blender/blenkernel/BKE_mask.h 2012-06-05 12:51:11 UTC (rev 47462)
@@ -98,6 +98,7 @@
void BKE_mask_point_segment_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float co[2]);
void BKE_mask_point_normal(struct MaskSpline *spline, struct MaskSplinePoint *point,
float u, float n[2]);
+float BKE_mask_point_weight_scalar(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u);
float BKE_mask_point_weight(struct MaskSpline *spline, struct MaskSplinePoint *point, float u);
struct MaskSplinePointUW *BKE_mask_point_sort_uw(struct MaskSplinePoint *point, struct MaskSplinePointUW *uw);
void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w);
Modified: trunk/blender/source/blender/blenkernel/intern/mask.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask.c 2012-06-05 12:33:20 UTC (rev 47461)
+++ trunk/blender/source/blender/blenkernel/intern/mask.c 2012-06-05 12:51:11 UTC (rev 47462)
@@ -782,7 +782,7 @@
return (bezt->weight * (1.0f - u)) + (bezt_next->weight * u);
}
-float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, float u)
+float BKE_mask_point_weight_scalar(MaskSpline *spline, MaskSplinePoint *point, const float u)
{
MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point);
BezTriple *bezt = &point->bezt, *bezt_next;
@@ -799,6 +799,27 @@
return bezt_next->weight;
}
else {
+ return mask_point_interp_weight(bezt, bezt_next, u);
+ }
+}
+
+float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const float u)
+{
+ MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point);
+ BezTriple *bezt = &point->bezt, *bezt_next;
+
+ bezt_next = mask_spline_point_next_bezt(spline, points_array, point);
+
+ 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;
Modified: trunk/blender/source/blender/editors/mask/mask_ops.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_ops.c 2012-06-05 12:33:20 UTC (rev 47461)
+++ trunk/blender/source/blender/editors/mask/mask_ops.c 2012-06-05 12:51:11 UTC (rev 47462)
@@ -387,15 +387,18 @@
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
- int j;
if (point->bezt.weight != 0.0f)
return FALSE;
+ /* comment for now. if all bezt weights are zero - this is as good-as initial */
+#if 0
+ int j;
for (j = 0; j < point->tot_uw; j++) {
if (point->uw[j].w != 0.0f)
return FALSE;
}
+#endif
}
return TRUE;
@@ -454,25 +457,21 @@
if (uw) {
float co[2];
+ float weight_scalar = BKE_mask_point_weight_scalar(spline, point, uw->u);
- customdata->weight = point->bezt.weight;
-
customdata->weight = uw->w;
BKE_mask_point_segment_co(spline, point, uw->u, co);
BKE_mask_point_normal(spline, point, uw->u, customdata->no);
- customdata->feather[0] = co[0] + customdata->no[0] * uw->w;
- customdata->feather[1] = co[1] + customdata->no[1] * uw->w;
+ madd_v2_v2v2fl(customdata->feather, co, customdata->no, uw->w * weight_scalar);
}
else {
BezTriple *bezt = &point->bezt;
+ customdata->weight = bezt->weight;
BKE_mask_point_normal(spline, point, 0.0f, customdata->no);
- customdata->feather[0] = bezt->vec[1][0] + customdata->no[0] * bezt->weight;
- customdata->feather[1] = bezt->vec[1][1] + customdata->no[1] * bezt->weight;
-
- customdata->weight = bezt->weight;
+ madd_v2_v2v2fl(customdata->feather, bezt->vec[1], customdata->no, bezt->weight);
}
if (customdata->action == SLIDE_ACTION_FEATHER)
@@ -533,17 +532,20 @@
for (i = 0; i < data->spline->tot_point; i++) {
MaskSplinePoint *point = &data->spline->points[i];
MaskSplinePoint *orig_point = &data->orig_spline->points[i];
- int j;
point->bezt.weight = orig_point->bezt.weight + delta;
if (point->bezt.weight < 0.0f)
point->bezt.weight = 0.0f;
+ /* not needed anymore */
+#if 0
+ int j;
for (j = 0; j < point->tot_uw; j++) {
point->uw[j].w = orig_point->uw[j].w + delta;
if (point->uw[j].w < 0.0f)
point->uw[j].w = 0.0f;
}
+#endif
}
}
@@ -645,6 +647,7 @@
else if (data->action == SLIDE_ACTION_FEATHER) {
float vec[2], no[2], p[2], c[2], w, offco[2];
float *weight = NULL;
+ float weight_scalar = 1.0f;
int overall_feather = data->overall_feather || data->initial_feather;
add_v2_v2v2(offco, data->feather, dco);
@@ -679,12 +682,18 @@
data->uw = BKE_mask_point_sort_uw(data->point, data->uw);
weight = &data->uw->w;
+ weight_scalar = BKE_mask_point_weight_scalar(data->spline, data->point, u);
+ if (weight_scalar != 0.0f) {
+ weight_scalar = 1.0f / weight_scalar;
+ }
+
BKE_mask_point_normal(data->spline, data->point, data->uw->u, no);
BKE_mask_point_segment_co(data->spline, data->point, data->uw->u, p);
}
}
else {
weight = &bezt->weight;
+ /* weight_scalar = 1.0f; keep as is */
copy_v2_v2(no, data->no);
copy_v2_v2(p, bezt->vec[1]);
}
@@ -707,7 +716,7 @@
/* restore weight for currently sliding point, so orig_spline would be created
* with original weights used
*/
- *weight = data->weight;
+ *weight = data->weight * weight_scalar;
data->orig_spline = BKE_mask_spline_copy(data->spline);
}
@@ -726,7 +735,9 @@
data->orig_spline = NULL;
}
- *weight = w;
+ if (weight_scalar != 0.0f) {
+ *weight = w * weight_scalar;
+ }
}
}
}
More information about the Bf-blender-cvs
mailing list