2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * Contributor(s): Blender Foundation
23 * ***** END GPL LICENSE BLOCK *****
26 /** \file ED_armature.h
30 #ifndef __ED_ARMATURE_H__
31 #define __ED_ARMATURE_H__
45 struct MeshDeformModifierData;
55 typedef struct EditBone {
56 struct EditBone *next, *prev;
57 struct IDProperty *prop; /* User-Defined Properties on this Bone */
58 struct EditBone *parent; /* Editbones have a one-way link (i.e. children refer
59 * to parents. This is converted to a two-way link for
60 * normal bones when leaving editmode. */
61 char name[64]; /* MAXBONENAME */
62 float roll; /* Roll along axis. We'll ultimately use the axis/angle method
63 * for determining the transformation matrix of the bone. The axis
64 * is tail-head while roll provides the angle. Refer to Graphics
65 * Gems 1 p. 466 (section IX.6) if it's not already in here somewhere*/
67 float head[3]; /* Orientation and length is implicit during editing */
69 /* All joints are considered to have zero rotation with respect to
70 * their parents. Therefore any rotations specified during the
71 * animation are automatically relative to the bones' rest positions*/
76 float xwidth, length, zwidth; /* put them in order! transform uses this as scale */
77 float rad_head, rad_tail;
79 /* Bendy-Bone parameters */
81 float curveOutX, curveOutY;
82 float curveInX, curveInY;
84 float scaleIn, scaleOut;
86 float oldlength; /* for envelope scaling */
90 /* Used to store temporary data */
92 struct EditBone *ebone;
99 #define BONESEL_ROOT (1 << 28)
100 #define BONESEL_TIP (1 << 29)
101 #define BONESEL_BONE (1 << 30)
102 #define BONESEL_ANY (BONESEL_TIP | BONESEL_ROOT | BONESEL_BONE)
104 #define BONESEL_NOSEL (1u << 31u)
107 #define EBONE_VISIBLE(arm, ebone) ( \
108 CHECK_TYPE_INLINE(arm, bArmature *), \
109 CHECK_TYPE_INLINE(ebone, EditBone *), \
110 (((arm)->layer & (ebone)->layer) && !((ebone)->flag & BONE_HIDDEN_A)) \
113 #define EBONE_SELECTABLE(arm, ebone) (EBONE_VISIBLE(arm, ebone) && !(ebone->flag & BONE_UNSELECTABLE))
115 #define EBONE_EDITABLE(ebone) ( \
116 CHECK_TYPE_INLINE(ebone, EditBone *), \
117 (((ebone)->flag & BONE_SELECTED) && !((ebone)->flag & BONE_EDITMODE_LOCKED)) \
120 /* used in armature_select_hierarchy_exec() */
121 #define BONE_SELECT_PARENT 0
122 #define BONE_SELECT_CHILD 1
125 void ED_operatortypes_armature(void);
126 void ED_operatormacros_armature(void);
127 void ED_keymap_armature(struct wmKeyConfig *keyconf);
130 void ED_armature_from_edit(struct Main *bmain, struct bArmature *arm);
131 void ED_armature_to_edit(struct bArmature *arm);
132 void ED_armature_edit_free(struct bArmature *arm);
134 void ED_armature_edit_deselect_all(struct Object *obedit);
135 void ED_armature_edit_deselect_all_visible(struct Object *obedit);
137 bool ED_armature_pose_select_pick_with_buffer(
138 struct Scene *scene, struct Base *base, const unsigned int *buffer, short hits,
139 bool extend, bool deselect, bool toggle, bool do_nearest);
140 bool ED_armature_edit_select_pick(
141 struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
142 int join_armature_exec(struct bContext *C, struct wmOperator *op);
143 struct Bone *ED_armature_bone_find_index(struct Object *ob, int index);
144 float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float new_up_axis[3], const bool axis_only);
145 EditBone *ED_armature_ebone_find_name(const struct ListBase *edbo, const char *name);
146 EditBone *ED_armature_ebone_get_mirrored(const struct ListBase *edbo, EditBone *ebo);
147 void ED_armature_edit_sync_selection(struct ListBase *edbo);
148 void ED_armature_edit_validate_active(struct bArmature *arm);
150 EditBone *ED_armature_ebone_add_primitive(struct Object *obedit_arm, float length, bool view_aligned);
151 EditBone *ED_armature_ebone_add(struct bArmature *arm, const char *name);
153 void ED_armature_ebone_remove_ex(struct bArmature *arm, EditBone *exBone, bool clear_connected);
154 void ED_armature_ebone_remove(struct bArmature *arm, EditBone *exBone);
156 bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);
157 EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot);
159 void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]);
160 void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]);
162 void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]);
163 void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]);
165 void ED_armature_edit_transform_mirror_update(struct Object *obedit);
166 void ED_armature_origin_set(struct Main *bmain, struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);
168 void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props);
169 void ED_armature_transform_apply(struct Main *bmain, struct Object *ob, float mat[4][4], const bool do_props);
170 void ED_armature_transform(struct Main *bmain, struct bArmature *arm, float mat[4][4], const bool do_props);
172 #define ARM_GROUPS_NAME 1
173 #define ARM_GROUPS_ENVELOPE 2
174 #define ARM_GROUPS_AUTO 3
176 void ED_object_vgroup_calc_from_armature(struct ReportList *reports, struct Scene *scene, struct Object *ob,
177 struct Object *par, const int mode, const bool mirror);
179 /* if bone is already in list, pass it as param to ignore it */
180 void ED_armature_ebone_unique_name(struct ListBase *ebones, char *name, EditBone *bone);
181 void ED_armature_bone_rename(struct Main *bmain, struct bArmature *arm, const char *oldnamep, const char *newnamep);
182 void ED_armature_bones_flip_names(struct Main *bmain, struct bArmature *arm, struct ListBase *bones_names, const bool do_strip_numbers);
184 /* low level selection functions which handle */
185 int ED_armature_ebone_selectflag_get(const EditBone *ebone);
186 void ED_armature_ebone_selectflag_set(EditBone *ebone, int flag);
187 void ED_armature_ebone_select_set(EditBone *ebone, bool select);
188 void ED_armature_ebone_selectflag_enable(EditBone *ebone, int flag);
189 void ED_armature_ebone_selectflag_disable(EditBone *ebone, int flag);
191 /* editarmature_undo.c */
192 void ED_armature_undosys_type(struct UndoType *ut);
194 /* armature_utils.c */
195 void ED_armature_ebone_listbase_temp_clear(struct ListBase *lb);
196 void ED_armature_ebone_listbase_free(struct ListBase *lb);
197 void ED_armature_ebone_listbase_copy(struct ListBase *lb_dst, struct ListBase *lb_src);
200 bool ED_object_posemode_exit_ex(struct Object *ob);
201 bool ED_object_posemode_exit(struct bContext *C, struct Object *ob);
202 bool ED_object_posemode_enter_ex(struct Object *ob);
203 bool ED_object_posemode_enter(struct bContext *C, struct Object *ob);
204 void ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility);
205 void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
206 void ED_pose_recalculate_paths(struct Main *bmain, struct Scene *scene, struct Object *ob);
207 struct Object *ED_pose_object_from_context(struct bContext *C);
211 int ED_operator_sketch_mode_active_stroke(struct bContext *C);
212 int ED_operator_sketch_full_mode(struct bContext *C);
213 int ED_operator_sketch_mode(const struct bContext *C);
215 void BIF_convertSketch(struct bContext *C);
216 void BIF_deleteSketch(struct bContext *C);
217 void BIF_selectAllSketch(struct bContext *C, int mode); /* -1: deselect, 0: select, 1: toggle */
219 void BIF_makeListTemplates(const struct bContext *C);
220 int BIF_currentTemplate(const struct bContext *C);
221 void BIF_freeTemplates(struct bContext *C);
222 void BIF_setTemplate(struct bContext *C, int index);
223 int BIF_nbJointsTemplate(const struct bContext *C);
224 const char *BIF_nameBoneTemplate(const struct bContext *C);
226 void BDR_drawSketch(const struct bContext *vc);
227 int BDR_drawSketchNames(struct ViewContext *vc);
229 /* meshlaplacian.c */
230 void ED_mesh_deform_bind_callback(struct Scene *scene,
231 struct MeshDeformModifierData *mmd,
232 struct DerivedMesh *cagedm,
233 float *vertexcos, int totvert, float cagemat[4][4]);
239 #endif /* __ED_ARMATURE_H__ */