Cycles: non-camera viewport render border support
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 16 Oct 2012 11:57:46 +0000 (11:57 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 16 Oct 2012 11:57:46 +0000 (11:57 +0000)
This makes it possible to do a border render inside a viewport even
when not looking through the camera.

Render border could be defined by Ctrl-B shortcut (works for both
camera render border and viewport render border).

Camera render border could still be defined using Shift-B (so no
muscule memory would be broken). Currently used a special flag of
operator to do this, otherwise you'll need to either two operators
with different poll callback or it could go into conflict with a
border zoom,

Border render of a viewport could be enabled/disabled in View
panel using "Render Border" option.

12 files changed:
intern/cycles/blender/blender_camera.cpp
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_sync.h
release/scripts/startup/bl_ui/space_view3d.py
source/blender/blenkernel/BKE_blender.h
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_intern.h
source/blender/editors/space_view3d/view3d_ops.c
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesrna/intern/rna_space.c

index e16677336d5f9385a063bda3712813f4da7efab4..000d412ab2863e669b7f144aac5e8f4194056ce5 100644 (file)
@@ -425,12 +425,26 @@ static void blender_camera_border(BlenderCamera *bcam, BL::Scene b_scene, BL::Sp
        BL::RegionView3D b_rv3d, int width, int height)
 {
        BL::RenderSettings r = b_scene.render();
-
-       if(!r.use_border())
-               return;
+       bool is_camera_view;
 
        /* camera view? */
-       if(!(b_rv3d && b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA))
+       is_camera_view = b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA;
+
+       if(!is_camera_view) {
+               /* for non-camera view check whether render border is enabled for viewport
+                * and if so use border from 3d viewport
+                * assume viewport has got correctly clamped border already
+                */
+               if(b_v3d.use_render_border()) {
+                       bcam->border_left = b_v3d.render_border_min_x();
+                       bcam->border_right = b_v3d.render_border_max_x();
+                       bcam->border_bottom = b_v3d.render_border_min_y();
+                       bcam->border_top = b_v3d.render_border_max_y();
+
+                       return;
+               }
+       }
+       else if(!r.use_border())
                return;
 
        BL::Object b_ob = (b_v3d.lock_camera_and_layers())? b_scene.camera(): b_v3d.camera();
@@ -504,14 +518,20 @@ void BlenderSync::sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int
        blender_camera_sync(scene->camera, &bcam, width, height);
 }
 
-BufferParams BlenderSync::get_buffer_params(BL::Scene b_scene, Camera *cam, int width, int height)
+BufferParams BlenderSync::get_buffer_params(BL::Scene b_scene, BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, Camera *cam, int width, int height)
 {
        BufferParams params;
+       bool use_border = false;
 
        params.full_width = width;
        params.full_height = height;
 
-       if(b_scene.render().use_border()) {
+       if(b_v3d && b_rv3d && b_rv3d.view_perspective() != BL::RegionView3D::view_perspective_CAMERA)
+               use_border = b_v3d.use_render_border();
+       else
+               use_border = b_scene.render().use_border();
+
+       if(use_border) {
                /* border render */
                params.full_x = cam->border_left*width;
                params.full_y = cam->border_bottom*height;
index 0a09102bd4fe938741f3dad90cc7186f0090f119..3fdd4418eb664707bf6ef4670fd8fc2245ce4923 100644 (file)
@@ -105,7 +105,7 @@ void BlenderSession::create_session()
                sync->sync_camera(b_engine.camera_override(), width, height);
 
        /* set buffer parameters */
-       BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, width, height);
+       BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_v3d, b_rv3d, scene->camera, width, height);
        session->reset(buffer_params, session_params.samples);
 }
 
@@ -239,7 +239,7 @@ void BlenderSession::render()
 
        /* get buffer parameters */
        SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background);
-       BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, width, height);
+       BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_v3d, b_rv3d, scene->camera, width, height);
 
        /* render each layer */
        BL::RenderSettings r = b_scene.render();
@@ -399,7 +399,7 @@ void BlenderSession::synchronize()
 
        /* reset if needed */
        if(scene->need_reset()) {
-               BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, width, height);
+               BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_v3d, b_rv3d, scene->camera, width, height);
                session->reset(buffer_params, session_params.samples);
        }
 }
@@ -437,7 +437,7 @@ bool BlenderSession::draw(int w, int h)
                /* reset if requested */
                if(reset) {
                        SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background);
-                       BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, w, h);
+                       BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_v3d, b_rv3d, scene->camera, w, h);
 
                        session->reset(buffer_params, session_params.samples);
                }
@@ -447,7 +447,7 @@ bool BlenderSession::draw(int w, int h)
        update_status_progress();
 
        /* draw */
-       BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, width, height);
+       BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_v3d, b_rv3d, scene->camera, width, height);
 
        return !session->draw(buffer_params);
 }
index ce563087b4a3ff1b8bc197957bbd964bf2c49b9f..d7fcb01493174419940ed552418b717225adfe07 100644 (file)
@@ -63,7 +63,7 @@ public:
        static SceneParams get_scene_params(BL::Scene b_scene, bool background);
        static SessionParams get_session_params(BL::RenderEngine b_engine, BL::UserPreferences b_userpref, BL::Scene b_scene, bool background);
        static bool get_session_pause(BL::Scene b_scene, bool background);
-       static BufferParams get_buffer_params(BL::Scene b_scene, Camera *cam, int width, int height);
+       static BufferParams get_buffer_params(BL::Scene b_scene, BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, Camera *cam, int width, int height);
 
 private:
        /* sync */
index e96bc696087a49cc0940525a28890c6b5baf2c97..f787f18fad3b69666c7ce19bd346cbb1ae188e91 100644 (file)
@@ -2312,6 +2312,9 @@ class VIEW3D_PT_view3d_properties(Panel):
         subcol.label(text="Local Camera:")
         subcol.prop(view, "camera", text="")
 
+        col = layout.column(align=True)
+        col.prop(view, "use_render_border")
+
 
 class VIEW3D_PT_view3d_cursor(Panel):
     bl_space_type = 'VIEW_3D'
index e1c79f8d6c142df7cd216a5244c95e18771bc335..95d41a862395f7ffb5ce037221fe610f9412891c 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         264
-#define BLENDER_SUBVERSION      2
+#define BLENDER_SUBVERSION      3
 
 /* 262 was the last editmesh release but its has compatibility code for bmesh data,
  * so set the minversion to 2.61 */
index 884a6432ddaf11b17172354872a53dc048849e8e..35b6b4005596793db2b675b28bb79a4a6bb8ba35 100644 (file)
@@ -8046,40 +8046,63 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
-       /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
-       /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
-
-       {
-               Object *ob;
+       if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 3)) {
+               /* smoke branch */
+               {
+                       Object *ob;
 
-               for (ob = main->object.first; ob; ob = ob->id.next) {
-                       ModifierData *md;
-                       for (md = ob->modifiers.first; md; md = md->next) {
-                               if (md->type == eModifierType_Smoke) {
-                                       SmokeModifierData *smd = (SmokeModifierData *)md;
-                                       if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
-                                               /* keep branch saves if possible */
-                                               if (!smd->domain->flame_max_temp) {
-                                                       smd->domain->burning_rate = 0.75f;
-                                                       smd->domain->flame_smoke = 1.0f;
-                                                       smd->domain->flame_vorticity = 0.5f;
-                                                       smd->domain->flame_ignition = 1.25f;
-                                                       smd->domain->flame_max_temp = 1.75f;
-                                                       smd->domain->adapt_threshold = 0.02f;
-                                                       smd->domain->adapt_margin = 4;
-                                                       smd->domain->flame_smoke_color[0] = 0.7f;
-                                                       smd->domain->flame_smoke_color[1] = 0.7f;
-                                                       smd->domain->flame_smoke_color[2] = 0.7f;
+                       for (ob = main->object.first; ob; ob = ob->id.next) {
+                               ModifierData *md;
+                               for (md = ob->modifiers.first; md; md = md->next) {
+                                       if (md->type == eModifierType_Smoke) {
+                                               SmokeModifierData *smd = (SmokeModifierData *)md;
+                                               if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
+                                                       /* keep branch saves if possible */
+                                                       if (!smd->domain->flame_max_temp) {
+                                                               smd->domain->burning_rate = 0.75f;
+                                                               smd->domain->flame_smoke = 1.0f;
+                                                               smd->domain->flame_vorticity = 0.5f;
+                                                               smd->domain->flame_ignition = 1.25f;
+                                                               smd->domain->flame_max_temp = 1.75f;
+                                                               smd->domain->adapt_threshold = 0.02f;
+                                                               smd->domain->adapt_margin = 4;
+                                                               smd->domain->flame_smoke_color[0] = 0.7f;
+                                                               smd->domain->flame_smoke_color[1] = 0.7f;
+                                                               smd->domain->flame_smoke_color[2] = 0.7f;
+                                                       }
+                                               }
+                                               else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
+                                                       if (!smd->flow->texture_size) {
+                                                               smd->flow->fuel_amount = 1.0;
+                                                               smd->flow->surface_distance = 1.5;
+                                                               smd->flow->color[0] = 0.7f;
+                                                               smd->flow->color[1] = 0.7f;
+                                                               smd->flow->color[2] = 0.7f;
+                                                               smd->flow->texture_size = 1.0f;
+                                                       }
                                                }
                                        }
-                                       else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
-                                               if (!smd->flow->texture_size) {
-                                                       smd->flow->fuel_amount = 1.0;
-                                                       smd->flow->surface_distance = 1.5;
-                                                       smd->flow->color[0] = 0.7f;
-                                                       smd->flow->color[1] = 0.7f;
-                                                       smd->flow->color[2] = 0.7f;
-                                                       smd->flow->texture_size = 1.0f;
+                               }
+                       }
+               }
+
+               /* render border for viewport */
+               {
+                       bScreen *sc;
+
+                       for (sc = main->screen.first; sc; sc = sc->id.next) {
+                               ScrArea *sa;
+                               for (sa = sc->areabase.first; sa; sa = sa->next) {
+                                       SpaceLink *sl;
+                                       for (sl = sa->spacedata.first; sl; sl = sl->next) {
+                                               if (sl->spacetype == SPACE_VIEW3D) {
+                                                       View3D *v3d = (View3D *)sl;
+                                                       if (v3d->render_border.xmin == 0.0f && v3d->render_border.ymin == 0.0f &&
+                                                           v3d->render_border.xmax == 0.0f && v3d->render_border.ymax == 0.0f)
+                                                       {
+                                                               v3d->render_border.xmax = 1.0f;
+                                                               v3d->render_border.ymax = 1.0f;
+                                                       }
                                                }
                                        }
                                }
@@ -8087,6 +8110,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
+       /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
+       /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
+
        /* don't forget to set version number in blender.c! */
 }
 
index 88375c409b8e1b72243fe5f73e66ccdfe57cc9ac..8e1b0716136885f93940074797149197133780d7 100644 (file)
@@ -2878,12 +2878,20 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
                rctf viewborder;
                rcti cliprct;
 
-               ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
+               if (rv3d->persp == RV3D_CAMOB) {
+                       ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
 
-               cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder);
-               cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder);
-               cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder);
-               cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder);
+                       cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder);
+                       cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder);
+                       cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder);
+                       cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder);
+               }
+               else {
+                       cliprct.xmin = v3d->render_border.xmin * ar->winx;
+                       cliprct.xmax = v3d->render_border.xmax * ar->winx;
+                       cliprct.ymin = v3d->render_border.ymin * ar->winy;
+                       cliprct.ymax = v3d->render_border.ymax * ar->winy;
+               }
 
                cliprct.xmin += ar->winrct.xmin;
                cliprct.xmax += ar->winrct.xmin;
@@ -3129,8 +3137,20 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
 
        Object *ob;
 
-       if (rv3d->persp == RV3D_CAMOB)
+       if (rv3d->persp == RV3D_CAMOB) {
                drawviewborder(scene, ar, v3d);
+       }
+       else if (v3d->flag2 & V3D_RENDER_BORDER) {
+               glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+               setlinestyle(3);
+               cpack(0x4040FF);
+
+               glRectf(v3d->render_border.xmin * ar->winx, v3d->render_border.ymin * ar->winy,
+                       v3d->render_border.xmax * ar->winx, v3d->render_border.ymax * ar->winy);
+
+               setlinestyle(0);
+               glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+       }
 
        if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
                /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
@@ -3180,7 +3200,12 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
        View3D *v3d = CTX_wm_view3d(C);
        RegionView3D *rv3d = CTX_wm_region_view3d(C);
        const char *grid_unit = NULL;
-       int draw_border = (rv3d->persp == RV3D_CAMOB && (scene->r.mode & R_BORDER));
+       int draw_border = FALSE;
+
+       if (rv3d->persp == RV3D_CAMOB)
+               draw_border = scene->r.mode & R_BORDER;
+       else
+               draw_border = v3d->flag2 & V3D_RENDER_BORDER;
 
        /* draw viewport using opengl */
        if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(C) || draw_border) {
index 2a210ef0ee4563c46dd8e5d620eb2f07003a8e69..96264081f10a85382e80d6926a3b6554de77d2f7 100644 (file)
@@ -929,18 +929,6 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
        }
 }
 
-static int view3d_camera_active_poll(bContext *C)
-{
-       if (ED_operator_view3d_active(C)) {
-               RegionView3D *rv3d = CTX_wm_region_view3d(C);
-               if (rv3d && rv3d->persp == RV3D_CAMOB) {
-                       return 1;
-               }
-       }
-
-       return 0;
-}
-
 /* test for unlocked camera view in quad view */
 static int view3d_camera_user_poll(bContext *C)
 {
@@ -2633,42 +2621,71 @@ static int render_border_exec(bContext *C, wmOperator *op)
        View3D *v3d = CTX_wm_view3d(C);
        ARegion *ar = CTX_wm_region(C);
        RegionView3D *rv3d = ED_view3d_context_rv3d(C);
+
        Scene *scene = CTX_data_scene(C);
 
        rcti rect;
-       rctf vb;
+       rctf vb, border;
+
+       int camera_only = RNA_boolean_get(op->ptr, "camera_only");
+
+       if (camera_only && rv3d->persp != RV3D_CAMOB)
+               return OPERATOR_PASS_THROUGH;
 
        /* get border select values using rna */
        WM_operator_properties_border_to_rcti(op, &rect);
 
        /* calculate range */
-       ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
 
-       scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_rctf_size_x(&vb);
-       scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_rctf_size_y(&vb);
-       scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_rctf_size_x(&vb);
-       scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_rctf_size_y(&vb);
+       if (rv3d->persp == RV3D_CAMOB) {
+               ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
+       }
+       else {
+               vb.xmin = 0;
+               vb.ymin = 0;
+               vb.xmax = ar->winx;
+               vb.ymax = ar->winy;
+       }
+
+       border.xmin = ((float)rect.xmin - vb.xmin) / BLI_rctf_size_x(&vb);
+       border.ymin = ((float)rect.ymin - vb.ymin) / BLI_rctf_size_y(&vb);
+       border.xmax = ((float)rect.xmax - vb.xmin) / BLI_rctf_size_x(&vb);
+       border.ymax = ((float)rect.ymax - vb.ymin) / BLI_rctf_size_y(&vb);
 
        /* actually set border */
-       CLAMP(scene->r.border.xmin, 0.0f, 1.0f);
-       CLAMP(scene->r.border.ymin, 0.0f, 1.0f);
-       CLAMP(scene->r.border.xmax, 0.0f, 1.0f);
-       CLAMP(scene->r.border.ymax, 0.0f, 1.0f);
+       CLAMP(border.xmin, 0.0f, 1.0f);
+       CLAMP(border.ymin, 0.0f, 1.0f);
+       CLAMP(border.xmax, 0.0f, 1.0f);
+       CLAMP(border.ymax, 0.0f, 1.0f);
+
+       if (rv3d->persp == RV3D_CAMOB) {
+               scene->r.border = border;
+
+               WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+       }
+       else {
+               v3d->render_border = border;
+
+               WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+       }
 
        /* drawing a border surrounding the entire camera view switches off border rendering
         * or the border covers no pixels */
-       if ((scene->r.border.xmin <= 0.0f && scene->r.border.xmax >= 1.0f &&
-            scene->r.border.ymin <= 0.0f && scene->r.border.ymax >= 1.0f) ||
-           (scene->r.border.xmin == scene->r.border.xmax ||
-            scene->r.border.ymin == scene->r.border.ymax))
+       if ((border.xmin <= 0.0f && border.xmax >= 1.0f &&
+            border.ymin <= 0.0f && border.ymax >= 1.0f) ||
+           (border.xmin == border.xmax || border.ymin == border.ymax))
        {
-               scene->r.mode &= ~R_BORDER;
+               if (rv3d->persp == RV3D_CAMOB)
+                       scene->r.mode &= ~R_BORDER;
+               else
+                       v3d->flag2 &= ~V3D_RENDER_BORDER;
        }
        else {
-               scene->r.mode |= R_BORDER;
+               if (rv3d->persp == RV3D_CAMOB)
+                       scene->r.mode |= R_BORDER;
+               else
+                       v3d->flag2 |= V3D_RENDER_BORDER;
        }
-       
-       WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL);
 
        return OPERATOR_FINISHED;
 
@@ -2687,7 +2704,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
        ot->modal = WM_border_select_modal;
        ot->cancel = WM_border_select_cancel;
 
-       ot->poll = view3d_camera_active_poll;
+       ot->poll = ED_operator_view3d_active;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -2695,7 +2712,56 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
        /* rna */
        WM_operator_properties_border(ot);
 
+       RNA_def_boolean(ot->srna, "camera_only", 0, "Camera Only", "Set render border for camera view and final render only");
+}
+
+/* ********************* Set render border operator ****************** */
+
+static int clear_render_border_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       View3D *v3d = CTX_wm_view3d(C);
+       RegionView3D *rv3d = ED_view3d_context_rv3d(C);
+
+       Scene *scene = CTX_data_scene(C);
+       rctf *border = NULL;
+
+       if (rv3d->persp == RV3D_CAMOB) {
+               scene->r.mode &= ~R_BORDER;
+               border = &scene->r.border;
+
+               WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+       }
+       else {
+               v3d->flag2 &= ~V3D_RENDER_BORDER;
+               border = &v3d->render_border;
+
+               WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+       }
+
+       border->xmin = 0.0f;
+       border->ymin = 0.0f;
+       border->xmax = 1.0f;
+       border->ymax = 1.0f;
+
+       return OPERATOR_FINISHED;
+
 }
+
+void VIEW3D_OT_clear_render_border(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Clear Render Border";
+       ot->description = "Clear the boundaries of the border render and enables border render";
+       ot->idname = "VIEW3D_OT_clear_render_border";
+
+       /* api callbacks */
+       ot->exec = clear_render_border_exec;
+       ot->poll = ED_operator_view3d_active;
+
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 /* ********************* Border Zoom operator ****************** */
 
 static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
index e364014c42f4dadba7e686b2e948c41b2acac7ee..8f7656a1f37a273405c9407fda4a509c79c0c2fb 100644 (file)
@@ -98,6 +98,7 @@ void VIEW3D_OT_cursor3d(struct wmOperatorType *ot);
 void VIEW3D_OT_manipulator(struct wmOperatorType *ot);
 void VIEW3D_OT_enable_manipulator(struct wmOperatorType *ot);
 void VIEW3D_OT_render_border(struct wmOperatorType *ot);
+void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot);
 void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
 
 void view3d_boxview_copy(ScrArea *sa, ARegion *ar);
index cb4f85430c54a7cc8665e191df10f6324d151a78..73f1563417c3ab95170d5921bdeb9ff63ae9f6d6 100644 (file)
@@ -83,6 +83,7 @@ void view3d_operatortypes(void)
        WM_operatortype_append(VIEW3D_OT_select_circle);
        WM_operatortype_append(VIEW3D_OT_smoothview);
        WM_operatortype_append(VIEW3D_OT_render_border);
+       WM_operatortype_append(VIEW3D_OT_clear_render_border);
        WM_operatortype_append(VIEW3D_OT_zoom_border);
        WM_operatortype_append(VIEW3D_OT_manipulator);
        WM_operatortype_append(VIEW3D_OT_enable_manipulator);
@@ -345,7 +346,13 @@ void view3d_keymap(wmKeyConfig *keyconf)
        
        WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
        WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
-       WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0);
+
+       kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_boolean_set(kmi->ptr, "camera_only", TRUE);
+       kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_CTRL, 0);
+       RNA_boolean_set(kmi->ptr, "camera_only", FALSE);
+
+       WM_keymap_add_item(keymap, "VIEW3D_OT_clear_render_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
        
        WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT | KM_CTRL, 0);
        WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0);
index 9da10381af04063e2b2fc8684a68a11675b70548..c83b0bc366f112c7deedaacffdf1067b4f462160 100644 (file)
@@ -169,6 +169,7 @@ typedef struct View3D {
        short view   DNA_DEPRECATED;
        
        struct Object *camera, *ob_centre;
+       rctf render_border;
 
        struct ListBase bgpicbase;
        struct BGpic *bgpic  DNA_DEPRECATED; /* deprecated, use bgpicbase, only kept for do_versions(...) */
@@ -267,6 +268,7 @@ typedef struct View3D {
 #define V3D_SHOW_CAMERAPATH            256
 #define V3D_SHOW_BUNDLENAME            512
 #define V3D_BACKFACE_CULLING   1024
+#define V3D_RENDER_BORDER      2048
 
 /* View3D->around */
 #define V3D_CENTER              0
index bfd0f731626a02955165a9739ced65e2a6b19bed..13aa5557964e48c80a23cc9d936787e84a70e936 100644 (file)
@@ -1494,7 +1494,39 @@ static void rna_def_space_view3d(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Camera",
                                 "Active camera used in this view (when unlocked from the scene's active camera)");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-       
+
+       /* render border */
+       prop = RNA_def_property(srna, "use_render_border", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_RENDER_BORDER);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_ui_text(prop, "Render Border",
+                                "use a user-defined border region within the frame size for rendered viewport");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+       prop = RNA_def_property(srna, "render_border_min_x", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "render_border.xmin");
+       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_ui_text(prop, "Border Minimum X", "Minimum X value to for the render border");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+       prop = RNA_def_property(srna, "render_border_min_y", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "render_border.ymin");
+       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_ui_text(prop, "Border Minimum Y", "Minimum Y value for the render border");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+       prop = RNA_def_property(srna, "render_border_max_x", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "render_border.xmax");
+       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_ui_text(prop, "Border Maximum X", "Maximum X value for the render border");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+       prop = RNA_def_property(srna, "render_border_max_y", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "render_border.ymax");
+       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_ui_text(prop, "Border Maximum Y", "Maximum Y value for the render border");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
        prop = RNA_def_property(srna, "lock_object", PROP_POINTER, PROP_NONE);
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_pointer_sdna(prop, NULL, "ob_centre");