Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/armature/armature_add.c34
-rw-r--r--source/blender/editors/include/ED_armature.h2
-rw-r--r--source/blender/editors/object/object_add.c5
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)