Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h2
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c43
3 files changed, 29 insertions, 25 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 5c2fe184d65..4aa49bca366 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -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);
}
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 53bc5b7c5d5..69e4006770d 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -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);
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 */