35 const StringRef attribute_name =
".selection";
38 if (attributes.
contains(attribute_name)) {
41 switch (create_type) {
58 if (selection.
type().
is<
bool>()) {
61 else if (selection.
type().
is<
float>()) {
73 if (selection.
type().
is<
bool>()) {
76 else if (selection.
type().
is<
float>()) {
89 if (selection.
type().
is<
bool>()) {
92 else if (selection.
type().
is<
float>()) {
100 std::optional<IndexRange> range =
mask.to_range();
104 attributes.
remove(
".selection");
132 bool changed =
false;
153 changed |= !
mask.is_empty();
168 positions.
index_range(), memory, [&](
const int point) {
169 const float2 pos_proj = ED_view3d_project_float_v2_m4(
170 ®ion, positions[point], projection);
171 return BLI_rcti_isect_pt_v(&rect, int2(pos_proj));
190 positions.
index_range(), memory, [&](
const int point) {
191 const float2 pos_proj = ED_view3d_project_float_v2_m4(
192 ®ion, positions[point], projection);
193 if (!BLI_rcti_isect_pt_v(&bbox, int2(pos_proj))) {
197 lasso_coords,
int(pos_proj.x),
int(pos_proj.y),
IS_CLIPPED)) {
213 const float radius_sq = radius * radius;
219 positions.
index_range(), memory, [&](
const int point) {
220 const float2 pos_proj = ED_view3d_project_float_v2_m4(
221 ®ion, positions[point], projection);
222 return math::distance_squared(pos_proj, float2(coord)) <= radius_sq;
245 const float radius_sq = radius * radius;
251 FindClosestData best_match = init;
252 points_mask.slice(range).foreach_index([&](const int point) {
253 const float3 &pos = positions[point];
254 const float2 pos_proj = ED_view3d_project_float_v2_m4(®ion, pos, projection);
256 const float distance_proj_sq = math::distance_squared(pos_proj, mouse_pos);
257 if (distance_proj_sq > radius_sq || distance_proj_sq > best_match.distance_sq) {
261 best_match = {point, distance_proj_sq};
267 if (new_closest_data.distance_sq < initial_closest.distance_sq) {
268 return new_closest_data;
#define BLI_assert_unreachable()
const CPPType & type() const
MutableSpan< T > typed() const
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
constexpr IndexRange()=default
constexpr IndexRange index_range() const
IndexRange index_range() const
bool contains(StringRef name) const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
bool remove(const StringRef name)
GSpanAttributeWriter lookup_for_write_span(StringRef name)
IndexRange index_range() const
void invert_booleans(MutableSpan< bool > span)
bool contains(const VArray< bool > &varray, const IndexMask &indices_to_check, bool value)
bool select_box(PointCloud &pointcloud, const ARegion ®ion, const float4x4 &projection, const rcti &rect, const eSelectOp sel_op)
bool select_lasso(PointCloud &pointcloud, const ARegion ®ion, const float4x4 &projection, const Span< int2 > lasso_coords, const eSelectOp sel_op)
bool select_circle(PointCloud &pointcloud, const ARegion ®ion, const float4x4 &projection, const int2 coord, const float radius, const eSelectOp sel_op)
void fill_selection_true(GMutableSpan selection)
static void invert_selection(MutableSpan< float > selection, const IndexMask &mask)
static bool apply_selection_operation(PointCloud &pointcloud, const IndexMask &mask, eSelectOp sel_op)
static FindClosestData closer_elem(const FindClosestData &a, const FindClosestData &b)
IndexMask retrieve_selected_points(const PointCloud &pointcloud, IndexMaskMemory &memory)
bke::GSpanAttributeWriter ensure_selection_attribute(PointCloud &pointcloud, bke::AttrType create_type)
void fill_selection_false(GMutableSpan selection, const IndexMask &mask)
std::optional< FindClosestData > find_closest_point_to_screen_co(const ARegion ®ion, const Span< float3 > positions, const float4x4 &projection, const IndexMask &points_mask, const float2 mouse_pos, const float radius, const FindClosestData &initial_closest)
bool has_anything_selected(const PointCloud &pointcloud)
void select_all(PointCloud &pointcloud, int action)
constexpr ParallelGrainSize grain_size(int grain_size)
void masked_fill(MutableSpan< T > data, const T &value, const IndexMask &mask)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
MatBase< float, 4, 4 > float4x4
bool BLI_lasso_is_point_inside(Span< int2 > mcoords, int sx, int sy, int error_value)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void BLI_lasso_boundbox(rcti *rect, Span< int2 > mcoords)