38#include "RNA_prototypes.hh"
68 if (armature ==
nullptr) {
71 armature =
static_cast<bArmature *
>(
object->data);
105 ebone->rad_head *= scale;
106 ebone->rad_tail *= scale;
107 ebone->dist *= scale;
110 ebone->xwidth *= scale;
111 ebone->zwidth *= scale;
127 Main *bmain,
Object *ob,
const float cursor[3],
int centermode,
int around)
134 if (is_editmode ==
false) {
139 if (centermode == 2) {
142 mul_m4_v3(ob->world_to_object().ptr(), cent);
146 float min[3], max[3];
175 if (is_editmode ==
false) {
181 if (centermode && (is_editmode ==
false)) {
194 const float align_axis[3],
195 const bool axis_only)
197 float mat[3][3],
nor[3];
198 float vec[3], align_axis_proj[3], roll = 0.0f;
278 {0,
nullptr, 0,
nullptr,
nullptr},
296 for (
Object *ob : objects) {
298 bool changed =
false;
308 copy_m3_m4(imat, ob->object_to_world().ptr());
312 float cursor_local[3];
315 invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr());
317 mul_m4_v3(ob->world_to_object().ptr(), cursor_local);
341 if (is_edit || is_edit_parent) {
362 }
while ((is_vec_zero = (
normalize_v3(vec) < 0.00001f)) &&
363 (ebone_other = ebone_other->
parent));
376 if (is_edit_parent) {
379 ebone->
parent, vec, axis_only);
389 float vec[3] = {0.0f, 0.0f, 0.0f};
392 if (rv3d ==
nullptr) {
404 if (ebone ==
nullptr) {
418 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");
495 for (
Object *ob : objects) {
497 bool changed =
false;
512 ebone->roll = -ebone_mirr->
roll;
533 ot->
idname =
"ARMATURE_OT_roll_clear";
584 if (ebo == curBone) {
603 if (ld->
data == ebo) {
688 ListBase points = {
nullptr,
nullptr};
691 bool mixed_object_error =
false;
707 if (arm && (arm != arm_iter)) {
708 mixed_object_error =
true;
727 if (mixed_object_error) {
737 if (ob_iter->data == arm) {
754 mul_v3_m4v3(curs, obedit->world_to_object().ptr(), scene->cursor.location);
759 else if (
count == 2) {
761 float head[3], tail[3];
788 float dist_sq_a, dist_sq_b;
792 mul_v3_m4v3(curs, obedit->world_to_object().ptr(), scene->cursor.location);
799 headtail = (dist_sq_a < dist_sq_b) ? 2 : 1;
814 else if (headtail == 1) {
874 ot->
name =
"Fill Between Joints";
876 ot->
description =
"Add bone between selected joint(s) and/or 3D cursor";
900 ebone->flag &= ~BONE_TRANSFORM;
911 for (
Object *ob : objects) {
914 ListBase chains = {
nullptr,
nullptr};
933 EditBone *ebo, *child =
nullptr, *parent =
nullptr;
936 for (ebo =
static_cast<EditBone *
>(chain->data); ebo; ebo = parent) {
959 ebo->
flag &= ~BONE_CONNECTED;
973 ebo->
flag &= ~BONE_CONNECTED;
1007 ot->
name =
"Switch Direction";
1008 ot->
idname =
"ARMATURE_OT_switch_direction";
1009 ot->
description =
"Change the direction that a chain of bones points in (head and tail swap)";
1046 if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag &
BONE_CONNECTED)) {
1055 float selboneaxis[3], actboneaxis[3],
length;
1061 length =
len_v3(selboneaxis);
1079 int num_selected_bones;
1082 if (actbone ==
nullptr) {
1096 if (actmirb ==
nullptr) {
1105 if (num_selected_bones <= 1) {
1130 if (
ELEM(ebone, actbone, actmirb) == 0) {
1142 op->
reports,
RPT_INFO,
"%d bones aligned to bone '%s'", num_selected_bones, actbone->
name);
1155 ot->
name =
"Align Bones";
1157 ot->
description =
"Align selected bones to the active bone (or to their parent)";
1180 for (
Object *ob : objects) {
1185 bone->parent =
nullptr;
1186 bone->
flag &= ~BONE_CONNECTED;
1205 ot->
description =
"Split off selected bones from connected unselected bones";
1235 bool changed_multi =
false;
1246 for (
Object *obedit : objects) {
1248 bool changed =
false;
1254 for (curBone =
static_cast<EditBone *
>(arm->
edbo->
first); curBone; curBone = ebone_next) {
1255 ebone_next = curBone->
next;
1268 changed_multi =
true;
1278 if (!changed_multi) {
1290 IFACE_(
"Delete selected bones?"),
1302 ot->
name =
"Delete Selected Bone(s)";
1304 ot->
description =
"Remove selected bones from the armature";
1330 bool changed_multi =
false;
1334 for (
Object *obedit : objects) {
1336 bool changed =
false;
1339 GHash *ebone_flag_orig =
nullptr;
1343 ebone->
temp.
p =
nullptr;
1344 ebone->
flag &= ~BONE_DONE;
1357 val.flag = ebone->
flag;
1369 val_p->
flag = ebone->
flag & ~val_p->flag;
1422 for (ebone =
static_cast<EditBone *
>(arm->
edbo->
first); ebone; ebone = ebone_next) {
1423 ebone_next = ebone->
next;
1448 if (val_p && val_p->flag) {
1449 ebone->
flag &= ~val_p->flag;
1460 changed_multi =
true;
1468 if (!changed_multi) {
1478 ot->
name =
"Dissolve Selected Bone(s)";
1479 ot->
idname =
"ARMATURE_OT_dissolve";
1480 ot->
description =
"Dissolve selected bones from the armature";
1509 for (
Object *obedit : objects) {
1511 bool changed =
false;
1537 ot->
name =
"Hide Selected";
1539 ot->
description =
"Tag selected bones to not be visible in Edit Mode";
1550 ot->
srna,
"unselected",
false,
"Unselected",
"Hide unselected rather than selected");
1566 for (
Object *obedit : objects) {
1568 bool changed =
false;
1576 ebone->flag &= ~BONE_HIDDEN_A;
1595 ot->
name =
"Reveal Hidden";
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
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_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)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const struct 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_VISIBLE(arm, ebone)
#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 int armature_roll_clear_exec(bContext *C, wmOperator *op)
static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p)
static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone)
static int armature_split_exec(bContext *C, wmOperator *)
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 int armature_align_bones_exec(bContext *C, wmOperator *op)
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 int armature_reveal_exec(bContext *C, wmOperator *op)
static int armature_switch_direction_exec(bContext *C, wmOperator *)
static int armature_hide_exec(bContext *C, wmOperator *op)
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[]
static int armature_dissolve_selected_exec(bContext *C, wmOperator *)
static int armature_delete_selected_invoke(bContext *C, wmOperator *op, const wmEvent *)
void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
static int 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 int armature_delete_selected_exec(bContext *C, wmOperator *)
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 int armature_fill_bones_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_split(wmOperatorType *ot)
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)
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
Object * context_active_object(const bContext *C)
Frequency::GEOMETRY nor[]
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)
ObjectRuntimeHandle * runtime
struct EditBone * act_edbone
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_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
int WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, int icon, bool cancel_default)