Paint: Read selection before brush falloff
Reading the selection is much cheaper than calculating the brush radius since it just requires reading from a boolean array. Better to do it earlier so the radius calculation can be skipped for deselected points.
This commit is contained in:
parent
1c3d6fa4dd
commit
73a407061a
@ -1058,12 +1058,11 @@ static void do_vpaint_brush_blur_loops(bContext *C,
|
||||
for (const int i : range) {
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (*ss.pbvh, nodes[i], vd, PBVH_ITER_UNIQUE) {
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1198,12 +1197,11 @@ static void do_vpaint_brush_blur_verts(bContext *C,
|
||||
for (const int i : range) {
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (*ss.pbvh, nodes[i], vd, PBVH_ITER_UNIQUE) {
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1341,15 +1339,14 @@ static void do_vpaint_brush_smear(bContext *C,
|
||||
for (const int i : range) {
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (*ss.pbvh, nodes[i], vd, PBVH_ITER_UNIQUE) {
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
const float3 &mv_curr = ss.vert_positions[vert];
|
||||
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
const float3 &mv_curr = ss.vert_positions[vert];
|
||||
|
||||
/* Calculate the dot prod. between ray norm on surf and current vert
|
||||
* (ie splash prevention factor), and only paint front facing verts. */
|
||||
@ -1518,16 +1515,16 @@ static void calculate_average_color(VPaintData &vpd,
|
||||
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (*ss.pbvh, nodes[i], vd, PBVH_ITER_UNIQUE) {
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
if (BKE_brush_curve_strength(&brush, 0.0, cache->radius) <= 0.0f) {
|
||||
continue;
|
||||
}
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
accum2.len += gmap->vert_to_face[vert].size();
|
||||
/* if a vertex is within the brush region, then add its color to the blend. */
|
||||
@ -1636,13 +1633,13 @@ static void vpaint_do_draw(bContext *C,
|
||||
SculptBrushTest test = test_init;
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (*ss.pbvh, nodes[i], vd, PBVH_ITER_UNIQUE) {
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Calculate the dot product between ray normal on surface and current vertex
|
||||
* (ie splash prevention factor), and only paint front facing verts. */
|
||||
|
@ -1083,13 +1083,13 @@ static void do_wpaint_brush_blur_task(const Scene &scene,
|
||||
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (*ss.pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Get the average face weight */
|
||||
int total_hit_loops = 0;
|
||||
@ -1178,17 +1178,16 @@ static void do_wpaint_brush_smear_task(const Scene &scene,
|
||||
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (*ss.pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
const float3 &mv_curr = ss.vert_positions[vert];
|
||||
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float brush_strength = cache->bstrength;
|
||||
const float angle_cos = (use_normal && vd.no) ? dot_v3v3(sculpt_normal_frontface, vd.no) :
|
||||
1.0f;
|
||||
@ -1281,12 +1280,11 @@ static void do_wpaint_brush_draw_task(const Scene &scene,
|
||||
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (*ss.pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
float brush_strength = cache->bstrength;
|
||||
@ -1347,6 +1345,10 @@ static WPaintAverageAccum do_wpaint_brush_calc_average_weight(Object &ob,
|
||||
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (*ss.pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
if (!sculpt_brush_test_sq_fn(test, vd.co)) {
|
||||
continue;
|
||||
}
|
||||
@ -1359,11 +1361,6 @@ static WPaintAverageAccum do_wpaint_brush_calc_average_weight(Object &ob,
|
||||
continue;
|
||||
}
|
||||
|
||||
const int vert = vd.vert_indices[vd.i];
|
||||
if (!select_vert.is_empty() && !select_vert[vert]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const MDeformVert &dv = wpi.dvert[vert];
|
||||
accum.len += 1;
|
||||
accum.value += wpaint_get_active_weight(dv, wpi);
|
||||
|
Loading…
Reference in New Issue
Block a user