54 if (armature ==
nullptr) {
60 "Cannot add bone collections to a linked Armature without an "
61 "override on the Armature Data");
67 "Cannot add bone collections to a linked Armature with a system "
68 "override; explicitly create an override on the Armature Data");
79 if (armature ==
nullptr) {
85 "Cannot update a linked Armature with a system override; "
86 "explicitly create an override on the Armature Data");
91 if (bcoll ==
nullptr) {
98 C,
"Cannot edit bone collections that are linked from another blend file");
132 ot->name =
"Add Bone Collection";
133 ot->idname =
"ARMATURE_OT_collection_add";
134 ot->description =
"Add a new bone collection";
160 ot->name =
"Remove Bone Collection";
161 ot->idname =
"ARMATURE_OT_collection_remove";
162 ot->description =
"Remove the active bone collection";
194 {-1,
"UP", 0,
"Up",
""},
195 {1,
"DOWN", 0,
"Down",
""},
196 {0,
nullptr, 0,
nullptr,
nullptr},
200 ot->name =
"Move Bone Collection";
201 ot->idname =
"ARMATURE_OT_collection_move";
202 ot->description =
"Change position of active Bone Collection in list of Bone collections";
216 "Direction to move the active Bone Collection towards");
226 if (bcoll_name[0] ==
'\0') {
249 bool *made_any_changes,
250 bool *had_bones_to_assign)
254 *made_any_changes |= assign_func(bcoll, pchan->bone);
255 *had_bones_to_assign =
true;
269 bool *made_any_changes,
270 bool *had_bones_to_assign)
279 *made_any_changes |= assign_func(bcoll, ebone);
280 *had_bones_to_assign =
true;
298 bool *made_any_changes,
299 bool *had_bones_to_assign)
329 const char *bone_name,
332 bool *made_any_changes,
333 bool *had_bones_to_assign)
344 *had_bones_to_assign =
true;
359 *had_bones_to_assign =
true;
393 C,
"Cannot edit bone collections on linked Armatures without override");
398 "Cannot edit bone collections on a linked Armature with a system "
399 "override; explicitly create an override on the Armature Data");
419 if (bcoll ==
nullptr) {
429 bool made_any_changes =
false;
430 bool had_bones_to_assign =
false;
438 &had_bones_to_assign);
440 if (!mode_is_supported) {
442 op->
reports,
RPT_ERROR,
"This operator only works in pose mode and armature edit mode");
445 if (!had_bones_to_assign) {
450 if (!made_any_changes) {
463 ot->name =
"Add Selected Bones to Collection";
464 ot->idname =
"ARMATURE_OT_collection_assign";
465 ot->description =
"Add selected bones to the chosen bone collection";
480 "Name of the bone collection to assign this bone to; empty to assign to the "
481 "active bone collection");
499 C,
"Cannot edit bone collections on linked Armatures without override");
504 "Cannot edit bone collections on a linked Armature with a system "
505 "override; explicitly create an override on the Armature Data");
529 bool made_any_changes =
false;
530 bool had_bones_to_assign =
false;
538 &had_bones_to_assign);
540 if (!mode_is_supported) {
542 op->
reports,
RPT_ERROR,
"This operator only works in pose mode and armature edit mode");
546 if (!had_bones_to_assign) {
562 ot->name =
"Add Selected Bones to New Collection";
563 ot->idname =
"ARMATURE_OT_collection_create_and_assign";
564 ot->description =
"Create a new bone collection and assign all selected bones";
579 "Name of the bone collection to create");
590 if (bcoll ==
nullptr) {
594 bool made_any_changes =
false;
595 bool had_bones_to_unassign =
false;
603 &had_bones_to_unassign);
605 if (!mode_is_supported) {
607 op->
reports,
RPT_ERROR,
"This operator only works in pose mode and armature edit mode");
610 if (!had_bones_to_unassign) {
612 op->
reports,
RPT_WARNING,
"No bones selected, nothing to unassign from bone collection");
615 if (!made_any_changes) {
617 op->
reports,
RPT_WARNING,
"None of the selected bones were assigned to this collection");
626 ot->name =
"Remove Selected from Bone collections";
627 ot->idname =
"ARMATURE_OT_collection_unassign";
628 ot->description =
"Remove selected bones from the active bone collection";
642 "Name of the bone collection to unassign this bone from; empty to unassign from "
643 "the active bone collection");
654 if (bcoll ==
nullptr) {
665 bool made_any_changes =
false;
666 bool had_bones_to_unassign =
false;
675 &had_bones_to_unassign);
677 if (!mode_is_supported) {
679 op->
reports,
RPT_ERROR,
"This operator only works in pose mode and armature edit mode");
682 if (!had_bones_to_unassign) {
686 if (!made_any_changes) {
689 "Bone '%s' was not assigned to collection '%s'",
700 ot->name =
"Remove Bone from Bone Collection";
701 ot->idname =
"ARMATURE_OT_collection_unassign_named";
702 ot->description =
"Unassign the named bone from this bone collection";
716 "Name of the bone collection to unassign this bone from; empty to unassign from "
717 "the active bone collection");
723 "Name of the bone to unassign from the collection; empty to use the active bone");
729 if (ref->bcoll == bcoll) {
745 C,
"Cannot (de)select bones on linked object, that would need an override");
751 if (armature ==
nullptr) {
755 const bool is_editmode = armature->
edbo !=
nullptr;
758 if (!active_object || active_object->
type !=
OB_ARMATURE || active_object->
data != armature) {
778 const bool is_editmode = armature->
edbo !=
nullptr;
793 if (!active_object || active_object->
type !=
OB_ARMATURE || active_object->
data != armature) {
799 Bone *bone = member->bone;
801 BLI_assert_msg(pose_bone !=
nullptr,
"The pose bones and armature bones are out of sync");
833 if (armature ==
nullptr) {
838 if (bcoll ==
nullptr) {
849 ot->name =
"Select Bones of Bone Collection";
850 ot->idname =
"ARMATURE_OT_collection_select";
851 ot->description =
"Select bones in active Bone Collection";
864 if (armature ==
nullptr) {
869 if (bcoll ==
nullptr) {
880 ot->name =
"Deselect Bone Collection";
881 ot->idname =
"ARMATURE_OT_collection_deselect";
882 ot->description =
"Deselect bones of active Bone Collection";
896 const int collection_index =
RNA_int_get(op->
ptr,
"collection_index");
903 (collection_index < 0))
910 "It should always be possible to create a new bone collection on an armature");
917 "Bone collection with index %d not found on Armature %s",
928 "Bone collection %s is not editable, maybe add an override on the armature Data?",
957 bool made_any_changes =
false;
958 bool had_bones_to_assign =
false;
965 &had_bones_to_assign);
967 if (!mode_is_supported) {
969 op->
reports,
RPT_ERROR,
"This operator only works in pose mode and armature edit mode");
972 if (!had_bones_to_assign) {
977 if (!made_any_changes) {
1007 if (ob ==
nullptr) {
1024 "Cannot update a linked Armature with a system override; "
1025 "explicitly create an override on the Armature Data");
1049 const uintptr_t index_and_move_bit = ((bcoll_index + 1) << 1) | (is_move_operation << 0);
1050 return reinterpret_cast<void *
>(index_and_move_bit);
1060 const uintptr_t index_and_move_bit =
reinterpret_cast<intptr_t
>(menu_custom_data);
1061 const bool is_move_operation = (index_and_move_bit & 1) == 1;
1062 const int bcoll_index = int(index_and_move_bit >> 1) - 1;
1063 return std::make_pair(bcoll_index, is_move_operation);
1068 return collection_contains_active_bone ? ICON_REMOVE : ICON_ADD;
1074 const int bcoll_index,
1075 const bool is_move_operation)
1077 if (is_move_operation) {
1079 RNA_int_set(&op_ptr,
"collection_index", bcoll_index);
1086 if (contains_active_bone) {
1109 int parent_bcoll_index;
1110 bool is_move_operation;
1120 is_move_operation ?
"ARMATURE_OT_move_to_collection" :
"ARMATURE_OT_assign_to_collection",
1123 RNA_int_set(&op_ptr,
"collection_index", parent_bcoll_index);
1131 int child_index, child_count;
1132 if (parent_bcoll_index == -1) {
1142 layout, arm, parent, parent_bcoll_index, is_move_operation);
1151 for (
int index = child_index; index < child_index + child_count; index++) {
1181 const bool is_move_operation =
STREQ(op->
type->
idname,
"ARMATURE_OT_move_to_collection");
1193 C, op, 200,
IFACE_(
"Move to New Bone Collection"),
IFACE_(
"Create"));
1215 ot->name =
"Move to Collection";
1216 ot->description =
"Move bones to a collection";
1217 ot->idname =
"ARMATURE_OT_move_to_collection";
1237 "Index of the collection to move selected bones to. When the operator should create a new "
1238 "bone collection, do not include this parameter and pass new_collection_name",
1245 "new_collection_name",
1249 "Name of a to-be-added bone collection. Only pass this if you want to create a new bone "
1250 "collection and move the selected bones to it. To move to an existing collection, do not "
1251 "include this parameter and use collection_index");
1261 ot->name =
"Assign to Collection";
1263 "Assign all selected bones to a collection, or unassign them, depending on whether the "
1264 "active bone is already assigned or not";
1265 ot->idname =
"ARMATURE_OT_assign_to_collection";
1285 "Index of the collection to assign selected bones to. When the operator should create a new "
1286 "bone collection, use new_collection_name to define the collection name, and set this "
1287 "parameter to the parent index of the new bone collection",
1294 "new_collection_name",
1298 "Name of a to-be-added bone collection. Only pass this if you want to create a new bone "
1299 "collection and assign the selected bones to it. To assign to an existing collection, do "
1300 "not include this parameter and use collection_index");
Functions to deal with Armatures.
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
bool ANIM_armature_bonecoll_assign_and_move(BoneCollection *bcoll, Bone *bone)
void ANIM_armature_bonecoll_active_set(bArmature *armature, BoneCollection *bcoll)
bool ANIM_armature_bonecoll_is_editable(const bArmature *armature, const BoneCollection *bcoll)
bool ANIM_armature_bonecoll_assign_and_move_editbone(BoneCollection *bcoll, EditBone *ebone)
bool ANIM_armature_bonecoll_unassign_editbone(BoneCollection *bcoll, EditBone *ebone)
bool ANIM_armature_bonecoll_assign(BoneCollection *bcoll, Bone *bone)
void ANIM_armature_bonecoll_remove(bArmature *armature, BoneCollection *bcoll)
bool ANIM_armature_bonecoll_unassign(BoneCollection *bcoll, Bone *bone)
void ANIM_armature_bonecoll_active_runtime_refresh(bArmature *armature)
bool ANIM_armature_bonecoll_move(bArmature *armature, BoneCollection *bcoll, int step)
BoneCollection * ANIM_armature_bonecoll_new(bArmature *armature, const char *name, int parent_index=-1)
bool ANIM_armature_bonecoll_contains_active_bone(const bArmature *armature, const BoneCollection *bcoll)
BoneCollection * ANIM_armature_bonecoll_get_by_name(bArmature *armature, const char *name) ATTR_WARN_UNUSED_RESULT
bool ANIM_armature_bonecoll_assign_editbone(BoneCollection *bcoll, EditBone *ebone)
Blender kernel action and pose functionality.
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
#define FOREACH_PCHAN_SELECTED_IN_OBJECT_END
#define FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN(_ob, _pchan)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
bool BKE_lib_override_library_is_system_defined(const Main *bmain, const ID *id)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
#define LISTBASE_FOREACH(type, var, list)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
void DEG_id_tag_update(ID *id, unsigned int flags)
ID and Library types, which are fundamental for SDNA.
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
Object is a sort of wrapper for general info.
#define EBONE_SELECTABLE(arm, ebone)
#define EBONE_EDITABLE(ebone)
void ED_outliner_select_sync_from_edit_bone_tag(bContext *C)
void ED_outliner_select_sync_from_pose_bone_tag(bContext *C)
void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
uiPopupMenu * UI_popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
uiLayout * UI_popup_menu_layout(uiPopupMenu *pup)
#define ND_BONE_COLLECTION
bArmature * ED_armature_context(const bContext *C)
EditBone * ED_armature_ebone_find_name(const ListBase *edbo, const char *name)
void ED_armature_edit_sync_selection(ListBase *edbo)
void ED_armature_ebone_select_set(EditBone *ebone, bool select)
static bool active_bone_collection_poll(bContext *C)
static wmOperatorStatus move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent *)
void ARMATURE_OT_assign_to_collection(wmOperatorType *ot)
void ARMATURE_OT_collection_create_and_assign(wmOperatorType *ot)
static wmOperatorStatus bone_collection_deselect_exec(bContext *C, wmOperator *)
static bool bone_collection_create_and_assign_poll(bContext *C)
static wmOperatorStatus bone_collection_unassign_named_exec(bContext *C, wmOperator *op)
static wmOperatorStatus bone_collection_create_and_assign_exec(bContext *C, wmOperator *op)
static wmOperatorStatus bone_collection_select_exec(bContext *C, wmOperator *)
static void bone_collection_select(bContext *C, bArmature *armature, BoneCollection *bcoll, const bool select)
static wmOperatorStatus move_to_new_collection_invoke(bContext *C, wmOperator *op)
bool(*)(BoneCollection *bcoll, Bone *bone) assign_bone_func
void ARMATURE_OT_collection_deselect(wmOperatorType *ot)
void ARMATURE_OT_collection_remove(wmOperatorType *ot)
void ARMATURE_OT_collection_unassign_named(wmOperatorType *ot)
static void bone_collection_assign_pchans(bContext *C, Object *ob, BoneCollection *bcoll, assign_bone_func assign_func, bool *made_any_changes, bool *had_bones_to_assign)
static bool bone_collection_assign_named_mode_specific(bContext *C, Object *ob, BoneCollection *bcoll, const char *bone_name, assign_bone_func assign_bone_func, assign_ebone_func assign_ebone_func, bool *made_any_changes, bool *had_bones_to_assign)
static void * menu_custom_data_encode(const int bcoll_index, const bool is_move_operation)
static wmOperatorStatus bone_collection_move_exec(bContext *C, wmOperator *op)
static bool bone_collection_assign_poll(bContext *C)
static BoneCollection * add_or_move_to_collection_bcoll(wmOperator *op, bArmature *arm)
static wmOperatorStatus move_to_collection_exec(bContext *C, wmOperator *op)
static void move_to_collection_menu_create(bContext *C, uiLayout *layout, void *menu_custom_data)
static wmOperatorStatus bone_collection_remove_exec(bContext *C, wmOperator *)
void ARMATURE_OT_collection_assign(wmOperatorType *ot)
void ARMATURE_OT_collection_add(wmOperatorType *ot)
static wmOperatorStatus bone_collection_unassign_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_collection_move(wmOperatorType *ot)
static bool armature_bone_select_poll(bContext *C)
static void menu_add_item_for_move_assign_unassign(uiLayout *layout, const bArmature *arm, const BoneCollection *bcoll, const int bcoll_index, const bool is_move_operation)
static BoneCollection * get_bonecoll_named_or_active(bContext *, wmOperator *op, Object *ob)
static wmOperatorStatus add_or_move_to_collection_exec(bContext *C, wmOperator *op, const assign_bone_func assign_func_bone, const assign_ebone_func assign_func_ebone)
static std::pair< int, bool > menu_custom_data_decode(void *menu_custom_data)
static wmOperatorStatus assign_to_collection_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_move_to_collection(wmOperatorType *ot)
static void bone_collection_assign_editbones(bContext *C, Object *ob, BoneCollection *bcoll, assign_ebone_func assign_func, bool *made_any_changes, bool *had_bones_to_assign)
static int icon_for_bone_collection(const bool collection_contains_active_bone)
static bool editbone_is_member(const EditBone *ebone, const BoneCollection *bcoll)
static bool bone_collection_assign_mode_specific(bContext *C, Object *ob, BoneCollection *bcoll, assign_bone_func assign_bone_func, assign_ebone_func assign_ebone_func, bool *made_any_changes, bool *had_bones_to_assign)
static bool bone_collection_add_poll(bContext *C)
static wmOperatorStatus move_to_collection_regular_invoke(bContext *C, wmOperator *op)
bool(*)(BoneCollection *bcoll, EditBone *ebone) assign_ebone_func
static wmOperatorStatus bone_collection_add_exec(bContext *C, wmOperator *)
static bool move_to_collection_poll(bContext *C)
void ARMATURE_OT_collection_unassign(wmOperatorType *ot)
static wmOperatorStatus bone_collection_assign_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_collection_select(wmOperatorType *ot)
bool bone_is_visible(const bArmature *armature, const Bone *bone)
int armature_bonecoll_child_number_find(const bArmature *armature, const ::BoneCollection *bcoll)
bool bonecoll_has_children(const BoneCollection *bcoll)
int armature_bonecoll_find_parent_index(const bArmature *armature, int bcoll_index)
int armature_bonecoll_child_number_set(bArmature *armature, ::BoneCollection *bcoll, int new_child_number)
Object * context_object(const bContext *C)
Object * context_active_object(const bContext *C)
Object * ED_pose_object_from_context(bContext *C)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
int RNA_int_get(PointerRNA *ptr, const char *name)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
ListBase bone_collections
int active_collection_index
struct BoneCollection * active_collection
int collection_root_count
struct BoneCollection ** collection_array
struct bArmature_Runtime runtime
void operator_context_set(blender::wm::OpCallContext opcontext)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
void enabled_set(bool enabled)
void menu_fn(blender::StringRefNull name, int icon, uiMenuCreateFunc func, void *arg)
uiLayout & row(bool align)
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, blender::wm::OpCallContext context, eUI_Item_Flag flag)
const char * translation_context
struct ReportList * reports
struct wmOperatorType * type
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorStatus WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message)