[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37425] branches/soc-2011-onion: ** user selectable colors for paint/sculpt masks
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sun Jun 12 06:41:41 CEST 2011
Revision: 37425
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37425
Author: jwilkins
Date: 2011-06-12 04:41:40 +0000 (Sun, 12 Jun 2011)
Log Message:
-----------
** user selectable colors for paint/sculpt masks
* Each layer can have its own color
* The default color is chosen in user preferences
* I'm uncertain how useful users may find this flexibility
* User can ignore individual colors and just stick with the default
* Cannot change all mask layer colors at once however
* There are several other ideas for making masks distinct from paint that I'll outline on the wiki
Modified Paths:
--------------
branches/soc-2011-onion/release/scripts/startup/bl_ui/space_userpref.py
branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2011-onion/source/blender/blenkernel/BKE_blender.h
branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c
branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c
branches/soc-2011-onion/source/blender/editors/interface/resources.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.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/makesdna/DNA_userdef_types.h
branches/soc-2011-onion/source/blender/makesrna/intern/rna_mesh.c
branches/soc-2011-onion/source/blender/makesrna/intern/rna_userdef.c
Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/space_userpref.py 2011-06-12 01:41:07 UTC (rev 37424)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_userpref.py 2011-06-12 04:41:40 UTC (rev 37425)
@@ -339,7 +339,8 @@
row.separator()
col = row.column()
- col.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color")
+ col.prop(edit, "sculpt_paint_overlay_color", text="Paint/Sculpt Overlay Color")
+ col.prop(edit, "sculpt_paint_mask_color", text="Default Paint/Sculpt Mask Color")
col.separator()
col.separator()
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-12 01:41:07 UTC (rev 37424)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-06-12 04:41:40 UTC (rev 37425)
@@ -757,6 +757,8 @@
layout.prop(mesh.paint_mask_layers[mesh.active_paint_mask_index], "strength", slider=True)
+ layout.prop(mesh.paint_mask_layers[mesh.active_paint_mask_index], "color", text="")
+
if context.sculpt_object:
layout.separator()
col = layout.column(align=True)
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_blender.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_blender.h 2011-06-12 01:41:07 UTC (rev 37424)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_blender.h 2011-06-12 04:41:40 UTC (rev 37425)
@@ -44,7 +44,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 257
-#define BLENDER_SUBVERSION 2
+#define BLENDER_SUBVERSION 3 // temporary bump for testing purposes in Onion branch
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h 2011-06-12 01:41:07 UTC (rev 37424)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h 2011-06-12 04:41:40 UTC (rev 37425)
@@ -72,6 +72,12 @@
float paint_mask_from_vertex(struct CustomData *vdata, int vertex_index,
int pmask_totlayer, int pmask_first_layer);
+void paint_mask_color_from_gridelem(float *strength, float color[3], struct DMGridData *elem, struct GridKey *gridkey,
+ struct CustomData *vdata);
+void paint_mask_color_from_vertex(float *strength, float color[3], 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 */
struct MultiresModifierData *multires; /* Special handling for multires meshes */
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c 2011-06-12 01:41:07 UTC (rev 37424)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c 2011-06-12 04:41:40 UTC (rev 37425)
@@ -1342,6 +1342,10 @@
data->layers[index].data = newlayerdata;
data->layers[index].strength = 1;
+ data->layers[index].color[0]= 0.50f;
+ data->layers[index].color[1]= 0.50f;
+ data->layers[index].color[2]= 0.50f;
+
if(name || (name=typeInfo->defaultname)) {
BLI_strncpy(data->layers[index].name, name, 32);
CustomData_set_layer_unique_name(data, index);
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c 2011-06-12 01:41:07 UTC (rev 37424)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c 2011-06-12 04:41:40 UTC (rev 37425)
@@ -183,6 +183,76 @@
return mask;
}
+void paint_mask_color_from_gridelem(
+ float *strength,
+ float color[3],
+ DMGridData *elem,
+ GridKey *gridkey,
+ CustomData *vdata)
+{
+ CustomDataLayer *cdl;
+ int i, ndx;
+
+ *strength = 0;
+ zero_v3(color);
+
+ for(i=0; i < gridkey->mask; ++i) {
+ float s;
+
+ ndx = CustomData_get_named_layer_index(vdata,
+ CD_PAINTMASK,
+ gridkey->mask_names[i]);
+ cdl = &vdata->layers[ndx];
+
+ if(!(cdl->flag & CD_FLAG_ENABLED))
+ continue;
+
+ s = GRIDELEM_MASK(elem, gridkey)[i] * cdl->strength;
+
+ *strength += s;
+
+ madd_v3_v3fl(color, cdl->color, s);
+ }
+
+ if (*strength > 0)
+ mul_v3_fl(color, 1.0f / *strength);
+
+ CLAMP(*strength, 0, 1);
+}
+
+void paint_mask_color_from_vertex(
+ float* strength,
+ float color[3],
+ CustomData *vdata,
+ int vertex_index,
+ int pmask_totlayer,
+ int pmask_first_layer)
+{
+ int i;
+
+ *strength = 0.0f;
+ zero_v3(color);
+
+ for(i = 0; i < pmask_totlayer; ++i) {
+ float s;
+ CustomDataLayer *cdl= vdata->layers + pmask_first_layer + i;
+
+ if(!(cdl->flag & CD_FLAG_ENABLED))
+ continue;
+
+ s = ((float*)cdl->data)[vertex_index] * cdl->strength;
+
+ *strength += s;
+
+ madd_v3_v3fl(color, cdl->color, s);
+ }
+
+ if (*strength > 0)
+ mul_v3_fl(color, 1.0f / *strength);
+
+ CLAMP(*strength, 0, 1);
+}
+
void create_paintsession(Object *ob)
{
if(ob->paint)
Modified: branches/soc-2011-onion/source/blender/editors/interface/resources.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/interface/resources.c 2011-06-12 01:41:07 UTC (rev 37424)
+++ branches/soc-2011-onion/source/blender/editors/interface/resources.c 2011-06-12 04:41:40 UTC (rev 37425)
@@ -1555,6 +1555,12 @@
if (bmain->versionfile < 258)
U.hirestex = 0;
+ if (bmain->versionfile < 257 || (bmain->versionfile == 257 && bmain->subversionfile < 3)) {
+ U.sculpt_paint_mask_col[0]= 1.00f;
+ U.sculpt_paint_mask_col[1]= 0.39f;
+ U.sculpt_paint_mask_col[2]= 0.39f;
+ }
+
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
U.texcollectrate = 60;
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-12 01:41:07 UTC (rev 37424)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c 2011-06-12 04:41:40 UTC (rev 37425)
@@ -742,6 +742,11 @@
layer_name = CustomData_get_layer_name_at_offset(&me->vdata,
CD_PAINTMASK, top);
+ {
+ int first = CustomData_get_layer_index(&me->vdata, CD_PAINTMASK);
+ copy_v3_v3(me->vdata.layers[first+top].color, U.sculpt_paint_mask_col);
+ }
+
/* now that we have correct name, update multires and do undo push */
if(multires)
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-12 01:41:07 UTC (rev 37424)
+++ branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c 2011-06-12 04:41:40 UTC (rev 37425)
@@ -442,22 +442,21 @@
*buf = 0;
}
-static void gpu_colors_from_floats(unsigned char out[3],
- float fcol[3],
- float mask_strength)
+static void gpu_colors_from_floats(
+ unsigned char out[3],
+ float fcol[3],
+ float mask_strength,
+ float mask_color[3])
{
- float mask_col[3]= { 1.00f, 0.39f, 0.39f };
- float col[3];
+ float half[3];
CLAMP(mask_strength, 0, 1);
- col[0]= mask_strength*mask_col[0] / 2.0f;
- col[1]= mask_strength*mask_col[1] / 2.0f;
- col[2]= mask_strength*mask_col[2] / 2.0f;
+ mul_v3_v3fl(half, mask_color, mask_strength / 2.0f);
- out[0]= (unsigned char)(((1.0f-mask_strength)*fcol[0] + (fcol[0]*col[0] + col[0])) * 255.0f);
- out[1]= (unsigned char)(((1.0f-mask_strength)*fcol[1] + (fcol[1]*col[1] + col[1])) * 255.0f);
- out[2]= (unsigned char)(((1.0f-mask_strength)*fcol[2] + (fcol[2]*col[2] + col[2])) * 255.0f);
+ out[0]= (unsigned char)(((1.0f-mask_strength)*fcol[0] + (fcol[0]*half[0] + half[0])) * 255.0f);
+ out[1]= (unsigned char)(((1.0f-mask_strength)*fcol[1] + (fcol[1]*half[1] + half[1])) * 255.0f);
+ out[2]= (unsigned char)(((1.0f-mask_strength)*fcol[2] + (fcol[2]*half[2] + half[2])) * 255.0f);
}
/* Create or destroy the color buffer as needed, return a pointer to the color buffer data.
@@ -485,7 +484,7 @@
}
void GPU_update_mesh_color_buffers(GPU_Buffers *buffers, PBVH *bvh,
- PBVHNode *node, GPUDrawFlags flags)
+ PBVHNode *node, int flags)
{
unsigned char *color_data;
CustomData *vdata, *fdata;
@@ -530,7 +529,7 @@
transition from one face to another */
for(j = 0; j < S; ++j) {
int node_vert_index = face_vert_indices[i*4 + j];
- float mask;
+ float mask_strength, mask_color[3];
float v[3] = {1, 1, 1};
for(k = mcol_first_layer;
@@ -549,14 +548,14 @@
mcol->a / 255.0f);
}
- mask = paint_mask_from_vertex(vdata,
+ paint_mask_color_from_vertex(&mask_strength, mask_color, vdata,
vert_indices[node_vert_index],
pmask_totlayer,
pmask_first_layer);
- gpu_colors_from_floats(color_data + node_vert_index*3, v, mask);
- }
+ gpu_colors_from_floats(color_data + node_vert_index*3, v, mask_strength, mask_color);
}
+ }
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
}
@@ -698,7 +697,7 @@
for(j = 0; j < gridsize*gridsize; ++j, color_data += 3) {
DMGridData *elem = GRIDELEM_AT(grid, j, gridkey);
- float vc[3] = {1, 1, 1}, mask;
+ float vc[3] = {1, 1, 1}, mask_strength, mask_color[3];
/* combine colors */
for(k = 0; k < gridkey->color; ++k) {
@@ -713,11 +712,11 @@
interp_v3_v3v3(vc, vc, col, col[3]);
}
- mask = paint_mask_from_gridelem(elem, gridkey, vdata);
+ paint_mask_color_from_gridelem(&mask_strength, mask_color, elem, gridkey, vdata);
- gpu_colors_from_floats(color_data, vc, mask);
- }
-}
+ gpu_colors_from_floats(color_data, vc, mask_strength, mask_color);
+ }
+ }
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list