[Bf-blender-cvs] [108ad34] master: Mask: option not to treat overlapping curves as holes

Campbell Barton noreply at git.blender.org
Thu Feb 13 01:49:28 CET 2014


Commit: 108ad3442960ef6ead3015736b3de679146f7a8d
Author: Campbell Barton
Date:   Thu Feb 13 11:47:00 2014 +1100
https://developer.blender.org/rB108ad3442960ef6ead3015736b3de679146f7a8d

Mask: option not to treat overlapping curves as holes

===================================================================

M	release/scripts/startup/bl_ui/properties_mask_common.py
M	source/blender/blenkernel/intern/mask.c
M	source/blender/blenkernel/intern/mask_rasterize.c
M	source/blender/blenlib/intern/scanfill.c
M	source/blender/makesdna/DNA_mask_types.h
M	source/blender/makesrna/intern/rna_mask.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py
index 0efff3b..7e8873e 100644
--- a/release/scripts/startup/bl_ui/properties_mask_common.py
+++ b/release/scripts/startup/bl_ui/properties_mask_common.py
@@ -107,6 +107,9 @@ class MASK_PT_layers:
             layout.prop(active_layer, "blend")
             layout.prop(active_layer, "falloff")
 
+            row = layout.row(align=True)
+            layout.prop(active_layer, "use_fill_holes")
+
 
 class MASK_PT_spline():
     # subclasses must define...
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 23c0401..fab7ebf 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -150,6 +150,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
 
 	masklay->blend = MASK_BLEND_MERGE_ADD;
 	masklay->alpha = 1.0f;
+	masklay->flag = MASK_LAYERFLAG_FILL_DISCRETE;
 
 	return masklay;
 }
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index e1e310f..694f892 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -916,6 +916,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
 			unsigned int sf_tri_tot;
 			rctf bounds;
 			unsigned int face_index;
+			int scanfill_flag = 0;
 
 			/* now we have all the splines */
 			face_coords = MEM_mallocN((sizeof(float) * 3) * sf_vert_tot, "maskrast_face_coords");
@@ -941,7 +942,10 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
 			}
 
 			/* main scan-fill */
-			sf_tri_tot = (unsigned int)BLI_scanfill_calc_ex(&sf_ctx, BLI_SCANFILL_CALC_HOLES, zvec);
+			if ((masklay->flag & MASK_LAYERFLAG_FILL_DISCRETE) == 0)
+				scanfill_flag |= BLI_SCANFILL_CALC_HOLES;
+
+			sf_tri_tot = (unsigned int)BLI_scanfill_calc_ex(&sf_ctx, scanfill_flag, zvec);
 
 			face_array = MEM_mallocN(sizeof(*face_array) * ((size_t)sf_tri_tot + (size_t)tot_feather_quads), "maskrast_face_index");
 			face_index = 0;
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index ae0760e..a1d4859 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -1058,7 +1058,7 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
 	 *    the edgefill itself has good auto-hole detection)
 	 * WATCH IT: ONLY WORKS WITH SORTED POLYS!!! */
 	
-	if (poly > 1) {
+	if ((flag & BLI_SCANFILL_CALC_HOLES) && (poly > 1)) {
 		unsigned short *polycache, *pc;
 
 		/* so, sort first */
diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h
index a72e287..642bc73 100644
--- a/source/blender/makesdna/DNA_mask_types.h
+++ b/source/blender/makesdna/DNA_mask_types.h
@@ -216,7 +216,10 @@ enum {
 /* masklay->flag */
 enum {
 	MASK_LAYERFLAG_LOCKED = (1 << 4),
-	MASK_LAYERFLAG_SELECT = (1 << 5)
+	MASK_LAYERFLAG_SELECT = (1 << 5),
+
+	/* no holes */
+	MASK_LAYERFLAG_FILL_DISCRETE = (1 << 6),
 };
 
 /* masklay_shape->flag */
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index 16cfbbd..0e4db5b 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -884,6 +884,11 @@ static void rna_def_mask_layer(BlenderRNA *brna)
 	RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
 	RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
 
+	/* filling options */
+	prop = RNA_def_property(srna, "use_fill_holes", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MASK_LAYERFLAG_FILL_DISCRETE);
+	RNA_def_property_ui_text(prop, "Calculate Holes", "Calculate holes when filling overlapping curves");
+	RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
 }
 
 static void rna_def_masklayers(BlenderRNA *brna, PropertyRNA *cprop)




More information about the Bf-blender-cvs mailing list