Blender V5.3
BKE_constraint.h
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
5#pragma once
6
10
11#include "DNA_listBase.h"
12
13namespace blender {
14
15struct BlendDataReader;
16struct BlendWriter;
17struct Depsgraph;
18struct ID;
19struct Object;
20struct Scene;
21struct bConstraint;
23struct bPoseChannel;
24
25enum eBConstraint_Types : short;
26
27/* ---------------------------------------------------------------------------- */
28
29/* special struct for use in constraint evaluation */
32 struct Depsgraph *depsgraph;
34 struct Scene *scene;
36 struct Object *ob;
41
43 float matrix[4][4];
45 float startmat[4][4];
48
50 short type;
55 short rotOrder;
56};
57
58/* ---------------------------------------------------------------------------- */
59
60/* Callback format for performing operations on ID-pointers for Constraints */
61typedef void (*ConstraintIDFunc)(struct bConstraint *con,
62 struct ID **idpoin,
63 bool is_reference,
64 void *userdata);
65
66/* ....... */
67
82 /* Admin/identity. */
84 short type;
86 short size;
88 char name[32];
90 char struct_name[32];
91
92 /* data management function pointers - special handling */
94 void (*free_data)(struct bConstraint *con);
96 void (*id_looper)(struct bConstraint *con, ConstraintIDFunc func, void *userdata);
98 void (*copy_data)(struct bConstraint *con, struct bConstraint *src);
103 void (*new_data)(void *cdata);
104
105 /* target handling function pointers */
110 int (*get_constraint_targets)(struct bConstraint *con, ListBaseT<bConstraintTarget> *list);
116 ListBaseT<bConstraintTarget> *list,
117 bool no_copy);
118
119 /* evaluation */
129 bool (*get_target_matrix)(struct Depsgraph *depsgraph,
130 struct bConstraint *con,
131 struct bConstraintOb *cob,
132 struct bConstraintTarget *ct,
133 float ctime);
138 void (*evaluate_constraint)(struct bConstraint *con,
139 struct bConstraintOb *cob,
140 ListBaseT<bConstraintTarget> *targets);
141};
142
143/* Function Prototypes for bConstraintTypeInfo's */
144
155
156/* ---------------------------------------------------------------------------- */
157
158/* Constraint function prototypes */
159
163void BKE_constraint_unique_name(struct bConstraint *con, ListBaseT<bConstraint> *list);
164
168struct bConstraint *BKE_constraint_duplicate_ex(struct bConstraint *src, int flag, bool do_extern);
169
174 struct bPoseChannel *pchan,
175 struct bConstraint *src);
179struct bConstraint *BKE_constraint_copy_for_object(struct Object *ob, struct bConstraint *src);
180
181void BKE_constraints_free(ListBaseT<bConstraint> *list);
185void BKE_constraints_free_ex(ListBaseT<bConstraint> *list, bool do_id_user);
186void BKE_constraints_copy(ListBaseT<bConstraint> *dst,
187 const ListBaseT<bConstraint> *src,
188 bool do_extern);
192void BKE_constraints_copy_ex(ListBaseT<bConstraint> *dst,
193 const ListBaseT<bConstraint> *src,
194 int flag,
195 bool do_extern);
202void BKE_constraints_id_loop(ListBaseT<bConstraint> *list,
203 ConstraintIDFunc func,
204 const int flag,
205 void *userdata);
206void BKE_constraint_free_data(struct bConstraint *con);
212void BKE_constraint_free_data_ex(struct bConstraint *con, bool do_id_user);
213
215
216/* Constraint API function prototypes */
217
221struct bConstraint *BKE_constraints_active_get(ListBaseT<bConstraint> *list);
225void BKE_constraints_active_set(ListBaseT<bConstraint> *list, struct bConstraint *con);
227struct bConstraint *BKE_constraints_find_name(ListBaseT<bConstraint> *list, const char *name);
228
233 struct bConstraintTarget *tgt,
234 struct bPoseChannel **r_pchan);
235
243 const struct bConstraint *con);
244
249 const char *name,
250 eBConstraint_Types type);
255 struct bPoseChannel *pchan,
256 const char *name,
257 eBConstraint_Types type);
258
262bool BKE_constraint_remove_ex(ListBaseT<bConstraint> *list,
263 struct Object *ob,
264 struct bConstraint *con);
265
269bool BKE_constraint_apply_for_object(struct Depsgraph *depsgraph,
270 struct Scene *scene,
271 struct Object *ob,
272 struct bConstraint *con);
273bool BKE_constraint_apply_and_remove_for_object(struct Depsgraph *depsgraph,
274 struct Scene *scene,
275 ListBaseT<bConstraint> *constraints,
276 struct Object *ob,
277 struct bConstraint *con);
278
279bool BKE_constraint_apply_for_pose(struct Depsgraph *depsgraph,
280 struct Scene *scene,
281 struct Object *ob,
282 struct bPoseChannel *pchan,
283 struct bConstraint *con);
284bool BKE_constraint_apply_and_remove_for_pose(struct Depsgraph *depsgraph,
285 struct Scene *scene,
286 ListBaseT<bConstraint> *constraints,
287 struct Object *ob,
288 struct bConstraint *con,
289 struct bPoseChannel *pchan);
290
292
293/* Constraint Evaluation function prototypes */
294
301struct bConstraintOb *BKE_constraints_make_evalob(struct Depsgraph *depsgraph,
302 struct Scene *scene,
303 struct Object *ob,
304 void *subdata,
305 short datatype);
310
317 struct bPoseChannel *pchan,
318 struct bConstraintOb *cob,
319 float mat[4][4],
320 short from,
321 short to,
322 bool keep_scale);
323
335void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph,
336 struct Scene *scene,
337 struct bConstraint *con,
338 int index,
339 short ownertype,
340 void *ownerdata,
341 float mat[4][4],
342 float ctime);
343
351int BKE_constraint_targets_get(struct bConstraint *con, ListBaseT<bConstraintTarget> *r_targets);
352
361 ListBaseT<bConstraintTarget> *targets,
362 bool no_copy);
363
367void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph,
368 struct bConstraint *con,
369 struct bConstraintOb *ob,
370 ListBaseT<bConstraintTarget> *targets,
371 float ctime);
372
380
388void BKE_constraints_solve(struct Depsgraph *depsgraph,
389 ListBaseT<bConstraint> *conlist,
390 struct bConstraintOb *cob,
391 float ctime);
392
393void BKE_constraint_blend_write(struct BlendWriter *writer, ListBaseT<bConstraint> *conlist);
395 struct ID *id_owner,
396 ListBaseT<bConstraint> *lb);
397
398} // namespace blender
These structs are the foundation for all linked lists in the library system.
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint ** constraints
BMesh Iterators.
void BKE_constraints_free(ListBaseT< bConstraint > *list)
void BKE_constraint_free_data(struct bConstraint *con)
void BKE_constraints_copy_ex(ListBaseT< bConstraint > *dst, const ListBaseT< bConstraint > *src, int flag, bool do_extern)
bool BKE_constraint_apply_for_pose(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, struct bConstraint *con)
struct bConstraint * BKE_constraint_add_for_pose(struct Object *ob, struct bPoseChannel *pchan, const char *name, eBConstraint_Types type)
void BKE_constraint_targets_flush(struct bConstraint *con, ListBaseT< bConstraintTarget > *targets, bool no_copy)
const bConstraintTypeInfo * BKE_constraint_typeinfo_from_type(int type)
void BKE_constraints_solve(struct Depsgraph *depsgraph, ListBaseT< bConstraint > *conlist, struct bConstraintOb *cob, float ctime)
void BKE_constraint_free_data_ex(struct bConstraint *con, bool do_id_user)
struct bConstraintOb * BKE_constraints_make_evalob(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, void *subdata, short datatype)
void(*) ConstraintIDFunc(struct bConstraint *con, struct ID **idpoin, bool is_reference, void *userdata)
struct bConstraint * BKE_constraint_copy_for_object(struct Object *ob, struct bConstraint *src)
bool BKE_constraint_apply_for_object(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bConstraint *con)
struct bConstraint * BKE_constraint_add_for_object(struct Object *ob, const char *name, eBConstraint_Types type)
struct bConstraint * BKE_constraint_find_from_target(struct Object *ob, struct bConstraintTarget *tgt, struct bPoseChannel **r_pchan)
struct bConstraint * BKE_constraint_copy_for_pose(struct Object *ob, struct bPoseChannel *pchan, struct bConstraint *src)
const bConstraintTypeInfo * BKE_constraint_typeinfo_get(struct bConstraint *con)
void BKE_constraint_unique_name(struct bConstraint *con, ListBaseT< bConstraint > *list)
void BKE_constraint_mat_convertspace(struct Object *ob, struct bPoseChannel *pchan, struct bConstraintOb *cob, float mat[4][4], short from, short to, bool keep_scale)
void BKE_constraint_custom_object_space_init(struct bConstraintOb *cob, struct bConstraint *con)
bool BKE_constraint_has_influence(const struct bConstraint *con)
void BKE_constraints_copy(ListBaseT< bConstraint > *dst, const ListBaseT< bConstraint > *src, bool do_extern)
bool BKE_constraint_is_nonlocal_in_liboverride(const struct Object *ob, const struct bConstraint *con)
struct bConstraint * BKE_constraint_duplicate_ex(struct bConstraint *src, int flag, bool do_extern)
bool BKE_constraint_apply_and_remove_for_pose(struct Depsgraph *depsgraph, struct Scene *scene, ListBaseT< bConstraint > *constraints, struct Object *ob, struct bConstraint *con, struct bPoseChannel *pchan)
int BKE_constraint_targets_get(struct bConstraint *con, ListBaseT< bConstraintTarget > *r_targets)
bool BKE_constraint_remove_ex(ListBaseT< bConstraint > *list, struct Object *ob, struct bConstraint *con)
bool BKE_constraint_target_uses_bbone(struct bConstraint *con, struct bConstraintTarget *ct)
struct bConstraint * BKE_constraints_active_get(ListBaseT< bConstraint > *list)
void BKE_constraint_blend_read_data(struct BlendDataReader *reader, struct ID *id_owner, ListBaseT< bConstraint > *lb)
void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph, struct bConstraint *con, struct bConstraintOb *ob, ListBaseT< bConstraintTarget > *targets, float ctime)
void BKE_constraints_clear_evalob(struct bConstraintOb *cob)
void BKE_constraints_active_set(ListBaseT< bConstraint > *list, struct bConstraint *con)
void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph, struct Scene *scene, struct bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
void BKE_constraints_free_ex(ListBaseT< bConstraint > *list, bool do_id_user)
void BKE_constraints_id_loop(ListBaseT< bConstraint > *list, ConstraintIDFunc func, const int flag, void *userdata)
struct bConstraint * BKE_constraints_find_name(ListBaseT< bConstraint > *list, const char *name)
void BKE_constraint_panel_expand(struct bConstraint *con)
void BKE_constraint_blend_write(struct BlendWriter *writer, ListBaseT< bConstraint > *conlist)
bool BKE_constraint_apply_and_remove_for_object(struct Depsgraph *depsgraph, struct Scene *scene, ListBaseT< bConstraint > *constraints, struct Object *ob, struct bConstraint *con)
struct bPoseChannel * pchan
float space_obj_world_matrix[4][4]
struct Depsgraph * depsgraph
struct Bone * pchan_armbone
void(*) new_data(void *cdata)
void(*) copy_data(struct bConstraint *con, struct bConstraint *src)
void(*) flush_constraint_targets(struct bConstraint *con, ListBaseT< bConstraintTarget > *list, bool no_copy)
bool(*) get_target_matrix(struct Depsgraph *depsgraph, struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime)
void(*) free_data(struct bConstraint *con)
void(*) id_looper(struct bConstraint *con, ConstraintIDFunc func, void *userdata)
int(*) get_constraint_targets(struct bConstraint *con, ListBaseT< bConstraintTarget > *list)
void(*) evaluate_constraint(struct bConstraint *con, struct bConstraintOb *cob, ListBaseT< bConstraintTarget > *targets)