35 const StringRef attribute_name =
".selection";
38 if (attributes.
contains(attribute_name)) {
42 switch (create_type) {
44 attributes.
add(attribute_name,
50 attributes.
add(attribute_name,
63 if (selection.
type().
is<
bool>()) {
66 else if (selection.
type().
is<
float>()) {
78 if (selection.
type().
is<
bool>()) {
81 else if (selection.
type().
is<
float>()) {
94 if (selection.
type().
is<
bool>()) {
97 else if (selection.
type().
is<
float>()) {
105 std::optional<IndexRange> range =
mask.to_range();
109 attributes.
remove(
".selection");
137 bool changed =
false;
158 changed |= !
mask.is_empty();
175 ®ion, positions[point], projection);
197 ®ion, positions[point], projection);
218 const float radius_sq = radius * radius;
226 ®ion, positions[point], projection);
250 const float radius_sq = radius * radius;
256 FindClosestData best_match = init;
257 points_mask.slice(range).foreach_index([&](const int point) {
258 const float3 &pos = positions[point];
259 const float2 pos_proj = ED_view3d_project_float_v2_m4(®ion, pos, projection);
261 const float distance_proj_sq = math::distance_squared(pos_proj, mouse_pos);
262 if (distance_proj_sq > radius_sq || distance_proj_sq > best_match.distance_sq) {
266 best_match = {point, distance_proj_sq};
272 if (new_closest_data.distance_sq < initial_closest.distance_sq) {
273 return new_closest_data;
#define BLI_assert_unreachable()
bool BLI_lasso_is_point_inside(blender::Span< blender::int2 > mcoords, int sx, int sy, int error_value)
void BLI_lasso_boundbox(rcti *rect, blender::Span< blender::int2 > mcoords)
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
blender::float2 ED_view3d_project_float_v2_m4(const ARegion *region, const float co[3], const blender::float4x4 &mat)
static IndexMask from_bools(Span< bool > bools, IndexMaskMemory &memory)
const CPPType & type() const
MutableSpan< T > typed() const
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
constexpr IndexRange index_range() const
IndexRange index_range() const
static VArray from_single(T value, const int64_t size)
bool contains(StringRef attribute_id) const
bool add(const StringRef attribute_id, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
bool remove(const StringRef attribute_id)
GSpanAttributeWriter lookup_for_write_span(StringRef attribute_id)
IndexRange index_range() const
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
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 span)
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)
void masked_fill(MutableSpan< T > data, const T &value, const IndexMask &mask)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
static void init(bNodeTree *, bNode *node)