[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50245] branches/soc-2011-tomato: svn merge ^/trunk/blender -r50240:50244
Campbell Barton
ideasman42 at gmail.com
Mon Aug 27 11:46:50 CEST 2012
Revision: 50245
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50245
Author: campbellbarton
Date: 2012-08-27 09:46:49 +0000 (Mon, 27 Aug 2012)
Log Message:
-----------
svn merge ^/trunk/blender -r50240:50244
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50240
Modified Paths:
--------------
branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_mask_common.py
branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_evaluate.c
branches/soc-2011-tomato/source/blender/blenlib/BLI_math_vector.h
branches/soc-2011-tomato/source/blender/blenlib/intern/math_vector.c
branches/soc-2011-tomato/source/blender/editors/space_sequencer/sequencer_edit.c
branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_mask.c
Property Changed:
----------------
branches/soc-2011-tomato/
branches/soc-2011-tomato/source/blender/editors/interface/interface.c
branches/soc-2011-tomato/source/blender/editors/space_outliner/
Property changes on: branches/soc-2011-tomato
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/vgroup_modifiers:38694-39989
/trunk/blender:36831-50240
+ /branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/vgroup_modifiers:38694-39989
/trunk/blender:36831-50244
Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_mask_common.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_mask_common.py 2012-08-27 09:46:08 UTC (rev 50244)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_mask_common.py 2012-08-27 09:46:49 UTC (rev 50245)
@@ -121,6 +121,7 @@
spline = mask.layers.active.splines.active
col = layout.column()
+ col.prop(spline, "offset_mode")
col.prop(spline, "weight_interpolation")
row = col.row()
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-08-27 09:46:08 UTC (rev 50244)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-08-27 09:46:49 UTC (rev 50245)
@@ -1194,17 +1194,6 @@
mask_calc_point_handle(point, point_prev, point_next);
}
-static void enforce_dist_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);
- }
-}
-
void BKE_mask_calc_handle_adjacent_interp(MaskSpline *spline, MaskSplinePoint *point, const float u)
{
/* TODO! - make this interpolate between siblings - not always midpoint! */
@@ -1246,8 +1235,8 @@
length_average /= (float)length_tot;
weight_average /= (float)length_tot;
- enforce_dist_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average);
- enforce_dist_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average);
+ dist_ensure_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average);
+ dist_ensure_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average);
point->bezt.weight = weight_average;
}
}
@@ -1279,8 +1268,8 @@
/* preserve length by applying it back */
if (do_recalc_length == FALSE) {
- enforce_dist_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average);
- enforce_dist_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average);
+ dist_ensure_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average);
+ dist_ensure_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average);
}
}
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_evaluate.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_evaluate.c 2012-08-27 09:46:08 UTC (rev 50244)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_evaluate.c 2012-08-27 09:46:49 UTC (rev 50245)
@@ -507,15 +507,12 @@
#undef BUCKET_INDEX
}
-/**
- * values align with #BKE_mask_spline_differentiate_with_resolution_ex
- * when \a resol arguments match.
- */
-float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline,
- int *tot_feather_point,
- const unsigned int resol,
- const int do_feather_isect
- ))[2]
+/** only called from #BKE_mask_spline_feather_differentiated_points_with_resolution_ex() ! */
+static float (*mask_spline_feather_differentiated_points_with_resolution_ex__even(MaskSpline *spline,
+ int *tot_feather_point,
+ const unsigned int resol,
+ const int do_feather_isect
+ ))[2]
{
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
MaskSplinePoint *point_curr, *point_prev;
@@ -583,6 +580,161 @@
return feather;
}
+/** only called from #BKE_mask_spline_feather_differentiated_points_with_resolution_ex() ! */
+static float (*mask_spline_feather_differentiated_points_with_resolution_ex__double(MaskSpline *spline,
+ int *tot_feather_point,
+ const unsigned int resol,
+ const int do_feather_isect
+ ))[2]
+{
+ MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
+
+ MaskSplinePoint *point_curr, *point_prev;
+ float (*feather)[2], (*fp)[2];
+ const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol);
+ int a;
+
+ if (spline->tot_point <= 1) {
+ /* nothing to differentiate */
+ *tot_feather_point = 0;
+ return NULL;
+ }
+
+ /* len+1 because of 'forward_diff_bezier' function */
+ *tot_feather_point = tot;
+ feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline vets");
+
+ a = spline->tot_point - 1;
+ if (spline->flag & MASK_SPLINE_CYCLIC)
+ a++;
+
+ point_prev = points_array;
+ point_curr = point_prev + 1;
+
+ while (a--) {
+ BezTriple local_prevbezt;
+ BezTriple local_bezt;
+ float point_prev_n[2], point_curr_n[2], tvec[2];
+ float weight_prev, weight_curr;
+ float len_base, len_feather, len_scalar;
+
+ BezTriple *bezt_prev;
+ BezTriple *bezt_curr;
+ int j;
+
+ if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC))
+ point_curr = points_array;
+
+ bezt_prev = &point_prev->bezt;
+ bezt_curr = &point_curr->bezt;
+
+ /* modified copy for feather */
+ local_prevbezt = *bezt_prev;
+ local_bezt = *bezt_curr;
+
+ bezt_prev = &local_prevbezt;
+ bezt_curr = &local_bezt;
+
+ /* calc the normals */
+ sub_v2_v2v2(tvec, bezt_prev->vec[1], bezt_prev->vec[0]);
+ normalize_v2(tvec);
+ point_prev_n[0] = -tvec[1];
+ point_prev_n[1] = tvec[0];
+
+ sub_v2_v2v2(tvec, bezt_curr->vec[1], bezt_curr->vec[0]);
+ normalize_v2(tvec);
+ point_curr_n[0] = -tvec[1];
+ point_curr_n[1] = tvec[0];
+
+ weight_prev = bezt_prev->weight;
+ weight_curr = bezt_curr->weight;
+
+ mul_v2_fl(point_prev_n, weight_prev);
+ mul_v2_fl(point_curr_n, weight_curr);
+
+ /* before we transform verts */
+ len_base = len_v2v2(bezt_prev->vec[1], bezt_curr->vec[1]);
+
+ // add_v2_v2(bezt_prev->vec[0], point_prev_n); // not needed
+ add_v2_v2(bezt_prev->vec[1], point_prev_n);
+ add_v2_v2(bezt_prev->vec[2], point_prev_n);
+
+ add_v2_v2(bezt_curr->vec[0], point_curr_n);
+ add_v2_v2(bezt_curr->vec[1], point_curr_n);
+ // add_v2_v2(bezt_curr->vec[2], point_curr_n); // not needed
+
+ len_feather = len_v2v2(bezt_prev->vec[1], bezt_curr->vec[1]);
+
+ /* scale by chane in length */
+ len_scalar = len_feather / len_base;
+ dist_ensure_v2_v2fl(bezt_prev->vec[2], bezt_prev->vec[1], len_scalar * len_v2v2(bezt_prev->vec[2], bezt_prev->vec[1]));
+ dist_ensure_v2_v2fl(bezt_curr->vec[0], bezt_curr->vec[1], len_scalar * len_v2v2(bezt_curr->vec[0], bezt_curr->vec[1]));
+
+
+ for (j = 0; j < 2; j++) {
+ BKE_curve_forward_diff_bezier(bezt_prev->vec[1][j], bezt_prev->vec[2][j],
+ bezt_curr->vec[0][j], bezt_curr->vec[1][j],
+ &(*fp)[j], resol, 2 * sizeof(float));
+ }
+
+
+ /* scale by the uw's */
+ if (point_prev->tot_uw) {
+ for (j = 0; j < resol; j++, fp++) {
+ float u = (float) j / resol;
+ float weight_uw, weight_scalar;
+ float co[2];
+
+ /* TODO - these calls all calculate similar things
+ * could be unified for some speed */
+ BKE_mask_point_segment_co(spline, point_prev, u, co);
+
+ weight_uw = BKE_mask_point_weight(spline, point_prev, u);
+ weight_scalar = BKE_mask_point_weight_scalar(spline, point_prev, u);
+
+ dist_ensure_v2_v2fl(*fp, co, len_v2v2(*fp, co) * (weight_uw / weight_scalar));
+ }
+ }
+ else {
+ fp += resol;
+ }
+
+ if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) {
+ copy_v2_v2(*fp, bezt_curr->vec[1]);
+ }
+
+ point_prev = point_curr;
+ point_curr++;
+ }
+
+ if ((spline->flag & MASK_SPLINE_NOINTERSECT) && do_feather_isect) {
+ BKE_mask_spline_feather_collapse_inner_loops(spline, feather, tot);
+ }
+
+ return feather;
+}
+
+/**
+ * values align with #BKE_mask_spline_differentiate_with_resolution_ex
+ * when \a resol arguments match.
+ */
+float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline,
+ int *tot_feather_point,
+ const unsigned int resol,
+ const int do_feather_isect
+ ))[2]
+{
+ switch (spline->offset_mode) {
+ case MASK_SPLINE_OFFSET_EVEN:
+ return mask_spline_feather_differentiated_points_with_resolution_ex__even(spline, tot_feather_point, resol, do_feather_isect);
+ break;
+ case MASK_SPLINE_OFFSET_SMOOTH:
+ default:
+ return mask_spline_feather_differentiated_points_with_resolution_ex__double(spline, tot_feather_point, resol, do_feather_isect);
+ break;
+ }
+}
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list