36#include "RNA_prototypes.hh"
66 if (armature ==
nullptr) {
69 armature =
static_cast<bArmature *
>(
object->data);
103 ebone->rad_head *= scale;
104 ebone->rad_tail *= scale;
105 ebone->dist *= scale;
108 ebone->xwidth *= scale;
109 ebone->zwidth *= scale;
125 Main *bmain,
Object *ob,
const float cursor[3],
int centermode,
int around)
132 if (is_editmode ==
false) {
137 if (centermode == 2) {
140 mul_m4_v3(ob->world_to_object().ptr(), cent);
173 if (is_editmode ==
false) {
179 if (centermode && (is_editmode ==
false)) {
192 const float align_axis[3],
193 const bool axis_only)
195 float mat[3][3],
nor[3];
196 float vec[3], align_axis_proj[3], roll = 0.0f;
276 {0,
nullptr, 0,
nullptr,
nullptr},
294 for (
Object *ob : objects) {
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) {
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";
479 RNA_def_boolean(
ot->srna,
"axis_flip",
false,
"Flip Axis",
"Negate the alignment axis");
484 "Ignore the axis direction, use the shortest rotation to align");
495 for (
Object *ob : objects) {
497 bool changed =
false;
514 ebone->roll = -ebone_mirr->
roll;
534 ot->name =
"Clear Roll";
535 ot->idname =
"ARMATURE_OT_roll_clear";
536 ot->description =
"Clear roll for selected bones";
586 if (ebo == curBone) {
605 if (ld->
data == ebo) {
690 ListBase points = {
nullptr,
nullptr};
693 bool mixed_object_error =
false;
709 if (arm && (arm != arm_iter)) {
710 mixed_object_error =
true;
729 if (mixed_object_error) {
739 if (ob_iter->data == arm) {
761 else if (
count == 2) {
763 float head[3], tail[3];
790 float dist_sq_a, dist_sq_b;
801 headtail = (dist_sq_a < dist_sq_b) ? 2 : 1;
816 else if (headtail == 1) {
876 ot->name =
"Fill Between Joints";
877 ot->idname =
"ARMATURE_OT_fill";
878 ot->description =
"Add bone between selected joint(s) and/or 3D cursor";
913 for (
Object *ob : objects) {
916 ListBase chains = {
nullptr,
nullptr};
935 EditBone *ebo, *child =
nullptr, *parent =
nullptr;
938 for (ebo =
static_cast<EditBone *
>(chain->data); ebo; ebo = parent) {
1011 ot->name =
"Switch Direction";
1012 ot->idname =
"ARMATURE_OT_switch_direction";
1013 ot->description =
"Change the direction that a chain of bones points in (head and tail swap)";
1050 if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag &
BONE_CONNECTED)) {
1059 float selboneaxis[3], actboneaxis[3],
length;
1083 int num_selected_bones;
1086 if (actbone ==
nullptr) {
1100 if (actmirb ==
nullptr) {
1109 if (num_selected_bones <= 1) {
1134 if (
ELEM(ebone, actbone, actmirb) == 0) {
1148 op->
reports,
RPT_INFO,
"%d bones aligned to bone '%s'", num_selected_bones, actbone->
name);
1161 ot->name =
"Align Bones";
1162 ot->idname =
"ARMATURE_OT_align";
1163 ot->description =
"Align selected bones to the active bone (or to their parent)";
1186 for (
Object *ob : objects) {
1191 bone->parent =
nullptr;
1210 ot->idname =
"ARMATURE_OT_split";
1211 ot->description =
"Split off selected bones from connected unselected bones";
1241 bool changed_multi =
false;
1252 for (
Object *obedit : objects) {
1254 bool changed =
false;
1260 for (curBone =
static_cast<EditBone *
>(arm->
edbo->
first); curBone; curBone = ebone_next) {
1261 ebone_next = curBone->
next;
1272 changed_multi =
true;
1282 if (!changed_multi) {
1296 IFACE_(
"Delete selected bones?"),
1308 ot->name =
"Delete Selected Bone(s)";
1309 ot->idname =
"ARMATURE_OT_delete";
1310 ot->description =
"Remove selected bones from the armature";
1336 bool changed_multi =
false;
1340 for (
Object *obedit : objects) {
1342 bool changed =
false;
1345 GHash *ebone_flag_orig =
nullptr;
1349 ebone->
temp.
p =
nullptr;
1363 val.flag = ebone->
flag;
1375 val_p->
flag = ebone->
flag & ~val_p->flag;
1428 for (ebone =
static_cast<EditBone *
>(arm->
edbo->
first); ebone; ebone = ebone_next) {
1429 ebone_next = ebone->
next;
1454 if (val_p && val_p->flag) {
1455 ebone->
flag &= ~val_p->flag;
1466 changed_multi =
true;
1474 if (!changed_multi) {
1484 ot->name =
"Dissolve Selected Bone(s)";
1485 ot->idname =
"ARMATURE_OT_dissolve";
1486 ot->description =
"Dissolve selected bones from the armature";
1515 for (
Object *obedit : objects) {
1517 bool changed =
false;
1543 ot->name =
"Hide Selected";
1544 ot->idname =
"ARMATURE_OT_hide";
1545 ot->description =
"Tag selected bones to not be visible in Edit Mode";
1556 ot->srna,
"unselected",
false,
"Unselected",
"Hide unselected rather than selected");
1572 for (
Object *obedit : objects) {
1574 bool changed =
false;
1601 ot->name =
"Reveal Hidden";
1602 ot->idname =
"ARMATURE_OT_reveal";
1603 ot->description =
"Reveal all bones hidden in Edit Mode";
Functions to deal with Armatures.
bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone)
Blender kernel action and pose functionality.
void BKE_pose_channels_remove(Object *ob, bool(*filter_fn)(const char *bone_name, void *user_data), void *user_data) ATTR_NONNULL(1
void BKE_pose_tag_recalc(Main *bmain, bPose *pose) ATTR_NONNULL(1
void BKE_armature_transform(bArmature *arm, const float mat[4][4], bool do_props)
void mat3_to_vec_roll(const float mat[3][3], float r_vec[3], float *r_roll)
void vec_roll_to_mat3_normalized(const float nor[3], float roll, float r_mat[3][3])
#define CTX_DATA_BEGIN_WITH_ID(C, Type, instance, member, Type_id, instance_id)
#define CTX_DATA_BEGIN(C, Type, instance, member)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
#define CTX_DATA_COUNT(C, member)
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)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
#define FOREACH_OBJECT_IN_EDIT_MODE_END
blender::Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
#define FOREACH_OBJECT_IN_EDIT_MODE_BEGIN(_scene, _view_layer, _v3d, _instance)
General operations, lookup, etc. for blender objects.
bool BKE_object_is_in_editmode(const Object *ob)
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()
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void ** BLI_ghashIterator_getValue_p(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER(gh_iter_, ghash_)
void ** BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_ptr_new_ex(const char *info, unsigned int nentries_reserve) 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)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define BLI_ASSERT_UNIT_V3(v)
float mat4_to_scale(const float mat[4][4])
void mul_m3_v3(const float M[3][3], float r[3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void normalize_m3(float R[3][3]) ATTR_NONNULL()
void mul_m4_v3(const float M[4][4], float r[3])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
bool invert_m3(float mat[3][3])
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
float angle_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE bool equals_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void swap_v3_v3(float a[3], float b[3])
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
#define INIT_MINMAX(min, max)
#define SET_FLAG_FROM_TEST(value, test, flag)
void DEG_id_tag_update(ID *id, unsigned int flags)
Object is a sort of wrapper for general info.
@ V3D_AROUND_CENTER_BOUNDS
#define EBONE_EDITABLE(ebone)
void ED_outliner_select_sync_from_edit_bone_tag(bContext *C)
bool ED_operator_editarmature(bContext *C)
Read Guarded memory(de)allocation.
#define RNA_ENUM_ITEM_HEADING(name, description)
EditBone * add_points_bone(Object *obedit, float head[3], float tail[3])
void ARMATURE_OT_hide(wmOperatorType *ot)
void ARMATURE_OT_delete(wmOperatorType *ot)
static void armature_clear_swap_done_flags(bArmature *arm)
static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p)
static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone)
static wmOperatorStatus armature_fill_bones_exec(bContext *C, wmOperator *op)
static wmOperatorStatus armature_reveal_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_roll_clear(wmOperatorType *ot)
bArmature * ED_armature_context(const bContext *C)
void ARMATURE_OT_fill(wmOperatorType *ot)
static void fix_connected_bone(EditBone *ebone)
static void chains_find_tips(ListBase *edbo, ListBase *list)
static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actbone)
float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float align_axis[3], const bool axis_only)
static wmOperatorStatus armature_delete_selected_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus armature_delete_selected_exec(bContext *C, wmOperator *)
void ARMATURE_OT_align(wmOperatorType *ot)
static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
static const EnumPropertyItem prop_calc_roll_types[]
void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
static wmOperatorStatus armature_calc_roll_exec(bContext *C, wmOperator *op)
void ED_armature_origin_set(Main *bmain, Object *ob, const float cursor[3], int centermode, int around)
void ED_armature_transform(bArmature *arm, const float mat[4][4], const bool do_props)
static wmOperatorStatus armature_dissolve_selected_exec(bContext *C, wmOperator *)
static wmOperatorStatus armature_roll_clear_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_switch_direction(wmOperatorType *ot)
void ED_armature_edit_transform(bArmature *arm, const float mat[4][4], const bool do_props)
void ARMATURE_OT_dissolve(wmOperatorType *ot)
void ARMATURE_OT_reveal(wmOperatorType *ot)
static bool armature_dissolve_ebone_cb(const char *bone_name, void *arm_p)
static wmOperatorStatus armature_split_exec(bContext *C, wmOperator *)
static wmOperatorStatus armature_hide_exec(bContext *C, wmOperator *op)
static wmOperatorStatus armature_switch_direction_exec(bContext *C, wmOperator *)
void ARMATURE_OT_split(wmOperatorType *ot)
static wmOperatorStatus armature_align_bones_exec(bContext *C, wmOperator *op)
void armature_tag_select_mirrored(bArmature *arm)
void armature_select_mirrored(bArmature *arm)
void armature_tag_unselect(bArmature *arm)
void armature_select_mirrored_ex(bArmature *arm, int flag)
bool ED_armature_edit_deselect_all(Object *obedit)
EditBone * ED_armature_ebone_find_name(const ListBase *edbo, const char *name)
void ED_armature_ebone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_connected)
void ED_armature_edit_sync_selection(ListBase *edbo)
int ED_armature_ebone_selectflag_get(const EditBone *ebone)
void ED_armature_ebone_select_set(EditBone *ebone, bool select)
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_ebone_remove(bArmature *arm, EditBone *exBone)
void ED_armature_to_edit(bArmature *arm)
EditBone * ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo)
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
float length(VecOp< float, D >) RET
CCL_NAMESPACE_BEGIN ccl_device float invert(const float color, const float factor)
void * MEM_callocN(size_t len, const char *str)
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)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
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)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
union EditBone::@275371335250266324235150226366250166246037204077 temp
ObjectRuntimeHandle * runtime
struct EditBone * act_edbone
struct ReportList * reports
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, int icon, bool cancel_default)