31 return *
static_cast<const bool *
>(info.
data) == value;
44 if (std::optional<IndexRange> range = sliced_mask.to_range()) {
45 return span.slice(*range).contains(value);
48 const IndexMaskSegment segment = sliced_mask.segment(segment_i);
49 for (const int i : segment) {
50 if (span[i] == value) {
60 indices_to_check.index_range(),
67 constexpr int64_t MaxChunkSize = 512;
69 for (
int64_t start = range.
start(); start < slice_end; start += MaxChunkSize) {
70 const int64_t end = std::min<int64_t>(start + MaxChunkSize, slice_end);
71 const int64_t size = end - start;
72 const IndexMask sliced_mask = indices_to_check.slice(start, size);
73 std::array<bool, MaxChunkSize> values;
74 auto values_end = values.begin() + size;
75 varray.materialize_compressed(sliced_mask, values);
76 if (std::find(values.begin(), values_end, value) != values_end) {
100 const StringRef attribute_name =
".selection";
103 if (attributes.
contains(attribute_name)) {
107 switch (create_type) {
109 attributes.
add(attribute_name,
115 attributes.
add(attribute_name,
128 if (selection.
type().
is<
bool>()) {
131 else if (selection.
type().
is<
float>()) {
143 if (selection.
type().
is<
bool>()) {
146 else if (selection.
type().
is<
float>()) {
159 if (selection.
type().
is<
bool>()) {
162 else if (selection.
type().
is<
float>()) {
170 std::optional<IndexRange> range =
mask.to_range();
174 attributes.
remove(
".selection");
201 bool changed =
false;
221 changed |= !
mask.is_empty();
238 ®ion, positions[point], projection);
260 ®ion, positions[point], projection);
281 const float radius_sq = radius * radius;
289 ®ion, positions[point], projection);
313 const float radius_sq = radius * radius;
319 FindClosestData best_match = init;
320 points_mask.slice(range).foreach_index([&](const int point) {
321 const float3 &pos = positions[point];
322 const float2 pos_proj = ED_view3d_project_float_v2_m4(®ion, pos, projection);
324 const float distance_proj_sq = math::distance_squared(pos_proj, mouse_pos);
325 if (distance_proj_sq > radius_sq || distance_proj_sq > best_match.distance_sq) {
329 best_match = {point, distance_proj_sq};
335 if (new_closest_data.distance_sq < initial_closest.distance_sq) {
336 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)
for(;discarded_id_iter !=nullptr;discarded_id_iter=static_cast< ID * >(discarded_id_iter->next))
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
static IndexMask from_bools(Span< bool > bools, IndexMaskMemory &memory)
const CPPType & type() const
MutableSpan< T > typed() const
constexpr int64_t one_after_last() const
constexpr int64_t start() const
constexpr IndexRange index_range() const
IndexRange index_range() const
CommonVArrayInfo common_info() const
static VArray ForSingle(T value, const int64_t size)
bool contains(StringRef attribute_id) const
bool remove(const StringRef attribute_id)
bool add(const StringRef attribute_id, const AttrDomain domain, const eCustomDataType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_for_write_span(StringRef attribute_id)
IndexMask slice(IndexRange range) const
IndexRange index_range() const
VecBase< float, 2 > float2
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void invert_booleans(MutableSpan< bool > span)
static bool contains(const VArray< bool > &varray, const IndexMask &indices_to_check, const 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, eCustomDataType 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)