Revision: 37191
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37191
Author:   jwilkins
Date:     2011-06-04 20:29:00 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
== Sculpt Mask ==
This makes the last major commit of the sculpt masking code from GSOC 2010.

Revision: 29893
Author: nicholasbishop
Date: 2:07:54 AM, Saturday, July 03, 2010
Message:
* Added DNA/RNA/UI for enabling and disabling mask layers.

** jwilkins:
** the PBVH iterator macro has become monstrous

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

Property Changed:
----------------
    branches/soc-2011-onion/


Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29796,29832,29860,29862,29878,29887-29888
/trunk/blender:36833-37054
   + /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29796,29832,29860,29862,29878,29887-29888,29893
/trunk/blender:36833-37054

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c       
2011-06-04 19:45:47 UTC (rev 37190)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c       
2011-06-04 20:29:00 UTC (rev 37191)
@@ -1296,7 +1296,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-2011-onion/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h   2011-06-04 
19:45:47 UTC (rev 37190)
+++ branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h   2011-06-04 
20:29:00 UTC (rev 37191)
@@ -34,6 +34,8 @@
 
 #include "BKE_dmgrid.h"
 
+#include "DNA_customdata_types.h"
+
 struct BoundBox;
 struct CustomData;
 struct MFace;
@@ -246,8 +248,10 @@
                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; \
+               } \
        }\
-       }\
        \
        for(vi.i=0, vi.g=0; vi.g<vi.totgrid; vi.g++) { \
                if(vi.grids) { \
@@ -278,8 +282,11 @@
                                        if(vi.gridkey->mask) { \
                                                int j; \
                                                vi.mask_combined= 0; \
-                                               for(j=0; j<vi.gridkey->mask; 
++j) \
-                                                       vi.mask_combined+= 
GRIDELEM_MASK(vi.grid, vi.gridkey)[j]; \
+                                               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); \
                                                if(vi.pmask_active_layer != -1) 
\
                                                        vi.mask_active= 
&GRIDELEM_MASK(vi.grid, \
@@ -296,14 +303,17 @@
                                        if(vi.pmask_layer_count) { \
                                                int j; \
                                                vi.mask_combined= 0; \
-                                               for(j=0; 
j<vi.pmask_layer_count; ++j) \
+                                               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*)vi.vdata->layers[vi.pmask_first_layer + 
j].data)[vi.vert_indices[vi.gx]]; \
+                                                               
((float*)cdl->data)[vi.vert_indices[vi.gx]] * cdl->strength; \
+                                               } \
                                                CLAMP(vi.mask_combined, 0, 1); \
                                                if(vi.pmask_active_layer != -1) 
\
                                                        vi.mask_active = 
&((float*)vi.vdata->layers[vi.pmask_active_layer].data)[vi.vert_indices[vi.gx]];
 \
+                                       } \
                                } \
-                               } \
 
 #define BLI_pbvh_vertex_iter_end \
                        } \

Modified: 
branches/soc-2011-onion/source/blender/editors/interface/interface_templates.c
===================================================================
--- 
branches/soc-2011-onion/source/blender/editors/interface/interface_templates.c  
    2011-06-04 19:45:47 UTC (rev 37190)
+++ 
branches/soc-2011-onion/source/blender/editors/interface/interface_templates.c  
    2011-06-04 20:29:00 UTC (rev 37191)
@@ -2118,6 +2118,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-2011-onion/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c     
2011-06-04 19:45:47 UTC (rev 37190)
+++ branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c     
2011-06-04 20:29:00 UTC (rev 37191)
@@ -492,6 +492,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;
                        }
 
@@ -637,6 +638,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-2011-onion/source/blender/makesdna/DNA_customdata_types.h
===================================================================
--- branches/soc-2011-onion/source/blender/makesdna/DNA_customdata_types.h      
2011-06-04 19:45:47 UTC (rev 37190)
+++ branches/soc-2011-onion/source/blender/makesdna/DNA_customdata_types.h      
2011-06-04 20:29:00 UTC (rev 37191)
@@ -138,6 +138,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-2011-onion/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/soc-2011-onion/source/blender/makesrna/RNA_access.h        
2011-06-04 19:45:47 UTC (rev 37190)
+++ branches/soc-2011-onion/source/blender/makesrna/RNA_access.h        
2011-06-04 20:29:00 UTC (rev 37191)
@@ -303,6 +303,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-2011-onion/source/blender/makesrna/intern/rna_mesh.c
===================================================================
--- branches/soc-2011-onion/source/blender/makesrna/intern/rna_mesh.c   
2011-06-04 19:45:47 UTC (rev 37190)
+++ branches/soc-2011-onion/source/blender/makesrna/intern/rna_mesh.c   
2011-06-04 20:29:00 UTC (rev 37191)
@@ -1708,6 +1708,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)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to