Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ED_armature.h « include « editors « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b8943421bdd3dd776d752207d3a869da8915a01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 * All rights reserved.
 *
 * Contributor(s): Blender Foundation
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/** \file ED_armature.h
 *  \ingroup editors
 */

#ifndef __ED_ARMATURE_H__
#define __ED_ARMATURE_H__

#ifdef __cplusplus
extern "C" {
#endif

struct bArmature;
struct Base;
struct bContext;
struct Bone;
struct bPoseChannel;
struct IDProperty;
struct ListBase;
struct MeshDeformModifierData;
struct DerivedMesh;
struct Object;
struct ReportList;
struct Scene;
struct ViewContext;
struct wmKeyConfig;
struct wmOperator;

typedef struct EditBone {
	struct EditBone *next, *prev;
	struct IDProperty *prop; /* User-Defined Properties on this Bone */
	struct EditBone *parent; /* Editbones have a one-way link  (i.e. children refer
	                          * to parents.  This is converted to a two-way link for
	                          * normal bones when leaving editmode. */
	char    name[64];       /* MAXBONENAME */
	float   roll;           /* Roll along axis.  We'll ultimately use the axis/angle method
	                         * for determining the transformation matrix of the bone.  The axis
	                         * is tail-head while roll provides the angle. Refer to Graphics
	                         * Gems 1 p. 466 (section IX.6) if it's not already in here somewhere*/

	float head[3];          /* Orientation and length is implicit during editing */
	float tail[3];
	/* All joints are considered to have zero rotation with respect to
	 * their parents.	Therefore any rotations specified during the
	 * animation are automatically relative to the bones' rest positions*/
	int flag;
	int layer;
	
	float dist, weight;
	float xwidth, length, zwidth;  /* put them in order! transform uses this as scale */
	float ease1, ease2;
	float rad_head, rad_tail;
	float roll1, roll2;
	float curveOutX, curveOutY;
	float curveInX, curveInY;
	float scaleIn, scaleOut;
	float oldlength;        /* for envelope scaling */
	
	short segments;

	/* Used to store temporary data */
	union {
		struct EditBone *ebone;
		struct Bone     *bone;
		void            *p;
		int              i;
	} temp;
} EditBone;

#define BONESEL_ROOT    (1 << 28)
#define BONESEL_TIP     (1 << 29)
#define BONESEL_BONE    (1 << 30)
#define BONESEL_ANY     (BONESEL_TIP | BONESEL_ROOT | BONESEL_BONE)

#define BONESEL_NOSEL   (1u << 31u)

/* useful macros */
#define EBONE_VISIBLE(arm, ebone) ( \
	CHECK_TYPE_INLINE(arm, bArmature *), \
	CHECK_TYPE_INLINE(ebone, EditBone *), \
	(((arm)->layer & (ebone)->layer) && !((ebone)->flag & BONE_HIDDEN_A)) \
	)

#define EBONE_SELECTABLE(arm, ebone) (EBONE_VISIBLE(arm, ebone) && !(ebone->flag & BONE_UNSELECTABLE))

#define EBONE_EDITABLE(ebone) ( \
	CHECK_TYPE_INLINE(ebone, EditBone *), \
	(((ebone)->flag & BONE_SELECTED) && !((ebone)->flag & BONE_EDITMODE_LOCKED)) \
	)

/* used in armature_select_hierarchy_exec() */
#define BONE_SELECT_PARENT  0
#define BONE_SELECT_CHILD   1

/* armature_ops.c */
void ED_operatortypes_armature(void);
void ED_operatormacros_armature(void);
void ED_keymap_armature(struct wmKeyConfig *keyconf);

/* editarmature.c */
void ED_armature_from_edit(struct bArmature *arm);
void ED_armature_to_edit(struct bArmature *arm);
void ED_armature_edit_free(struct bArmature *arm);
void ED_armature_ebone_listbase_temp_clear(struct ListBase *lb);

void ED_armature_deselect_all(struct Object *obedit);
void ED_armature_deselect_all_visible(struct Object *obedit);

bool ED_do_pose_selectbuffer(
        struct Scene *scene, struct Base *base, const unsigned int *buffer, short hits,
        bool extend, bool deselect, bool toggle, bool do_nearest);
bool ED_armature_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
int join_armature_exec(struct bContext *C, struct wmOperator *op);
struct Bone *get_indexed_bone(struct Object *ob, int index);
float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const bool axis_only);
EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name);
EditBone *ED_armature_bone_get_mirrored(const struct ListBase *edbo, EditBone *ebo);
void ED_armature_sync_selection(struct ListBase *edbo);
void ED_armature_validate_active(struct bArmature *arm);

EditBone *ED_armature_edit_bone_add_primitive(struct Object *obedit_arm, float length, bool view_aligned);
EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name);
void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);

bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);
EditBone *ED_armature_bone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot);

void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]);
void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]);

void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]);
void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]);

void transform_armature_mirror_update(struct Object *obedit);
void ED_armature_origin_set(struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);

void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4]);
void ED_armature_apply_transform(struct Object *ob, float mat[4][4]);
void ED_armature_transform(struct bArmature *arm, float mat[4][4]);

#define ARM_GROUPS_NAME     1
#define ARM_GROUPS_ENVELOPE 2
#define ARM_GROUPS_AUTO     3

void create_vgroups_from_armature(struct ReportList *reports, struct Scene *scene, struct Object *ob,
                                  struct Object *par, const int mode, const bool mirror);

/* if bone is already in list, pass it as param to ignore it */
void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone);
void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep);
void ED_armature_bones_flip_names(struct bArmature *arm, struct ListBase *bones_names);

void undo_push_armature(struct bContext *C, const char *name);

/* low level selection functions which handle */
int  ED_armature_ebone_selectflag_get(const EditBone *ebone);
void ED_armature_ebone_selectflag_set(EditBone *ebone, int flag);
void ED_armature_ebone_select_set(EditBone *ebone, bool select);
void ED_armature_ebone_selectflag_enable(EditBone *ebone, int flag);
void ED_armature_ebone_selectflag_disable(EditBone *ebone, int flag);

/* poseobject.c */
void ED_armature_exit_posemode(struct bContext *C, struct Base *base);
void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
void ED_pose_de_selectall(struct Object *ob, int select_mode, const bool ignore_visibility);
void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
struct Object *ED_pose_object_from_context(struct bContext *C);

/* sketch */

int ED_operator_sketch_mode_active_stroke(struct bContext *C);
int ED_operator_sketch_full_mode(struct bContext *C);
int ED_operator_sketch_mode(const struct bContext *C);

void BIF_convertSketch(struct bContext *C);
void BIF_deleteSketch(struct bContext *C);
void BIF_selectAllSketch(struct bContext *C, int mode); /* -1: deselect, 0: select, 1: toggle */

void  BIF_makeListTemplates(const struct bContext *C);
int   BIF_currentTemplate(const struct bContext *C);
void  BIF_freeTemplates(struct bContext *C);
void  BIF_setTemplate(struct bContext *C, int index);
int   BIF_nbJointsTemplate(const struct bContext *C);
const char *BIF_nameBoneTemplate(const struct bContext *C);

void BDR_drawSketch(const struct bContext *vc);
int BDR_drawSketchNames(struct ViewContext *vc);

/* meshlaplacian.c */
void mesh_deform_bind(struct Scene *scene,
                      struct MeshDeformModifierData *mmd,
                      struct DerivedMesh *cagedm,
                      float *vertexcos, int totvert, float cagemat[4][4]);
	
#ifdef __cplusplus
}
#endif

#endif /* __ED_ARMATURE_H__ */