Blender V4.3
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 IndexMaskMemory memory;
28 IndexMask selection = retrieve_selected_points(curves, memory);
29 MutableSpan<float3> positions = curves.positions_for_write();
30
31 tvs->transverts = static_cast<TransVert *>(
32 MEM_calloc_arrayN(selection.size(), sizeof(TransVert), __func__));
33 tvs->transverts_tot = selection.size();
34
35 selection.foreach_index(GrainSize(1024), [&](const int64_t i, const int64_t pos) {
36 TransVert &tv = tvs->transverts[pos];
37 tv.loc = positions[i];
38 tv.flag = SELECT;
39 copy_v3_v3(tv.oldloc, tv.loc);
40 });
41}
42
44{
45 using namespace blender;
46 const bke::CurvesGeometry &curves = curves_id->geometry.wrap();
47 const int size = curves.points_num();
48 float3 *data = static_cast<float3 *>(MEM_malloc_arrayN(size, sizeof(float3), __func__));
50 return reinterpret_cast<float(*)[3]>(data);
51}
52
53} // 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.
void append(const T &value)
#define SELECT
draw_view in_light_buf[] float
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
Definition mallocn.cc:45
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
Definition mallocn.cc:43
void curves_normals_point_domain_calc(const CurvesGeometry &curves, MutableSpan< float3 > normals)
float(* point_normals_array_create(const Curves *curves_id))[3]
Vector< MutableSpan< float3 > > get_curves_positions_for_write(bke::CurvesGeometry &curves)
void transverts_from_curves_positions_create(bke::CurvesGeometry &curves, TransVertStore *tvs)
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
__int64 int64_t
Definition stdint.h:89
TransVert * transverts
float * loc
float oldloc[3]