[Bf-blender-cvs] [288b2d0aa6b] master: Vertex Paint: Alpha Support
Campbell Barton
noreply at git.blender.org
Fri Sep 29 09:54:19 CEST 2017
Commit: 288b2d0aa6bc8097f92e85f8d16fd2125d6eb2e9
Author: Campbell Barton
Date: Fri Sep 29 17:10:15 2017 +1000
Branches: master
https://developer.blender.org/rB288b2d0aa6bc8097f92e85f8d16fd2125d6eb2e9
Vertex Paint: Alpha Support
GSOC 2017 by Darshan Kadu, see: D2859.
This is a partial merge of some of the features from
the soc-2017-vertex_paint branch.
- Alpha painting & drawing.
- 10 new color blending modes.
- Support for vertex select in vertex paint mode.
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/intern/cdderivedmesh.c
M source/blender/blenkernel/intern/paint.c
M source/blender/blenloader/intern/versioning_270.c
M source/blender/editors/include/ED_mesh.h
M source/blender/editors/mesh/mesh_data.c
M source/blender/editors/sculpt_paint/CMakeLists.txt
M source/blender/editors/sculpt_paint/paint_intern.h
M source/blender/editors/sculpt_paint/paint_ops.c
M source/blender/editors/sculpt_paint/paint_vertex.c
A source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/space_view3d/view3d_header.c
M source/blender/gpu/intern/gpu_buffers.c
M source/blender/makesdna/DNA_brush_types.h
M source/blender/makesrna/intern/rna_brush.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 2a96905a359..1086f22b8da 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -55,7 +55,7 @@ class VIEW3D_HT_header(Header):
# Occlude geometry
if ((view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and (mode == 'PARTICLE_EDIT' or (mode == 'EDIT' and obj.type == 'MESH'))) or
- (mode == 'WEIGHT_PAINT')):
+ (mode in {'WEIGHT_PAINT', 'VERTEX_PAINT'})):
row.prop(view, "use_occlude_geometry", text="")
# Proportional editing
@@ -170,7 +170,7 @@ class VIEW3D_MT_editor_menus(Menu):
mesh = obj.data
if mesh.use_paint_mask:
layout.menu("VIEW3D_MT_select_paint_mask")
- elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
+ elif mesh.use_paint_mask_vertex and mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
layout.menu("VIEW3D_MT_select_paint_mask_vertex")
elif mode_string != 'SCULPT':
layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
@@ -1780,6 +1780,7 @@ class VIEW3D_MT_paint_vertex(Menu):
layout.operator("paint.vertex_color_set")
layout.operator("paint.vertex_color_smooth")
layout.operator("paint.vertex_color_dirt")
+ layout.operator("paint.vertex_color_from_weight")
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 8562cb419b4..6a319b45b06 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1168,6 +1168,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
# row.prop(brush, "use_pressure_jitter", toggle=True, text="")
col.separator()
col.prop(brush, "vertex_tool", text="Blend")
+ col.prop(brush, "use_accumulate")
+ col.prop(brush, "use_alpha")
col.separator()
col.template_ID(settings, "palette", new="palette.new")
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 88693600653..015fd7c8a14 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -220,6 +220,7 @@ typedef struct SculptSession {
/* For non-airbrush painting to re-apply from the original (MLoop aligned). */
unsigned int *previous_color;
+ unsigned int *previous_accum;
} vpaint;
struct {
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index e97de07752e..2ed5cc450a4 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -752,8 +752,18 @@ static void cdDM_drawMappedFaces(
/* avoid buffer problems in following code */
}
else if (setDrawOptions == NULL) {
+ const bool show_alpha = true;
+ if (show_alpha) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+
/* just draw the entire face array */
GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, 0, tot_tri_elem);
+
+ if (show_alpha) {
+ glDisable(GL_BLEND);
+ }
}
else {
for (mat_index = 0; mat_index < dm->drawObject->totmaterial; mat_index++) {
@@ -1525,8 +1535,8 @@ static void cdDM_buffer_copy_mcol(
for (i = 0; i < totpoly; i++, mpoly++) {
for (j = 0; j < mpoly->totloop; j++) {
- copy_v3_v3_uchar(&varray[start], &mloopcol[mpoly->loopstart + j].r);
- start += 3;
+ copy_v4_v4_uchar(&varray[start], &mloopcol[mpoly->loopstart + j].r);
+ start += 4;
}
}
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 25ea6ad079f..05d53ae4771 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -466,7 +466,7 @@ bool BKE_paint_select_vert_test(Object *ob)
(ob->type == OB_MESH) &&
(ob->data != NULL) &&
(((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) &&
- (ob->mode & OB_MODE_WEIGHT_PAINT)
+ (ob->mode & OB_MODE_WEIGHT_PAINT || ob->mode & OB_MODE_VERTEX_PAINT)
);
}
@@ -680,6 +680,7 @@ void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss)
gmap = &ss->mode.vpaint.gmap;
MEM_SAFE_FREE(ss->mode.vpaint.previous_color);
+ MEM_SAFE_FREE(ss->mode.vpaint.previous_accum);
}
else if (ss->mode_type == OB_MODE_WEIGHT_PAINT) {
gmap = &ss->mode.wpaint.gmap;
@@ -737,7 +738,10 @@ void BKE_sculptsession_bm_to_me_for_render(Object *object)
*/
BKE_object_free_derived_caches(object);
- MEM_SAFE_FREE(object->sculpt->pbvh);
+ if (object->sculpt->pbvh) {
+ BKE_pbvh_free(object->sculpt->pbvh);
+ object->sculpt->pbvh = NULL;
+ }
sculptsession_bm_to_me_update_data_only(object, false);
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 40fed37b1b0..8459e080f99 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1653,6 +1653,23 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
+ {
+ Brush *br;
+ br = (Brush *)BKE_libblock_find_name_ex(main, ID_BR, "Average");
+ if (!br) {
+ br = BKE_brush_add(main, "Average", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
+ br->vertexpaint_tool = PAINT_BLEND_AVERAGE;
+ br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
+ }
+
+ br = (Brush *)BKE_libblock_find_name_ex(main, ID_BR, "Smear");
+ if (!br) {
+ br = BKE_brush_add(main, "Smear", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
+ br->vertexpaint_tool = PAINT_BLEND_SMEAR;
+ br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
+ }
+ }
+
FOREACH_NODETREE(main, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
do_versions_compositor_render_passes(ntree);
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index de798b1fce2..c867df2d01a 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -282,6 +282,7 @@ bool ED_mesh_uv_texture_remove_active(struct Mesh *me);
bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name);
void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me);
void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum);
+bool ED_mesh_color_ensure(struct Mesh *me, const char *name);
int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set);
bool ED_mesh_color_remove_index(struct Mesh *me, const int n);
bool ED_mesh_color_remove_active(struct Mesh *me);
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 3294490d5b1..737c8ac665d 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -464,6 +464,20 @@ int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set)
return layernum;
}
+bool ED_mesh_color_ensure(struct Mesh *me, const char *name)
+{
+ BLI_assert(me->edit_btmesh == NULL);
+
+ if (!me->mloopcol && me->totloop) {
+ CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop, name);
+ BKE_mesh_update_customdata_pointers(me, true);
+ }
+
+ DAG_id_tag_update(&me->id, 0);
+
+ return (me->mloopcol != NULL);
+}
+
bool ED_mesh_color_remove_index(Mesh *me, const int n)
{
CustomData *ldata = GET_CD_DATA(me, ldata);
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index 46753df4e13..fa669d236b9 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -52,6 +52,7 @@ set(SRC
paint_undo.c
paint_utils.c
paint_vertex.c
+ paint_vertex_color_ops.c
paint_vertex_proj.c
sculpt.c
sculpt_undo.c
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 0ec7d97a04d..16570b0fdde 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -123,6 +123,8 @@ void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
unsigned int vpaint_get_current_col(struct Scene *scene, struct VPaint *vp);
+/* paint_vertex_color_ops.c */
+void PAINT_OT_vertex_color_from_weight(struct wmOperatorType *ot);
/* paint_vertex_proj.c */
struct VertProjHandle;
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 4ebf14ed0b9..23231b7ccc7 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -1349,6 +1349,7 @@ void ED_operatortypes_paint(void)
WM_operatortype_append(PAINT_OT_vertex_color_hsv);
WM_operatortype_append(PAINT_OT_vertex_color_invert);
WM_operatortype_append(PAINT_OT_vertex_color_levels);
+ WM_operatortype_append(PAINT_OT_vertex_color_from_weight);
/* face-select */
WM_operatortype_append(PAINT_OT_face_select_linked);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index a88b834d601..18b71dedc07 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -83,6 +83,8 @@
#include "sculpt_intern.h"
#include "paint_intern.h" /* own include */
+#define EPS_SATURATION 0.0005f
+
/* Use for 'blur' brush, align with PBVH nodes, created and freed on each update. */
struct VPaintAverageAccum {
uint len;
@@ -256,29 +258,6 @@ static void do_shared_vertexcol(Mesh *me, bool *mlooptag)
MEM_freeN(scol);
}
-static bool make_vertexcol(Object *ob) /* single ob */
-{
- Mesh *me;
-
- if (ID_IS_LINKED_DATABLOCK(ob) ||
- ((me = BKE_mesh_from_object(ob)) == NULL) ||
- (me->totpoly == 0) ||
- (me->edit_btmesh)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list