[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43411] trunk/blender/source/blender: Allow camera 1:1 and center camera view to run from menu's.

Campbell Barton ideasman42 at gmail.com
Mon Jan 16 07:57:47 CET 2012


Revision: 43411
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43411
Author:   campbellbarton
Date:     2012-01-16 06:57:37 +0000 (Mon, 16 Jan 2012)
Log Message:
-----------
Allow camera 1:1 and center camera view to run from menu's.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2012-01-16 06:43:58 UTC (rev 43410)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2012-01-16 06:57:37 UTC (rev 43411)
@@ -1608,7 +1608,7 @@
 	return(ok);
 }
 
-/* same as BKE_write_ibuf_as but crappy workaround not to perminantly modify
+/* same as BKE_write_ibuf() but crappy workaround not to perminantly modify
  * _some_, values in the imbuf */
 int BKE_write_ibuf_as(ImBuf *ibuf, const char *name, ImageFormatData *imf,
                       const short save_copy)

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2012-01-16 06:43:58 UTC (rev 43410)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2012-01-16 06:57:37 UTC (rev 43411)
@@ -921,6 +921,22 @@
 	return 0;
 }
 
+/* test for unlocked camera view in quad view */
+static int view3d_camera_user_poll(bContext *C)
+{
+	View3D *v3d;
+	ARegion *ar;
+
+	if (ED_view3d_context_user_region(C, &v3d, &ar)) {
+		RegionView3D *rv3d = ar->regiondata;
+		if(rv3d->persp==RV3D_CAMOB) {
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
 static int viewrotate_cancel(bContext *C, wmOperator *op)
 {
 	viewops_data_free(C, op);
@@ -2257,13 +2273,18 @@
 
 static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was view3d_home() in 2.4x */
 {
-	ARegion *ar= CTX_wm_region(C);
-	RegionView3D *rv3d= CTX_wm_region_view3d(C);
-	View3D *v3d= CTX_wm_view3d(C);
 	Scene *scene= CTX_data_scene(C);
 	float xfac, yfac;
 	float size[2];
 
+	View3D *v3d;
+	ARegion *ar;
+	RegionView3D *rv3d;
+
+	/* no NULL check is needed, poll checks */
+	ED_view3d_context_user_region(C, &v3d, &ar);
+	rv3d = ar->regiondata;
+
 	rv3d->camdx= rv3d->camdy= 0.0f;
 
 	ED_view3d_calc_camera_border_size(scene, ar, v3d, rv3d, size);
@@ -2289,7 +2310,7 @@
 
 	/* api callbacks */
 	ot->exec= view3d_center_camera_exec;
-	ot->poll= view3d_camera_active_poll;
+	ot->poll= view3d_camera_user_poll;
 
 	/* flags */
 	ot->flag= 0;
@@ -2543,12 +2564,17 @@
 static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Scene *scene= CTX_data_scene(C);
-	ARegion *ar= CTX_wm_region(C);
 
-	view3d_set_1_to_1_viewborder(scene, ar, CTX_wm_view3d(C));
+	View3D *v3d;
+	ARegion *ar;
 
-	WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
+	/* no NULL check is needed, poll checks */
+	ED_view3d_context_user_region(C, &v3d, &ar);
 
+	view3d_set_1_to_1_viewborder(scene, ar, v3d);
+
+	WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);
+
 	return OPERATOR_FINISHED;
 }
 
@@ -2561,7 +2587,7 @@
 
 	/* api callbacks */
 	ot->exec= view3d_zoom_1_to_1_camera_exec;
-	ot->poll= view3d_camera_active_poll;
+	ot->poll= view3d_camera_user_poll;
 
 	/* flags */
 	ot->flag= 0;
@@ -2660,6 +2686,7 @@
 	static int perspo = RV3D_PERSP;
 	int viewnum, align_active, nextperspo;
 
+	/* no NULL check is needed, poll checks */
 	ED_view3d_context_user_region(C, &v3d, &ar);
 	rv3d = ar->regiondata;
 



More information about the Bf-blender-cvs mailing list