Blender V4.5
curves_data.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_curves.hh"
6
7#include "DNA_object_types.h"
8
9#include "ED_curves.hh"
10#include "ED_transverts.hh"
11
12namespace blender::ed::curves {
13
15{
16 Vector<MutableSpan<float3>> positions_per_attribute;
17 positions_per_attribute.append(curves.positions_for_write());
18 if (curves.has_curve_with_type(CURVE_TYPE_BEZIER)) {
19 positions_per_attribute.append(curves.handle_positions_left_for_write());
20 positions_per_attribute.append(curves.handle_positions_right_for_write());
21 }
22 return positions_per_attribute;
23}
24
26{
27 Vector<Span<float3>> positions_per_attribute;
28 positions_per_attribute.append(curves.positions());
29 if (curves.has_curve_with_type(CURVE_TYPE_BEZIER)) {
30 positions_per_attribute.append(curves.handle_positions_left());
31 positions_per_attribute.append(curves.handle_positions_right());
32 }
33 return positions_per_attribute;
34}
35
37 TransVertStore *tvs,
38 const bool skip_handles)
39{
41
42 IndexMaskMemory memory;
43 std::array<IndexMask, 3> selection;
44 for (const int i : selection_names.index_range()) {
45 selection[i] = ed::curves::retrieve_selected_points(curves, selection_names[i], memory);
46 }
47
48 if (skip_handles) {
49 /* When the control point is selected, both handles are ignored. */
50 selection[1] = IndexMask::from_difference(selection[1], selection[0], memory);
51 selection[2] = IndexMask::from_difference(selection[2], selection[0], memory);
52 }
53
54 const int size = selection[0].size() + selection[1].size() + selection[2].size();
55 if (size == 0) {
56 return;
57 }
58
60 tvs->transverts_tot = size;
61
62 int offset = 0;
64 for (const int attribute_i : positions.index_range()) {
65 selection[attribute_i].foreach_index(GrainSize(1024), [&](const int64_t i, const int64_t pos) {
66 TransVert &tv = tvs->transverts[pos + offset];
67 tv.loc = positions[attribute_i][i];
68 tv.flag = SELECT;
69 copy_v3_v3(tv.oldloc, tv.loc);
70 });
71
72 offset += selection[attribute_i].size();
73 }
74}
75
76float (*point_normals_array_create(const Curves *curves_id))[3]
77{
78 using namespace blender;
79 const bke::CurvesGeometry &curves = curves_id->geometry.wrap();
80 const int size = curves.points_num();
83 return reinterpret_cast<float(*)[3]>(data);
84}
85
86} // namespace blender::ed::curves
Low-level operations for curves.
MINLINE void copy_v3_v3(float r[3], const float a[3])
@ CURVE_TYPE_BEZIER
Object is a sort of wrapper for general info.
BMesh const char void * data
long long int int64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
static IndexMask from_difference(const IndexMask &mask_a, const IndexMask &mask_b, IndexMaskMemory &memory)
constexpr IndexRange index_range() const
Definition BLI_span.hh:401
void append(const T &value)
IndexRange index_range() const
#define SELECT
uint pos
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:123
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:133
void curves_normals_point_domain_calc(const CurvesGeometry &curves, MutableSpan< float3 > normals)
void transverts_from_curves_positions_create(bke::CurvesGeometry &curves, TransVertStore *tvs, const bool skip_handles)
Vector< Span< float3 > > get_curves_positions(const bke::CurvesGeometry &curves)
float(* point_normals_array_create(const Curves *curves_id))[3]
Vector< MutableSpan< float3 > > get_curves_positions_for_write(bke::CurvesGeometry &curves)
Span< StringRef > get_curves_selection_attribute_names(const bke::CurvesGeometry &curves)
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
VecBase< float, 3 > float3
TransVert * transverts
float * loc
float oldloc[3]
i
Definition text_draw.cc:230