[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37423] branches/soc-2011-onion: Revision: 30815

Jason Wilkins Jason.A.Wilkins at gmail.com
Sun Jun 12 03:20:14 CEST 2011


Revision: 37423
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37423
Author:   jwilkins
Date:     2011-06-12 01:20:11 +0000 (Sun, 12 Jun 2011)
Log Message:
-----------
Revision: 30815
Author: nicholasbishop
Date: 2:56:16 PM, Tuesday, July 27, 2010
Message:
== VPaint ==

Masking for vpaint

* Enabled combined display of masks and vertex colors
* Added mask painting to vpaint
* VPaint factors masks into strength
* Added functions in BKE paint to find the combined mask value for an element

TODO:
* Because vpaint doesn't have proper undo yet, and mask painting is shared between sculpt and vpaint, undoing the effects of the mask brush is disabled for now.

**jwilkins:
**because the generalized masking code regressed some features (like undo in sculpt mode) I kept the old code for sculpt masking
**I rewrote the code for combining colors so that it blends between multiplying the mask and adding the mask.  The result is that both white and black base colors will have a visible mask (the original code in this revision would let the mask be invisible on a black surface.
**I put a lot of comments where I had to temporarily use the old bglMats instead of the new pmat for texture projection
**Still a lot of bugs in texturing and masking and vpaint.
**I think texturing still works in sculpt mode though, it is just the overlay that is broken for now

Modified Paths:
--------------
    branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
    branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c
    branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
    branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.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-30783,30792-30793,30797-30798
/trunk/blender:36833-37386
   + /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30783,30792-30793,30797-30798,30815
/trunk/blender:36833-37386

Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2011-06-11 20:58:03 UTC (rev 37422)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2011-06-12 01:20:11 UTC (rev 37423)
@@ -693,19 +693,26 @@
                 col.template_color_wheel(brush, "color", value_slider=True)
                 col.prop(brush, "color", text="")
 
+            col.separator()
             row = col.row(align=True)
             row.prop(brush, "size", slider=True)
             row.prop(brush, "use_pressure_size", toggle=True, text="")
 
+            col.separator()
             row = col.row(align=True)
             row.prop(brush, "strength", text="Strength", slider=True)
             row.prop(brush, "use_pressure_strength", toggle=True, text="")
 
             if brush.vertex_tool == 'ALPHA':
+                col.separator()
                 row = col.row(align=True)
                 row.prop(brush, "direction", expand=True)
 
+            col.separator()
+            col.prop(brush, "mask")
+
             # XXX - TODO
+            #col.separator()
             #row = col.row(align=True)
             #row.prop(brush, "jitter", slider=True)
             #row.prop(brush, "use_pressure_jitter", toggle=True, text="")
@@ -717,8 +724,7 @@
 
     @classmethod
     def poll(self, context):
-        settings = self.paint_settings(context)
-        return (settings)
+        return context.sculpt_object or context.vertex_paint_object
 
     def draw(self, context):
         layout = self.layout

Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h	2011-06-11 20:58:03 UTC (rev 37422)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h	2011-06-12 01:20:11 UTC (rev 37423)
@@ -35,6 +35,9 @@
 #include "DNA_vec_types.h"
 
 struct Brush;
+struct CustomData;
+struct DMGridData;
+struct GridKey;
 struct MFace;
 struct MultireModifierData;
 struct MVert;
@@ -62,7 +65,12 @@
  * however hiding faces is useful */
 int paint_facesel_test(struct Object *ob);
 
+
 void paint_refresh_mask_display(struct Object *ob);
+float paint_mask_from_gridelem(struct DMGridData *elem, struct GridKey *gridkey,
+			       struct CustomData *vdata);
+float paint_mask_from_vertex(struct CustomData *vdata, int vertex_index,
+			     int pmask_totlayer, int pmask_first_layer);
 
 typedef struct SculptSession {
 	/* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c	2011-06-11 20:58:03 UTC (rev 37422)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c	2011-06-12 01:20:11 UTC (rev 37423)
@@ -45,6 +45,7 @@
 
 #include "BKE_brush.h"
 #include "BKE_DerivedMesh.h"
+#include "BKE_dmgrid.h"
 #include "BKE_library.h"
 #include "BKE_paint.h"
 #include "BKE_utildefines.h"
@@ -137,6 +138,51 @@
 	}
 }
 
+
+float paint_mask_from_gridelem(DMGridData *elem, GridKey *gridkey,
+			      CustomData *vdata)
+{
+	CustomDataLayer *cdl;
+	float mask = 0;
+	int i, ndx;
+
+	for(i=0; i < gridkey->mask; ++i) {
+		ndx = CustomData_get_named_layer_index(vdata,
+						       CD_PAINTMASK,
+						       gridkey->mask_names[i]);
+		cdl = &vdata->layers[ndx];
+
+		if(!(cdl->flag & CD_FLAG_ENABLED))
+			continue;
+
+		mask += GRIDELEM_MASK(elem, gridkey)[i] * cdl->strength;
+	}
+
+	CLAMP(mask, 0, 1);
+
+	return mask;
+}
+
+float paint_mask_from_vertex(CustomData *vdata, int vertex_index,
+			    int pmask_totlayer, int pmask_first_layer)
+{
+	float mask = 0;
+	int i;
+
+	for(i = 0; i < pmask_totlayer; ++i) {
+		CustomDataLayer *cdl= vdata->layers + pmask_first_layer + i;
+
+		if(!(cdl->flag & CD_FLAG_ENABLED))
+			continue;
+
+		mask +=	((float*)cdl->data)[vertex_index] * cdl->strength;
+	}
+
+	CLAMP(mask, 0, 1);
+
+	return mask;
+}
+
 void create_paintsession(Object *ob)
 {
 	if(ob->paint)

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c	2011-06-11 20:58:03 UTC (rev 37422)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c	2011-06-12 01:20:11 UTC (rev 37423)
@@ -526,7 +526,7 @@
 
 		/* copy paint mask data */
 		for(j = 0; j < gridkey->mask; ++j)
-			vertData[3 + gridkey->color * 3 + j] = ((float*)dm->vertData.layers[pmask_first_layer+j].data)[i];
+			vertData[3 + gridkey->color*4 + j] = ((float*)dm->vertData.layers[pmask_first_layer+j].data)[i];
 
 		ccgSubSurf_syncVert(ss, SET_INT_IN_POINTER(i), vertData, 0, &v);
 

Modified: branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h	2011-06-11 20:58:03 UTC (rev 37422)
+++ branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h	2011-06-12 01:20:11 UTC (rev 37423)
@@ -292,14 +292,9 @@
 					vi.fno= GRIDELEM_NO(vi.grid, vi.gridkey); \
 					\
 					if(vi.gridkey->mask) { \
-						int j; \
-						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); \
+						vi.mask_combined = \
+							paint_mask_from_gridelem(vi.grid, vi.gridkey, vi.vdata); \
+						\
 						if(vi.pmask_active_layer != -1) \
 							vi.mask_active= &GRIDELEM_MASK(vi.grid, \
 										       vi.gridkey)[vi.pmask_active_layer - \
@@ -313,15 +308,11 @@
 					vi.co= vi.mvert->co; \
 					vi.no= vi.mvert->no; \
 					if(vi.pmask_layer_count) { \
-						int j; \
-						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; \
-						} \
-						CLAMP(vi.mask_combined, 0, 1); \
+						vi.mask_combined = \
+							paint_mask_from_vertex(vi.vdata, vi.vert_indices[vi.gx], \
+									       vi.pmask_layer_count, \
+									       vi.pmask_first_layer); \
+						\
 						if(vi.pmask_active_layer != -1) \
 							vi.mask_active = &((float*)vi.vdata->layers[vi.pmask_active_layer].data)[vi.vert_indices[vi.gx]]; \
 					} \

Modified: branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c	2011-06-11 20:58:03 UTC (rev 37422)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c	2011-06-12 01:20:11 UTC (rev 37423)
@@ -40,6 +40,7 @@
 #include "BKE_dmgrid.h"
 #include "BKE_global.h"
 #include "BKE_mesh.h"
+#include "BKE_paint.h"
 
 #include "GPU_buffers.h"
 

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h	2011-06-11 20:58:03 UTC (rev 37422)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h	2011-06-12 01:20:11 UTC (rev 37423)
@@ -45,6 +45,7 @@
 struct Mesh;
 struct Object;
 struct Multires;
+struct Paint;
 struct PaintStroke;
 struct PointerRNA;
 struct Scene;
@@ -92,6 +93,19 @@
 int paint_poll(struct bContext *C);
 void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
 
+typedef struct PaintStrokeTest {
+	float radius_squared;
+	float location[3];
+	float dist;
+} PaintStrokeTest;
+void paint_stroke_test_init(PaintStrokeTest *test, float loc[3],
+			    float radius_squared);
+int paint_stroke_test(PaintStrokeTest *test, float co[3]);
+int paint_stroke_test_sq(PaintStrokeTest *test, float co[3]);
+int paint_stroke_test_fast(PaintStrokeTest *test, float co[3]);
+int paint_stroke_test_cube(PaintStrokeTest *test, float co[3], float *fade, float local[4][4]);
+float paint_stroke_test_dist(PaintStrokeTest *test);
+
 /* paint_vertex.c */
 int weight_paint_poll(struct bContext *C);
 int weight_paint_mode_poll(struct bContext *C);
@@ -171,6 +185,20 @@
 void undo_paint_push_end(int type);
 
 /* paint_mask.c */
+void paintmask_brush_apply(
+	struct Paint *paint,
+	struct PaintStroke *stroke,
+	struct Object *ob,
+	struct PBVHNode **nodes,
+	int totnode,
+	float location[3],
+	float bstrength,
+	float radius3d,
+	float symm_brush_local_mat[4][4],
+	int mirror_symmetry_pass,
+	float special_rotation,
+	struct bglMats* mats);
+
 void PAINT_OT_mask_layer_add(struct wmOperatorType *ot);
 void PAINT_OT_mask_layer_remove(struct wmOperatorType *ot);
 

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c	2011-06-11 20:58:03 UTC (rev 37422)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c	2011-06-12 01:20:11 UTC (rev 37423)
@@ -38,10 +38,12 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
-#include "DNA_material_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_brush_types.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -49,6 +51,7 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "BKE_brush.h"
 #include "BKE_context.h"

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list