[Bf-blender-cvs] [39a2294d38b] soc-2017-vertex_paint: added the non-occluded mode
Darshan Kadu
noreply at git.blender.org
Thu Jun 22 12:26:40 CEST 2017
Commit: 39a2294d38b0e740dbef47b423b78141d5a6d5a0
Author: Darshan Kadu
Date: Thu Jun 22 15:55:08 2017 +0530
Branches: soc-2017-vertex_paint
https://developer.blender.org/rB39a2294d38b0e740dbef47b423b78141d5a6d5a0
added the non-occluded mode
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/editors/sculpt_paint/paint_vertex.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index fa7ab428b08..c4085e4867d 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1797,6 +1797,7 @@ class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
# col.prop(vpaint, "mode", text="")
row.prop(vpaint, "use_normal")
col.prop(vpaint, "use_spray")
+ col.prop(vpaint, "use_occlude")
self.unified_paint_settings(col, context)
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 7fe05644a46..75f7b2745ca 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -934,7 +934,7 @@ BLI_INLINE unsigned int mcol_exclusion(unsigned int col1, unsigned int col2, int
BLI_INLINE unsigned int mcol_luminocity(unsigned int col1, unsigned int col2, int fac)
{
unsigned char *cp1, *cp2, *cp;
- int mfac, temp;
+ int mfac;
unsigned int col = 0;
if (fac == 0) {
@@ -966,7 +966,7 @@ BLI_INLINE unsigned int mcol_luminocity(unsigned int col1, unsigned int col2, in
BLI_INLINE unsigned int mcol_saturation(unsigned int col1, unsigned int col2, int fac)
{
unsigned char *cp1, *cp2, *cp;
- int mfac, temp;
+ int mfac;
unsigned int col = 0;
if (fac == 0) {
@@ -1000,7 +1000,7 @@ BLI_INLINE unsigned int mcol_saturation(unsigned int col1, unsigned int col2, in
BLI_INLINE unsigned int mcol_hue(unsigned int col1, unsigned int col2, int fac)
{
unsigned char *cp1, *cp2, *cp;
- int mfac, temp;
+ int mfac;
unsigned int col = 0;
if (fac == 0) {
@@ -3617,6 +3617,21 @@ static void handle_texture_brush(
rgb_float_to_uchar((unsigned char *)r_color, rgba_br);
}
+static bool is_non_occluded(StrokeCache *cache, PBVHVertexIter vd,
+ float *dist, const float radius, const bool do_occlude)
+{
+ if (cache->vc->ar && !do_occlude) {
+ float sco[2];
+ ED_view3d_project_float_v2_m4(cache->vc->ar, vd.co, sco, cache->projection_mat);
+ const float dist_sq = len_squared_v2v2(cache->mouse, sco);
+ *dist = sqrtf(dist_sq);
+ if (dist_sq <= radius*radius) {
+ return true;
+ }
+ }
+ return false;
+}
+
static void do_vpaint_brush_draw_task_cb_ex(
void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
{
@@ -3633,6 +3648,9 @@ static void do_vpaint_brush_draw_task_cb_ex(
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;
+ float dist;
+ bool non_occlude;
+ const float radius = BKE_brush_size_get(scene, brush);
SculptBrushTest test;
sculpt_brush_test_init(ss, &test);
@@ -3641,8 +3659,11 @@ static void do_vpaint_brush_draw_task_cb_ex(
PBVHVertexIter vd;
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- /* Test to see if the vertex coordinates are within the spherical brush region. */
- if (sculpt_brush_test(&test, vd.co)) {
+ const bool do_occlude = data->vp->flag&VP_OCCLUDE ? 1 : 0;
+ non_occlude = is_non_occluded(cache, vd, &dist, radius, do_occlude);
+ /* Test to see if the vertex coordinates are within the spherical brush region or
+ * occluded vertex for non-occluded mode. */
+ if (sculpt_brush_test(&test, vd.co) || non_occlude) {
/* Note: Grids are 1:1 with corners (aka loops).
* For grid based pbvh, take the vert whose loop cooresponds to the current grid.
* Otherwise, take the current vert. */
@@ -3652,13 +3673,14 @@ static void do_vpaint_brush_draw_task_cb_ex(
const bool v_flag = data->me->mvert[v_index].flag;
/* If the vertex is selected for painting. */
- if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT || non_occlude) {
/* 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;
+ float view_dot = (vd.no && !non_occlude) ? 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);
+ const float brush_fade = BKE_brush_curve_strength(brush, dist, radius);
unsigned int color_final = data->vpd->paintcol;
+ dist = non_occlude ? dist : test.dist;
/* If we're painting with a texture, sample the texture color and alpha. */
float tex_alpha = 1.0;
@@ -3720,6 +3742,9 @@ static void do_vpaint_brush_blur_task_cb_ex(
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;
+ float dist;
+ bool non_occlude;
+ const float radius = BKE_brush_size_get(scene, brush);
SculptBrushTest test;
sculpt_brush_test_init(ss, &test);
@@ -3728,8 +3753,11 @@ static void do_vpaint_brush_blur_task_cb_ex(
PBVHVertexIter vd;
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- /* Test to see if the vertex coordinates are within the spherical brush region. */
- if (sculpt_brush_test(&test, vd.co)) {
+ const bool do_occlude = data->vp->flag&VP_OCCLUDE ? 1 : 0;
+ non_occlude = is_non_occluded(cache, vd, &dist, radius, do_occlude);
+ /* Test to see if the vertex coordinates are within the spherical brush region or
+ * occluded vertex for non-occluded mode. */
+ if (sculpt_brush_test(&test, vd.co) || non_occlude) {
/* For grid based pbvh, take the vert whose loop cooresponds to the current grid.
Otherwise, take the current vert. */
const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
@@ -3737,12 +3765,12 @@ static void do_vpaint_brush_blur_task_cb_ex(
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;
+ const float view_dot = (vd.no && !non_occlude) ? 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 || use_vert_sel) || v_flag & SELECT) {
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT || non_occlude) {
/* Get the average poly color */
unsigned int color_final = 0;
int total_hit_loops = 0;
@@ -3818,6 +3846,9 @@ static void do_vpaint_brush_smear_task_cb_ex(
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;
+ float dist;
+ bool non_occlude;
+ const float radius = BKE_brush_size_get(scene, brush);
sub_v3_v3v3(brush_dir, cache->location, cache->last_location);
if (normalize_v3(brush_dir) != 0.0f) {
@@ -3829,8 +3860,11 @@ static void do_vpaint_brush_smear_task_cb_ex(
PBVHVertexIter vd;
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- /* Test to see if the vertex coordinates are within the spherical brush region. */
- if (sculpt_brush_test(&test, vd.co)) {
+ const bool do_occlude = data->vp->flag&VP_OCCLUDE ? 1 : 0;
+ non_occlude = is_non_occluded(cache, vd, &dist, radius, do_occlude);
+ /* Test to see if the vertex coordinates are within the spherical brush region or
+ * occluded vertex for non-occluded mode. */
+ if (sculpt_brush_test(&test, vd.co) || non_occlude) {
/* For grid based pbvh, take the vert whose loop cooresponds to the current grid.
Otherwise, take the current vert. */
const int v_index = ccgdm ? data->me->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
@@ -3839,10 +3873,10 @@ static void do_vpaint_brush_smear_task_cb_ex(
const bool v_flag = data->me->mvert[v_index].flag;
/* if the vertex is selected for painting. */
- if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
+ if (!(use_face_sel || use_vert_sel) || v_flag & SELECT || non_occlude) {
/* 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;
+ const float view_dot = (vd.no && !non_occlude) ? 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);
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 3503abb606e..3cb1158f57d 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1175,6 +1175,7 @@ enum {
VP_NORMALS = (1 << 3),
VP_SPRAY = (1 << 4),
// VP_MIRROR_X = (1 << 5), /* deprecated in 2.5x use (me->editflag & ME_EDIT_MIRROR_X) */
+ VP_OCCLUDE = (1 << 6),
VP_ONLYVGROUP = (1 << 7) /* weight paint only */
};
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 98dbfa3ae5f..630ea4ec0af 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -669,6 +669,11 @@ static void rna_def_vertex_paint(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of vertex and weight paint mode");
/* vertex paint only */
+ prop = RNA_def_property(srna, "use_occlude", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_OCCLUDE);
+ RNA_def_property_ui_text(prop, "Occlude", "Only paint onto the vertices directly under the brush (slower)");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list