From 66e3a6e0efd782c09bd94dd22313558f3b91240b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Jun 2010 19:48:55 +0000 Subject: == View Navigation == Orbiting the view while in camera mode now starts from the camera view rather then switching back to the last user 3d view settings. * I added this some years back but it was rejected, however it was requested today for durian because with set scenes its not always easy to select whats infront of the camera to navigate to it. Its possible to end up in an annoying situation where you are looking at the main characters head (in a set scene), but when you orbit the view, the camera jumps 500+ BU away and you need to manually navigate back to what you were just looking at. * If a user wants to go back to the view they had before entering the camera view they can still press Numpad zero which toggles. --- source/blender/editors/space_view3d/view3d_view.c | 43 ++++++++++------------- 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'source/blender/editors/space_view3d/view3d_view.c') diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 31ddc442cc2..9790e928188 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -138,37 +138,32 @@ static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, f * * The dist is not modified for this function, if NULL its assimed zero * */ -static void view_settings_from_ob(Object *ob, float *ofs, float *quat, float *dist, float *lens) -{ - float bmat[4][4]; - float imat[4][4]; - float tmat[3][3]; - +void view3d_settings_from_ob(Object *ob, float *ofs, float *quat, float *dist, float *lens) +{ if (!ob) return; - + /* Offset */ if (ofs) negate_v3_v3(ofs, ob->obmat[3]); /* Quat */ if (quat) { - copy_m4_m4(bmat, ob->obmat); - normalize_m4(bmat); - invert_m4_m4(imat, bmat); - copy_m3_m4(tmat, imat); - mat3_to_quat( quat,tmat); + float imat[4][4]; + invert_m4_m4(imat, ob->obmat); + mat4_to_quat(quat, imat); } - + if (dist) { - float vec[3]; - copy_m3_m4(tmat, ob->obmat); - - vec[0]= vec[1] = 0.0; - vec[2]= -(*dist); - mul_m3_v3(tmat, vec); + float vec[3] = {0.0f, 0.0f, -(*dist)}; + float tquat[4]; + + mat4_to_quat(tquat, ob->obmat); + + mul_qt_v3(tquat, vec); + sub_v3_v3(ofs, vec); } - + /* Lens */ if (lens) object_lens_clip_settings(ob, lens, NULL, NULL); @@ -212,7 +207,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo if(lens) sms.new_lens= *lens; if (camera) { - view_settings_from_ob(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); + view3d_settings_from_ob(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); sms.to_camera= 1; /* restore view3d values in end */ } @@ -259,7 +254,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo /* original values */ if (oldcamera) { sms.orig_dist= rv3d->dist; // below function does weird stuff with it... - view_settings_from_ob(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); + view3d_settings_from_ob(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); } else { VECCOPY(sms.orig_ofs, rv3d->ofs); @@ -1122,7 +1117,7 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->persp=RV3D_PERSP; rv3d->dist= 0.0; - view_settings_from_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); + view3d_settings_from_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); smooth_view(NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX rv3d->persp=RV3D_CAMOB; /* just to be polite, not needed */ @@ -2688,7 +2683,7 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f VECCOPY(orig_ofs, rv3d->ofs); rv3d->persp= RV3D_PERSP; rv3d->dist= 0.0; - view_settings_from_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); + view3d_settings_from_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); smooth_view(NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX } else { if (rv3d->persp==RV3D_CAMOB) rv3d->persp= RV3D_PERSP; /* switch out of camera mode */ -- cgit v1.2.3