diff options
author | Michael Fox <mfoxdogg@gmail.com> | 2009-02-18 04:50:26 +0300 |
---|---|---|
committer | Michael Fox <mfoxdogg@gmail.com> | 2009-02-18 04:50:26 +0300 |
commit | 4a2155e3abe7b02b50515b175297ee24cd70c911 (patch) | |
tree | fd597d362fc5e7dbec4abfe00b09b49ad4ea5983 /source/blender/editors/armature | |
parent | 94e583b476600f13a490af448162ce390422025f (diff) |
2.5
******
added a ARMATURE_OT_bone_add operator, ita generic operator to add a bone it behaves the same way as the old add bone (making a bone not set the tail but have it selected), commiting this so other add bone ops like add bonre pinative or making new armature
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r-- | source/blender/editors/armature/armature_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 54 |
3 files changed, 57 insertions, 1 deletions
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index ace30fab20e..8b5f6f5985a 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_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 ffd547806ba..b396e16ac72 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -108,6 +108,8 @@ 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_align_bones); WM_operatortype_append(ARMATURE_OT_calculate_roll); WM_operatortype_append(ARMATURE_OT_switch_direction); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 68e9cb6ab5a..393d1771c0b 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -2977,6 +2977,60 @@ void extrude_armature(Scene *scene, int forked) // Transform(); } +/* ********************** Bone Add ********************/ + +/*op makes a new bone and returns it with its tip selected */ + +static int armature_bone_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"); + char name[32]; + + RNA_string_get(op->ptr, "name", name); + + BLI_strncpy(bone->name, name, 32); + unique_editbone_name(arm->edbo, bone->name); + + BLI_addtail(arm->edbo, bone); + + 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; + + armature_sync_selection(arm->edbo); + + WM_event_add_notifier(C, NC_OBJECT, ob); + + return OPERATOR_FINISHED; +} + +void ARMATURE_OT_bone_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Bone"; + ot->idname= "ARMATURE_OT_bone_add"; + + /* api callbacks */ + ot->exec = armature_bone_add_exec; + ot->poll = ED_operator_editarmature; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_string(ot->srna, "name", "Bone", 32, "Name", "Name of the newly created bone"); + +} + /* ----------- */ |