diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-03 14:05:16 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-03 14:05:23 +0300 |
commit | 780bb88a7a5b30eaf8a62b999a30ac7bb4153ebf (patch) | |
tree | 621e1c05f686c3c522c31b0061202671fdc32139 /source/blender/editors/space_view3d | |
parent | 16ed20ff3cc68589a5fe48075d2b80692d3c90ea (diff) |
Refactor 'fit in camera view' code, and expose it to RNA.
This changes BKE's fitting code to use `BKE_camera_params_compute_viewplane` instead of
`BKE_camera_view_frame`. This allows that code to work with orthographic projection too.
Also, two funcs were added to rna's Object, to resp. get the projection matrix of that
object (mostly useful for cameras and lamps objects), and return position this object
should be to see all (to fit) a given set of points.
Reviewers: campbellbarton
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D961
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index c0e26498af6..5a3893f733f 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -496,26 +496,22 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) Object *camera_ob = v3d ? v3d->camera : scene->camera; float r_co[3]; /* the new location to apply */ + float r_scale; /* only for ortho cameras */ if (camera_ob == NULL) { BKE_report(op->reports, RPT_ERROR, "No active camera"); return OPERATOR_CANCELLED; } - else if (camera_ob->type != OB_CAMERA) { - BKE_report(op->reports, RPT_ERROR, "Object not a camera"); - return OPERATOR_CANCELLED; - } - else if (((Camera *)camera_ob->data)->type == R_ORTHO) { - BKE_report(op->reports, RPT_ERROR, "Orthographic cameras not supported"); - return OPERATOR_CANCELLED; - } /* this function does all the important stuff */ - if (BKE_camera_view_frame_fit_to_scene(scene, v3d, camera_ob, r_co)) { - + if (BKE_camera_view_frame_fit_to_scene(scene, v3d, camera_ob, r_co, &r_scale)) { ObjectTfmProtectedChannels obtfm; float obmat_new[4][4]; + if ((camera_ob->type == OB_CAMERA) && (((Camera *)camera_ob->data)->type == CAM_ORTHO)) { + ((Camera *)camera_ob->data)->ortho_scale = r_scale; + } + copy_m4_m4(obmat_new, camera_ob->obmat); copy_v3_v3(obmat_new[3], r_co); |