apply offset to the camera view - this works exactly like camera shift (transforms...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 13 Jun 2012 13:23:48 +0000 (13:23 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 13 Jun 2012 13:23:48 +0000 (13:23 +0000)
release/scripts/startup/bl_ui/space_view3d.py
source/blender/editors/space_view3d/view3d_draw.c

index eb2f14fa3a898d2e2607b776e94344d0ab25d524..d7fe7ebbbf72c9c4cff5437098fd02f6e9bc08bd 100644 (file)
@@ -2586,9 +2586,10 @@ class VIEW3D_PT_background_image(Panel):
 
                     if bg.view_axis != 'CAMERA':
                         col.prop(bg, "size")
-                        row = col.row(align=True)
-                        row.prop(bg, "offset_x", text="X")
-                        row.prop(bg, "offset_y", text="Y")
+
+                    row = col.row(align=True)
+                    row.prop(bg, "offset_x", text="X")
+                    row.prop(bg, "offset_y", text="Y")
 
 
 class VIEW3D_PT_transform_orientations(Panel):
index 6ef5d538b2412359ef050e7bbc10c053e85d08a3..5073eca96ad02e7502e7105608dab858928d4846 100644 (file)
@@ -1618,6 +1618,19 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
                                        y2 = ar->winrct.ymax;
                                }
 
+                               /* apply offset last - camera offset is different to offset in blender units */
+                               /* so this has some sane way of working - this matches camera's shift _exactly_ */
+                               {
+                                       const float max_dim = maxf(x2 - x1, y2 - y1);
+                                       const float xof_scale = bgpic->xof * max_dim;
+                                       const float yof_scale = bgpic->yof * max_dim;
+
+                                       x1 += xof_scale;
+                                       y1 += yof_scale;
+                                       x2 += xof_scale;
+                                       y2 += yof_scale;
+                               }
+
                                /* aspect correction */
                                if (bgpic->flag & V3D_BGPIC_CAMERA_ASPECT)
                                {