49 if (armature ==
nullptr) {
55 "Cannot add bone collections to a linked Armature without an "
56 "override on the Armature Data");
62 "Cannot add bone collections to a linked Armature with a system "
63 "override; explicitly create an override on the Armature Data");
74 if (armature ==
nullptr) {
80 "Cannot update a linked Armature with a system override; "
81 "explicitly create an override on the Armature Data");
86 if (bcoll ==
nullptr) {
93 C,
"Cannot edit bone collections that are linked from another blend file");
106 const int parent_index = armature_bonecoll_find_parent_index(
112 const int active_child_index = armature_bonecoll_child_number_find(
114 armature_bonecoll_child_number_set(armature, bcoll, active_child_index + 1);
127 ot->
name =
"Add Bone Collection";
128 ot->
idname =
"ARMATURE_OT_collection_add";
155 ot->
name =
"Remove Bone Collection";
156 ot->
idname =
"ARMATURE_OT_collection_remove";
189 {-1,
"UP", 0,
"Up",
""},
190 {1,
"DOWN", 0,
"Down",
""},
191 {0,
nullptr, 0,
nullptr,
nullptr},
195 ot->
name =
"Move Bone Collection";
196 ot->
idname =
"ARMATURE_OT_collection_move";
197 ot->
description =
"Change position of active Bone Collection in list of Bone collections";
211 "Direction to move the active Bone Collection towards");
221 if (bcoll_name[0] ==
'\0') {
244 bool *made_any_changes,
245 bool *had_bones_to_assign)
249 *made_any_changes |= assign_func(bcoll, pchan->bone);
250 *had_bones_to_assign =
true;
264 bool *made_any_changes,
265 bool *had_bones_to_assign)
274 *made_any_changes |= assign_func(bcoll, ebone);
275 *had_bones_to_assign =
true;
293 bool *made_any_changes,
294 bool *had_bones_to_assign)
324 const char *bone_name,
327 bool *made_any_changes,
328 bool *had_bones_to_assign)
339 *had_bones_to_assign =
true;
354 *had_bones_to_assign =
true;
383 C,
"Cannot edit bone collections on linked Armatures without override");
388 "Cannot edit bone collections on a linked Armature with a system "
389 "override; explicitly create an override on the Armature Data");
409 if (bcoll ==
nullptr) {
419 bool made_any_changes =
false;
420 bool had_bones_to_assign =
false;
428 &had_bones_to_assign);
430 if (!mode_is_supported) {
434 if (!had_bones_to_assign) {
438 if (!made_any_changes) {
450 ot->
name =
"Add Selected Bones to Collection";
451 ot->
idname =
"ARMATURE_OT_collection_assign";
452 ot->
description =
"Add selected bones to the chosen bone collection";
467 "Name of the bone collection to assign this bone to; empty to assign to the "
468 "active bone collection");
486 C,
"Cannot edit bone collections on linked Armatures without override");
491 "Cannot edit bone collections on a linked Armature with a system "
492 "override; explicitly create an override on the Armature Data");
516 bool made_any_changes =
false;
517 bool had_bones_to_assign =
false;
525 &had_bones_to_assign);
527 if (!mode_is_supported) {
532 if (!had_bones_to_assign) {
547 ot->
name =
"Add Selected Bones to New Collection";
548 ot->
idname =
"ARMATURE_OT_collection_create_and_assign";
549 ot->
description =
"Create a new bone collection and assign all selected bones";
564 "Name of the bone collection to create");
575 if (bcoll ==
nullptr) {
579 bool made_any_changes =
false;
580 bool had_bones_to_unassign =
false;
588 &had_bones_to_unassign);
590 if (!mode_is_supported) {
594 if (!had_bones_to_unassign) {
598 if (!made_any_changes) {
608 ot->
name =
"Remove Selected from Bone collections";
609 ot->
idname =
"ARMATURE_OT_collection_unassign";
610 ot->
description =
"Remove selected bones from the active bone collection";
624 "Name of the bone collection to unassign this bone from; empty to unassign from "
625 "the active bone collection");
636 if (bcoll ==
nullptr) {
647 bool made_any_changes =
false;
648 bool had_bones_to_unassign =
false;
657 &had_bones_to_unassign);
659 if (!mode_is_supported) {
663 if (!had_bones_to_unassign) {
667 if (!made_any_changes) {
669 RPT_WARNING,
"Bone '%s' was not assigned to collection '%s'", bone_name, bcoll->
name);
678 ot->
name =
"Remove Bone from Bone Collection";
679 ot->
idname =
"ARMATURE_OT_collection_unassign_named";
680 ot->
description =
"Unassign the named bone from this bone collection";
694 "Name of the bone collection to unassign this bone from; empty to unassign from "
695 "the active bone collection");
701 "Name of the bone to unassign from the collection; empty to use the active bone");
707 if (ref->bcoll == bcoll) {
725 C,
"Cannot (de)select bones on linked object, that would need an override");
743 const bool is_editmode = armature->
edbo !=
nullptr;
758 Bone *bone = member->bone;
770 bone->
flag &= ~BONE_SELECTED;
795 if (bcoll ==
nullptr) {
806 ot->
name =
"Select Bones of Bone Collection";
807 ot->
idname =
"ARMATURE_OT_collection_select";
827 if (bcoll ==
nullptr) {
838 ot->
name =
"Deselect Bone Collection";
839 ot->
idname =
"ARMATURE_OT_collection_deselect";
840 ot->
description =
"Deselect bones of active Bone Collection";
854 const int collection_index =
RNA_int_get(op->
ptr,
"collection_index");
861 (collection_index < 0))
868 "It should always be possible to create a new bone collection on an armature");
875 "Bone collection with index %d not found on Armature %s",
886 "Bone collection %s is not editable, maybe add an override on the armature Data?",
915 bool made_any_changes =
false;
916 bool had_bones_to_assign =
false;
923 &had_bones_to_assign);
925 if (!mode_is_supported) {
929 if (!had_bones_to_assign) {
933 if (!made_any_changes) {
979 "Cannot update a linked Armature with a system override; "
980 "explicitly create an override on the Armature Data");
1004 const uintptr_t index_and_move_bit = ((bcoll_index + 1) << 1) | (is_move_operation << 0);
1005 return reinterpret_cast<void *
>(index_and_move_bit);
1015 const uintptr_t index_and_move_bit =
reinterpret_cast<intptr_t>(menu_custom_data);
1016 const bool is_move_operation = (index_and_move_bit & 1) == 1;
1017 const int bcoll_index =
int(index_and_move_bit >> 1) - 1;
1018 return std::make_pair(bcoll_index, is_move_operation);
1023 return collection_contains_active_bone ? ICON_REMOVE : ICON_ADD;
1029 const int bcoll_index,
1030 const bool is_move_operation)
1032 if (is_move_operation) {
1036 "ARMATURE_OT_move_to_collection",
1045 if (contains_active_bone) {
1047 layout, bcoll->
name, icon,
"ARMATURE_OT_collection_unassign",
"name", bcoll->
name);
1066 int parent_bcoll_index;
1067 bool is_move_operation;
1077 "New Bone Collection",
1079 is_move_operation ?
"ARMATURE_OT_move_to_collection" :
1080 "ARMATURE_OT_assign_to_collection",
1082 parent_bcoll_index);
1090 int child_index, child_count;
1091 if (parent_bcoll_index == -1) {
1101 layout, arm, parent, parent_bcoll_index, is_move_operation);
1110 for (
int index = child_index; index < child_index + child_count; index++) {
1141 const bool is_move_operation =
STREQ(op->
type->
idname,
"ARMATURE_OT_move_to_collection");
1153 C, op, 200,
IFACE_(
"Move to New Bone Collection"),
IFACE_(
"Create"));
1173 ot->
name =
"Move to Collection";
1175 ot->
idname =
"ARMATURE_OT_move_to_collection";
1195 "Index of the collection to move selected bones to. When the operator should create a new "
1196 "bone collection, do not include this parameter and pass new_collection_name",
1203 "new_collection_name",
1207 "Name of a to-be-added bone collection. Only pass this if you want to create a new bone "
1208 "collection and move the selected bones to it. To move to an existing collection, do not "
1209 "include this parameter and use collection_index");
1219 ot->
name =
"Assign to Collection";
1221 "Assign all selected bones to a collection, or unassign them, depending on whether the "
1222 "active bone is already assigned or not";
1223 ot->
idname =
"ARMATURE_OT_assign_to_collection";
1243 "Index of the collection to assign selected bones to. When the operator should create a new "
1244 "bone collection, use new_collection_name to define the collection name, and set this "
1245 "parameter to the parent index of the new bone collection",
1252 "new_collection_name",
1256 "Name of a to-be-added bone collection. Only pass this if you want to create a new bone "
1257 "collection and assign the selected bones to it. To assign to an existing collection, do "
1258 "not include this parameter and use collection_index");
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_bone_is_visible(const bArmature *armature, const Bone *bone)
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
#define BLI_assert_msg(a, msg)
#define LISTBASE_FOREACH(type, var, list)
#define CTX_IFACE_(context, msgid)
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 uiLayoutSetEnabled(uiLayout *layout, bool enabled)
void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
void uiItemS(uiLayout *layout)
uiPopupMenu * UI_popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
uiLayout * UI_popup_menu_layout(uiPopupMenu *pup)
void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value)
void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg)
void uiLayoutSetOperatorContext(uiLayout *layout, wmOperatorCallContext opcontext)
#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 int bone_collection_select_exec(bContext *C, wmOperator *)
static void bone_collection_select(bContext *C, Object *ob, BoneCollection *bcoll, const bool select)
static bool active_bone_collection_poll(bContext *C)
void ARMATURE_OT_assign_to_collection(wmOperatorType *ot)
void ARMATURE_OT_collection_create_and_assign(wmOperatorType *ot)
static bool bone_collection_create_and_assign_poll(bContext *C)
static int bone_collection_remove_exec(bContext *C, wmOperator *)
static int bone_collection_create_and_assign_exec(bContext *C, wmOperator *op)
static int move_to_collection_regular_invoke(bContext *C, wmOperator *op)
static int bone_collection_deselect_exec(bContext *C, wmOperator *)
static int bone_collection_move_exec(bContext *C, wmOperator *op)
bool(*)(BoneCollection *bcoll, Bone *bone) assign_bone_func
static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent *)
void ARMATURE_OT_collection_deselect(wmOperatorType *ot)
void ARMATURE_OT_collection_remove(wmOperatorType *ot)
void ARMATURE_OT_collection_unassign_named(wmOperatorType *ot)
static int 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 int bone_collection_unassign_named_exec(bContext *C, wmOperator *op)
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 int bone_collection_add_exec(bContext *C, wmOperator *)
static bool bone_collection_assign_poll(bContext *C)
static BoneCollection * add_or_move_to_collection_bcoll(wmOperator *op, bArmature *arm)
static int move_to_collection_exec(bContext *C, wmOperator *op)
static void move_to_collection_menu_create(bContext *C, uiLayout *layout, void *menu_custom_data)
void ARMATURE_OT_collection_assign(wmOperatorType *ot)
void ARMATURE_OT_collection_add(wmOperatorType *ot)
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 std::pair< int, bool > menu_custom_data_decode(void *menu_custom_data)
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 int move_to_new_collection_invoke(bContext *C, wmOperator *op)
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 int bone_collection_unassign_exec(bContext *C, wmOperator *op)
static bool bone_collection_add_poll(bContext *C)
static int assign_to_collection_exec(bContext *C, wmOperator *op)
bool(*)(BoneCollection *bcoll, EditBone *ebone) assign_ebone_func
static bool move_to_collection_poll(bContext *C)
static int bone_collection_assign_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_collection_unassign(wmOperatorType *ot)
void ARMATURE_OT_collection_select(wmOperatorType *ot)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
bool bonecoll_has_children(const BoneCollection *bcoll)
Object * context_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_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_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)
_W64 unsigned int uintptr_t
ListBase bone_collections
int active_collection_index
struct BoneCollection * active_collection
int collection_root_count
struct BoneCollection ** collection_array
struct bArmature_Runtime runtime
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
const char * translation_context
struct ReportList * reports
struct wmOperatorType * type
void WM_report(eReportType type, const char *message)
void WM_main_add_notifier(uint type, void *reference)
void WM_reportf(eReportType type, const char *format,...)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int 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)