diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-11-09 16:32:56 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-11-09 16:32:56 +0300 |
commit | ca134581a2a312ebb27f8f79ffb3cc757421a816 (patch) | |
tree | 3d83e511702acc3fd3089e9dba5c9bc7be3ebd8f /source/blender/editors | |
parent | 0a01bec40061cea4070c9d21b93f6123c7c1a356 (diff) |
First setup of rv3d.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.cc | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 9ca181e2683..2da8e86b043 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -1550,20 +1550,56 @@ static void view3d_virtual_camera_update(const bContext *C, ARegion *region, Obj Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); int2 resolution(1920 / 2, 1080 / 2); - Camera *camera = static_cast<Camera *>(object->data); - RenderEngineType *engine_type = ED_view3d_engine_type(scene, OB_RENDER); + RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata); + int old_persp = rv3d->persp; + Object *old_camera = v3d->camera; + v3d->camera = object; + rv3d->persp = RV3D_CAMOB; + + Camera *camera = static_cast<Camera *>(object->data); if (camera->runtime.virtual_display_texture == nullptr) { camera->runtime.virtual_display_texture = GPU_offscreen_create( UNPACK2(resolution), true, GPU_RGBA16F, nullptr); } + + float4x4 winmat; + + // TODO: Multi view support? + CameraParams params; + BKE_camera_params_init(¶ms); + /* fallback for non camera objects */ + params.clip_start = v3d->clip_start; + params.clip_end = v3d->clip_end; + BKE_camera_params_from_object(¶ms, object); + BKE_camera_params_compute_viewplane(¶ms, UNPACK2(resolution), scene->r.xasp, scene->r.yasp); + BKE_camera_params_compute_matrix(¶ms); + copy_m4_m4(winmat.ptr(), params.winmat); + GPUOffScreen *offscreen = camera->runtime.virtual_display_texture; + GPU_offscreen_bind(offscreen, true); - DRW_draw_render_loop_offscreen( - depsgraph, engine_type, region, v3d, true, false, false, offscreen, nullptr); + ED_view3d_draw_offscreen(depsgraph, + scene, + OB_MATERIAL, + v3d, + region, + UNPACK2(resolution), + nullptr, + winmat.ptr(), + false, + true, + nullptr, + false, + true, + offscreen, + nullptr); GPU_offscreen_unbind(offscreen, true); camera->runtime.gpu_texture = GPU_offscreen_color_texture( camera->runtime.virtual_display_texture); + + v3d->camera = old_camera; + rv3d->persp = old_persp; } static void view3d_draw_virtual_camera(const bContext *C, ARegion *region) |