Blender  V3.3
curves_sculpt_selection.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "BLI_index_mask_ops.hh"
4 
5 #include "BKE_curves.hh"
6 
8 
9 #include "ED_curves_sculpt.h"
10 
11 namespace blender::ed::sculpt_paint {
12 
14 {
15  switch (domain) {
16  case ATTR_DOMAIN_CURVE:
17  return curves.selection_curve_float();
18  case ATTR_DOMAIN_POINT:
19  return curves.adapt_domain(
20  curves.selection_point_float(), ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE);
21  default:
23  return {};
24  }
25 }
26 
28 {
29  if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
31  }
33  eAttrDomain(curves_id.selection_domain));
34 }
35 
37 {
38  switch (domain) {
39  case ATTR_DOMAIN_CURVE:
40  return curves.adapt_domain(
41  curves.selection_curve_float(), ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT);
42  case ATTR_DOMAIN_POINT:
43  return curves.selection_point_float();
44  default:
46  return {};
47  }
48 }
49 
51 {
52  if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
54  }
56  eAttrDomain(curves_id.selection_domain));
57 }
58 
60  const eAttrDomain domain,
61  Vector<int64_t> &r_indices)
62 {
63  switch (domain) {
64  case ATTR_DOMAIN_POINT: {
65  const VArray<float> selection = curves.selection_point_float();
66  if (selection.is_single()) {
67  return selection.get_internal_single() <= 0.0f ? IndexMask(0) :
68  IndexMask(curves.curves_num());
69  }
71  curves.curves_range(), 512, r_indices, [&](const int curve_i) {
72  for (const int i : curves.points_for_curve(curve_i)) {
73  if (selection[i] > 0.0f) {
74  return true;
75  }
76  }
77  return false;
78  });
79  }
80  case ATTR_DOMAIN_CURVE: {
81  const VArray<float> selection = curves.selection_curve_float();
82  if (selection.is_single()) {
83  return selection.get_internal_single() <= 0.0f ? IndexMask(0) :
84  IndexMask(curves.curves_num());
85  }
87  curves.curves_range(), 2048, r_indices, [&](const int i) {
88  return selection[i] > 0.0f;
89  });
90  }
91  default:
93  return {};
94  }
95 }
96 
98 {
99  if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
100  return CurvesGeometry::wrap(curves_id.geometry).curves_range();
101  }
103  eAttrDomain(curves_id.selection_domain),
104  r_indices);
105 }
106 
108  const eAttrDomain domain,
109  Vector<int64_t> &r_indices)
110 {
111  switch (domain) {
112  case ATTR_DOMAIN_POINT: {
113  const VArray<float> selection = curves.selection_point_float();
114  if (selection.is_single()) {
115  return selection.get_internal_single() <= 0.0f ? IndexMask(0) :
116  IndexMask(curves.points_num());
117  }
119  curves.points_range(), 2048, r_indices, [&](const int i) {
120  return selection[i] > 0.0f;
121  });
122  }
123  case ATTR_DOMAIN_CURVE: {
124  const VArray<float> selection = curves.selection_curve_float();
125  if (selection.is_single()) {
126  return selection.get_internal_single() <= 0.0f ? IndexMask(0) :
127  IndexMask(curves.points_num());
128  }
129  const VArray<float> point_selection = curves.adapt_domain(
132  curves.points_range(), 2048, r_indices, [&](const int i) {
133  return point_selection[i] > 0.0f;
134  });
135  }
136  default:
138  return {};
139  }
140 }
141 
143 {
144  if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
145  return CurvesGeometry::wrap(curves_id.geometry).points_range();
146  }
148  eAttrDomain(curves_id.selection_domain),
149  r_indices);
150 }
151 
152 } // namespace blender::ed::sculpt_paint
eAttrDomain
Definition: BKE_attribute.h:25
@ ATTR_DOMAIN_CURVE
Definition: BKE_attribute.h:31
@ ATTR_DOMAIN_POINT
Definition: BKE_attribute.h:27
Low-level operations for curves.
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
@ CV_SCULPT_SELECTION_ENABLED
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
static VArray ForSingle(T value, const int64_t size)
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
Definition: BKE_curves.hh:138
static struct PartialUpdateUser * wrap(PartialUpdateUserImpl *user)
IndexMask retrieve_selected_curves(const Curves &curves_id, Vector< int64_t > &r_indices)
VArray< float > get_curves_selection(const Curves &curves_id)
VArray< float > get_point_selection(const Curves &curves_id)
static IndexMask retrieve_selected_curves(const CurvesGeometry &curves, const eAttrDomain domain, Vector< int64_t > &r_indices)
IndexMask retrieve_selected_points(const Curves &curves_id, Vector< int64_t > &r_indices)
IndexMask find_indices_based_on_predicate(const IndexMask indices_to_check, const int64_t parallel_grain_size, Vector< int64_t > &r_indices, const Predicate &predicate)
CurvesGeometry geometry
char selection_domain