Blender V4.3
ED_curves.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BKE_crazyspace.hh"
12#include "BKE_curves.hh"
13
14#include "BLI_index_mask_fwd.hh"
15#include "BLI_vector.hh"
16#include "BLI_vector_set.hh"
17
18#include "ED_select_utils.hh"
19
20struct bContext;
21struct Curves;
22struct UndoType;
23struct ViewContext;
24struct rcti;
25struct TransVertStore;
26struct wmKeyConfig;
27namespace blender::bke {
28enum class AttrDomain : int8_t;
29struct GSpanAttributeWriter;
30} // namespace blender::bke
31
32namespace blender::ed::curves {
33
37void keymap_curves(wmKeyConfig *keyconf);
38
44float (*point_normals_array_create(const Curves *curves_id))[3];
45
52Span<StringRef> get_curves_selection_attribute_names(const bke::CurvesGeometry &curves);
53
57Vector<MutableSpan<float3>> get_curves_positions_for_write(bke::CurvesGeometry &curves);
58
59/* Get all possible curve selection attribute names. */
61
66Span<StringRef> get_curves_bezier_selection_attribute_names(const bke::CurvesGeometry &curves);
67
73 bke::MutableAttributeAccessor &attributes,
74 Span<StringRef> selection_attribute_names = get_curves_all_selection_attribute_names());
75
80 const bke::CurvesGeometry &curves,
81 const bke::crazyspace::GeometryDeformation &deformation,
82 const StringRef attribute_name);
83
85 IndexRange range, Span<float3> positions, StringRef selection_attribute_name)>;
95 const bke::crazyspace::GeometryDeformation &deformation,
96 SelectionRangeFn range_consumer);
97
104 const bke::crazyspace::GeometryDeformation &deformation,
105 SelectionRangeFn range_consumer);
106
107bool object_has_editable_curves(const Main &bmain, const Object &object);
108bke::CurvesGeometry primitive_random_sphere(int curves_size, int points_per_curve);
111
118
119/* -------------------------------------------------------------------- */
127bool curves_poll(bContext *C);
128
131/* -------------------------------------------------------------------- */
138
141/* -------------------------------------------------------------------- */
149 const IndexMask &point_mask,
150 const GrainSize grain_size,
151 IndexMaskMemory &memory);
152
161 int amount_start,
162 int amount_end,
163 bool inverted,
164 IndexMaskMemory &memory);
166 const IndexMask &curves_mask,
167 int amount_start,
168 int amount_end,
169 bool inverted,
170 IndexMaskMemory &memory);
171
181 bke::AttrDomain selection_domain,
182 uint32_t random_seed,
183 float probability,
184 IndexMaskMemory &memory);
186 const IndexMask &mask,
187 bke::AttrDomain selection_domain,
188 uint32_t random_seed,
189 float probability,
190 IndexMaskMemory &memory);
191
194/* -------------------------------------------------------------------- */
209void fill_selection(GMutableSpan selection, bool value);
210void fill_selection_false(GMutableSpan selection, const IndexMask &mask);
211void fill_selection_true(GMutableSpan selection, const IndexMask &mask);
212
217bool has_anything_selected(const bke::CurvesGeometry &curves, bke::AttrDomain selection_domain);
219 bke::AttrDomain selection_domain,
220 const IndexMask &mask);
221
225bool has_anything_selected(GSpan selection);
226bool has_anything_selected(const VArray<bool> &varray, IndexRange range_to_check);
227bool has_anything_selected(const VArray<bool> &varray, const IndexMask &indices_to_check);
228
235
242 StringRef attribute_name,
243 IndexMaskMemory &memory);
245
250 bke::AttrDomain selection_domain,
251 eCustomDataType create_type,
252 StringRef attribute_name = ".selection");
253
255 bke::CurvesGeometry &curves,
256 bke::AttrDomain selection_domain,
257 FunctionRef<void(bke::GSpanAttributeWriter &selection)> fn);
258
260void apply_selection_operation_at_index(GMutableSpan selection, int index, eSelectOp sel_op);
261
270void select_all(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain, int action);
272 const IndexMask &mask,
273 bke::AttrDomain selection_domain,
274 int action);
275
282void select_linked(bke::CurvesGeometry &curves, const IndexMask &curves_mask);
283
289void select_alternate(bke::CurvesGeometry &curves, const bool deselect_ends);
291 const IndexMask &curves_mask,
292 const bool deselect_ends);
293
299void select_adjacent(bke::CurvesGeometry &curves, bool deselect);
300void select_adjacent(bke::CurvesGeometry &curves, const IndexMask &curves_mask, bool deselect);
301
306 int index = -1;
307 float distance = FLT_MAX;
308};
309
315std::optional<FindClosestData> closest_elem_find_screen_space(const ViewContext &vc,
316 OffsetIndices<int> points_by_curve,
317 Span<float3> deformed_positions,
318 const VArray<bool> &cyclic,
319 const float4x4 &projection,
320 const IndexMask &mask,
321 bke::AttrDomain domain,
322 int2 coord,
323 const FindClosestData &initial);
324
328bool select_box(const ViewContext &vc,
329 bke::CurvesGeometry &curves,
330 const bke::crazyspace::GeometryDeformation &deformation,
331 const float4x4 &projection,
332 const IndexMask &selection_mask,
333 const IndexMask &bezier_mask,
334 bke::AttrDomain selection_domain,
335 const rcti &rect,
336 eSelectOp sel_op);
337
341bool select_lasso(const ViewContext &vc,
342 bke::CurvesGeometry &curves,
343 const bke::crazyspace::GeometryDeformation &deformation,
344 const float4x4 &projection_matrix,
345 const IndexMask &selection_mask,
346 const IndexMask &bezier_mask,
347 bke::AttrDomain selection_domain,
348 Span<int2> lasso_coords,
349 eSelectOp sel_op);
350
354bool select_circle(const ViewContext &vc,
355 bke::CurvesGeometry &curves,
356 const bke::crazyspace::GeometryDeformation &deformation,
357 const float4x4 &projection,
358 const IndexMask &selection_mask,
359 const IndexMask &bezier_mask,
360 bke::AttrDomain selection_domain,
361 int2 coord,
362 float radius,
363 eSelectOp sel_op);
364
369 StringRef attribute_name,
370 bool deselect,
371 IndexMaskMemory &memory);
373 const IndexMask &curves_mask,
374 StringRef attribute_name,
375 bool deselect,
376 IndexMaskMemory &memory);
377
382 const bke::CurvesGeometry &curves,
383 const bke::crazyspace::GeometryDeformation &deformation,
384 const float4x4 &projection,
385 const IndexMask &selection_mask,
386 const IndexMask &bezier_mask,
387 bke::AttrDomain selection_domain,
388 StringRef attribute_name,
389 const rcti &rect,
390 IndexMaskMemory &memory);
391
396 const bke::CurvesGeometry &curves,
397 const bke::crazyspace::GeometryDeformation &deformation,
398 const float4x4 &projection,
399 const IndexMask &selection_mask,
400 const IndexMask &bezier_mask,
401 bke::AttrDomain selection_domain,
402 StringRef attribute_name,
403 Span<int2> lasso_coords,
404 IndexMaskMemory &memory);
405
410 const bke::CurvesGeometry &curves,
411 const bke::crazyspace::GeometryDeformation &deformation,
412 const float4x4 &projection,
413 const IndexMask &selection_mask,
414 const IndexMask &bezier_mask,
415 bke::AttrDomain selection_domain,
416 StringRef attribute_name,
417 int2 coord,
418 float radius,
419 IndexMaskMemory &memory);
422/* -------------------------------------------------------------------- */
430bool remove_selection(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain);
431
432void duplicate_points(bke::CurvesGeometry &curves, const IndexMask &mask);
433void duplicate_curves(bke::CurvesGeometry &curves, const IndexMask &mask);
434
439void add_curves(bke::CurvesGeometry &curves, Span<int> new_sizes);
440
449 const IndexMask &curves_to_resize,
450 Span<int> new_sizes);
451
454} // namespace blender::ed::curves
Low-level operations for curves.
eSelectOp
draw_view in_light_buf[] float
void select_linked(bke::CurvesGeometry &curves, const IndexMask &curves_mask)
void apply_selection_operation_at_index(GMutableSpan selection, const int index, const eSelectOp sel_op)
IndexMask select_circle_mask(const ViewContext &vc, const bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, const float4x4 &projection, const IndexMask &selection_mask, const IndexMask &bezier_mask, const bke::AttrDomain selection_domain, const StringRef attribute_name, const int2 coord, const float radius, IndexMaskMemory &memory)
bool remove_selection(bke::CurvesGeometry &curves, const bke::AttrDomain selection_domain)
void keymap_curves(wmKeyConfig *keyconf)
void CURVES_OT_draw(wmOperatorType *ot)
static bool has_anything_selected(const Span< Curves * > curves_ids)
void resize_curves(bke::CurvesGeometry &curves, const IndexMask &curves_to_resize, const Span< int > new_sizes)
IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
void remove_selection_attributes(bke::MutableAttributeAccessor &attributes, Span< StringRef > selection_attribute_names)
void select_all(bke::CurvesGeometry &curves, const IndexMask &mask, const bke::AttrDomain selection_domain, int action)
void duplicate_curves(bke::CurvesGeometry &curves, const IndexMask &mask)
float(* point_normals_array_create(const Curves *curves_id))[3]
void select_alternate(bke::CurvesGeometry &curves, const IndexMask &curves_mask, const bool deselect_ends)
void duplicate_points(bke::CurvesGeometry &curves, const IndexMask &mask)
Span< float3 > get_selection_attribute_positions(const bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, const StringRef attribute_name)
VectorSet< Curves * > get_unique_editable_curves(const bContext &C)
Definition curves_ops.cc:96
void foreach_selectable_point_range(const bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, SelectionRangeFn range_consumer)
bool editable_curves_poll(bContext *C)
void select_adjacent(bke::CurvesGeometry &curves, const IndexMask &curves_mask, const bool deselect)
void foreach_selection_attribute_writer(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain, blender::FunctionRef< void(bke::GSpanAttributeWriter &selection)> fn)
IndexMask curve_mask_from_points(const bke::CurvesGeometry &curves, const IndexMask &point_mask, const GrainSize grain_size, IndexMaskMemory &memory)
Span< StringRef > get_curves_bezier_selection_attribute_names(const bke::CurvesGeometry &curves)
void fill_selection_false(GMutableSpan selection)
bool object_has_editable_curves(const Main &bmain, const Object &object)
Definition curves_ops.cc:82
void add_curves(bke::CurvesGeometry &curves, const Span< int > new_sizes)
IndexMask select_lasso_mask(const ViewContext &vc, const bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, const float4x4 &projection, const IndexMask &selection_mask, const IndexMask &bezier_mask, const bke::AttrDomain selection_domain, const StringRef attribute_name, const Span< int2 > lasso_coords, IndexMaskMemory &memory)
bool editable_curves_in_edit_mode_poll(bContext *C)
bool select_circle(const ViewContext &vc, bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, const float4x4 &projection, const IndexMask &selection_mask, const IndexMask &bezier_mask, const bke::AttrDomain selection_domain, const int2 coord, const float radius, const eSelectOp sel_op)
IndexMask select_adjacent_mask(const bke::CurvesGeometry &curves, const IndexMask &curves_mask, const StringRef attribute_name, const bool deselect, IndexMaskMemory &memory)
void fill_selection_true(GMutableSpan selection)
Vector< MutableSpan< float3 > > get_curves_positions_for_write(bke::CurvesGeometry &curves)
bke::CurvesGeometry primitive_random_sphere(const int curves_size, const int points_per_curve)
Span< StringRef > get_curves_selection_attribute_names(const bke::CurvesGeometry &curves)
void fill_selection(GMutableSpan selection, bool value)
std::optional< FindClosestData > closest_elem_find_screen_space(const ViewContext &vc, const OffsetIndices< int > points_by_curve, const Span< float3 > positions, const VArray< bool > &cyclic, const float4x4 &projection, const IndexMask &mask, const bke::AttrDomain domain, const int2 coord, const FindClosestData &initial_closest)
void undosys_type_register(UndoType *ut)
void transverts_from_curves_positions_create(bke::CurvesGeometry &curves, TransVertStore *tvs)
void ensure_surface_deformation_node_exists(bContext &C, Object &curves_ob)
Definition curves_add.cc:61
Span< StringRef > get_curves_all_selection_attribute_names()
IndexMask end_points(const bke::CurvesGeometry &curves, const IndexMask &curves_mask, const int amount_start, const int amount_end, const bool inverted, IndexMaskMemory &memory)
bool curves_with_surface_poll(bContext *C)
IndexMask select_box_mask(const ViewContext &vc, const bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, const float4x4 &projection, const IndexMask &selection_mask, const IndexMask &bezier_mask, const bke::AttrDomain selection_domain, const StringRef attribute_name, const rcti &rect, IndexMaskMemory &memory)
bke::GSpanAttributeWriter ensure_selection_attribute(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain, eCustomDataType create_type, StringRef attribute_name)
void CURVES_OT_attribute_set(wmOperatorType *ot)
bool curves_poll(bContext *C)
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
void foreach_selectable_curve_range(const bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, SelectionRangeFn range_consumer)
void CURVES_OT_extrude(wmOperatorType *ot)
IndexMask random_mask(const bke::CurvesGeometry &curves, const IndexMask &mask, const bke::AttrDomain selection_domain, const uint32_t random_seed, const float probability, IndexMaskMemory &memory)
bool select_lasso(const ViewContext &vc, bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, const float4x4 &projection_matrix, const IndexMask &selection_mask, const IndexMask &bezier_mask, const bke::AttrDomain selection_domain, const Span< int2 > lasso_coords, const eSelectOp sel_op)
bool editable_curves_with_surface_poll(bContext *C)
bool select_box(const ViewContext &vc, bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, const float4x4 &projection, const IndexMask &selection_mask, const IndexMask &bezier_mask, const bke::AttrDomain selection_domain, const rcti &rect, const eSelectOp sel_op)
#define FLT_MAX
Definition stdcycles.h:14
unsigned int uint32_t
Definition stdint.h:80
signed char int8_t
Definition stdint.h:75
wmOperatorType * ot
Definition wm_files.cc:4125