Commit: 0f00ede65ccaefadfec28fb71cd1699329b5b365 Author: Nathan Vollmer Date: Mon Jan 9 22:18:59 2017 -0700 Branches: soc-2016-pbvh-painting https://developer.blender.org/rB0f00ede65ccaefadfec28fb71cd1699329b5b365
Fixed vertex selection being ignored. =================================================================== M source/blender/editors/sculpt_paint/paint_vertex.c =================================================================== diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 96858b203a..f0e275a00d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2415,39 +2415,43 @@ static void do_wpaint_brush_draw_task_cb_ex( sculpt_brush_test_init(ss, &test); if (sculpt_brush_test(&test, vd.co)) { const int vertexIndex = vd.vert_indices[vd.i]; - const float dot = dot_vf3vs3(cache->sculpt_normal_symm, vd.no); - const float fade = BKE_brush_curve_strength(brush, test.dist, cache->radius); - const float brush_alpha_value = BKE_brush_alpha_get(scene, brush); - const float brush_alpha_pressure = - brush_alpha_value * (BKE_brush_use_alpha_pressure(scene, brush) ? ss->cache->pressure : 1.0f); - float actualStrength = bstrength * fade * dot * brush_alpha_pressure; - float currentWeight; - - /* Spray logic */ - if (!(data->vp->flag & VP_SPRAY)) { - MDeformVert *dv = &data->me->dvert[vertexIndex]; - MDeformWeight *dw; - dw = (data->vp->flag & VP_ONLYVGROUP) ? defvert_find_index(dv, data->wpi->active.index) : - defvert_verify_index(dv, data->wpi->active.index); - currentWeight = dw->weight; - if (ss->max_weight[vertexIndex] < 0) { - ss->max_weight[vertexIndex] = min_ff(bstrength + dw->weight, 1.0f); - } - CLAMP(actualStrength, 0.0, ss->max_weight[vertexIndex] - dw->weight); - } - - /* Splash Prevention */ - if (dot > 0.0){ - switch (data->vp->flag) { - case VP_SPRAY: - if (currentWeight < ss->max_weight[vertexIndex]) - do_weight_paint_vertex(data->vp, data->ob, data->wpi, vertexIndex, actualStrength, paintweight); - break; - default: - do_weight_paint_vertex(data->vp, data->ob, data->wpi, vertexIndex, actualStrength, paintweight); - break; - } - } + MVert v = data->me->mvert[vertexIndex]; + /* If the vertex is selected */ + if (v.flag & 1) { + const float dot = dot_vf3vs3(cache->sculpt_normal_symm, vd.no); + const float fade = BKE_brush_curve_strength(brush, test.dist, cache->radius); + const float brush_alpha_value = BKE_brush_alpha_get(scene, brush); + const float brush_alpha_pressure = + brush_alpha_value * (BKE_brush_use_alpha_pressure(scene, brush) ? ss->cache->pressure : 1.0f); + float actualStrength = bstrength * fade * dot * brush_alpha_pressure; + float currentWeight; + + /* Spray logic */ + if (!(data->vp->flag & VP_SPRAY)) { + MDeformVert *dv = &data->me->dvert[vertexIndex]; + MDeformWeight *dw; + dw = (data->vp->flag & VP_ONLYVGROUP) ? defvert_find_index(dv, data->wpi->active.index) : + defvert_verify_index(dv, data->wpi->active.index); + currentWeight = dw->weight; + if (ss->max_weight[vertexIndex] < 0) { + ss->max_weight[vertexIndex] = min_ff(bstrength + dw->weight, 1.0f); + } + CLAMP(actualStrength, 0.0, ss->max_weight[vertexIndex] - dw->weight); + } + + /* Splash Prevention */ + if (dot > 0.0){ + switch (data->vp->flag) { + case VP_SPRAY: + if (currentWeight < ss->max_weight[vertexIndex]) + do_weight_paint_vertex(data->vp, data->ob, data->wpi, vertexIndex, actualStrength, paintweight); + break; + default: + do_weight_paint_vertex(data->vp, data->ob, data->wpi, vertexIndex, actualStrength, paintweight); + break; + } + } + } } BKE_pbvh_vertex_iter_end; } @@ -2477,17 +2481,20 @@ static void do_wpaint_brush_calc_ave_weight_cb_ex( float dot = dot_vf3vs3(cache->sculpt_normal_symm, vd.no); if (dot > 0.0 && BKE_brush_curve_strength(data->brush, test.dist, cache->radius) > 0.0) { int vertexIndex = vd.vert_indices[vd.i]; - - ss->tot_loops_hit[n] += ss->vert_to_loop[vertexIndex].count; - /* if a vertex is within the brush region, then add it's weight to the total weight. */ - for (int j = 0; j < ss->vert_to_loop[vertexIndex].count; ++j) { - int loopIndex = ss->vert_to_loop[vertexIndex].indices[j]; - - MLoop loop = data->me->mloop[loopIndex]; - MDeformVert *dv = &data->me->dvert[loop.v]; - MDeformWeight *dw = defvert_verify_index(dv, data->wpi->active.index); - weight += dw->weight; - } + MVert v = data->me->mvert[vertexIndex]; + /* If the vertex is selected. */ + if (v.flag & 1) { + ss->tot_loops_hit[n] += ss->vert_to_loop[vertexIndex].count; + /* if a vertex is within the brush region, then add it's weight to the total weight. */ + for (int j = 0; j < ss->vert_to_loop[vertexIndex].count; ++j) { + int loopIndex = ss->vert_to_loop[vertexIndex].indices[j]; + + MLoop loop = data->me->mloop[loopIndex]; + MDeformVert *dv = &data->me->dvert[loop.v]; + MDeformWeight *dw = defvert_verify_index(dv, data->wpi->active.index); + weight += dw->weight; + } + } } } BKE_pbvh_vertex_iter_end; @@ -3072,16 +3079,19 @@ static void do_vpaint_brush_calc_ave_color_cb_ex( if (sculpt_brush_test_fast(&test, vd.co)) { if (BKE_brush_curve_strength(data->brush, test.dist, cache->radius) > 0.0) { int vertexIndex = vd.vert_indices[vd.i]; - - ss->tot_loops_hit[n] += ss->vert_to_loop[vertexIndex].count; - /* if a vertex is within the brush region, then add it's color to the blend. */ - for (int j = 0; j < ss->vert_to_loop[vertexIndex].count; ++j) { - int loopIndex = ss->vert_to_loop[vertexIndex].indices[j]; - col = (char *)(&lcol[loopIndex]); - /* Color is squared to compensate the sqrt color encoding. */ - blend[0] += (long)col[0] * (long)col[0]; - blend[1] += (long)col[1] * (long)col[1]; - blend[2] += (long)col[2] * (long)col[2]; + /* If the vertex is selected for painting. */ + MVert v = data->me->mvert[vertexIndex]; + if (v.flag & 1) { + ss->tot_loops_hit[n] += ss->vert_to_loop[vertexIndex].count; + /* if a vertex is within the brush region, then add it's color to the blend. */ + for (int j = 0; j < ss->vert_to_loop[vertexIndex].count; ++j) { + int loopIndex = ss->vert_to_loop[vertexIndex].indices[j]; + col = (char *)(&lcol[loopIndex]); + /* Color is squared to compensate the sqrt color encoding. */ + blend[0] += (long)col[0] * (long)col[0]; + blend[1] += (long)col[1] * (long)col[1]; + blend[2] += (long)col[2] * (long)col[2]; + } } } } @@ -3130,37 +3140,39 @@ static void do_vpaint_brush_draw_task_cb_ex( { SculptBrushTest test; sculpt_brush_test_init(ss, &test); - /* Test to see if the vertex coordinates are within the spherical brush region. */ if (sculpt_brush_test(&test, vd.co)) { int vertexIndex = vd.vert_indices[vd.i]; - const float dot = dot_vf3vs3(cache->sculpt_normal_symm, vd.no); - const float fade = BKE_brush_curve_strength(brush, test.dist, cache->radius); - unsigned int actualColor = data->vpd->paintcol; - - float alpha = 1.0; - if (data->vpd->is_texbrush) { - handle_texture_brush(data, vd, &alpha, &actualColor, brush_size_pressure, brush_alpha_pressure); - } + /* If the vertex is selected for painting. */ + MVert v = data->me->mvert[vertexIndex]; + if (v.flag & 1) { + const float dot = dot_vf3vs3(cache->sculpt_normal_symm, vd.no); + const float fade = BKE_brush_curve_strength(brush, test.dist, cache->radius); + unsigned int actualColor = data->vpd->paintcol; - if (dot > 0.0) - /* if a vertex is within the brush region, then paint each loop that vertex owns. */ - for (int j = 0; j < ss->vert_to_loop[vertexIndex].count; ++j) { - int loopIndex = ss->vert_to_loop[vertexIndex].indices[j]; + float alpha = 1.0; + if (data->vpd->is_texbrush) { + handle_texture_brush(data, vd, &alpha, &actualColor, brush_size_pressure, brush_alpha_pressure); + } - /* Previous color logic */ - if (ss->previous_color[loopIndex] == 0) { - ss->previous_color[loopIndex] = lcol[loopIndex]; + if (dot > 0.0) { + /* if a vertex is within the brush region, then paint each loop that vertex owns. */ + for (int j = 0; j < ss->vert_to_loop[vertexIndex].count; ++j) { + int loopIndex = ss->vert_to_loop[vertexIndex].indices[j]; + /* Previous color logic */ + if (ss->previous_color[loopIndex] == 0) { + ss->previous_color[loopIndex] = lcol[loopIndex]; + } + /* Mix the new color with the original based on the brush strength and the curve. */ + lcol[loopIndex] = vpaint_blend(data->vp, lcol[loopIndex], ss->previous_color[loopIndex], actualColor, + 255 * fade * bstrength * dot * alpha * brush_alpha_pressure, 255.0*bstrength); } - - /* Mix the new color with the original based on the brush strength and the curve. */ - lcol[loopIndex] = vpaint_blend(data->vp, lcol[loopIndex], ss->previous_color[loopIndex], actualColor, - 255 * fade * bstrength * dot * alpha * brush_alpha_pressure, 255.0*bstrength); } } - BKE_pbvh_vertex_iter_end; } + BKE_pbvh_vertex_iter_end; } +} static void do_vpaint_brush_blur_task_cb_ex( void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id)) @@ -3189,46 +3201,49 @@ static void do_vpaint_brush_blur_task_cb_ex( if (dot > 0.0){ const float fade = BKE_brush_curve_strength(brush, test.dist, cache->radius); int vertexIndex = vd.vert_indices[vd.i]; - - /* Get the average poly color */ - total_hit_loops = 0; - finalColor = 0; - blend[0] = 0; - blend[1] = 0; - blend[2] = 0; - blend[3] = 0; - for (int j = 0; j < ss->vert_to_poly[vertexIndex].count; j++) { - int polyIndex = ss->vert_to_poly[vertexIndex].indices[j]; - MPoly poly = data->me->mpoly[polyIndex]; - total_hit_loops += poly.totloop; - for (int k = 0; k < poly.totloop; k++) { - unsigned int loopIndex = poly.loopstart + k; - col = (char *)(&lcol[loopIndex]); - /* Color is squared to compensate the sqrt color encoding. */ - blend[0] += (unsigned int)col[0] * (unsigned int)col[0]; - blend[1] += (unsigned int)col[1] * (unsigned int)col[1]; - blend @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs