Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_camera.cpp
| Show First 20 Lines • Show All 557 Lines • ▼ Show 20 Lines | void BlenderSync::sync_camera(BL::RenderSettings &b_render, | ||||
| if (b_ob) { | if (b_ob) { | ||||
| BL::Array<float, 16> b_ob_matrix; | BL::Array<float, 16> b_ob_matrix; | ||||
| blender_camera_from_object(&bcam, b_engine, b_ob); | blender_camera_from_object(&bcam, b_engine, b_ob); | ||||
| b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix); | b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix); | ||||
| bcam.matrix = get_transform(b_ob_matrix); | bcam.matrix = get_transform(b_ob_matrix); | ||||
| } | } | ||||
| /* sync */ | /* sync */ | ||||
| Camera *cam = scene->camera; | Camera *cam = scene->get_camera(); | ||||
| blender_camera_sync(cam, &bcam, width, height, viewname, &cscene); | blender_camera_sync(cam, &bcam, width, height, viewname, &cscene); | ||||
| /* dicing camera */ | /* dicing camera */ | ||||
| b_ob = BL::Object(RNA_pointer_get(&cscene, "dicing_camera")); | b_ob = BL::Object(RNA_pointer_get(&cscene, "dicing_camera")); | ||||
| if (b_ob) { | if (b_ob) { | ||||
| BL::Array<float, 16> b_ob_matrix; | BL::Array<float, 16> b_ob_matrix; | ||||
| blender_camera_from_object(&bcam, b_engine, b_ob); | blender_camera_from_object(&bcam, b_engine, b_ob); | ||||
| b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix); | b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix); | ||||
| bcam.matrix = get_transform(b_ob_matrix); | bcam.matrix = get_transform(b_ob_matrix); | ||||
| blender_camera_sync(scene->dicing_camera, &bcam, width, height, viewname, &cscene); | blender_camera_sync(scene->get_dicing_camera(), &bcam, width, height, viewname, &cscene); | ||||
| } | } | ||||
| else { | else { | ||||
| *scene->dicing_camera = *cam; | *scene->get_dicing_camera() = *cam; | ||||
| } | } | ||||
| } | } | ||||
| void BlenderSync::sync_camera_motion( | void BlenderSync::sync_camera_motion( | ||||
| BL::RenderSettings &b_render, BL::Object &b_ob, int width, int height, float motion_time) | BL::RenderSettings &b_render, BL::Object &b_ob, int width, int height, float motion_time) | ||||
| { | { | ||||
| if (!b_ob) | if (!b_ob) | ||||
| return; | return; | ||||
| Camera *cam = scene->camera; | Camera *cam = scene->get_camera(); | ||||
| BL::Array<float, 16> b_ob_matrix; | BL::Array<float, 16> b_ob_matrix; | ||||
| b_engine.camera_model_matrix(b_ob, cam->get_use_spherical_stereo(), b_ob_matrix); | b_engine.camera_model_matrix(b_ob, cam->get_use_spherical_stereo(), b_ob_matrix); | ||||
| Transform tfm = get_transform(b_ob_matrix); | Transform tfm = get_transform(b_ob_matrix); | ||||
| tfm = blender_camera_matrix(tfm, cam->get_camera_type(), cam->get_panorama_type()); | tfm = blender_camera_matrix(tfm, cam->get_camera_type(), cam->get_panorama_type()); | ||||
| if (motion_time == 0.0f) { | if (motion_time == 0.0f) { | ||||
| /* When motion blur is not centered in frame, cam->matrix gets reset. */ | /* When motion blur is not centered in frame, cam->matrix gets reset. */ | ||||
| cam->set_matrix(tfm); | cam->set_matrix(tfm); | ||||
| ▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | void BlenderSync::sync_view(BL::SpaceView3D &b_v3d, | ||||
| int height) | int height) | ||||
| { | { | ||||
| BlenderCamera bcam; | BlenderCamera bcam; | ||||
| BL::RenderSettings b_render_settings(b_scene.render()); | BL::RenderSettings b_render_settings(b_scene.render()); | ||||
| blender_camera_init(&bcam, b_render_settings); | blender_camera_init(&bcam, b_render_settings); | ||||
| blender_camera_from_view(&bcam, b_engine, b_scene, b_v3d, b_rv3d, width, height); | blender_camera_from_view(&bcam, b_engine, b_scene, b_v3d, b_rv3d, width, height); | ||||
| blender_camera_border(&bcam, b_engine, b_render_settings, b_scene, b_v3d, b_rv3d, width, height); | blender_camera_border(&bcam, b_engine, b_render_settings, b_scene, b_v3d, b_rv3d, width, height); | ||||
| PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); | PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); | ||||
| blender_camera_sync(scene->camera, &bcam, width, height, "", &cscene); | blender_camera_sync(scene->get_camera(), &bcam, width, height, "", &cscene); | ||||
| /* dicing camera */ | /* dicing camera */ | ||||
| BL::Object b_ob = BL::Object(RNA_pointer_get(&cscene, "dicing_camera")); | BL::Object b_ob = BL::Object(RNA_pointer_get(&cscene, "dicing_camera")); | ||||
| if (b_ob) { | if (b_ob) { | ||||
| BL::Array<float, 16> b_ob_matrix; | BL::Array<float, 16> b_ob_matrix; | ||||
| blender_camera_from_object(&bcam, b_engine, b_ob); | blender_camera_from_object(&bcam, b_engine, b_ob); | ||||
| b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix); | b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix); | ||||
| bcam.matrix = get_transform(b_ob_matrix); | bcam.matrix = get_transform(b_ob_matrix); | ||||
| blender_camera_sync(scene->dicing_camera, &bcam, width, height, "", &cscene); | blender_camera_sync(scene->get_dicing_camera(), &bcam, width, height, "", &cscene); | ||||
| } | } | ||||
| else { | else { | ||||
| *scene->dicing_camera = *scene->camera; | *scene->get_dicing_camera() = *scene->get_camera(); | ||||
| } | } | ||||
| } | } | ||||
| BufferParams BlenderSync::get_buffer_params(BL::RenderSettings &b_render, | BufferParams BlenderSync::get_buffer_params(BL::RenderSettings &b_render, | ||||
| BL::SpaceView3D &b_v3d, | BL::SpaceView3D &b_v3d, | ||||
| BL::RegionView3D &b_rv3d, | BL::RegionView3D &b_rv3d, | ||||
| Camera *cam, | Camera *cam, | ||||
| int width, | int width, | ||||
| int height, | int height, | ||||
| const bool use_denoiser) | const bool use_denoiser) | ||||
| { | { | ||||
| BufferParams params; | BufferParams params; | ||||
| bool use_border = false; | bool use_border = false; | ||||
| params.full_width = width; | params.set_full_width(width); | ||||
| params.full_height = height; | params.set_full_height(height); | ||||
| if (b_v3d && b_rv3d && b_rv3d.view_perspective() != BL::RegionView3D::view_perspective_CAMERA) | if (b_v3d && b_rv3d && b_rv3d.view_perspective() != BL::RegionView3D::view_perspective_CAMERA) | ||||
| use_border = b_v3d.use_render_border(); | use_border = b_v3d.use_render_border(); | ||||
| else | else | ||||
| use_border = b_render.use_border(); | use_border = b_render.use_border(); | ||||
| if (use_border) { | if (use_border) { | ||||
| /* border render */ | /* border render */ | ||||
| /* the viewport may offset the border outside the view */ | /* the viewport may offset the border outside the view */ | ||||
| BoundBox2D border = cam->border.clamp(); | BoundBox2D border = cam->get_border().clamp(); | ||||
| params.full_x = (int)(border.left * (float)width); | params.set_full_x((int)(border.left * (float)width)); | ||||
| params.full_y = (int)(border.bottom * (float)height); | params.set_full_y((int)(border.bottom * (float)height)); | ||||
| params.width = (int)(border.right * (float)width) - params.full_x; | params.set_width((int)(border.right * (float)width) - params.get_full_x()); | ||||
| params.height = (int)(border.top * (float)height) - params.full_y; | params.set_height((int)(border.top * (float)height) - params.get_full_y()); | ||||
| /* survive in case border goes out of view or becomes too small */ | /* survive in case border goes out of view or becomes too small */ | ||||
| params.width = max(params.width, 1); | params.set_width(max(params.get_width(), 1)); | ||||
| params.height = max(params.height, 1); | params.set_height(max(params.get_height(), 1)); | ||||
| } | } | ||||
| else { | else { | ||||
| params.width = width; | params.set_width(width); | ||||
| params.height = height; | params.set_height(height); | ||||
| } | } | ||||
| PassType display_pass = update_viewport_display_passes(b_v3d, params.passes); | PassType display_pass = update_viewport_display_passes(b_v3d, params.get_passes()); | ||||
| /* Can only denoise the combined image pass */ | /* Can only denoise the combined image pass */ | ||||
| params.denoising_data_pass = display_pass == PASS_COMBINED && use_denoiser; | params.set_denoising_data_pass(display_pass == PASS_COMBINED && use_denoiser); | ||||
| return params; | return params; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||