78 ListBase targets = {
nullptr,
nullptr};
83 if (ct->tar == srcArm) {
84 if (ct->subtarget[0] ==
'\0') {
88 else if (
STREQ(ct->subtarget, pchan->
name)) {
105 &tarArm->
id, data->act,
"pose.bones[", pchan->
name, curbone->
name, 0, 0,
false);
125 ID *src_id = &srcArm->
id;
126 ID *dst_id = &tarArm->
id;
129 bool changed =
false;
132 if ((
id == src_id) && strstr(fcu->
rna_path,
"pose.bones[")) {
139 if (!
STREQ(old_name, new_name) && strstr(fcu->
rna_path, old_name)) {
141 id, fcu->
rna_path,
"pose.bones", old_name, new_name, 0, 0,
false);
159 fcu->
flag &= ~FCURVE_DISABLED;
160 driver->
flag &= ~DRIVER_FLAG_INVALID;
167 if (dtar->id == src_id) {
176 if ((dtar->rna_path && strstr(dtar->rna_path,
"pose.bones[")) || (dtar->pchan_name[0])) {
179 const char *new_name =
static_cast<const char *
>(
183 if (!
STREQ(old_name, new_name)) {
184 if ((dtar->rna_path) && strstr(dtar->rna_path, old_name)) {
187 id, dtar->rna_path,
"pose.bones", old_name, new_name, 0, 0,
false);
190 if (
STREQ(dtar->pchan_name, old_name)) {
192 STRNCPY(dtar->pchan_name, new_name);
225 bmain, ob, tarArm, srcArm, pchan, curbone, &pchant->constraints);
232 bmain, ob, tarArm, srcArm, pchan, curbone, &ob->
constraints);
270 const int src_parent_index = armature_bonecoll_find_parent_index(src_arm, src_index);
271 int parent_index = -1;
273 if (src_parent_index >= 0) {
275 src_arm, src_parent_index, dest_arm, bone_collection_by_name);
278 parent_index = armature_bonecoll_find_index(dest_arm, mapped_parent);
293 bone_collection_by_name.
add(bcoll->
name, new_bcoll);
306 float mat[4][4], oimat[4][4];
313 if (!arm || arm->
edbo) {
318 if (ob_iter == ob_active) {
339 bone_collection_by_name.
add(bcoll->name, bcoll);
350 pose = ob_active->
pose;
351 ob_active->
mode &= ~OB_MODE_POSE;
354 if ((ob_iter->type ==
OB_ARMATURE) && (ob_iter != ob_active)) {
369 curarm, i, arm, bone_collection_by_name);
375 opose = ob_iter->pose;
376 ob_iter->mode &= ~OB_MODE_POSE;
380 mul_m4_m4m4(mat, oimat, ob_iter->object_to_world().ptr());
384 pchann = pchan->
next;
416 curbone->
roll -=
atan2f(difmat[2][0], difmat[2][2]);
437 bcoll_ref->bcoll = bone_collection_remap.
lookup(bcoll_ref->bcoll);
461 if (ob_active->
adt ==
nullptr) {
473 if (arm->
adt ==
nullptr) {
528 ListBase targets = {
nullptr,
nullptr};
538 if (ct->subtarget[0] != 0) {
539 if (ct->tar == origArm) {
544 else if (ct->tar == newArm) {
561 ListBase targets = {
nullptr,
nullptr};
570 if (ct->subtarget[0] !=
'\0') {
571 if (ct->tar == origArm) {
576 else if (ct->tar == newArm) {
619 pchann = pchan->
next;
627 if (ebo->parent == curbone) {
628 ebo->parent =
nullptr;
630 ebo->temp.p =
nullptr;
631 ebo->flag &= ~BONE_CONNECTED;
637 if (pchn->parent == pchan) {
638 pchn->parent =
nullptr;
640 if (pchn->bbone_next == pchan) {
641 pchn->bbone_next =
nullptr;
643 if (pchn->bbone_prev == pchan) {
644 pchn->bbone_prev =
nullptr;
678 for (
Base *base_old : bases) {
679 Object *ob_old = base_old->object;
683 bool has_selected_bone =
false;
684 bool has_selected_any =
false;
688 has_selected_bone =
true;
692 has_selected_any =
true;
696 if (has_selected_bone ==
false) {
697 if (has_selected_any) {
716 ob_old->
mode &= ~OB_MODE_POSE;
768 ot->
name =
"Separate Bones";
769 ot->
idname =
"ARMATURE_OT_separate";
770 ot->
description =
"Isolate selected bones into a separate armature";
787#define ARM_PAR_CONNECT 1
788#define ARM_PAR_OFFSET 2
791#define ARM_PAR_CLEAR 1
792#define ARM_PAR_CLEAR_DISCONNECT 2
815 selbone->
parent = actbone;
818 for (ebone = actbone->
parent; ebone; ebone = ebone->
parent) {
819 if (ebone->
parent == selbone) {
821 ebone->
flag &= ~BONE_CONNECTED;
840 if (par == selbone) {
850 selbone->
flag &= ~BONE_CONNECTED;
857 {0,
nullptr, 0,
nullptr,
nullptr},
869 if (actbone ==
nullptr) {
882 if (actmirb ==
nullptr) {
889 bool is_active_only_selected =
false;
891 is_active_only_selected =
true;
894 if (ebone != actbone) {
895 is_active_only_selected =
false;
902 if (is_active_only_selected) {
926 if (ebone != actbone) {
933 if (ebone_mirror != actmirb) {
952 bool enable_offset =
false;
954 bool enable_connect =
false;
963 if (ebone == actbone) {
967 if (ebone->parent != actbone) {
968 enable_offset =
true;
969 enable_connect =
true;
973 enable_connect =
true;
999 ot->
idname =
"ARMATURE_OT_parent_set";
1000 ot->
description =
"Set the active bone as the parent of the selected bones";
1017 {0,
nullptr, 0,
nullptr,
nullptr},
1030 ebone->
flag &= ~BONE_CONNECTED;
1046 for (
Object *ob : objects) {
1048 bool changed =
false;
1074 bool enable_disconnect =
false;
1076 bool enable_clear =
false;
1084 if (ebone->parent ==
nullptr) {
1087 enable_clear =
true;
1090 enable_disconnect =
true;
1107 "ARMATURE_OT_parent_clear",
1121 ot->
name =
"Clear Parent";
1122 ot->
idname =
"ARMATURE_OT_parent_clear";
1124 "Remove the parent-child relationship between selected bones and their parents";
1139 "What way to clear parenting");
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
void ANIM_armature_runtime_refresh(bArmature *armature)
BoneCollection * ANIM_armature_bonecoll_new(bArmature *armature, const char *name, int parent_index=-1)
Blender kernel action and pose functionality.
void BKE_pose_channels_hash_free(bPose *pose) ATTR_NONNULL(1)
void BKE_pose_channel_free(bPoseChannel *pchan) ATTR_NONNULL(1)
void BKE_animdata_merge_copy(Main *bmain, ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes action_mode, bool fix_drivers)
AnimData * BKE_animdata_copy(Main *bmain, AnimData *adt, int flag)
void BKE_fcurves_main_cb(struct Main *bmain, blender::FunctionRef< void(ID *, FCurve *)> func)
void BKE_action_fix_paths_rename(struct ID *owner_id, struct bAction *act, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
char * BKE_animsys_fix_rna_path_rename(struct ID *owner_id, char *old_path, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targets, bool no_copy)
int BKE_constraint_targets_get(struct bConstraint *con, struct ListBase *r_targets)
#define CTX_DATA_BEGIN(C, Type, instance, member)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
Main * CTX_data_main(const bContext *C)
EditBone * CTX_data_active_bone(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
blender::Vector< Base * > BKE_view_layer_array_from_bases_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
blender::Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER(gh_iter_, ghash_)
GHash * BLI_ghash_str_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void unit_m4(float m[4][4])
void copy_m4_m3(float m1[4][4], const float m2[3][3])
void mul_m4_v3(const float M[4][4], float r[3])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void invert_m4_m4_safe_ortho(float inverse[4][4], const float mat[4][4])
void mul_m4_m3m4(float R[4][4], const float A[3][3], const float B[4][4])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
#define STRNCPY(dst, src)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
Object is a sort of wrapper for general info.
#define EBONE_VISIBLE(arm, ebone)
#define EBONE_EDITABLE(ebone)
void ED_outliner_select_sync_from_object_tag(bContext *C)
bool ED_operator_editarmature(bContext *C)
Read Guarded memory(de)allocation.
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value)
uiPopupMenu * UI_popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
uiLayout * UI_popup_menu_layout(uiPopupMenu *pup)
void bone_free(bArmature *arm, EditBone *bone)
void ED_armature_ebone_unique_name(ListBase *ebones, char *name, EditBone *bone)
static void separate_armature_bones(Main *bmain, Object *ob, const bool is_select)
static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcArm, bPoseChannel *pchan, EditBone *curbone)
static const EnumPropertyItem prop_editarm_clear_parent_types[]
void ARMATURE_OT_parent_clear(wmOperatorType *ot)
static void joined_armature_fix_animdata_cb(Main *bmain, ID *id, FCurve *fcu, Object *srcArm, Object *tarArm, GHash *names_map)
static int armature_parent_set_invoke(bContext *C, wmOperator *, const wmEvent *)
static BoneCollection * join_armature_remap_collection(const bArmature *src_arm, const int src_index, bArmature *dest_arm, blender::Map< std::string, BoneCollection * > &bone_collection_by_name)
#define ARM_PAR_CLEAR_DISCONNECT
static int armature_parent_set_exec(bContext *C, wmOperator *op)
static void joined_armature_fix_links_constraints(Main *bmain, Object *ob, Object *tarArm, Object *srcArm, bPoseChannel *pchan, EditBone *curbone, ListBase *lb)
static int separate_armature_exec(bContext *C, wmOperator *op)
static int armature_parent_clear_exec(bContext *C, wmOperator *op)
int ED_armature_join_objects_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_parent_set(wmOperatorType *ot)
static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *newArm)
static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBone *actbone, short mode)
void ARMATURE_OT_separate(wmOperatorType *ot)
static void editbone_clear_parent(EditBone *ebone, int mode)
static const EnumPropertyItem prop_editarm_make_parent_types[]
static void bone_connect_to_existing_parent(EditBone *bone)
static int armature_parent_clear_invoke(bContext *C, wmOperator *, const wmEvent *)
bool ED_armature_edit_deselect_all(Object *obedit)
EditBone * ED_armature_ebone_find_name(const ListBase *edbo, const char *name)
void ED_armature_edit_sync_selection(ListBase *edbo)
void ED_armature_edit_free(bArmature *arm)
void ED_armature_ebone_to_mat3(EditBone *ebone, float r_mat[3][3])
void ED_armature_from_edit(Main *bmain, bArmature *arm)
void ED_armature_to_edit(bArmature *arm)
EditBone * ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo)
bool add(const Key &key, const Value &value)
const Value & lookup(const Key &key) const
Value lookup_default(const Key &key, const Value &default_value) const
void MEM_freeN(void *vmemh)
Base * add_duplicate(Main *bmain, Scene *scene, ViewLayer *view_layer, Base *base, eDupli_ID_Flags dupflag)
void base_free_and_unlink(Main *bmain, Scene *scene, Object *ob)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
ListBase bone_collections
struct BoneCollection ** collection_array
struct EditBone * act_edbone
struct bPoseChannel * next
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_cursor_wait(bool val)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)