[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46701] branches/soc-2011-tomato/source/ blender: improvements to mask editor path editing
Campbell Barton
ideasman42 at gmail.com
Wed May 16 20:05:35 CEST 2012
Revision: 46701
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46701
Author: campbellbarton
Date: 2012-05-16 18:05:35 +0000 (Wed, 16 May 2012)
Log Message:
-----------
improvements to mask editor path editing
- adding new points de-selects previous so Ctrl+Click+Drag works usefully.
- cyclic curves now extrude properly
- adding new points inbetween existing now use the surrounding points handle length.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h 2012-05-16 16:41:51 UTC (rev 46700)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h 2012-05-16 18:05:35 UTC (rev 46701)
@@ -82,9 +82,9 @@
void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime);
void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene);
void BKE_mask_parent_init(struct MaskParent *parent);
+void BKE_mask_calc_handle_adjacent_length(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point);
void BKE_mask_calc_handle_point(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point);
-void BKE_mask_calc_handle_point_auto(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point,
- const short do_length_match);
+void BKE_mask_calc_handle_point_auto(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point);
void BKE_mask_get_handle_point_adjacent(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point,
struct MaskSplinePoint **r_point_prev, struct MaskSplinePoint **r_point_next);
void BKE_mask_calc_handles(struct Mask *mask);
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-16 16:41:51 UTC (rev 46700)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-16 18:05:35 UTC (rev 46701)
@@ -758,7 +758,7 @@
{
BezTriple *bezt = &point->bezt;
BezTriple *prev_bezt = NULL, *next_bezt = NULL;
- int handle_type = bezt->h1;
+ //int handle_type = bezt->h1;
if (prev_point)
prev_bezt = &prev_point->bezt;
@@ -766,6 +766,9 @@
if (next_point)
next_bezt = &next_point->bezt;
+#if 1
+ BKE_nurb_handle_calc(bezt, prev_bezt, next_bezt, 0);
+#else
if (handle_type == HD_VECT) {
BKE_nurb_handle_calc(bezt, prev_bezt, next_bezt, 0);
}
@@ -792,6 +795,7 @@
add_v3_v3v3(bezt->vec[0], bezt->vec[1], h);
sub_v3_v3v3(bezt->vec[2], bezt->vec[1], h);
}
+#endif
}
void BKE_mask_get_handle_point_adjacent(Mask *UNUSED(mask), MaskSpline *spline, MaskSplinePoint *point,
@@ -851,85 +855,55 @@
}
}
+void BKE_mask_calc_handle_adjacent_length(Mask *mask, MaskSpline *spline, MaskSplinePoint *point)
+{
+ /* TODO! - make this aspect aware! */
+ int length_tot = 0;
+ float length_average = 0.0f;
+
+ MaskSplinePoint *prev_point, *next_point;
+ BKE_mask_get_handle_point_adjacent(mask, spline, point,
+ &prev_point, &next_point);
+
+ if (prev_point) {
+ length_average += len_v2v2(prev_point->bezt.vec[0], prev_point->bezt.vec[1]);
+ length_tot++;
+ }
+
+ if (next_point) {
+ length_average += len_v2v2(next_point->bezt.vec[2], next_point->bezt.vec[1]);
+ length_tot++;
+ }
+
+ if (length_tot) {
+ length_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);
+ }
+}
+
+
/**
* \brief Resets auto handles even for non-auto bezier points
*
* Useful for giving sane defaults.
*/
-void BKE_mask_calc_handle_point_auto(Mask *mask, MaskSpline *spline, MaskSplinePoint *point,
- const short do_length_match)
+void BKE_mask_calc_handle_point_auto(Mask *mask, MaskSpline *spline, MaskSplinePoint *point)
{
+ /* TODO! - make this aspect aware! */
MaskSplinePoint *prev_point, *next_point;
-
const char h_back[2] = {point->bezt.h1, point->bezt.h2};
-int i1=999, i2=999;
+
BKE_mask_get_handle_point_adjacent(mask, spline, point,
&prev_point, &next_point);
- if (prev_point) i1 = (int)(prev_point - spline->points);
- if (next_point) i2 = (int)(next_point - spline->points);
-
-printf("found points %d %d : %d\n", i1, i2, (int)(point - spline->points));
-
point->bezt.h1 = HD_AUTO;
point->bezt.h2 = HD_AUTO;
mask_calc_point_handle(point, prev_point, next_point);
point->bezt.h1 = h_back[0];
point->bezt.h2 = h_back[1];
- mask_calc_point_handle(point, prev_point, next_point);
-
- /* TODO! - make this aspect aware! */
- /* TODO! - not working right with cyclic curves, need to investigate! */
- if (do_length_match) {
- int length_tot = 0;
- float length_average = 0.0f;
-
- if (prev_point) {
- length_average += len_v2v2(prev_point->bezt.vec[0], prev_point->bezt.vec[1]);
- length_tot++;
- }
-
- if (next_point) {
- length_average += len_v2v2(next_point->bezt.vec[2], next_point->bezt.vec[1]);
- length_tot++;
- }
-
- if (length_tot) {
- length_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);
- }
- }
-
- mask_calc_point_handle(point, prev_point, next_point);
-
- // XXX
- if ((point->bezt.h1 == HD_ALIGN || point->bezt.h2 == HD_ALIGN) ){
- float vec[2];
- sub_v2_v2(point->bezt.vec[0], point->bezt.vec[1]);
- sub_v2_v2(point->bezt.vec[2], point->bezt.vec[1]);
-
- copy_v2_v2(vec, point->bezt.vec[0]);
- point->bezt.vec[0][0] = vec[1];
- point->bezt.vec[0][0] = -vec[0];
- add_v2_v2(point->bezt.vec[0], point->bezt.vec[1]);
-
- copy_v2_v2(vec, point->bezt.vec[2]);
- point->bezt.vec[2][0] = vec[1];
- point->bezt.vec[2][0] = -vec[0];
- add_v2_v2(point->bezt.vec[2], point->bezt.vec[1]);
-
- copy_v2_v2(vec, point->bezt.vec[2]);
- copy_v2_v2(point->bezt.vec[0], vec);
- copy_v2_v2(point->bezt.vec[2], point->bezt.vec[0]);
-
-
-
- }
-
- mask_calc_point_handle(point, prev_point, next_point);
}
void BKE_mask_calc_handles(Mask *mask)
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c 2012-05-16 16:41:51 UTC (rev 46700)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c 2012-05-16 18:05:35 UTC (rev 46701)
@@ -1146,6 +1146,10 @@
sub_v2_v2(bezt->vec[0], vec);
add_v2_v2(bezt->vec[2], vec);
+
+ if (reference_adjacent) {
+ BKE_mask_calc_handle_adjacent_length(mask, spline, new_point);
+ }
}
else {
@@ -1196,10 +1200,10 @@
add_v2_v2(bezt->vec[0], vec);
sub_v2_v2(bezt->vec[2], vec);
#else
- BKE_mask_calc_handle_point_auto(mask, spline, new_point, TRUE);
+ BKE_mask_calc_handle_point_auto(mask, spline, new_point);
+ BKE_mask_calc_handle_adjacent_length(mask, spline, new_point);
#endif
-
}
BKE_mask_parent_init(&new_point->parent);
@@ -1223,10 +1227,7 @@
MaskSplinePoint *new_point_array, *new_point;
int point_index = point - spline->points;
- /* adding _could_ deselect, for now don't */
-#if 0
toggle_selection_all(mask, SEL_DESELECT);
-#endif
new_point_array = MEM_callocN(sizeof(MaskSplinePoint) * (spline->tot_point + 1), "add mask vert points");
@@ -1302,10 +1303,7 @@
MaskSplinePoint *point;
MaskSplinePoint *new_point = NULL, *ref_point = NULL;
- /* adding _could_ deselect, for now don't */
-#if 0
toggle_selection_all(mask, SEL_DESELECT);
-#endif
shape = BKE_mask_shape_active(mask);
More information about the Bf-blender-cvs
mailing list