diff options
author | Matt Ebb <matt@mke3.net> | 2010-01-11 09:57:41 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-01-11 09:57:41 +0300 |
commit | 9565322d3254eb1ea0a2e3ea3bb42b6b0f5962af (patch) | |
tree | e8adf40cd4050e1e6fb92667a83a2a7d94ac2b28 /source/blender/editors/object | |
parent | 1afb01876c8b35fb2b72ca89d6e12d844a811cf2 (diff) |
Fix [#20600] First added camera is not made active
Also forced view align on when adding cameras
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 50 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 1 |
3 files changed, 52 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index abc182ef7ae..7af66d98df4 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -298,6 +298,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) int enter_editmode; float loc[3], rot[3]; + object_add_generic_invoke_options(C, op); ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); if(type==PFIELD_GUIDE) { @@ -357,6 +358,54 @@ void OBJECT_OT_effector_add(wmOperatorType *ot) ED_object_add_generic_props(ot, TRUE); } +/* ***************** Add Camera *************** */ + +static int object_camera_add_exec(bContext *C, wmOperator *op) +{ + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d= CTX_wm_region_view3d(C); + Scene *scene= CTX_data_scene(C); + Object *ob; + int enter_editmode; + float loc[3], rot[3]; + + /* force view align for cameras */ + RNA_boolean_set(op->ptr, "view_align", 1); + + object_add_generic_invoke_options(C, op); + ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); + + ob= ED_object_add_type(C, OB_CAMERA, loc, rot, FALSE); + + if (v3d) { + if (v3d->camera == NULL) + v3d->camera = ob; + if (v3d->scenelock && scene->camera==NULL) { + scene->camera = ob; + } + } + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_camera_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Camera"; + ot->description = "Add a camera object to the scene."; + ot->idname= "OBJECT_OT_camera_add"; + + /* api callbacks */ + ot->exec= object_camera_add_exec; + ot->poll= ED_operator_scene_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + ED_object_add_generic_props(ot, TRUE); +} + + /* ***************** add primitives *************** */ static EnumPropertyItem prop_curve_types[] = { @@ -583,6 +632,7 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", prop_metaball_types, 0, "Primitive", ""); ED_object_add_generic_props(ot, TRUE); } + static int object_add_text_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index d47cecb762b..861b2cc0a6e 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -100,6 +100,7 @@ void OBJECT_OT_text_add(struct wmOperatorType *ot); void OBJECT_OT_armature_add(struct wmOperatorType *ot); void OBJECT_OT_lamp_add(struct wmOperatorType *ot); void OBJECT_OT_effector_add(struct wmOperatorType *ot); +void OBJECT_OT_camera_add(struct wmOperatorType *ot); void OBJECT_OT_group_instance_add(struct wmOperatorType *ot); void OBJECT_OT_duplicates_make_real(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index a1889b97169..5d6636f68d0 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -117,6 +117,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_surface_add); WM_operatortype_append(OBJECT_OT_armature_add); WM_operatortype_append(OBJECT_OT_lamp_add); + WM_operatortype_append(OBJECT_OT_camera_add); WM_operatortype_append(OBJECT_OT_add); WM_operatortype_append(OBJECT_OT_effector_add); WM_operatortype_append(OBJECT_OT_group_instance_add); |