[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36824] trunk/blender: fix [#27459] Flymode moves parent

Campbell Barton ideasman42 at gmail.com
Mon May 23 04:53:31 CEST 2011


Revision: 36824
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36824
Author:   campbellbarton
Date:     2011-05-23 02:53:30 +0000 (Mon, 23 May 2011)
Log Message:
-----------
fix [#27459] Flymode moves parent
for durian we had camera rigs which needed to have the parent transformed rather then the camera, for this reason I made fly mode fly the parent rather then the camera its self.

Make this a preference and use this for view camera/view locking too.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
    trunk/blender/source/blender/editors/space_view3d/view3d_fly.c
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py	2011-05-23 02:23:03 UTC (rev 36823)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py	2011-05-23 02:53:30 UTC (rev 36824)
@@ -199,6 +199,7 @@
         col.prop(view, "use_zoom_to_mouse")
         col.prop(view, "use_rotate_around_active")
         col.prop(view, "use_global_pivot")
+        col.prop(view, "use_camera_lock_parent")
 
         col.separator()
 

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2011-05-23 02:23:03 UTC (rev 36823)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2011-05-23 02:53:30 UTC (rev 36824)
@@ -92,9 +92,39 @@
 void ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d)
 {
 	if(v3d->camera && (v3d->flag2 & V3D_LOCK_CAMERA) && (rv3d->persp==RV3D_CAMOB)) {
-		ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
-		DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB);
-		WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera);
+		Object *root_parent;
+
+		if((U.uiflag & USER_CAM_LOCK_NO_PARENT)==0 && (root_parent= v3d->camera->parent)) {
+			Object *ob_update;
+			float view_mat[4][4];
+			float diff_mat[4][4];
+			float parent_mat[4][4];
+
+			while(root_parent->parent) {
+				root_parent= root_parent->parent;
+			}
+
+			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, v3d->camera->imat, view_mat);
+
+			mul_m4_m4m4(parent_mat, root_parent->obmat, diff_mat);
+			object_apply_mat4(root_parent, parent_mat, TRUE, FALSE);
+
+			ob_update= v3d->camera;
+			while(ob_update) {
+				DAG_id_tag_update(&ob_update->id, OB_RECALC_OB);
+				WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, ob_update);
+				ob_update= ob_update->parent;
+			}
+		}
+		else {
+			ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
+			root_parent= v3d->camera;
+			DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB);
+			WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera);
+		}
 	}
 }
 

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_fly.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_fly.c	2011-05-23 02:23:03 UTC (rev 36823)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_fly.c	2011-05-23 02:53:30 UTC (rev 36824)
@@ -307,7 +307,7 @@
 	fly->dist_backup= fly->rv3d->dist;
 	if (fly->rv3d->persp==RV3D_CAMOB) {
 		Object *ob_back;
-		if((fly->root_parent=fly->v3d->camera->parent)) {
+		if((U.uiflag & USER_CAM_LOCK_NO_PARENT)==0 && (fly->root_parent=fly->v3d->camera->parent)) {
 			while(fly->root_parent->parent)
 				fly->root_parent= fly->root_parent->parent;
 			ob_back= fly->root_parent;

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2011-05-23 02:23:03 UTC (rev 36823)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2011-05-23 02:53:30 UTC (rev 36824)
@@ -469,7 +469,7 @@
 #define USER_HIDE_DOT			(1 << 16)
 #define USER_SHOW_ROTVIEWICON	(1 << 17)
 #define USER_SHOW_VIEWPORTNAME	(1 << 18)
-// old flag for #define USER_KEYINSERTNEED		(1 << 19)
+#define USER_CAM_LOCK_NO_PARENT	(1 << 19)
 #define USER_ZOOM_TO_MOUSEPOS	(1 << 20)
 #define USER_SHOW_FPS			(1 << 21)
 #define USER_MMB_PASTE			(1 << 22)

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2011-05-23 02:23:03 UTC (rev 36823)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2011-05-23 02:53:30 UTC (rev 36824)
@@ -2040,6 +2040,10 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ORBIT_ZBUF);
 	RNA_def_property_ui_text(prop, "Auto Depth", "Use the depth under the mouse to improve view pan/rotate/zoom functionality");
 
+	prop= RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "uiflag", USER_CAM_LOCK_NO_PARENT);
+	RNA_def_property_ui_text(prop, "Camera Parent Lock", "When the camera is locked to the view and in fly mode, transform the parent rather then the camera");
+
 	/* view zoom */
 	prop= RNA_def_property(srna, "use_zoom_to_mouse", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_TO_MOUSEPOS);




More information about the Bf-blender-cvs mailing list