diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-07-04 18:59:26 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-07-04 18:59:26 +0400 |
commit | ea5f0ec96245b2bc26d7f21090752b57a7de0aca (patch) | |
tree | 3305a8b7362c670d56108af26eacd3edc8c931c9 /source/blender/editors | |
parent | 7eb5cf869962e958f812c58a37ca82d4c44c487a (diff) |
Fix #35997: add armature > single bone, then change location or rotation would
move only the origin and not the bone. It doesn't need to use any object
matrices to add the bone, the only reason this worked before is because they
were still unit matrices due to depsgraph not running immediately on add.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/armature/armature_add.c | 34 | ||||
-rw-r--r-- | source/blender/editors/include/ED_armature.h | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 5 |
3 files changed, 13 insertions, 28 deletions
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 13c1f2d5b2b..d480d41f5d6 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -84,39 +84,25 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) return bone; } -/* v3d and rv3d are allowed to be NULL */ -void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) +void add_primitive_bone(Object *obedit_arm, bool view_aligned) { - Object *obedit = scene->obedit; // XXX get from context - bArmature *arm = obedit->data; - float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; - EditBone *bone; - - /* Get inverse point for head and orientation for tail */ - invert_m4_m4(obedit->imat, obedit->obmat); - mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d)); + bArmature *arm = obedit_arm->data; + EditBone *bone; - if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - copy_m3_m4(obmat, rv3d->viewmat); - else unit_m3(obmat); - - copy_m3_m4(viewmat, obedit->obmat); - mul_m3_m3m3(totmat, obmat, viewmat); - invert_m3_m3(imat, totmat); - - ED_armature_deselect_all(obedit, 0); + ED_armature_deselect_all(obedit_arm, 0); /* Create a bone */ bone = ED_armature_edit_bone_add(arm, "Bone"); arm->act_edbone = bone; - copy_v3_v3(bone->head, curs); - - if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 + zero_v3(bone->head); + zero_v3(bone->tail); + + if (view_aligned) + bone->tail[1] = 1.0f; else - add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z + bone->tail[2] = 1.0f; } diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 3367dcb9c4c..801fa12d444 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -132,7 +132,7 @@ EditBone *ED_armature_bone_get_mirrored(struct ListBase *edbo, EditBone *ebo); / void ED_armature_sync_selection(struct ListBase *edbo); void ED_armature_validate_active(struct bArmature *arm); -void add_primitive_bone(struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d); +void add_primitive_bone(struct Object *obedit_arm, bool view_aligned); struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name); void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone); bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index d6f48b4d350..1e0a8cefb87 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -657,12 +657,12 @@ void OBJECT_OT_text_add(wmOperatorType *ot) static int object_armature_add_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); - View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); bool newob = false; bool enter_editmode; unsigned int layer; float loc[3], rot[3]; + bool view_aligned = rv3d && (U.flag & USER_ADD_VIEWALIGNED); if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; @@ -681,8 +681,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - /* v3d and rv3d are allowed to be NULL */ - add_primitive_bone(CTX_data_scene(C), v3d, rv3d); + add_primitive_bone(obedit, view_aligned); /* userdef */ if (newob && !enter_editmode) |