35#include "RNA_prototypes.hh"
65 if (armature ==
nullptr) {
68 armature = id_cast<bArmature *>(
object->data);
124 Main *bmain,
Object *ob,
const float cursor[3],
int centermode,
int around)
131 if (is_editmode ==
false) {
136 if (centermode == 2) {
139 mul_m4_v3(ob->world_to_object().ptr(), cent);
172 if (is_editmode ==
false) {
178 if (centermode && (is_editmode ==
false)) {
191 const float align_axis[3],
192 const bool axis_only)
194 float mat[3][3], nor[3];
195 float vec[3], align_axis_proj[3], roll = 0.0f;
275 {0,
nullptr, 0,
nullptr,
nullptr},
294 for (
Object *ob : objects) {
295 bArmature *arm = id_cast<bArmature *>(ob->data);
296 bool changed =
false;
306 copy_m3_m4(imat, ob->object_to_world().ptr());
310 float cursor_local[3];
313 invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr());
315 mul_m4_v3(ob->world_to_object().ptr(), cursor_local);
339 if (is_edit || is_edit_parent) {
360 }
while ((is_vec_zero = (
normalize_v3(vec) < 0.00001f)) &&
361 (ebone_other = ebone_other->
parent));
374 if (is_edit_parent) {
377 ebone.
parent, vec, axis_only);
387 float vec[3] = {0.0f, 0.0f, 0.0f};
390 if (rv3d ==
nullptr) {
400 bArmature *arm_active = id_cast<bArmature *>(ob_active->
data);
402 if (ebone ==
nullptr) {
416 vec[type - 2] = -1.0f;
465 ot->
name =
"Recalculate Roll";
466 ot->
idname =
"ARMATURE_OT_calculate_roll";
467 ot->
description =
"Automatically fix alignment of select bones' axes";
484 "Ignore the axis direction, use the shortest rotation to align");
496 for (
Object *ob : objects) {
497 bArmature *arm = id_cast<bArmature *>(ob->data);
498 bool changed =
false;
535 ot->
name =
"Clear Roll";
536 ot->
idname =
"ARMATURE_OT_roll_clear";
587 if (ebo == &curBone) {
606 if (ld.
data == ebo) {
691 ListBaseT<EditBonePoint> points = {
nullptr,
nullptr};
694 bool mixed_object_error =
false;
710 if (arm && (arm != arm_iter)) {
711 mixed_object_error =
true;
723 count = points.count();
730 if (mixed_object_error) {
732 points.free_no_destruct();
741 if (ob_iter->data == id_cast<const ID *>(arm)) {
754 ebp = points.first();
771 else if (count == 2) {
773 float head[3], tail[3];
777 ebp_a = points.first();
784 points.free_no_destruct();
800 float dist_sq_a, dist_sq_b;
811 headtail = (dist_sq_a < dist_sq_b) ? 2 : 1;
826 else if (headtail == 1) {
877 points.free_no_destruct();
892 points.free_no_destruct();
900 ot->
name =
"Fill Between Joints";
901 ot->
idname =
"ARMATURE_OT_fill";
902 ot->
description =
"Add bone between selected joint(s) and/or 3D cursor";
938 for (
Object *ob : objects) {
939 bArmature *arm = id_cast<bArmature *>(ob->data);
941 ListBaseT<LinkData> chains = {
nullptr,
nullptr};
945 if (chains.is_empty()) {
960 EditBone *ebo, *child =
nullptr, *parent =
nullptr;
963 for (ebo =
static_cast<EditBone *
>(chain.data); ebo; ebo = parent) {
1017 chains.free_no_destruct();
1034 ot->
name =
"Switch Direction";
1035 ot->
idname =
"ARMATURE_OT_switch_direction";
1036 ot->
description =
"Change the direction that a chain of bones points in (head and tail swap)";
1073 if ((selbone.parent) && (selbone.parent == ebone) && (selbone.flag &
BONE_CONNECTED)) {
1082 float selboneaxis[3], actboneaxis[3],
length;
1106 int num_selected_bones;
1109 if (actbone ==
nullptr) {
1123 if (actmirb ==
nullptr) {
1132 if (num_selected_bones <= 1) {
1157 if (
ELEM(ebone, actbone, actmirb) == 0) {
1171 op->
reports,
RPT_INFO,
"%d bones aligned to bone '%s'", num_selected_bones, actbone->
name);
1184 ot->
name =
"Align Bones";
1185 ot->
idname =
"ARMATURE_OT_align";
1186 ot->
description =
"Align selected bones to the active bone (or to their parent)";
1210 for (
Object *ob : objects) {
1211 bArmature *arm = id_cast<bArmature *>(ob->data);
1234 ot->
idname =
"ARMATURE_OT_split";
1235 ot->
description =
"Split off selected bones from connected unselected bones";
1265 bool changed_multi =
false;
1277 for (
Object *obedit : objects) {
1278 bArmature *arm = id_cast<bArmature *>(obedit->data);
1279 bool changed =
false;
1285 for (curBone = arm->
edbo->first(); curBone; curBone = ebone_next) {
1286 ebone_next = curBone->
next;
1297 changed_multi =
true;
1307 if (!changed_multi) {
1321 IFACE_(
"Delete selected bones?"),
1333 ot->
name =
"Delete Selected Bone(s)";
1334 ot->
idname =
"ARMATURE_OT_delete";
1335 ot->
description =
"Remove selected bones from the armature";
1362 bool changed_multi =
false;
1366 for (
Object *obedit : objects) {
1367 bArmature *arm = id_cast<bArmature *>(obedit->data);
1368 bool changed =
false;
1375 ebone.
temp.p =
nullptr;
1381 ebone_flag_orig.
reserve(ebone_num);
1383 ebone_flag_orig.
add(&ebone, ebone.
flag);
1388 for (
const auto &item : ebone_flag_orig.
items()) {
1391 flag = ebone->
flag & ~flag;
1413 if (ebone.
temp.ebone == &ebone) {
1414 ebone.
temp.ebone =
nullptr;
1423 ebone.
temp.ebone =
nullptr;
1444 for (ebone = arm->
edbo->first(); ebone; ebone = ebone_next) {
1445 ebone_next = ebone->
next;
1467 ebone.
flag &= ~*flag_p;
1474 changed_multi =
true;
1482 if (!changed_multi) {
1492 ot->
name =
"Dissolve Selected Bone(s)";
1493 ot->
idname =
"ARMATURE_OT_dissolve";
1494 ot->
description =
"Dissolve selected bones from the armature";
1524 for (
Object *obedit : objects) {
1525 bArmature *arm = id_cast<bArmature *>(obedit->data);
1526 bool changed =
false;
1552 ot->
name =
"Hide Selected";
1553 ot->
idname =
"ARMATURE_OT_hide";
1554 ot->
description =
"Tag selected bones to not be visible in Edit Mode";
1565 ot->
srna,
"unselected",
false,
"Unselected",
"Hide unselected rather than selected");
1582 for (
Object *obedit : objects) {
1583 bArmature *arm = id_cast<bArmature *>(obedit->data);
1584 bool changed =
false;
1611 ot->
name =
"Reveal Hidden";
1612 ot->
idname =
"ARMATURE_OT_reveal";
1613 ot->
description =
"Reveal all bones hidden in Edit Mode";
Functions to deal with Armatures.
Blender kernel action and pose functionality.
#define CTX_DATA_BEGIN_WITH_ID(C, Type, instance, member, Type_id, instance_id)
#define CTX_DATA_BEGIN(C, Type, instance, member)
#define CTX_DATA_COUNT(C, member)
#define FOREACH_OBJECT_IN_EDIT_MODE_END
#define FOREACH_OBJECT_IN_EDIT_MODE_BEGIN(_bmain, _scene, _view_layer, _v3d, _instance)
General operations, lookup, etc. for blender objects.
#define BLI_ASSERT_UNIT_V3(v)
Object is a sort of wrapper for general info.
#define EBONE_EDITABLE(ebone)
Read Blender memory allocation and freeing.
#define RNA_ENUM_ITEM_HEADING(name, description)
#define ND_ARMATURE_STRUCTURE
#define INIT_MINMAX(min, max)
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
const Value * lookup_ptr(const Key &key) const
bool add(const Key &key, const Value &value)
ItemIterator items() const &
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
float length(VecOp< float, D >) RET
float2x2 invert(float2x2 mat)
float3x3 scale(float3x3 mat, float2 scale)
bool bone_is_visible(const bArmature *armature, const Bone *bone)
bool bone_is_selected(const bArmature *armature, const Bone *bone)
Object * context_active_object(const bContext *C)
void ARMATURE_OT_hide(wmOperatorType *ot)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void mul_m3_v3(const float M[3][3], float r[3])
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
void ARMATURE_OT_dissolve(wmOperatorType *ot)
void ARMATURE_OT_split(wmOperatorType *ot)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void BKE_pose_tag_recalc(Main *bmain, bPose *pose) ATTR_NONNULL(1
MINLINE void copy_v3_v3(float r[3], const float a[3])
static void fix_editbone_connected_children(ListBaseT< EditBone > *edbo, EditBone *ebone)
void ED_armature_origin_set(Main *bmain, Object *ob, const float cursor[3], int centermode, int around)
void ED_armature_to_edit(bArmature *arm)
void ED_armature_from_edit(Main *bmain, bArmature *arm)
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void mat3_to_vec_roll(const float mat[3][3], float r_vec[3], float *r_roll)
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
static wmOperatorStatus armature_roll_clear_exec(bContext *C, wmOperator *op)
static wmOperatorStatus armature_split_exec(bContext *C, wmOperator *)
float mat4_to_scale(const float mat[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p)
void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
void normalize_m3(float R[3][3]) ATTR_NONNULL()
float angle_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
@ V3D_AROUND_CENTER_BOUNDS
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 armature_tag_unselect(bArmature *arm)
bool ED_operator_editarmature(bContext *C)
void ED_armature_ebone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_connected)
static wmOperatorStatus armature_switch_direction_exec(bContext *C, wmOperator *)
void ED_armature_edit_transform(bArmature *arm, const float mat[4][4], const bool do_props)
ViewLayer * CTX_data_view_layer(const bContext *C)
static void fix_connected_bone(EditBone *ebone)
MINLINE void mul_v3_fl(float r[3], float f)
EditBone * CTX_data_active_bone(const bContext *C)
MINLINE void sub_v3_v3(float r[3], const float a[3])
void mul_m4_v3(const float M[4][4], float r[3])
void ARMATURE_OT_fill(wmOperatorType *ot)
MINLINE bool equals_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
EditBone * ED_armature_ebone_get_mirrored(const ListBaseT< EditBone > *edbo, EditBone *ebo)
void armature_tag_select_mirrored(bArmature *arm)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
static wmOperatorStatus armature_calc_roll_exec(bContext *C, wmOperator *op)
void ED_armature_ebone_to_mat3(EditBone *ebone, float r_mat[3][3])
static void fill_add_joint(EditBone *ebo, short eb_tail, ListBaseT< EditBonePoint > *points)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void DEG_id_tag_update(ID *id, unsigned int flags)
MINLINE void swap_v3_v3(float a[3], float b[3])
void BKE_report(ReportList *reports, eReportType type, const char *message)
void ED_armature_edit_sync_selection(ListBaseT< EditBone > *edbo)
Object * CTX_data_edit_object(const bContext *C)
bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone)
bArmature * ED_armature_context(const bContext *C)
void ARMATURE_OT_reveal(wmOperatorType *ot)
static void armature_clear_swap_done_flags(bArmature *arm)
void ARMATURE_OT_roll_clear(wmOperatorType *ot)
static const EnumPropertyItem prop_calc_roll_types[]
MINLINE void negate_v3(float r[3])
void ED_armature_transform(bArmature *arm, const float mat[4][4], const bool do_props)
void BKE_pose_channels_remove(Object *ob, bool(*filter_fn)(const char *bone_name, void *user_data), void *user_data) ATTR_NONNULL(1
RegionView3D * CTX_wm_region_view3d(const bContext *C)
void ED_armature_edit_free(bArmature *arm)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, ui::AlertIcon icon, bool cancel_default)
MINLINE void zero_v3(float r[3])
void ARMATURE_OT_align(wmOperatorType *ot)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
bool invert_m3(float mat[3][3])
bool BKE_object_is_in_editmode(const Object *ob)
static void chains_find_tips(ListBaseT< EditBone > *edbo, ListBaseT< LinkData > *list)
static wmOperatorStatus armature_dissolve_selected_exec(bContext *C, wmOperator *)
MINLINE float normalize_v3(float n[3])
void ED_armature_ebone_remove(bArmature *arm, EditBone *exBone)
MINLINE void add_v3_v3(float r[3], const float a[3])
int ED_armature_ebone_selectflag_get(const EditBone *ebone)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
static void bone_align_to_bone(ListBaseT< EditBone > *edbo, EditBone *selbone, EditBone *actbone)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Main * CTX_data_main(const bContext *C)
void ANIM_armature_bonecoll_assign_from_other_editbone(EditBone *dst, EditBone *src)
void armature_select_mirrored(bArmature *arm)
PropertyRNA * RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void armature_select_mirrored_ex(bArmature *arm, eBone_Flag flag)
void ARMATURE_OT_switch_direction(wmOperatorType *ot)
static wmOperatorStatus armature_hide_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_delete(wmOperatorType *ot)
Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
void ED_outliner_select_sync_from_edit_bone_tag(bContext *C)
EditBone * add_points_bone(Object *obedit, float head[3], float tail[3])
Scene * CTX_data_scene(const bContext *C)
void vec_roll_to_mat3_normalized(const float nor[3], float roll, float r_mat[3][3])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float align_axis[3], const bool axis_only)
static bool armature_dissolve_ebone_cb(const char *bone_name, void *arm_p)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
static wmOperatorStatus armature_delete_selected_exec(bContext *C, wmOperator *)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
static wmOperatorStatus armature_delete_selected_invoke(bContext *C, wmOperator *op, const wmEvent *)
void ED_armature_ebone_select_set(EditBone *ebone, bool select)
static wmOperatorStatus armature_align_bones_exec(bContext *C, wmOperator *op)
float RNA_float_get(PointerRNA *ptr, const char *name)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
View3D * CTX_wm_view3d(const bContext *C)
void BKE_armature_transform(bArmature *arm, const float mat[4][4], bool do_props)
static wmOperatorStatus armature_fill_bones_exec(bContext *C, wmOperator *op)
EditBone * ED_armature_ebone_find_name(const ListBaseT< EditBone > *edbo, const char *name)
static wmOperatorStatus armature_reveal_exec(bContext *C, wmOperator *op)
bool ED_armature_edit_deselect_all(Object *obedit)
union blender::EditBone::@252003325204232231327014100071366025164067232113 temp
const c_style_mat & ptr() const
bke::ObjectRuntime * runtime
ListBaseT< EditBone > * edbo
struct EditBone * act_edbone
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports