[Bf-blender-cvs] [f4a01c8a8bf] master: Fix T98101: Handle single point curves in delete brush

Hans Goudey noreply at git.blender.org
Mon May 23 09:47:34 CEST 2022


Commit: f4a01c8a8bfcc948aedf45888d9303b7ce571124
Author: Hans Goudey
Date:   Mon May 23 09:47:17 2022 +0200
Branches: master
https://developer.blender.org/rBf4a01c8a8bfcc948aedf45888d9303b7ce571124

Fix T98101: Handle single point curves in delete brush

The 3D brush utility and the delete brush only considered segments,
so they did not handle single points. Fix by adding special cases for
single point curves.

Differential Revision: https://developer.blender.org/D14944

===================================================================

M	source/blender/editors/sculpt_paint/curves_sculpt_brush.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_delete.cc

===================================================================

diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc
index 83e0d493d00..92ce6ba3153 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc
@@ -95,6 +95,26 @@ static std::optional<float3> find_curves_brush_position(const CurvesGeometry &cu
         for (const int curve_i : curves_range) {
           const IndexRange points = curves.points_for_curve(curve_i);
 
+          if (points.size() == 1) {
+            const float3 &pos_cu = positions[points.first()];
+
+            const float depth_sq_cu = math::distance_squared(ray_start_cu, pos_cu);
+            if (depth_sq_cu > max_depth_sq_cu) {
+              continue;
+            }
+
+            float2 pos_re;
+            ED_view3d_project_float_v2_m4(&region, pos_cu, pos_re, projection.values);
+
+            BrushPositionCandidate candidate;
+            candidate.position_cu = pos_cu;
+            candidate.depth_sq_cu = depth_sq_cu;
+            candidate.distance_sq_re = math::distance_squared(brush_pos_re, pos_re);
+
+            update_if_better(best_candidate, candidate);
+            continue;
+          }
+
           for (const int segment_i : points.drop_back(1)) {
             const float3 &p1_cu = positions[segment_i];
             const float3 &p2_cu = positions[segment_i + 1];
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc b/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc
index 5f5de9524cc..e57f7056224 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_delete.cc
@@ -163,6 +163,17 @@ struct DeleteOperationExecutor {
     threading::parallel_for(curves_->curves_range(), 512, [&](IndexRange curve_range) {
       for (const int curve_i : curve_range) {
         const IndexRange points = curves_->points_for_curve(curve_i);
+        if (points.size() == 1) {
+          const float3 pos_cu = brush_transform_inv * positions_cu[points.first()];
+          float2 pos_re;
+          ED_view3d_project_float_v2_m4(region_, pos_cu, pos_re, projection.values);
+
+          if (math::distance_squared(brush_pos_re_, pos_re) <= brush_radius_sq_re) {
+            curves_to_delete[curve_i] = true;
+          }
+          continue;
+        }
+
         for (const int segment_i : points.drop_back(1)) {
           const float3 pos1_cu = brush_transform_inv * positions_cu[segment_i];
           const float3 pos2_cu = brush_transform_inv * positions_cu[segment_i + 1];
@@ -213,6 +224,16 @@ struct DeleteOperationExecutor {
     threading::parallel_for(curves_->curves_range(), 512, [&](IndexRange curve_range) {
       for (const int curve_i : curve_range) {
         const IndexRange points = curves_->points_for_curve(curve_i);
+
+        if (points.size() == 1) {
+          const float3 &pos_cu = positions_cu[points.first()];
+          const float distance_sq_cu = math::distance_squared(pos_cu, brush_cu);
+          if (distance_sq_cu < brush_radius_sq_cu) {
+            curves_to_delete[curve_i] = true;
+          }
+          continue;
+        }
+
         for (const int segment_i : points.drop_back(1)) {
           const float3 &pos1_cu = positions_cu[segment_i];
           const float3 &pos2_cu = positions_cu[segment_i + 1];



More information about the Bf-blender-cvs mailing list