== 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.
This commit is contained in:
@@ -691,8 +691,15 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
if (U.uiflag & USER_AUTOPERSP)
|
||||
vod->rv3d->persp= RV3D_PERSP;
|
||||
else if(vod->rv3d->persp==RV3D_CAMOB)
|
||||
else if(vod->rv3d->persp==RV3D_CAMOB) {
|
||||
|
||||
/* changed since 2.4x, use the camera view */
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
if(v3d->camera)
|
||||
view3d_settings_from_ob(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
|
||||
|
||||
vod->rv3d->persp= RV3D_PERSP;
|
||||
}
|
||||
ED_region_tag_redraw(vod->ar);
|
||||
}
|
||||
|
||||
|
@@ -139,6 +139,8 @@ void VIEW3D_OT_select_border(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_select_lasso(struct wmOperatorType *ot);
|
||||
|
||||
/* view3d_view.c */
|
||||
void view3d_settings_from_ob(struct Object *ob, float *ofs, float *quat, float *dist, float *lens);
|
||||
|
||||
void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_setcameratoview(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_setobjectascamera(struct wmOperatorType *ot);
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user