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:
authorMichael Fox <mfoxdogg@gmail.com>2009-02-18 05:13:36 +0300
committerMichael Fox <mfoxdogg@gmail.com>2009-02-18 05:13:36 +0300
commitbf5e267c97daae9baaf8fb06e34d68a829fd0119 (patch)
tree4d61127c49b69fc2fe7c9d4ea1e389fde50bc7b4 /source/blender/editors/armature
parent4a2155e3abe7b02b50515b175297ee24cd70c911 (diff)
2.5
***** added add_primitive_bone, removed operator from previous commit as it was not needed
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r--source/blender/editors/armature/armature_intern.h2
-rw-r--r--source/blender/editors/armature/armature_ops.c2
-rw-r--r--source/blender/editors/armature/editarmature.c57
3 files changed, 35 insertions, 26 deletions
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 8b5f6f5985a..c8ca85fc08b 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -32,7 +32,7 @@
struct wmOperatorType;
/* editarmature.c */
-void ARMATURE_OT_bone_add(struct wmOperatorType *ot);
+void ARMATURE_OT_bone_primitive_add(struct wmOperatorType *ot);
void ARMATURE_OT_align_bones(struct wmOperatorType *ot);
void ARMATURE_OT_calculate_roll(struct wmOperatorType *ot);
void ARMATURE_OT_switch_direction(struct wmOperatorType *ot);
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index b396e16ac72..cccec052aa6 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -108,7 +108,7 @@ void ARMATURE_OT_test(wmOperatorType *ot)
void ED_operatortypes_armature(void)
{
/* EDIT ARMATURE */
- WM_operatortype_append(ARMATURE_OT_bone_add);
+ WM_operatortype_append(ARMATURE_OT_bone_primitive_add);
WM_operatortype_append(ARMATURE_OT_align_bones);
WM_operatortype_append(ARMATURE_OT_calculate_roll);
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 393d1771c0b..ad0fa0c1241 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -2981,47 +2981,56 @@ void extrude_armature(Scene *scene, int forked)
/*op makes a new bone and returns it with its tip selected */
-static int armature_bone_add_exec(bContext *C, wmOperator *op)
+static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_edit_object(C);
- bArmature *arm= (bArmature *)ob->data;
- EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone");
+ RegionView3D *rv3d= CTX_wm_region_view3d(C);
+ Object *obedit = CTX_data_edit_object(C);
+ bArmature *arm= (bArmature *)obedit->data;
+ EditBone *bone;
+ float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
char name[32];
-
+
RNA_string_get(op->ptr, "name", name);
+
+ VECCOPY(curs, give_cursor(CTX_data_scene(C),CTX_wm_view3d(C)));
- BLI_strncpy(bone->name, name, 32);
- unique_editbone_name(arm->edbo, bone->name);
+ /* Get inverse point for head and orientation for tail */
+ Mat4Invert(obedit->imat, obedit->obmat);
+ Mat4MulVecfl(obedit->imat, curs);
+
+ if (U.flag & USER_ADD_VIEWALIGNED)
+ Mat3CpyMat4(obmat, rv3d->viewmat);
+ else Mat3One(obmat);
- BLI_addtail(arm->edbo, bone);
+ Mat3CpyMat4(viewmat, obedit->obmat);
+ Mat3MulMat3(totmat, obmat, viewmat);
+ Mat3Inv(imat, totmat);
- bone->flag |= BONE_TIPSEL;
- bone->weight= 1.0f;
- bone->dist= 0.25f;
- bone->xwidth= 0.1f;
- bone->zwidth= 0.1f;
- bone->ease1= 1.0f;
- bone->ease2= 1.0f;
- bone->rad_head= 0.10f;
- bone->rad_tail= 0.05f;
- bone->segments= 1;
- bone->layer= arm->layer;
+ deselectall_armature(obedit, 0, 0);
- armature_sync_selection(arm->edbo);
+ /* Create a bone */
+ bone= add_editbone(obedit, name);
- WM_event_add_notifier(C, NC_OBJECT, ob);
+ VECCOPY(bone->head, curs);
+
+ if(U.flag & USER_ADD_VIEWALIGNED)
+ VecAddf(bone->tail, bone->head, imat[1]); // bone with unit length 1
+ else
+ VecAddf(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
+
+ WM_event_add_notifier(C, NC_OBJECT, obedit);
return OPERATOR_FINISHED;
}
-void ARMATURE_OT_bone_add(wmOperatorType *ot)
+void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Bone";
- ot->idname= "ARMATURE_OT_bone_add";
+ ot->idname= "ARMATURE_OT_bone_primitive_add";
/* api callbacks */
- ot->exec = armature_bone_add_exec;
+ ot->exec = armature_bone_primitive_add_exec;
ot->poll = ED_operator_editarmature;
/* flags */