Blender V4.5
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
8
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 "DNA_view3d_types.h"
20
21#include "ED_select_utils.hh"
22
23struct bContext;
24struct Curves;
25struct UndoType;
26struct ViewContext;
27struct rcti;
28struct TransVertStore;
29struct wmKeyConfig;
30struct wmOperator;
31namespace blender::bke {
32enum class AttrDomain : int8_t;
34} // namespace blender::bke
35
36namespace blender::ed::curves {
37
40void undosys_type_register(UndoType *ut);
41void keymap_curves(wmKeyConfig *keyconf);
42
48float (*point_normals_array_create(const Curves *curves_id))[3];
49
56Span<StringRef> get_curves_selection_attribute_names(const bke::CurvesGeometry &curves);
57
62
66Vector<Span<float3>> get_curves_positions(const bke::CurvesGeometry &curves);
67
68/* Get all possible curve selection attribute names. */
70
75Span<StringRef> get_curves_bezier_selection_attribute_names(const bke::CurvesGeometry &curves);
76
82 bke::MutableAttributeAccessor &attributes,
83 Span<StringRef> selection_attribute_names = get_curves_all_selection_attribute_names());
84
89 const bke::CurvesGeometry &curves,
90 const bke::crazyspace::GeometryDeformation &deformation,
91 StringRef attribute_name);
92
94 IndexRange range, Span<float3> positions, StringRef selection_attribute_name)>;
104 const bke::crazyspace::GeometryDeformation &deformation,
105 eHandleDisplay handle_display,
106 SelectionRangeFn range_consumer);
107
114 const bke::crazyspace::GeometryDeformation &deformation,
115 eHandleDisplay handle_display,
116 SelectionRangeFn range_consumer);
117
118bool object_has_editable_curves(const Main &bmain, const Object &object);
119bke::CurvesGeometry primitive_random_sphere(int curves_size, int points_per_curve);
122
129 TransVertStore *tvs,
130 const bool skip_handles);
131
132/* -------------------------------------------------------------------- */
135
140bool curves_poll(bContext *C);
141
143
144/* -------------------------------------------------------------------- */
147
153
155
156/* -------------------------------------------------------------------- */
159
164 const IndexMask &point_mask,
165 const GrainSize grain_size,
166 IndexMaskMemory &memory);
167
176 int amount_start,
177 int amount_end,
178 bool inverted,
179 IndexMaskMemory &memory);
181 const IndexMask &curves_mask,
182 int amount_start,
183 int amount_end,
184 bool inverted,
185 IndexMaskMemory &memory);
186
188
189/* -------------------------------------------------------------------- */
201
202void fill_selection_false(GMutableSpan selection);
203void fill_selection_true(GMutableSpan selection);
204void fill_selection(GMutableSpan selection, bool value);
205void fill_selection_false(GMutableSpan selection, const IndexMask &mask);
206void fill_selection_true(GMutableSpan selection, const IndexMask &mask);
207
214 bke::AttrDomain selection_domain,
215 const IndexMask &mask);
216
220bool has_anything_selected(GSpan selection);
221bool has_anything_selected(const VArray<bool> &varray, IndexRange range_to_check);
222bool has_anything_selected(const VArray<bool> &varray, const IndexMask &indices_to_check);
223
230
237 StringRef attribute_name,
238 IndexMaskMemory &memory);
240
246
251 bke::AttrDomain selection_domain,
252 eCustomDataType create_type,
253 StringRef attribute_name = ".selection");
254
257 bke::AttrDomain selection_domain,
258 FunctionRef<void(bke::GSpanAttributeWriter &selection)> fn);
259
261void apply_selection_operation_at_index(GMutableSpan selection, int index, eSelectOp sel_op);
262
271void select_all(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain, int action);
273 const IndexMask &mask,
274 bke::AttrDomain selection_domain,
275 int action);
276
283void select_linked(bke::CurvesGeometry &curves, const IndexMask &curves_mask);
284
290void select_alternate(bke::CurvesGeometry &curves, const bool deselect_ends);
292 const IndexMask &curves_mask,
293 const bool deselect_ends);
294
300void select_adjacent(bke::CurvesGeometry &curves, bool deselect);
301void select_adjacent(bke::CurvesGeometry &curves, const IndexMask &curves_mask, bool deselect);
302
307 int index = -1;
309};
310
316std::optional<FindClosestData> closest_elem_find_screen_space(const ViewContext &vc,
317 OffsetIndices<int> points_by_curve,
318 Span<float3> deformed_positions,
319 const VArray<bool> &cyclic,
320 const float4x4 &projection,
321 const IndexMask &mask,
322 bke::AttrDomain domain,
323 int2 coord,
324 const FindClosestData &initial);
325
329bool select_box(const ViewContext &vc,
331 const bke::crazyspace::GeometryDeformation &deformation,
332 const float4x4 &projection,
333 const IndexMask &selection_mask,
334 const IndexMask &bezier_mask,
335 bke::AttrDomain selection_domain,
336 const rcti &rect,
337 eSelectOp sel_op);
338
342bool select_lasso(const ViewContext &vc,
344 const bke::crazyspace::GeometryDeformation &deformation,
345 const float4x4 &projection,
346 const IndexMask &selection_mask,
347 const IndexMask &bezier_mask,
348 bke::AttrDomain selection_domain,
349 Span<int2> lasso_coords,
350 eSelectOp sel_op);
351
355bool select_circle(const ViewContext &vc,
357 const bke::crazyspace::GeometryDeformation &deformation,
358 const float4x4 &projection,
359 const IndexMask &selection_mask,
360 const IndexMask &bezier_mask,
361 bke::AttrDomain selection_domain,
362 int2 coord,
363 float radius,
364 eSelectOp sel_op);
365
370 StringRef attribute_name,
371 bool deselect,
372 IndexMaskMemory &memory);
374 const IndexMask &curves_mask,
375 StringRef attribute_name,
376 bool deselect,
377 IndexMaskMemory &memory);
378
384 const bke::crazyspace::GeometryDeformation &deformation,
385 const float4x4 &projection,
386 const IndexMask &selection_mask,
387 const IndexMask &bezier_mask,
388 bke::AttrDomain selection_domain,
389 StringRef attribute_name,
390 const rcti &rect,
391 IndexMaskMemory &memory);
392
398 const bke::crazyspace::GeometryDeformation &deformation,
399 const float4x4 &projection,
400 const IndexMask &selection_mask,
401 const IndexMask &bezier_mask,
402 bke::AttrDomain selection_domain,
403 StringRef attribute_name,
404 Span<int2> lasso_coords,
405 IndexMaskMemory &memory);
406
412 const bke::crazyspace::GeometryDeformation &deformation,
413 const float4x4 &projection,
414 const IndexMask &selection_mask,
415 const IndexMask &bezier_mask,
416 bke::AttrDomain selection_domain,
417 StringRef attribute_name,
418 int2 coord,
419 float radius,
420 IndexMaskMemory &memory);
422
423/* -------------------------------------------------------------------- */
426
432
435
437 const IndexMask &points_to_separate,
438 bke::CurvesGeometry &separated,
439 bke::CurvesGeometry &retained);
440
442 const IndexMask &points_to_split);
443
449
458 const IndexMask &curves_to_resize,
459 Span<int> new_sizes);
465void reorder_curves(bke::CurvesGeometry &curves, Span<int> old_by_new_indices_map);
466
468
470
471} // namespace blender::ed::curves
Low-level operations for curves.
float[3] Vector
struct Curves Curves
eHandleDisplay
struct wmKeyConfig wmKeyConfig
eSelectOp
#define C
Definition RandGen.cpp:29
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void select_linked(bke::CurvesGeometry &curves, const IndexMask &curves_mask)
void transverts_from_curves_positions_create(bke::CurvesGeometry &curves, TransVertStore *tvs, const bool skip_handles)
void apply_selection_operation_at_index(GMutableSpan selection, const int index, const eSelectOp sel_op)
void foreach_selectable_point_range(const bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, eHandleDisplay handle_display, SelectionRangeFn range_consumer)
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)
Vector< Span< float3 > > get_curves_positions(const bke::CurvesGeometry &curves)
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)
void foreach_selectable_curve_range(const bke::CurvesGeometry &curves, const bke::crazyspace::GeometryDeformation &deformation, eHandleDisplay handle_display, SelectionRangeFn range_consumer)
VectorSet< Curves * > get_unique_editable_curves(const bContext &C)
Definition curves_ops.cc:91
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 retrieve_all_selected_points(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
IndexMask curve_mask_from_points(const bke::CurvesGeometry &curves, const IndexMask &point_mask, const GrainSize grain_size, IndexMaskMemory &memory)
void separate_points(const bke::CurvesGeometry &curves, const IndexMask &points_to_separate, bke::CurvesGeometry &separated, bke::CurvesGeometry &retained)
Span< StringRef > get_curves_bezier_selection_attribute_names(const bke::CurvesGeometry &curves)
bke::CurvesGeometry split_points(const bke::CurvesGeometry &curves, const IndexMask &points_to_split)
void fill_selection_false(GMutableSpan selection)
bool object_has_editable_curves(const Main &bmain, const Object &object)
Definition curves_ops.cc:77
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 ensure_surface_deformation_node_exists(bContext &C, Object &curves_ob)
Definition curves_add.cc:64
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)
FunctionRef< void( IndexRange range, Span< float3 > positions, StringRef selection_attribute_name)> SelectionRangeFn
Definition ED_curves.hh:93
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_separate(wmOperatorType *ot)
bool select_lasso(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 Span< int2 > lasso_coords, const eSelectOp sel_op)
void CURVES_OT_attribute_set(wmOperatorType *ot)
bool curves_poll(bContext *C)
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
wmOperatorStatus join_objects_exec(bContext *C, wmOperator *op)
void CURVES_OT_extrude(wmOperatorType *ot)
void CURVES_OT_select_linked_pick(wmOperatorType *ot)
void reorder_curves(bke::CurvesGeometry &curves, const Span< int > old_by_new_indices_map)
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)
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
#define FLT_MAX
Definition stdcycles.h:14
wmOperatorType * ot
Definition wm_files.cc:4225