31 return *
static_cast<const bool *
>(
info.data) ==
value;
44 if (std::optional<IndexRange>
range = sliced_mask.to_range()) {
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);
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)) {
106 const int domain_size = pointcloud.
totpoint;
107 switch (create_type) {
109 attributes.
add(attribute_name,
115 attributes.
add(attribute_name,
128 if (selection.
type().
is<
bool>()) {
129 index_mask::masked_fill(selection.
typed<
bool>(),
false,
mask);
131 else if (selection.
type().
is<
float>()) {
132 index_mask::masked_fill(selection.
typed<
float>(), 0.0f,
mask);
143 if (selection.
type().
is<
bool>()) {
144 index_mask::masked_fill(selection.
typed<
bool>(),
true,
mask);
146 else if (selection.
type().
is<
float>()) {
147 index_mask::masked_fill(selection.
typed<
float>(), 1.0f,
mask);
154 GrainSize(2048), [&](
const int64_t i) { selection[i] = 1.0f - selection[i]; });
159 if (selection.
type().
is<
bool>()) {
160 array_utils::invert_booleans(selection.
typed<
bool>(),
mask);
162 else if (selection.
type().
is<
float>()) {
170 std::optional<IndexRange>
range =
mask.to_range();
174 attributes.
remove(
".selection");
181 fill_selection_true(selection.
span,
mask);
184 fill_selection_false(selection.
span,
mask);
201 bool changed =
false;
210 fill_selection_true(selection.
span,
mask);
213 fill_selection_false(selection.
span,
mask);
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;
345 ".selection", bke::AttrDomain::Point,
true);
346 return IndexMask::from_bools(selection, memory);
#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 DBVT_INLINE btScalar size(const btDbvtVolume &a)
const CPPType & type() const
MutableSpan< T > typed() const
constexpr Span slice(int64_t start, int64_t size) const
constexpr IndexRange index_range() const
constexpr bool contains(const T &value) const
IndexRange index_range() const
CommonVArrayInfo common_info() const
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)
static bool contains(const VArray< bool > &varray, const IndexMask &indices_to_check, const bool value)
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)
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)
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)