[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57440] trunk/blender/source/blender/ editors/space_view3d: fixes for using scaled cameras

Campbell Barton ideasman42 at gmail.com
Thu Jun 13 17:09:32 CEST 2013


Revision: 57440
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57440
Author:   campbellbarton
Date:     2013-06-13 15:09:32 +0000 (Thu, 13 Jun 2013)
Log Message:
-----------
fixes for using scaled cameras
- ED_view3d_from_m4() got incorrect rotation from scaled cameras, was noticable with smoothview transitions.
- when you lock the camera to the view, any view edits would reset the cameras scale to 1.
- another problem with view locking if the camera was scaled and had a parent, the parent would be transformed incorrectly.
- fly mode was chaning object scale a little over time, now restore after applying scale so it never changes.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
    trunk/blender/source/blender/editors/space_view3d/view3d_fly.c

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2013-06-13 15:02:42 UTC (rev 57439)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2013-06-13 15:09:32 UTC (rev 57440)
@@ -134,6 +134,8 @@
 
 		if ((U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0 && (root_parent = v3d->camera->parent)) {
 			Object *ob_update;
+			float tmat[4][4];
+			float imat[4][4];
 			float view_mat[4][4];
 			float diff_mat[4][4];
 			float parent_mat[4][4];
@@ -144,9 +146,11 @@
 
 			ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
 
-			invert_m4_m4(v3d->camera->imat, v3d->camera->obmat);
-			mul_m4_m4m4(diff_mat, view_mat, v3d->camera->imat);
+			normalize_m4_m4(tmat, v3d->camera->obmat);
 
+			invert_m4_m4(imat, tmat);
+			mul_m4_m4m4(diff_mat, view_mat, imat);
+
 			mul_m4_m4m4(parent_mat, diff_mat, root_parent->obmat);
 
 			BKE_object_tfm_protected_backup(root_parent, &obtfm);
@@ -161,9 +165,11 @@
 			}
 		}
 		else {
+			/* always maintain the same scale */
+			const short protect_scale_all = (OB_LOCK_SCALEX | OB_LOCK_SCALEY | OB_LOCK_SCALEZ);
 			BKE_object_tfm_protected_backup(v3d->camera, &obtfm);
 			ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
-			BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag);
+			BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag | protect_scale_all);
 
 			DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB);
 			WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, v3d->camera);
@@ -4167,7 +4173,8 @@
 	/* Quat */
 	if (quat) {
 		float imat[4][4];
-		invert_m4_m4(imat, mat);
+		normalize_m4_m4(imat, mat);
+		invert_m4(imat);
 		mat4_to_quat(quat, imat);
 	}
 

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_fly.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_fly.c	2013-06-13 15:02:42 UTC (rev 57439)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_fly.c	2013-06-13 15:09:32 UTC (rev 57440)
@@ -762,13 +762,19 @@
 	else {
 		float view_mat[4][4];
 		float size_mat[4][4];
+		float size_back[3];
 
+		/* even though we handle the size matrix, this still changes over time */
+		copy_v3_v3(size_back, v3d->camera->size);
+
 		ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
 		size_to_mat4(size_mat, v3d->camera->size);
 		mul_m4_m4m4(view_mat, view_mat, size_mat);
 
 		BKE_object_apply_mat4(v3d->camera, view_mat, true, true);
 
+		copy_v3_v3(v3d->camera->size, size_back);
+
 		id_key = &v3d->camera->id;
 	}
 




More information about the Bf-blender-cvs mailing list