[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47246] branches/soc-2011-tomato: Adds property to mask splines to allow them to be negated (black masks), still needs work in tracking.c

Peter Larabell xgl.asyliax at gmail.com
Wed May 30 23:15:17 CEST 2012


Revision: 47246
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47246
Author:   xglasyliax
Date:     2012-05-30 21:15:17 +0000 (Wed, 30 May 2012)
Log Message:
-----------
Adds property to mask splines to allow them to be negated (black masks), still needs work in tracking.c

Modified Paths:
--------------
    branches/soc-2011-tomato/intern/raskter/raskter.c
    branches/soc-2011-tomato/intern/raskter/raskter.h
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_mask.c

Modified: branches/soc-2011-tomato/intern/raskter/raskter.c
===================================================================
--- branches/soc-2011-tomato/intern/raskter/raskter.c	2012-05-30 21:09:50 UTC (rev 47245)
+++ branches/soc-2011-tomato/intern/raskter/raskter.c	2012-05-30 21:15:17 UTC (rev 47246)
@@ -171,7 +171,7 @@
  * for speed, but waiting on final design choices for curve-data before eliminating data the DEM code will need
  * if it ends up being coupled with this function.
  */
-int rast_scan_fill(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts)
+int rast_scan_fill(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, float fill_color)
 {
 	int x_curr;                 /* current pixel position in X */
 	int y_curr;                 /* current scan line being drawn */
@@ -308,11 +308,7 @@
 			if((y_curr >= 0) && (y_curr < ctx->rb.sizey)){
 				/* draw the pixels. */
 				for (; cpxl <= mpxl; cpxl++){
-					if(*cpxl < 0.5f){
-						*cpxl = 1.0f;
-					}else{
-						*cpxl = 0.0f;
-					}
+					*cpxl = fill_color;
 				}
 			}
 		}
@@ -388,7 +384,7 @@
 	return 1;
 }
 
-int PLX_raskterize(float *verts, int num, float *buf, int buf_x, int buf_y) {
+int PLX_raskterize(float *verts, int num, float *buf, int buf_x, int buf_y, float fill_color) {
 	int i;                                       /* i: Loop counter. */
 	struct poly_vert *ply;                       /* ply: Pointer to a list of integer buffer-space vertex coordinates. */
 	struct r_fill_context ctx = {0};
@@ -421,7 +417,7 @@
 	ctx.rb.sizex = buf_x;                        /* Set the output buffer size in X. (width) */
 	ctx.rb.sizey = buf_y;                        /* Set the output buffer size in Y. (height) */
 
-	i = rast_scan_fill(&ctx, ply, num);                /* Call our rasterizer, passing in the integer coords for each vert. */
+	i = rast_scan_fill(&ctx, ply, num, fill_color);                /* Call our rasterizer, passing in the integer coords for each vert. */
 	free(ply);                                   /* Free the memory allocated for the integer coordinate table. */
 	return(i);                                   /* Return the value returned by the rasterizer. */
 }

Modified: branches/soc-2011-tomato/intern/raskter/raskter.h
===================================================================
--- branches/soc-2011-tomato/intern/raskter/raskter.h	2012-05-30 21:09:50 UTC (rev 47245)
+++ branches/soc-2011-tomato/intern/raskter/raskter.h	2012-05-30 21:15:17 UTC (rev 47246)
@@ -48,7 +48,7 @@
 extern "C" {
 #endif
 
-int PLX_raskterize(float *verts, int num, float *buf, int buf_x, int buf_y);
+int PLX_raskterize(float *verts, int num, float *buf, int buf_x, int buf_y, float fill_color);
 
 #ifdef __cplusplus
 }

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2012-05-30 21:09:50 UTC (rev 47245)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2012-05-30 21:15:17 UTC (rev 47246)
@@ -618,6 +618,7 @@
         col = layout.column()
         col.prop(spline, "weight_interpolation")
         col.prop(spline, "use_cyclic")
+        col.prop(spline, "mask_negate")
 
 
 class CLIP_PT_active_mask_point(Panel):

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c	2012-05-30 21:09:50 UTC (rev 47245)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c	2012-05-30 21:15:17 UTC (rev 47246)
@@ -1754,7 +1754,7 @@
 			}
 
 			if (tot_diff_point) {
-				PLX_raskterize(diff_points, tot_diff_point, buffer, width, height);
+				PLX_raskterize(diff_points, tot_diff_point, buffer, width, height, (spline->flag & MASK_SPLINE_NEGATE)?0.0f:1.0f);
 
 				MEM_freeN(diff_points);
 			}

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2012-05-30 21:09:50 UTC (rev 47245)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2012-05-30 21:15:17 UTC (rev 47246)
@@ -1322,9 +1322,9 @@
 					fp[0] = stroke_points[i].x * width / ibuf->x - marker->search_min[0];
 					fp[1] = stroke_points[i].y * height * aspy / ibuf->x - marker->search_min[1];
 				}
+				/* TODO: not sure best method to get spline->flag here... to tell if mask is negative color */
+				PLX_raskterize(mask_points, stroke->totpoints, mask, ibuf->x, ibuf->y, /* TODO: this is color */ 1.0f);
 
-				PLX_raskterize(mask_points, stroke->totpoints, mask, ibuf->x, ibuf->y);
-
 				MEM_freeN(mask_points);
 			}
 

Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h	2012-05-30 21:09:50 UTC (rev 47245)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h	2012-05-30 21:15:17 UTC (rev 47246)
@@ -120,6 +120,7 @@
 /* MaskSpline->flag */
 /* reserve (1 << 0) for SELECT */
 #define MASK_SPLINE_CYCLIC  (1 << 1)
+#define MASK_SPLINE_NEGATE  (1 << 2)
 
 /* MaskSpline->weight_interp */
 #define MASK_SPLINE_INTERP_LINEAR   1

Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_mask.c	2012-05-30 21:09:50 UTC (rev 47245)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_mask.c	2012-05-30 21:15:17 UTC (rev 47246)
@@ -506,6 +506,13 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", MASK_SPLINE_CYCLIC);
 	RNA_def_property_ui_text(prop, "Cyclic", "Make this spline a closed loop");
 	RNA_def_property_update(prop, 0, "rna_Mask_update_data");
+
+	/* negative mask? */
+	prop = RNA_def_property(srna, "mask_negate", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", MASK_SPLINE_NEGATE);
+	RNA_def_property_ui_text(prop, "Negate", "Make this spline subtract from mask");
+	RNA_def_property_update(prop, 0, "rna_Mask_update_data");
 }
 
 static void rna_def_mask_object(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list