Blender  V2.93
BKE_constraint.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
26 struct BlendDataReader;
27 struct BlendExpander;
28 struct BlendLibReader;
29 struct BlendWriter;
30 struct Depsgraph;
31 struct ID;
32 struct ListBase;
33 struct Object;
34 struct Scene;
35 struct bConstraint;
36 struct bConstraintTarget;
37 struct bPoseChannel;
38 
39 /* ---------------------------------------------------------------------------- */
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /* special struct for use in constraint evaluation */
45 typedef struct bConstraintOb {
49  struct Scene *scene;
51  struct Object *ob;
54 
56  float matrix[4][4];
58  float startmat[4][4];
61 
63  short type;
65  short rotOrder;
67 
68 /* ---------------------------------------------------------------------------- */
69 
70 /* Callback format for performing operations on ID-pointers for Constraints */
71 typedef void (*ConstraintIDFunc)(struct bConstraint *con,
72  struct ID **idpoin,
73  bool is_reference,
74  void *userdata);
75 
76 /* ....... */
77 
91 typedef struct bConstraintTypeInfo {
92  /* admin/ident */
94  short type;
96  short size;
98  char name[32];
100  char structName[32];
101 
102  /* data management function pointers - special handling */
104  void (*free_data)(struct bConstraint *con);
106  void (*id_looper)(struct bConstraint *con, ConstraintIDFunc func, void *userdata);
108  void (*copy_data)(struct bConstraint *con, struct bConstraint *src);
113  void (*new_data)(void *cdata);
114 
115  /* target handling function pointers */
120  int (*get_constraint_targets)(struct bConstraint *con, struct ListBase *list);
125  void (*flush_constraint_targets)(struct bConstraint *con, struct ListBase *list, bool no_copy);
126 
127  /* evaluation */
130  struct bConstraint *con,
131  struct bConstraintOb *cob,
132  struct bConstraintTarget *ct,
133  float ctime);
135  void (*evaluate_constraint)(struct bConstraint *con,
136  struct bConstraintOb *cob,
137  struct ListBase *targets);
139 
140 /* Function Prototypes for bConstraintTypeInfo's */
143 
144 /* ---------------------------------------------------------------------------- */
145 
146 /* Constraint function prototypes */
147 void BKE_constraint_unique_name(struct bConstraint *con, struct ListBase *list);
148 
150  const int flag,
151  const bool do_extern);
152 
154  struct bPoseChannel *pchan,
155  struct bConstraint *src);
156 struct bConstraint *BKE_constraint_copy_for_object(struct Object *ob, struct bConstraint *src);
157 
158 void BKE_constraints_free(struct ListBase *list);
159 void BKE_constraints_free_ex(struct ListBase *list, bool do_id_user);
160 void BKE_constraints_copy(struct ListBase *dst, const struct ListBase *src, bool do_extern);
162  const struct ListBase *src,
163  const int flag,
164  bool do_extern);
165 void BKE_constraints_id_loop(struct ListBase *list, ConstraintIDFunc func, void *userdata);
166 void BKE_constraint_free_data(struct bConstraint *con);
167 void BKE_constraint_free_data_ex(struct bConstraint *con, bool do_id_user);
168 
170 
171 /* Constraint API function prototypes */
172 struct bConstraint *BKE_constraints_active_get(struct ListBase *list);
173 void BKE_constraints_active_set(ListBase *list, struct bConstraint *con);
174 struct bConstraint *BKE_constraints_find_name(struct ListBase *list, const char *name);
175 
177  struct bConstraintTarget *tgt,
178  struct bPoseChannel **r_pchan);
179 
181  const struct bConstraint *con);
182 
183 struct bConstraint *BKE_constraint_add_for_object(struct Object *ob, const char *name, short type);
185  struct bPoseChannel *pchan,
186  const char *name,
187  short type);
188 
190  struct Object *ob,
191  struct bConstraint *con,
192  bool clear_dep);
193 bool BKE_constraint_remove(ListBase *list, struct bConstraint *con);
194 
195 void BKE_constraint_panel_expand(struct bConstraint *con);
196 
197 /* Constraints + Proxies function prototypes */
198 void BKE_constraints_proxylocal_extract(struct ListBase *dst, struct ListBase *src);
199 bool BKE_constraints_proxylocked_owner(struct Object *ob, struct bPoseChannel *pchan);
200 
201 /* Constraint Evaluation function prototypes */
203  struct Scene *scene,
204  struct Object *ob,
205  void *subdata,
206  short datatype);
208 
210  struct bPoseChannel *pchan,
211  struct bConstraintOb *cob,
212  float mat[4][4],
213  short from,
214  short to,
215  const bool keep_scale);
216 
218  struct Scene *scene,
219  struct bConstraint *con,
220  int index,
221  short ownertype,
222  void *ownerdata,
223  float mat[4][4],
224  float ctime);
226  struct bConstraint *con,
227  struct bConstraintOb *ob,
228  struct ListBase *targets,
229  float ctime);
230 void BKE_constraint_custom_object_space_get(float r_mat[4][4], struct bConstraint *con);
232  struct ListBase *conlist,
233  struct bConstraintOb *cob,
234  float ctime);
235 
236 void BKE_constraint_blend_write(struct BlendWriter *writer, struct ListBase *conlist);
237 void BKE_constraint_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb);
239  struct ID *id,
240  struct ListBase *conlist);
241 void BKE_constraint_blend_read_expand(struct BlendExpander *expander, struct ListBase *lb);
242 
243 #ifdef __cplusplus
244 }
245 #endif
struct bConstraintOb bConstraintOb
bool BKE_constraint_remove(ListBase *list, struct bConstraint *con)
Definition: constraint.c:5515
void BKE_constraints_id_loop(struct ListBase *list, ConstraintIDFunc func, void *userdata)
Definition: constraint.c:5680
void BKE_constraints_free_ex(struct ListBase *list, bool do_id_user)
Definition: constraint.c:5498
struct bConstraint * BKE_constraint_copy_for_object(struct Object *ob, struct bConstraint *src)
Definition: constraint.c:5777
struct bConstraintTypeInfo bConstraintTypeInfo
void BKE_constraints_solve(struct Depsgraph *depsgraph, struct ListBase *conlist, struct bConstraintOb *cob, float ctime)
Definition: constraint.c:6177
void BKE_constraint_mat_convertspace(struct Object *ob, struct bPoseChannel *pchan, struct bConstraintOb *cob, float mat[4][4], short from, short to, const bool keep_scale)
Definition: constraint.c:264
void BKE_constraints_free(struct ListBase *list)
Definition: constraint.c:5509
void BKE_constraints_proxylocal_extract(struct ListBase *dst, struct ListBase *src)
Definition: constraint.c:5978
struct bConstraint * BKE_constraint_duplicate_ex(struct bConstraint *src, const int flag, const bool do_extern)
Definition: constraint.c:5755
struct bConstraint * BKE_constraint_add_for_object(struct Object *ob, const char *name, short type)
Definition: constraint.c:5672
void BKE_constraint_blend_write(struct BlendWriter *writer, struct ListBase *conlist)
Definition: constraint.c:6262
void BKE_constraint_blend_read_expand(struct BlendExpander *expander, struct ListBase *lb)
Definition: constraint.c:6421
void(* ConstraintIDFunc)(struct bConstraint *con, struct ID **idpoin, bool is_reference, void *userdata)
struct bConstraint * BKE_constraints_find_name(struct ListBase *list, const char *name)
Definition: constraint.c:5806
void BKE_constraint_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb)
Definition: constraint.c:6314
void BKE_constraints_copy(struct ListBase *dst, const struct ListBase *src, bool do_extern)
struct bConstraintOb * BKE_constraints_make_evalob(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, void *subdata, short datatype)
Definition: constraint.c:133
const bConstraintTypeInfo * BKE_constraint_typeinfo_from_type(int type)
Definition: constraint.c:5413
void BKE_constraints_copy_ex(struct ListBase *dst, const struct ListBase *src, const int flag, bool do_extern)
bool BKE_constraint_remove_ex(ListBase *list, struct Object *ob, struct bConstraint *con, bool clear_dep)
Definition: constraint.c:5526
void BKE_constraint_blend_read_lib(struct BlendLibReader *reader, struct ID *id, struct ListBase *conlist)
Definition: constraint.c:6384
void BKE_constraint_free_data(struct bConstraint *con)
Definition: constraint.c:5492
bool BKE_constraint_is_nonlocal_in_liboverride(const struct Object *ob, const struct bConstraint *con)
void BKE_constraint_free_data_ex(struct bConstraint *con, bool do_id_user)
Definition: constraint.c:5470
struct bConstraint * BKE_constraint_find_from_target(struct Object *ob, struct bConstraintTarget *tgt, struct bPoseChannel **r_pchan)
Definition: constraint.c:5865
bool BKE_constraint_target_uses_bbone(struct bConstraint *con, struct bConstraintTarget *ct)
struct bConstraint * BKE_constraints_active_get(struct ListBase *list)
Definition: constraint.c:5812
void BKE_constraint_custom_object_space_get(float r_mat[4][4], struct bConstraint *con)
Definition: constraint.c:6140
bool BKE_constraints_proxylocked_owner(struct Object *ob, struct bPoseChannel *pchan)
Definition: constraint.c:5995
const bConstraintTypeInfo * BKE_constraint_typeinfo_get(struct bConstraint *con)
Definition: constraint.c:5435
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)
Definition: constraint.c:6025
void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph, struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime)
Definition: constraint.c:6102
void BKE_constraints_clear_evalob(struct bConstraintOb *cob)
Definition: constraint.c:211
struct bConstraint * BKE_constraint_copy_for_pose(struct Object *ob, struct bPoseChannel *pchan, struct bConstraint *src)
Definition: constraint.c:5765
void BKE_constraints_active_set(ListBase *list, struct bConstraint *con)
Definition: constraint.c:5829
void BKE_constraint_panel_expand(struct bConstraint *con)
Definition: constraint.c:5540
struct bConstraint * BKE_constraint_add_for_pose(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type)
Definition: constraint.c:5659
void BKE_constraint_unique_name(struct bConstraint *con, struct ListBase *list)
Definition: constraint.c:123
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
StackEntry * from
Scene scene
const Depsgraph * depsgraph
Definition: DNA_ID.h:273
float startmat[4][4]
float matrix[4][4]
float space_obj_world_matrix[4][4]
struct bPoseChannel * pchan
struct Scene * scene
struct Object * ob
struct Depsgraph * depsgraph
void(* id_looper)(struct bConstraint *con, ConstraintIDFunc func, void *userdata)
int(* get_constraint_targets)(struct bConstraint *con, struct ListBase *list)
void(* evaluate_constraint)(struct bConstraint *con, struct bConstraintOb *cob, struct ListBase *targets)
void(* flush_constraint_targets)(struct bConstraint *con, struct ListBase *list, bool no_copy)
void(* copy_data)(struct bConstraint *con, struct bConstraint *src)
void(* get_target_matrix)(struct Depsgraph *depsgraph, struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime)
void(* free_data)(struct bConstraint *con)
void(* new_data)(void *cdata)