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;
56 typedef struct EditBone {
57 struct EditBone *next, *prev;
58 struct IDProperty *prop; /* User-Defined Properties on this Bone */
59 struct EditBone *parent; /* Editbones have a one-way link (i.e. children refer
60 * to parents. This is converted to a two-way link for
61 * normal bones when leaving editmode. */
62 void *temp; /* Used to store temporary data */
64 char name[64]; /* MAXBONENAME */
65 float roll; /* Roll along axis. We'll ultimately use the axis/angle method
66 * for determining the transformation matrix of the bone. The axis
67 * is tail-head while roll provides the angle. Refer to Graphics
68 * Gems 1 p. 466 (section IX.6) if it's not already in here somewhere*/
70 float head[3]; /* Orientation and length is implicit during editing */
72 /* All joints are considered to have zero rotation with respect to
73 * their parents. Therefore any rotations specified during the
74 * animation are automatically relative to the bones' rest positions*/
79 float xwidth, length, zwidth; /* put them in order! transform uses this as scale */
81 float rad_head, rad_tail;
83 float oldlength; /* for envelope scaling */
88 #define BONESEL_ROOT (1 << 28)
89 #define BONESEL_TIP (1 << 29)
90 #define BONESEL_BONE (1 << 30)
91 #define BONESEL_ANY (BONESEL_TIP | BONESEL_ROOT | BONESEL_BONE)
93 #define BONESEL_NOSEL (1 << 31) /* Indicates a negative number */
96 #define EBONE_VISIBLE(arm, ebone) ( \
97 CHECK_TYPE_INLINE(arm, bArmature *), \
98 CHECK_TYPE_INLINE(ebone, EditBone *), \
99 (((arm)->layer & (ebone)->layer) && !((ebone)->flag & BONE_HIDDEN_A)) \
102 #define EBONE_SELECTABLE(arm, ebone) (EBONE_VISIBLE(arm, ebone) && !(ebone->flag & BONE_UNSELECTABLE))
104 #define EBONE_EDITABLE(ebone) ( \
105 CHECK_TYPE_INLINE(ebone, EditBone *), \
106 (((ebone)->flag & BONE_SELECTED) && !((ebone)->flag & BONE_EDITMODE_LOCKED)) \
109 /* used in armature_select_hierarchy_exec() */
110 #define BONE_SELECT_PARENT 0
111 #define BONE_SELECT_CHILD 1
114 void ED_operatortypes_armature(void);
115 void ED_operatormacros_armature(void);
116 void ED_keymap_armature(struct wmKeyConfig *keyconf);
119 void ED_armature_from_edit(struct bArmature *arm);
120 void ED_armature_to_edit(struct bArmature *arm);
121 void ED_armature_edit_free(struct bArmature *arm);
122 void ED_armature_deselect_all(struct Object *obedit, int toggle);
123 void ED_armature_deselect_all_visible(struct Object *obedit);
125 int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int *buffer,
126 short hits, bool extend, bool deselect, bool toggle);
127 bool mouse_armature(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
128 int join_armature_exec(struct bContext *C, struct wmOperator *op);
129 struct Bone *get_indexed_bone(struct Object *ob, int index);
130 float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only);
131 EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name);
132 EditBone *ED_armature_bone_get_mirrored(const struct ListBase *edbo, EditBone *ebo);
133 void ED_armature_sync_selection(struct ListBase *edbo);
134 void ED_armature_validate_active(struct bArmature *arm);
136 void add_primitive_bone(struct Object *obedit_arm, bool view_aligned);
137 struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name);
138 void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
140 bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);
141 EditBone *ED_armature_bone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot);
143 void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]);
144 void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]);
146 void transform_armature_mirror_update(struct Object *obedit);
147 void ED_armature_origin_set(struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);
149 void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4]);
150 void ED_armature_apply_transform(struct Object *ob, float mat[4][4]);
151 void ED_armature_transform(struct bArmature *arm, float mat[4][4]);
153 #define ARM_GROUPS_NAME 1
154 #define ARM_GROUPS_ENVELOPE 2
155 #define ARM_GROUPS_AUTO 3
157 void create_vgroups_from_armature(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct Object *par, int mode, int mirror);
159 void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); /* if bone is already in list, pass it as param to ignore it */
160 void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep);
162 void undo_push_armature(struct bContext *C, const char *name);
164 /* low level selection functions which handle */
165 int ED_armature_ebone_selectflag_get(const EditBone *ebone);
166 void ED_armature_ebone_selectflag_set(EditBone *ebone, int flag);
167 void ED_armature_ebone_select_set(EditBone *ebone, bool select);
168 void ED_armature_ebone_selectflag_enable(EditBone *ebone, int flag);
169 void ED_armature_ebone_selectflag_disable(EditBone *ebone, int flag);
172 void ED_armature_exit_posemode(struct bContext *C, struct Base *base);
173 void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
174 void ED_pose_deselectall(struct Object *ob, int test);
175 void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
176 void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
177 struct Object *ED_pose_object_from_context(struct bContext *C);
181 int ED_operator_sketch_mode_active_stroke(struct bContext *C);
182 int ED_operator_sketch_full_mode(struct bContext *C);
183 int ED_operator_sketch_mode(const struct bContext *C);
185 void BIF_convertSketch(struct bContext *C);
186 void BIF_deleteSketch(struct bContext *C);
187 void BIF_selectAllSketch(struct bContext *C, int mode); /* -1: deselect, 0: select, 1: toggle */
189 void BIF_makeListTemplates(const struct bContext *C);
190 int BIF_currentTemplate(const struct bContext *C);
191 void BIF_freeTemplates(struct bContext *C);
192 void BIF_setTemplate(struct bContext *C, int index);
193 int BIF_nbJointsTemplate(const struct bContext *C);
194 const char *BIF_nameBoneTemplate(const struct bContext *C);
196 void BDR_drawSketch(const struct bContext *vc);
197 int BDR_drawSketchNames(struct ViewContext *vc);
199 /* meshlaplacian.c */
200 void mesh_deform_bind(struct Scene *scene,
201 struct MeshDeformModifierData *mmd,
202 float *vertexcos, int totvert, float cagemat[4][4]);
208 #endif /* __ED_ARMATURE_H__ */