[Bf-blender-cvs] [72533b087ac] soc-2017-vertex_paint: added vertex mask feature
Darshan Kadu
noreply at git.blender.org
Tue Jun 13 10:35:45 CEST 2017
Commit: 72533b087acc69ae1f4fa6ec750ca50979ae278f
Author: Darshan Kadu
Date: Tue Jun 13 14:04:55 2017 +0530
Branches: soc-2017-vertex_paint
https://developer.blender.org/rB72533b087acc69ae1f4fa6ec750ca50979ae278f
added vertex mask feature
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/blenkernel/intern/paint.c
M source/blender/editors/sculpt_paint/paint_vertex.c
M source/blender/editors/space_view3d/view3d_header.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 9245def7473..643a4b8cc00 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -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 == 'PAINT_WEIGHT' or mode_string == 'PAINT_VERTEX'):
layout.menu("VIEW3D_MT_select_paint_mask_vertex")
elif mode_string != 'SCULPT':
layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index b8dbfc6f71b..e56db89097d 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -452,7 +452,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)
);
}
@@ -670,6 +670,7 @@ void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss)
MEM_SAFE_FREE(ss->modes.vwpaint.total_weight);
MEM_SAFE_FREE(ss->modes.vwpaint.max_weight);
MEM_SAFE_FREE(ss->modes.vwpaint.previous_color);
+ MEM_SAFE_FREE(ss->modes.vwpaint.previous_accum);
}
/* Write out the sculpt dynamic-topology BMesh to the Mesh */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 53d67dd1c0c..7fe05644a46 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -3362,6 +3362,9 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
if (me->editflag & ME_EDIT_PAINT_FACE_SEL) {
BKE_mesh_flush_select_from_polys(me);
}
+ else if (me->editflag & ME_EDIT_PAINT_VERT_SEL) {
+ BKE_mesh_flush_select_from_verts(me);
+ }
/* If the cache is not released by a cancel or a done, free it now. */
if (ob->sculpt->cache) {
@@ -3556,6 +3559,7 @@ static void do_vpaint_brush_calc_ave_color_cb_ex(
char *col;
data->ob->sculpt->modes.vwpaint.tot_loops_hit[n] = 0;
const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (data->me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
SculptBrushTest test;
sculpt_brush_test_init(ss, &test);
@@ -3570,7 +3574,9 @@ static void do_vpaint_brush_calc_ave_color_cb_ex(
if (BKE_brush_curve_strength(data->brush, test.dist, cache->radius) > 0.0) {
/* If the vertex is selected for painting. */
const MVert *mv = &data->me->mvert[v_index];
- if (!use_face_sel || mv->flag & SELECT) {
+ const bool v_flag = data->me->mvert[v_index].flag;
+
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
ss->modes.vwpaint.tot_loops_hit[n] += ss->modes.vwpaint.vert_to_loop[v_index].count;
/* if a vertex is within the brush region, then add it's color to the blend. */
for (int j = 0; j < ss->modes.vwpaint.vert_to_loop[v_index].count; j++) {
@@ -3626,6 +3632,7 @@ static void do_vpaint_brush_draw_task_cb_ex(
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (data->me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
SculptBrushTest test;
sculpt_brush_test_init(ss, &test);
@@ -3642,9 +3649,10 @@ static void do_vpaint_brush_draw_task_cb_ex(
const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
const MVert *mv = &data->me->mvert[v_index];
+ const bool v_flag = data->me->mvert[v_index].flag;
/* If the vertex is selected for painting. */
- if (!use_face_sel || mv->flag & SELECT) {
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
/* Calc the dot prod. between ray norm on surf and current vert
* (ie splash prevention factor), and only paint front facing verts. */
const float view_dot = (vd.no) ? dot_vf3vs3(cache->sculpt_normal_symm, vd.no) : 1.0;
@@ -3711,6 +3719,7 @@ static void do_vpaint_brush_blur_task_cb_ex(
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (data->me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
SculptBrushTest test;
sculpt_brush_test_init(ss, &test);
@@ -3726,13 +3735,14 @@ static void do_vpaint_brush_blur_task_cb_ex(
const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
const MVert *mv = &data->me->mvert[v_index];
+ const bool v_flag = data->me->mvert[v_index].flag;
const float view_dot = (vd.no) ? dot_vf3vs3(cache->sculpt_normal_symm, vd.no) : 1.0;
if (view_dot > 0.0f) {
const float brush_fade = BKE_brush_curve_strength(brush, test.dist, cache->radius);
/* If the vertex is selected for painting. */
- if (!use_face_sel || mv->flag & SELECT) {
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
/* Get the average poly color */
unsigned int color_final = 0;
int total_hit_loops = 0;
@@ -3807,6 +3817,7 @@ static void do_vpaint_brush_smear_task_cb_ex(
get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
float brush_dir[3];
const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (data->me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
sub_v3_v3v3(brush_dir, cache->location, cache->last_location);
if (normalize_v3(brush_dir) != 0.0f) {
@@ -3825,9 +3836,10 @@ static void do_vpaint_brush_smear_task_cb_ex(
const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
const float grid_alpha = ccgdm ? 1.0f / vd.gridsize : 1.0f;
const MVert *mv_curr = &data->me->mvert[v_index];
+ const bool v_flag = data->me->mvert[v_index].flag;
/* if the vertex is selected for painting. */
- if (!use_face_sel || mv_curr->flag & SELECT) {
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
/* Calc the dot prod. between ray norm on surf and current vert
(ie splash prevention factor), and only paint front facing verts. */
const float view_dot = (vd.no) ? dot_vf3vs3(cache->sculpt_normal_symm, vd.no) : 1.0;
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index bf1bdf68619..70caee66b29 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -350,7 +350,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
PointerRNA meshptr;
RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr);
- if (ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT)) {
+ if (ob->mode & (OB_MODE_TEXTURE_PAINT)) {
uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
}
else {
More information about the Bf-blender-cvs
mailing list