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 /** \file 21 * \ingroup editors 22 */ 23 24 #pragma once 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 struct Base; 31 struct Bone; 32 struct Depsgraph; 33 struct EditBone; 34 struct IDProperty; 35 struct ListBase; 36 struct Main; 37 struct Mesh; 38 struct MeshDeformModifierData; 39 struct Object; 40 struct ReportList; 41 struct Scene; 42 struct UndoType; 43 struct View3D; 44 struct ViewLayer; 45 struct bArmature; 46 struct bContext; 47 struct bPoseChannel; 48 struct wmKeyConfig; 49 struct wmOperator; 50 51 #define BONESEL_ROOT (1u << 29) 52 #define BONESEL_TIP (1u << 30) 53 #define BONESEL_BONE (1u << 31) 54 #define BONESEL_ANY (BONESEL_TIP | BONESEL_ROOT | BONESEL_BONE) 55 56 /* useful macros */ 57 #define EBONE_VISIBLE(arm, ebone) \ 58 (CHECK_TYPE_INLINE(arm, bArmature *), \ 59 CHECK_TYPE_INLINE(ebone, EditBone *), \ 60 (((arm)->layer & (ebone)->layer) && !((ebone)->flag & BONE_HIDDEN_A))) 61 62 #define EBONE_SELECTABLE(arm, ebone) \ 63 (EBONE_VISIBLE(arm, ebone) && !((ebone)->flag & BONE_UNSELECTABLE)) 64 65 #define EBONE_EDITABLE(ebone) \ 66 (CHECK_TYPE_INLINE(ebone, EditBone *), \ 67 (((ebone)->flag & BONE_SELECTED) && !((ebone)->flag & BONE_EDITMODE_LOCKED))) 68 69 /* used in armature_select.c and pose_select.c */ 70 #define BONE_SELECT_PARENT 0 71 #define BONE_SELECT_CHILD 1 72 73 /* armature_add.c */ 74 struct EditBone *ED_armature_ebone_add(struct bArmature *arm, const char *name); 75 struct EditBone *ED_armature_ebone_add_primitive(struct Object *obedit_arm, 76 float length, 77 bool view_aligned); 78 79 /* armature_edit.c */ 80 float ED_armature_ebone_roll_to_vector(const struct EditBone *bone, 81 const float align_axis[3], 82 const bool axis_only); 83 void ED_armature_origin_set( 84 struct Main *bmain, struct Object *ob, const float cursor[3], int centermode, int around); 85 void ED_armature_edit_transform(struct bArmature *arm, const float mat[4][4], const bool do_props); 86 void ED_armature_transform(struct bArmature *arm, const float mat[4][4], const bool do_props); 87 88 /* armature_naming.c */ 89 void ED_armature_ebone_unique_name(struct ListBase *ebones, char *name, struct EditBone *bone); 90 void ED_armature_bone_rename(struct Main *bmain, 91 struct bArmature *arm, 92 const char *oldnamep, 93 const char *newnamep); 94 void ED_armature_bones_flip_names(struct Main *bmain, 95 struct bArmature *arm, 96 struct ListBase *bones_names, 97 const bool do_strip_numbers); 98 99 /* armature_ops.c */ 100 void ED_operatortypes_armature(void); 101 void ED_operatormacros_armature(void); 102 void ED_keymap_armature(struct wmKeyConfig *keyconf); 103 104 /* armature_relations.c */ 105 int ED_armature_join_objects_exec(struct bContext *C, struct wmOperator *op); 106 107 /* armature_select.c */ 108 struct Base *ED_armature_base_and_ebone_from_select_buffer(struct Base **bases, 109 uint bases_len, 110 int hit, 111 struct EditBone **r_ebone); 112 struct Object *ED_armature_object_and_ebone_from_select_buffer(struct Object **objects, 113 uint objects_len, 114 int hit, 115 struct EditBone **r_ebone); 116 struct Base *ED_armature_base_and_pchan_from_select_buffer(struct Base **bases, 117 uint bases_len, 118 int hit, 119 struct bPoseChannel **r_pchan); 120 struct Base *ED_armature_base_and_bone_from_select_buffer(struct Base **bases, 121 uint bases_len, 122 int hit, 123 struct Bone **r_bone); 124 bool ED_armature_edit_deselect_all(struct Object *obedit); 125 bool ED_armature_edit_deselect_all_visible(struct Object *obedit); 126 bool ED_armature_edit_deselect_all_multi_ex(struct Base **bases, uint bases_len); 127 bool ED_armature_edit_deselect_all_visible_multi_ex(struct Base **bases, uint bases_len); 128 bool ED_armature_edit_deselect_all_visible_multi(struct bContext *C); 129 bool ED_armature_edit_select_pick( 130 struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); 131 bool ED_armature_edit_select_op_from_tagged(struct bArmature *arm, const int sel_op); 132 133 /* armature_skinning.c */ 134 #define ARM_GROUPS_NAME 1 135 #define ARM_GROUPS_ENVELOPE 2 136 #define ARM_GROUPS_AUTO 3 137 void ED_object_vgroup_calc_from_armature(struct ReportList *reports, 138 struct Depsgraph *depsgraph, 139 struct Scene *scene, 140 struct Object *ob, 141 struct Object *par, 142 const int mode, 143 const bool mirror); 144 145 /* editarmature_undo.c */ 146 void ED_armature_undosys_type(struct UndoType *ut); 147 148 /* armature_utils.c */ 149 void ED_armature_edit_sync_selection(struct ListBase *edbo); 150 void ED_armature_edit_validate_active(struct bArmature *arm); 151 void ED_armature_edit_refresh_layer_used(struct bArmature *arm); 152 void ED_armature_ebone_remove_ex(struct bArmature *arm, 153 struct EditBone *exBone, 154 bool clear_connected); 155 void ED_armature_ebone_remove(struct bArmature *arm, struct EditBone *exBone); 156 bool ED_armature_ebone_is_child_recursive(struct EditBone *ebone_parent, 157 struct EditBone *ebone_child); 158 struct EditBone *ED_armature_ebone_find_shared_parent(struct EditBone *ebone_child[], 159 const unsigned int ebone_child_tot); 160 void ED_armature_ebone_to_mat3(struct EditBone *ebone, float r_mat[3][3]); 161 void ED_armature_ebone_to_mat4(struct EditBone *ebone, float r_mat[4][4]); 162 void ED_armature_ebone_from_mat3(struct EditBone *ebone, const float mat[3][3]); 163 void ED_armature_ebone_from_mat4(struct EditBone *ebone, const float mat[4][4]); 164 struct EditBone *ED_armature_ebone_find_name(const struct ListBase *edbo, const char *name); 165 struct EditBone *ED_armature_ebone_get_mirrored(const struct ListBase *edbo, struct EditBone *ebo); 166 void ED_armature_ebone_transform_mirror_update(struct bArmature *arm, 167 struct EditBone *ebo, 168 bool check_select); 169 void ED_armature_edit_transform_mirror_update(struct Object *obedit); 170 void ED_armature_from_edit(struct Main *bmain, struct bArmature *arm); 171 void ED_armature_to_edit(struct bArmature *arm); 172 void ED_armature_edit_free(struct bArmature *arm); 173 void ED_armature_ebone_listbase_temp_clear(struct ListBase *lb); 174 void ED_armature_ebone_listbase_free(struct ListBase *lb, const bool do_id_user); 175 void ED_armature_ebone_listbase_copy(struct ListBase *lb_dst, 176 struct ListBase *lb_src, 177 const bool do_id_user); 178 179 /* low level selection functions which handle */ 180 int ED_armature_ebone_selectflag_get(const struct EditBone *ebone); 181 void ED_armature_ebone_selectflag_set(struct EditBone *ebone, int flag); 182 void ED_armature_ebone_select_set(struct EditBone *ebone, bool select); 183 void ED_armature_ebone_selectflag_enable(struct EditBone *ebone, int flag); 184 void ED_armature_ebone_selectflag_disable(struct EditBone *ebone, int flag); 185 186 /* pose_edit.c */ 187 struct Object *ED_pose_object_from_context(struct bContext *C); 188 bool ED_object_posemode_exit_ex(struct Main *bmain, struct Object *ob); 189 bool ED_object_posemode_exit(struct bContext *C, struct Object *ob); 190 bool ED_object_posemode_enter_ex(struct Main *bmain, struct Object *ob); 191 bool ED_object_posemode_enter(struct bContext *C, struct Object *ob); 192 193 /* Corresponds to eAnimvizCalcRange. */ 194 typedef enum ePosePathCalcRange { 195 POSE_PATH_CALC_RANGE_CURRENT_FRAME, 196 POSE_PATH_CALC_RANGE_CHANGED, 197 POSE_PATH_CALC_RANGE_FULL, 198 } ePosePathCalcRange; 199 void ED_pose_recalculate_paths(struct bContext *C, 200 struct Scene *scene, 201 struct Object *ob, 202 ePosePathCalcRange range); 203 204 /* pose_select.c */ 205 bool ED_armature_pose_select_pick_with_buffer(struct ViewLayer *view_layer, 206 struct View3D *v3d, 207 struct Base *base, 208 const unsigned int *buffer, 209 short hits, 210 bool extend, 211 bool deselect, 212 bool toggle, 213 bool do_nearest); 214 void ED_armature_pose_select_in_wpaint_mode(struct ViewLayer *view_layer, 215 struct Base *base_select); 216 bool ED_pose_deselect_all_multi_ex(struct Base **bases, 217 uint bases_len, 218 int select_mode, 219 const bool ignore_visibility); 220 bool ED_pose_deselect_all_multi(struct bContext *C, int select_mode, const bool ignore_visibility); 221 bool ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility); 222 void ED_pose_bone_select_tag_update(struct Object *ob); 223 void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select); 224 225 /* meshlaplacian.c */ 226 void ED_mesh_deform_bind_callback(struct MeshDeformModifierData *mmd, 227 struct Mesh *cagemesh, 228 float *vertexcos, 229 int totvert, 230 float cagemat[4][4]); 231 232 #ifdef __cplusplus 233 } 234 #endif 235