[Bf-blender-cvs] [03ccf37162d] master: Cleanup: Rename curves sculpt selection variable
Hans Goudey
noreply at git.blender.org
Fri Nov 11 22:33:44 CET 2022
Commit: 03ccf37162d365f3fdc8d8cd0cd6e9ff314fec6e
Author: Hans Goudey
Date: Fri Nov 11 15:32:51 2022 -0600
Branches: master
https://developer.blender.org/rB03ccf37162d365f3fdc8d8cd0cd6e9ff314fec6e
Cleanup: Rename curves sculpt selection variable
It's a bit simpler to skip the "indices" in the name, that can be
assumed from the type.
===================================================================
M source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
===================================================================
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
index df23bdf0079..d6c4d43d5fc 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
@@ -592,8 +592,8 @@ namespace select_grow {
struct GrowOperatorDataPerCurve : NonCopyable, NonMovable {
Curves *curves_id;
- Vector<int> selected_point_indices;
- Vector<int> unselected_point_indices;
+ Vector<int> selected_points;
+ Vector<int> unselected_points;
Array<float> distances_to_selected;
Array<float> distances_to_unselected;
@@ -612,34 +612,32 @@ static void update_points_selection(const GrowOperatorDataPerCurve &data,
{
if (distance > 0.0f) {
threading::parallel_for(
- data.unselected_point_indices.index_range(), 256, [&](const IndexRange range) {
+ data.unselected_points.index_range(), 256, [&](const IndexRange range) {
for (const int i : range) {
- const int point_i = data.unselected_point_indices[i];
+ const int point_i = data.unselected_points[i];
const float distance_to_selected = data.distances_to_selected[i];
const float selection = distance_to_selected <= distance ? 1.0f : 0.0f;
points_selection[point_i] = selection;
}
});
- threading::parallel_for(
- data.selected_point_indices.index_range(), 512, [&](const IndexRange range) {
- for (const int point_i : data.selected_point_indices.as_span().slice(range)) {
- points_selection[point_i] = 1.0f;
- }
- });
+ threading::parallel_for(data.selected_points.index_range(), 512, [&](const IndexRange range) {
+ for (const int point_i : data.selected_points.as_span().slice(range)) {
+ points_selection[point_i] = 1.0f;
+ }
+ });
}
else {
+ threading::parallel_for(data.selected_points.index_range(), 256, [&](const IndexRange range) {
+ for (const int i : range) {
+ const int point_i = data.selected_points[i];
+ const float distance_to_unselected = data.distances_to_unselected[i];
+ const float selection = distance_to_unselected <= -distance ? 0.0f : 1.0f;
+ points_selection[point_i] = selection;
+ }
+ });
threading::parallel_for(
- data.selected_point_indices.index_range(), 256, [&](const IndexRange range) {
- for (const int i : range) {
- const int point_i = data.selected_point_indices[i];
- const float distance_to_unselected = data.distances_to_unselected[i];
- const float selection = distance_to_unselected <= -distance ? 0.0f : 1.0f;
- points_selection[point_i] = selection;
- }
- });
- threading::parallel_for(
- data.unselected_point_indices.index_range(), 512, [&](const IndexRange range) {
- for (const int point_i : data.unselected_point_indices.as_span().slice(range)) {
+ data.unselected_points.index_range(), 512, [&](const IndexRange range) {
+ for (const int point_i : data.unselected_points.as_span().slice(range)) {
points_selection[point_i] = 0.0f;
}
});
@@ -707,10 +705,10 @@ static void select_grow_invoke_per_curve(Curves &curves_id,
for (const int point_i : points_selection.index_range()) {
const float point_selection = points_selection[point_i];
if (point_selection > 0.0f) {
- curve_op_data.selected_point_indices.append(point_i);
+ curve_op_data.selected_points.append(point_i);
}
else {
- curve_op_data.unselected_point_indices.append(point_i);
+ curve_op_data.unselected_points.append(point_i);
}
}
@@ -725,12 +723,12 @@ static void select_grow_invoke_per_curve(Curves &curves_id,
const IndexRange points = curves.points_for_curve(curve_i);
if (curve_selection > 0.0f) {
for (const int point_i : points) {
- curve_op_data.selected_point_indices.append(point_i);
+ curve_op_data.selected_points.append(point_i);
}
}
else {
for (const int point_i : points) {
- curve_op_data.unselected_point_indices.append(point_i);
+ curve_op_data.unselected_points.append(point_i);
}
}
}
@@ -739,50 +737,46 @@ static void select_grow_invoke_per_curve(Curves &curves_id,
}
threading::parallel_invoke(
- 1024 < curve_op_data.selected_point_indices.size() +
- curve_op_data.unselected_point_indices.size(),
+ 1024 < curve_op_data.selected_points.size() + curve_op_data.unselected_points.size(),
[&]() {
/* Build KD-tree for the selected points. */
- KDTree_3d *kdtree = BLI_kdtree_3d_new(curve_op_data.selected_point_indices.size());
+ KDTree_3d *kdtree = BLI_kdtree_3d_new(curve_op_data.selected_points.size());
BLI_SCOPED_DEFER([&]() { BLI_kdtree_3d_free(kdtree); });
- for (const int point_i : curve_op_data.selected_point_indices) {
+ for (const int point_i : curve_op_data.selected_points) {
const float3 &position = positions[point_i];
BLI_kdtree_3d_insert(kdtree, point_i, position);
}
BLI_kdtree_3d_balance(kdtree);
/* For each unselected point, compute the distance to the closest selected point. */
- curve_op_data.distances_to_selected.reinitialize(
- curve_op_data.unselected_point_indices.size());
- threading::parallel_for(curve_op_data.unselected_point_indices.index_range(),
- 256,
- [&](const IndexRange range) {
- for (const int i : range) {
- const int point_i = curve_op_data.unselected_point_indices[i];
- const float3 &position = positions[point_i];
- KDTreeNearest_3d nearest;
- BLI_kdtree_3d_find_nearest(kdtree, position, &nearest);
- curve_op_data.distances_to_selected[i] = nearest.dist;
- }
- });
+ curve_op_data.distances_to_selected.reinitialize(curve_op_data.unselected_points.size());
+ threading::parallel_for(
+ curve_op_data.unselected_points.index_range(), 256, [&](const IndexRange range) {
+ for (const int i : range) {
+ const int point_i = curve_op_data.unselected_points[i];
+ const float3 &position = positions[point_i];
+ KDTreeNearest_3d nearest;
+ BLI_kdtree_3d_find_nearest(kdtree, position, &nearest);
+ curve_op_data.distances_to_selected[i] = nearest.dist;
+ }
+ });
},
[&]() {
/* Build KD-tree for the unselected points. */
- KDTree_3d *kdtree = BLI_kdtree_3d_new(curve_op_data.unselected_point_indices.size());
+ KDTree_3d *kdtree = BLI_kdtree_3d_new(curve_op_data.unselected_points.size());
BLI_SCOPED_DEFER([&]() { BLI_kdtree_3d_free(kdtree); });
- for (const int point_i : curve_op_data.unselected_point_indices) {
+ for (const int point_i : curve_op_data.unselected_points) {
const float3 &position = positions[point_i];
BLI_kdtree_3d_insert(kdtree, point_i, position);
}
BLI_kdtree_3d_balance(kdtree);
/* For each selected point, compute the distance to the closest unselected point. */
- curve_op_data.distances_to_unselected.reinitialize(
- curve_op_data.selected_point_indices.size());
+ curve_op_data.distances_to_unselected.reinitialize(curve_op_data.selected_points.size());
threading::parallel_for(
- curve_op_data.selected_point_indices.index_range(), 256, [&](const IndexRange range) {
+ curve_op_data.selected_points.index_range(), 256, [&](const IndexRange range) {
for (const int i : range) {
- const int point_i = curve_op_data.selected_point_indices[i];
+ const int point_i = curve_op_data.selected_points[i];
const float3 &position = positions[point_i];
KDTreeNearest_3d nearest;
BLI_kdtree_3d_find_nearest(kdtree, position, &nearest);
@@ -800,12 +794,12 @@ static void select_grow_invoke_per_curve(Curves &curves_id,
/* Compute how mouse movements in screen space are converted into grow/shrink distances in
* object space. */
curve_op_data.pixel_to_distance_factor = threading::parallel_reduce(
- curve_op_data.selected_point_indices.index_range(),
+ curve_op_data.selected_points.index_range(),
256,
FLT_MAX,
[&](const IndexRange range, float pixel_to_distance_factor) {
for (const int i : range) {
- const int point_i = curve_op_data.selected_point_indices[i];
+ const int point_i = curve_op_data.selected_points[i];
const float3 &pos_cu = positions[point_i];
float2 pos_re;
More information about the Bf-blender-cvs
mailing list