[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47183] branches/soc-2011-tomato/source/ blender: fix for using uninitialized memory when adding spline points, also fix for deleting points not working right.
Campbell Barton
ideasman42 at gmail.com
Tue May 29 16:54:40 CEST 2012
Revision: 47183
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47183
Author: campbellbarton
Date: 2012-05-29 14:54:40 +0000 (Tue, 29 May 2012)
Log Message:
-----------
fix for using uninitialized memory when adding spline points, also fix for deleting points not working right.
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-29 14:38:28 UTC (rev 47182)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h 2012-05-29 14:54:40 UTC (rev 47183)
@@ -90,6 +90,8 @@
/* parenting */
+void BKE_mask_update_display(struct Mask *mask, float ctime);
+
void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const int do_newframe);
void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene, const int do_newframe);
void BKE_mask_parent_init(struct MaskParent *parent);
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-29 14:38:28 UTC (rev 47182)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-29 14:54:40 UTC (rev 47183)
@@ -1232,22 +1232,52 @@
MaskSplinePoint *point_deform = &spline->points_deform[i];
float delta[2];
+ *point_deform = *point;
+ point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
+
if (BKE_mask_evaluate_parent_delta(&point->parent, ctime, delta)) {
-
- *point_deform = *point;
- point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
-
add_v2_v2(point_deform->bezt.vec[0], delta);
add_v2_v2(point_deform->bezt.vec[1], delta);
add_v2_v2(point_deform->bezt.vec[2], delta);
}
- else {
- *point_deform = *point;
- point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
+ }
+ }
+ }
+}
+
+/* the purpose of this function is to ensure spline->points_deform is never out of date.
+ * for now re-evaluate all. eventually this might work differently */
+void BKE_mask_update_display(Mask *mask, float ctime)
+{
+#if 0
+ MaskObject *maskobj;
+
+ for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
+ MaskSpline *spline;
+
+ for (spline = maskobj->splines.first; spline; spline = spline->next) {
+ if (spline->points_deform) {
+ int i = 0;
+
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point;
+
+ if (spline->points_deform) {
+ point = &spline->points_deform[i];
+ BKE_mask_point_free(point);
+ }
}
+ if (spline->points_deform) {
+ MEM_freeN(spline->points_deform);
+ }
+
+ spline->points_deform = NULL;
}
}
}
+#endif
+
+ BKE_mask_evaluate(mask, ctime, FALSE);
}
void BKE_mask_evaluate_all_masks(Main *bmain, float ctime, const int do_newframe)
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-29 14:38:28 UTC (rev 47182)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c 2012-05-29 14:54:40 UTC (rev 47183)
@@ -1230,6 +1230,9 @@
BKE_mask_calc_handle_point_auto(mask, spline, point, FALSE);
BKE_mask_calc_handle_point_auto(mask, spline, point_other, FALSE);
+ /* TODO: only update this spline */
+ BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
return OPERATOR_FINISHED;
}
@@ -1249,6 +1252,9 @@
}
}
+ /* TODO: only update this spline */
+ BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+
return OPERATOR_FINISHED;
}
@@ -1495,6 +1501,9 @@
}
}
+ /* TODO: only update edited splines */
+ BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
+
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
return OPERATOR_FINISHED;
More information about the Bf-blender-cvs
mailing list