[Bf-blender-cvs] [9a6aba2a94d] master: Vertex Paint: use squared distance test
Campbell Barton
noreply at git.blender.org
Sun Oct 1 15:39:03 CEST 2017
Commit: 9a6aba2a94dbaee818630c26232274dc2962c828
Author: Campbell Barton
Date: Mon Oct 2 00:44:04 2017 +1100
Branches: master
https://developer.blender.org/rB9a6aba2a94dbaee818630c26232274dc2962c828
Vertex Paint: use squared distance test
Avoids sqrt for verts that are later 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 638a2616fc4..ee7616b5682 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -2360,7 +2360,7 @@ static void do_vpaint_brush_draw_task_cb_ex(
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)) {
+ if (sculpt_brush_test_sq(&test, vd.co)) {
/* 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. */
@@ -2374,7 +2374,7 @@ static void do_vpaint_brush_draw_task_cb_ex(
* (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;
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, sqrtf(test.dist), cache->radius);
uint color_final = data->vpd->paintcol;
/* If we're painting with a texture, sample the texture color and alpha. */
@@ -2451,7 +2451,7 @@ static void do_vpaint_brush_blur_task_cb_ex(
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)) {
+ if (sculpt_brush_test_sq(&test, vd.co)) {
/* 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];
@@ -2460,7 +2460,7 @@ static void do_vpaint_brush_blur_task_cb_ex(
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);
+ const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
/* If the vertex is selected for painting. */
if (!use_vert_sel || mv->flag & SELECT) {
@@ -2561,7 +2561,7 @@ static void do_vpaint_brush_smear_task_cb_ex(
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)) {
+ if (sculpt_brush_test_sq(&test, vd.co)) {
/* 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];
@@ -2574,7 +2574,7 @@ static void do_vpaint_brush_smear_task_cb_ex(
* (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;
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, sqrtf(test.dist), cache->radius);
bool do_color = false;
/* Minimum dot product between brush direction and current
More information about the Bf-blender-cvs
mailing list