Blender V5.3
BKE_key.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
6#include <optional>
7#include <string>
8
9#include "BLI_array.hh"
12#include "BLI_span.hh"
13
14#include "DNA_key_types.h"
15#include "DNA_listBase.h"
16
17namespace blender {
18
22struct Curve;
23struct ID;
24struct Key;
25struct KeyBlock;
26struct Lattice;
27struct Main;
28struct Mesh;
29struct Nurb;
30struct Object;
31
32void BKE_key_free_nolib(Key *key);
33Key *BKE_key_add(Main *bmain, ID *id);
39void BKE_key_sort(Key *key);
40
41void key_curve_position_weights(float t, float data[4], KeyInterpolationType type);
45void key_curve_tangent_weights(float t, float data[4], KeyInterpolationType type);
49void key_curve_normal_weights(float t, float data[4], KeyInterpolationType type);
50
58 int *r_totelem,
59 float *arr,
60 size_t arr_size,
61 std::optional<Span<bool>> keys_to_process,
62 ID *obdata);
63float *BKE_key_evaluate_object(Object *ob, int *r_totelem);
64
68int BKE_keyblock_element_count_from_shape(const Key *key, int shape_index);
69int BKE_keyblock_element_count(const Key *key);
70
74size_t BKE_keyblock_element_calc_size_from_shape(const Key *key, int shape_index);
75size_t BKE_keyblock_element_calc_size(const Key *key);
76
77bool BKE_key_idtype_support(short id_type);
78
88
89KeyBlock *BKE_keyblock_add(Key *key, const char *name);
90
93
102KeyBlock *BKE_keyblock_add_ctime(Key *key, const char *name, bool do_force);
110KeyBlock *BKE_keyblock_find_name(Key *key, const char name[]);
111
112KeyBlock *BKE_keyblock_find_uid(Key *key, int uid);
113
117void BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src);
122std::optional<std::string> BKE_keyblock_curval_rnapath_get(const Key *key, const KeyBlock *kb);
123
124/* conversion functions */
125/* NOTE: 'update_from' versions do not (re)allocate mem in kb, while 'convert_from' do. */
126
130
131int BKE_keyblock_curve_element_count(const ListBaseT<Nurb> *nurb);
132void BKE_keyblock_curve_data_transform(const ListBaseT<Nurb> *nurb,
133 const float mat[4][4],
134 const void *src,
135 void *dst);
136void BKE_keyblock_update_from_curve(const Curve *cu, KeyBlock *kb, const ListBaseT<Nurb> *nurb);
137void BKE_keyblock_convert_from_curve(const Curve *cu, KeyBlock *kb, const ListBaseT<Nurb> *nurb);
138void BKE_keyblock_convert_to_curve(KeyBlock *kb, Curve *cu, ListBaseT<Nurb> *nurb);
139
141void BKE_keyblock_convert_from_mesh(const Mesh *mesh, const Key *key, KeyBlock *kb);
142void BKE_keyblock_convert_to_mesh(const KeyBlock *kb, MutableSpan<float3> vert_positions);
143
154 Mesh *mesh,
155 float (*r_vert_normals)[3],
156 float (*r_face_normals)[3],
157 float (*r_loop_normals)[3]);
158
159/* other management */
160
170bool BKE_keyblock_move(Object *ob, int org_index, int new_index);
171
175bool BKE_keyblock_is_basis(const Key *key, int index);
176
181std::optional<Array<bool>> BKE_keyblock_get_dependent_keys(const Key *key, int index);
182
183/* -------------------------------------------------------------------- */
186
190void BKE_keyblock_data_get_from_shape(const Key *key, MutableSpan<float3> arr, int shape_index);
191void BKE_keyblock_data_get(const Key *key, MutableSpan<float3> arr);
192
197 int shape_index,
198 Span<float3> coords,
199 const float4x4 &transform);
205 const ListBaseT<Nurb> *nurb,
206 int shape_index,
207 const void *data,
208 const float4x4 &transform);
212void BKE_keyblock_data_set(Key *key, int shape_index, const void *data);
213
214void BKE_keyblock_rename(Main &bmain, Key *key, KeyBlock *kb, const char *newname);
216
217} // namespace blender
These structs are the foundation for all linked lists in the library system.
BMesh Iterators.
void BKE_keyblock_data_set_with_mat4(Key *key, int shape_index, Span< float3 > coords, const float4x4 &transform)
Definition key.cc:1196
void BKE_keyblock_update_from_lattice(const Lattice *lt, KeyBlock *kb)
Definition key.cc:1475
void BKE_keyblock_data_get_from_shape(const Key *key, MutableSpan< float3 > arr, int shape_index)
Definition key.cc:1176
KeyBlock * BKE_keyblock_duplicate(Key *key, KeyBlock *kb_src)
Definition key.cc:1367
Key ** BKE_key_from_object_p(Object *ob)
Definition key.cc:1302
bool BKE_key_idtype_support(short id_type)
Definition key.cc:1254
bool BKE_keyblock_move(Object *ob, int org_index, int new_index)
Definition key.cc:1778
void BKE_keyblock_curve_data_transform(const ListBaseT< Nurb > *nurb, const float mat[4][4], const void *src, void *dst)
Definition key.cc:1584
bool BKE_keyblock_is_basis(const Key *key, int index)
Definition key.cc:1859
void BKE_keyblock_convert_to_mesh(const KeyBlock *kb, MutableSpan< float3 > vert_positions)
Definition key.cc:1697
int BKE_keyblock_element_count_from_shape(const Key *key, int shape_index)
Definition key.cc:1142
void BKE_keyblock_update_from_mesh(const Mesh *mesh, KeyBlock *kb)
Definition key.cc:1668
void BKE_key_sort(Key *key)
Definition key.cc:279
void BKE_keyblock_curve_data_set_with_mat4(Key *key, const ListBaseT< Nurb > *nurb, int shape_index, const void *data, const float4x4 &transform)
Definition key.cc:1222
KeyBlock * BKE_keyblock_from_object(Object *ob)
Definition key.cc:1407
void BKE_keyblock_convert_to_curve(KeyBlock *kb, Curve *cu, ListBaseT< Nurb > *nurb)
Definition key.cc:1658
float * BKE_key_evaluate_object_ex(Object *ob, int *r_totelem, float *arr, size_t arr_size, std::optional< Span< bool > > keys_to_process, ID *obdata)
Definition key.cc:1009
KeyBlock * BKE_keyblock_from_object_reference(Object *ob)
Definition key.cc:1414
KeyBlock * BKE_keyblock_find_name(Key *key, const char name[])
Definition key.cc:1434
MatBase< float, 4, 4 > float4x4
void key_curve_normal_weights(float t, float data[4], KeyInterpolationType type)
Definition key.cc:393
void BKE_keyblock_rename(Main &bmain, Key *key, KeyBlock *kb, const char *newname)
Definition key.cc:1916
std::optional< Array< bool > > BKE_keyblock_get_dependent_keys(const Key *key, int index)
Definition key.cc:1875
KeyBlock * BKE_keyblock_find_by_index(Key *key, int index)
Definition key.cc:1425
Key * BKE_key_from_id(ID *id)
Definition key.cc:1291
KeyBlock * BKE_keyblock_find_uid(Key *key, int uid)
Definition key.cc:1439
void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb, Mesh *mesh, float(*r_vert_normals)[3], float(*r_face_normals)[3], float(*r_loop_normals)[3])
Definition key.cc:1702
Key * BKE_key_add(Main *bmain, ID *id)
Definition key.cc:228
BMesh const char void * data
Key ** BKE_key_from_id_p(ID *id)
Definition key.cc:1266
std::optional< std::string > BKE_keyblock_curval_rnapath_get(const Key *key, const KeyBlock *kb)
Definition key.cc:1460
size_t BKE_keyblock_element_calc_size(const Key *key)
Definition key.cc:1164
void BKE_keyblock_data_get(const Key *key, MutableSpan< float3 > arr)
Definition key.cc:1191
void BKE_keyblock_convert_from_lattice(const Lattice *lt, KeyBlock *kb)
Definition key.cc:1493
void BKE_keyblock_data_set(Key *key, int shape_index, const void *data)
Definition key.cc:1239
int BKE_keyblock_curve_element_count(const ListBaseT< Nurb > *nurb)
Definition key.cc:1528
KeyBlock * BKE_keyblock_add(Key *key, const char *name)
Definition key.cc:1322
float * BKE_key_evaluate_object(Object *ob, int *r_totelem)
Definition key.cc:1137
void BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src)
copy shape-key attributes, but not key data or name/UID.
Definition key.cc:1449
int BKE_keyblock_element_count(const Key *key)
Definition key.cc:1154
KeyBlock * BKE_keyblock_add_ctime(Key *key, const char *name, bool do_force)
Definition key.cc:1380
void key_curve_position_weights(float t, float data[4], KeyInterpolationType type)
Definition key.cc:310
void BKE_key_free_nolib(Key *key)
Definition key.cc:218
size_t BKE_keyblock_element_calc_size_from_shape(const Key *key, int shape_index)
Definition key.cc:1159
Key * BKE_key_from_object(Object *ob)
Definition key.cc:1311
void BKE_keyblock_convert_to_lattice(const KeyBlock *kb, Lattice *lt)
Definition key.cc:1517
void BKE_keyblock_convert_from_mesh(const Mesh *mesh, const Key *key, KeyBlock *kb)
Definition key.cc:1681
void BKE_keyblock_update_from_curve(const Curve *cu, KeyBlock *kb, const ListBaseT< Nurb > *nurb)
Definition key.cc:1547
void BKE_keyblock_convert_from_curve(const Curve *cu, KeyBlock *kb, const ListBaseT< Nurb > *nurb)
Definition key.cc:1615
void key_curve_tangent_weights(float t, float data[4], KeyInterpolationType type)
Definition key.cc:353