[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47024] branches/soc-2011-tomato/source/ blender: fix for adding/ removing spline items with multiple splines in a mask-object
Campbell Barton
ideasman42 at gmail.com
Fri May 25 19:44:37 CEST 2012
Revision: 47024
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47024
Author: campbellbarton
Date: 2012-05-25 17:44:37 +0000 (Fri, 25 May 2012)
Log Message:
-----------
fix for adding/removing spline items with multiple splines in a mask-object
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-25 17:13:30 UTC (rev 47023)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h 2012-05-25 17:44:37 UTC (rev 47024)
@@ -110,6 +110,10 @@
void BKE_mask_object_shape_unlink(struct MaskObject *maskobj, struct MaskObjectShape *maskobj_shape);
void BKE_mask_object_shape_sort(struct MaskObject *maskobj);
+int BKE_mask_object_shape_spline_from_index(struct MaskObject *maskobj, int index,
+ struct MaskSpline **r_maskobj_shape, int *r_index);
+int BKE_mask_object_shape_spline_to_index(struct MaskObject *maskobj, struct MaskSpline *spline);
+
int BKE_mask_object_shape_spline_index(struct MaskObject *maskobj, int index,
struct MaskSpline **r_maskobj_shape, int *r_index);
void BKE_mask_object_shape_changed_add(struct MaskObject *maskobj, int index,
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-25 17:13:30 UTC (rev 47023)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-25 17:44:37 UTC (rev 47024)
@@ -1297,8 +1297,8 @@
BLI_sortlist(&maskobj->splines_shapes, mask_object_shape_sort_cb);
}
-int BKE_mask_object_shape_spline_index(MaskObject *maskobj, int index,
- MaskSpline **r_maskobj_shape, int *r_index)
+int BKE_mask_object_shape_spline_from_index(MaskObject *maskobj, int index,
+ MaskSpline **r_maskobj_shape, int *r_index)
{
MaskSpline *spline;
@@ -1314,6 +1314,20 @@
return FALSE;
}
+int BKE_mask_object_shape_spline_to_index(MaskObject *maskobj, MaskSpline *spline)
+{
+ MaskSpline *spline_iter;
+ int i_abs = 0;
+ for (spline_iter = maskobj->splines.first;
+ spline_iter && spline_iter != spline;
+ i_abs += spline_iter->tot_point, spline_iter = spline_iter->next)
+ {
+ /* pass */
+ }
+
+ return i_abs;
+}
+
/* basic 2D interpolation functions, could make more comprehensive later */
static void interp_weights_uv_v2_calc(float r_uv[2], const float pt[2], const float pt_a[2], const float pt_b[2])
{
@@ -1347,8 +1361,8 @@
MaskSpline *spline;
int spline_point_index;
- if (BKE_mask_object_shape_spline_index(maskobj, index,
- &spline, &spline_point_index))
+ if (BKE_mask_object_shape_spline_from_index(maskobj, index,
+ &spline, &spline_point_index))
{
/* sanity check */
/* the point has already been removed in this array so subtract one when comparing with the shapes */
@@ -1402,7 +1416,7 @@
mask_object_shape_from_mask_point(&spline->points[spline_point_index].bezt, fp);
- if (do_init_interpolate) {
+ if (do_init_interpolate && spline->tot_point > 2) {
for (i = 0; i < 3; i++) {
interp_weights_uv_v2_apply(uv[i],
&fp[i * 2],
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-25 17:13:30 UTC (rev 47023)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c 2012-05-25 17:44:37 UTC (rev 47024)
@@ -980,23 +980,9 @@
setup_vertex_point(C, mask, spline, new_point, co, tangent, NULL, TRUE);
+ /* TODO - we could pass the spline! */
+ BKE_mask_object_shape_changed_add(maskobj, BKE_mask_object_shape_spline_to_index(maskobj, spline) + point_index + 1, TRUE, TRUE);
- {
-
- /* this block could be a function */
- MaskSpline *spline_iter;
- int i_abs = 0;
- for (spline_iter = maskobj->splines.first;
- spline_iter && spline_iter != spline;
- spline_iter = spline_iter->next, i_abs += spline_iter->tot_point)
- {
- /* pass */
- }
-
- /* TODO - we could pass the spline! */
- BKE_mask_object_shape_changed_add(maskobj, i_abs + point_index + 1, TRUE, TRUE);
- }
-
maskobj->act_point = new_point;
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
@@ -1114,6 +1100,13 @@
maskobj->act_point = new_point;
setup_vertex_point(C, mask, spline, new_point, co, NULL, ref_point, FALSE);
+
+ {
+ //int point_index = (((int)(new_point - spline->points) + 1) % spline->tot_point);
+ int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
+ BKE_mask_object_shape_changed_add(maskobj, BKE_mask_object_shape_spline_to_index(maskobj, spline) + point_index, TRUE, TRUE);
+ }
+
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
return TRUE;
More information about the Bf-blender-cvs
mailing list