[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29893] branches/soc-2010-nicolasbishop/ source/blender: * Added DNA/RNA/UI for enabling and disabling mask layers.

Nicholas Bishop nicholasbishop at gmail.com
Sat Jul 3 09:07:55 CEST 2010


Revision: 29893
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29893
Author:   nicholasbishop
Date:     2010-07-03 09:07:54 +0200 (Sat, 03 Jul 2010)

Log Message:
-----------
* Added DNA/RNA/UI for enabling and disabling mask layers.

Modified Paths:
--------------
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c
    branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h
    branches/soc-2010-nicolasbishop/source/blender/editors/interface/interface_templates.c
    branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
    branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_customdata_types.h
    branches/soc-2010-nicolasbishop/source/blender/makesrna/RNA_access.h
    branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_mesh.c

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c	2010-07-03 07:03:21 UTC (rev 29892)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c	2010-07-03 07:07:54 UTC (rev 29893)
@@ -1245,7 +1245,7 @@
 		data->layers[index] = data->layers[index - 1];
 
 	data->layers[index].type = type;
-	data->layers[index].flag = flag;
+	data->layers[index].flag = flag | CD_FLAG_ENABLED;
 	data->layers[index].data = newlayerdata;
 	data->layers[index].strength = 1;
 

Modified: branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h	2010-07-03 07:03:21 UTC (rev 29892)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h	2010-07-03 07:07:54 UTC (rev 29893)
@@ -228,6 +228,8 @@
 		if(vi.pmask_layer_count) { \
 			vi.pmask_first_layer = CustomData_get_layer_index(vi.vdata, CD_PAINTMASK); \
 			vi.pmask_active_layer = CustomData_get_active_layer_index(vi.vdata, CD_PAINTMASK); \
+			if(vi.pmask_active_layer != -1 && !(vi.vdata->layers[vi.pmask_active_layer].flag & CD_FLAG_ENABLED)) \
+				vi.pmask_active_layer = -1; \
 		} \
 	}\
 	\
@@ -262,6 +264,7 @@
 						vi.mask_combined= 0; \
 						for(j=0; j<vi.gridkey->mask; ++j) { \
 							CustomDataLayer *cdl= vi.vdata->layers + vi.pmask_first_layer + j; \
+							if(!(cdl->flag & CD_FLAG_ENABLED)) continue; \
 							vi.mask_combined+= GRIDELEM_MASK(vi.grid, vi.gridkey)[j] * cdl->strength; \
 						} \
 						CLAMP(vi.mask_combined, 0, 1); \
@@ -282,6 +285,7 @@
 						vi.mask_combined= 0; \
 						for(j=0; j<vi.pmask_layer_count; ++j) { \
 							CustomDataLayer *cdl= vi.vdata->layers + vi.pmask_first_layer + j; \
+							if(!(cdl->flag & CD_FLAG_ENABLED)) continue; \
 							vi.mask_combined+= \
 								((float*)cdl->data)[vi.vert_indices[vi.gx]] * cdl->strength; \
 						} \

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/interface/interface_templates.c	2010-07-03 07:03:21 UTC (rev 29892)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/interface/interface_templates.c	2010-07-03 07:07:54 UTC (rev 29893)
@@ -2183,6 +2183,11 @@
 		//uiItemR(row, itemptr, "mute", 0, "", ICON_MUTE_IPO_OFF);
 		uiBlockSetEmboss(block, UI_EMBOSS);
 	}
+	else if(itemptr->type == &RNA_MeshPaintMaskLayer) {
+		uiItemL(sub, name, icon);
+		uiBlockSetEmboss(block, UI_EMBOSS);
+		uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "enabled", 0, 0, 0, 0, 0, NULL);
+	}
 	else
 		uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
 

Modified: branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c	2010-07-03 07:03:21 UTC (rev 29892)
+++ branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c	2010-07-03 07:07:54 UTC (rev 29893)
@@ -481,6 +481,7 @@
 			float v = 0;
 			for(j = 0; j < pmask_totlayer; ++j) {
 				CustomDataLayer *cdl = &vdata->layers[pmask_first_layer + j];
+				if(!(cdl->flag & CD_FLAG_ENABLED)) continue;
 				v += ((float*)cdl->data)[vert_indices[i]] * cdl->strength;
 			}
 
@@ -626,6 +627,7 @@
 				float v = 0;
 				for(k = 0; k < gridkey->mask; ++k) {
 					CustomDataLayer *cdl = &vdata->layers[pmask_first_layer + k];
+					if(!(cdl->flag & CD_FLAG_ENABLED)) continue;
 					v += GRIDELEM_MASK_AT(grid, j, gridkey)[k] * cdl->strength;
 				}
 

Modified: branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_customdata_types.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_customdata_types.h	2010-07-03 07:03:21 UTC (rev 29892)
+++ branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_customdata_types.h	2010-07-03 07:07:54 UTC (rev 29893)
@@ -130,6 +130,8 @@
 #define CD_FLAG_EXTERNAL  (1<<3)
 /* indicates external data is read into memory */
 #define CD_FLAG_IN_MEMORY (1<<4)
+/* used to enable/disable a layer */
+#define CD_FLAG_ENABLED   (1<<5)
 
 /* Limits */
 #define MAX_MTFACE 8

Modified: branches/soc-2010-nicolasbishop/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/makesrna/RNA_access.h	2010-07-03 07:03:21 UTC (rev 29892)
+++ branches/soc-2010-nicolasbishop/source/blender/makesrna/RNA_access.h	2010-07-03 07:07:54 UTC (rev 29893)
@@ -300,6 +300,7 @@
 extern StructRNA RNA_MeshFloatPropertyLayer;
 extern StructRNA RNA_MeshIntProperty;
 extern StructRNA RNA_MeshIntPropertyLayer;
+extern StructRNA RNA_MeshPaintMaskLayer;
 extern StructRNA RNA_MeshSticky;
 extern StructRNA RNA_MeshStringProperty;
 extern StructRNA RNA_MeshStringPropertyLayer;

Modified: branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_mesh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_mesh.c	2010-07-03 07:03:21 UTC (rev 29892)
+++ branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_mesh.c	2010-07-03 07:07:54 UTC (rev 29893)
@@ -1640,6 +1640,11 @@
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Strength", "Opacity of the paint mask");
 	RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MeshPaintMask_update_data");
+
+	prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", CD_FLAG_ENABLED);
+	RNA_def_property_ui_text(prop, "Enabled", "Enable the mask for display and affecting brushes.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MeshPaintMask_update_data");
 }
 
 static void rna_def_mproperties(BlenderRNA *brna)





More information about the Bf-blender-cvs mailing list