Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/camera.cpp
| Show First 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | if (previous_need_motion != need_motion) { | ||||
| * layer has got motion pass and another not */ | * layer has got motion pass and another not */ | ||||
| need_device_update = true; | need_device_update = true; | ||||
| } | } | ||||
| if (!is_modified()) | if (!is_modified()) | ||||
| return; | return; | ||||
| scoped_callback_timer timer([scene](double time) { | scoped_callback_timer timer([scene](double time) { | ||||
| if (scene->update_stats) { | if (scene->get_update_stats()) { | ||||
| scene->update_stats->camera.times.add_entry({"update", time}); | scene->get_update_stats()->camera.times.add_entry({"update", time}); | ||||
| } | } | ||||
| }); | }); | ||||
| /* Full viewport to camera border in the viewport. */ | /* Full viewport to camera border in the viewport. */ | ||||
| Transform fulltoborder = transform_from_viewplane(viewport_camera_border); | Transform fulltoborder = transform_from_viewplane(viewport_camera_border); | ||||
| Transform bordertofull = transform_inverse(fulltoborder); | Transform bordertofull = transform_inverse(fulltoborder); | ||||
| /* ndc to raster */ | /* ndc to raster */ | ||||
| ▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | |||||
| void Camera::device_update(Device * /* device */, DeviceScene *dscene, Scene *scene) | void Camera::device_update(Device * /* device */, DeviceScene *dscene, Scene *scene) | ||||
| { | { | ||||
| update(scene); | update(scene); | ||||
| if (!need_device_update) | if (!need_device_update) | ||||
| return; | return; | ||||
| scoped_callback_timer timer([scene](double time) { | scoped_callback_timer timer([scene](double time) { | ||||
| if (scene->update_stats) { | if (scene->get_update_stats()) { | ||||
| scene->update_stats->camera.times.add_entry({"device_update", time}); | scene->get_update_stats()->camera.times.add_entry({"device_update", time}); | ||||
| } | } | ||||
| }); | }); | ||||
| scene->lookup_tables->remove_table(&shutter_table_offset); | scene->get_lookup_tables()->remove_table(&shutter_table_offset); | ||||
| if (kernel_camera.shuttertime != -1.0f) { | if (kernel_camera.shuttertime != -1.0f) { | ||||
| vector<float> shutter_table; | vector<float> shutter_table; | ||||
| util_cdf_inverted(SHUTTER_TABLE_SIZE, | util_cdf_inverted(SHUTTER_TABLE_SIZE, | ||||
| 0.0f, | 0.0f, | ||||
| 1.0f, | 1.0f, | ||||
| function_bind(shutter_curve_eval, _1, shutter_curve), | function_bind(shutter_curve_eval, _1, shutter_curve), | ||||
| false, | false, | ||||
| shutter_table); | shutter_table); | ||||
| shutter_table_offset = scene->lookup_tables->add_table(dscene, shutter_table); | shutter_table_offset = scene->get_lookup_tables()->add_table(dscene, shutter_table); | ||||
| kernel_camera.shutter_table_offset = (int)shutter_table_offset; | kernel_camera.shutter_table_offset = (int)shutter_table_offset; | ||||
| } | } | ||||
| dscene->data.cam = kernel_camera; | dscene->data.cam = kernel_camera; | ||||
| size_t num_motion_steps = kernel_camera_motion.size(); | size_t num_motion_steps = kernel_camera_motion.size(); | ||||
| if (num_motion_steps) { | if (num_motion_steps) { | ||||
| DecomposedTransform *camera_motion = dscene->camera_motion.alloc(num_motion_steps); | DecomposedTransform *camera_motion = dscene->camera_motion.alloc(num_motion_steps); | ||||
| Show All 14 Lines | void Camera::device_update_volume(Device * /*device*/, DeviceScene *dscene, Scene *scene) | ||||
| KernelIntegrator *kintegrator = &dscene->data.integrator; | KernelIntegrator *kintegrator = &dscene->data.integrator; | ||||
| if (kintegrator->use_volumes) { | if (kintegrator->use_volumes) { | ||||
| KernelCamera *kcam = &dscene->data.cam; | KernelCamera *kcam = &dscene->data.cam; | ||||
| BoundBox viewplane_boundbox = viewplane_bounds_get(); | BoundBox viewplane_boundbox = viewplane_bounds_get(); | ||||
| /* Parallel object update, with grain size to avoid too much threading overhead | /* Parallel object update, with grain size to avoid too much threading overhead | ||||
| * for individual objects. */ | * for individual objects. */ | ||||
| static const int OBJECTS_PER_TASK = 32; | static const int OBJECTS_PER_TASK = 32; | ||||
| parallel_for(blocked_range<size_t>(0, scene->objects.size(), OBJECTS_PER_TASK), | parallel_for(blocked_range<size_t>(0, scene->get_objects().size(), OBJECTS_PER_TASK), | ||||
| [&](const blocked_range<size_t> &r) { | [&](const blocked_range<size_t> &r) { | ||||
| for (size_t i = r.begin(); i != r.end(); i++) { | for (size_t i = r.begin(); i != r.end(); i++) { | ||||
| Object *object = scene->objects[i]; | Object *object = scene->get_objects()[i]; | ||||
| if (object->get_geometry()->has_volume && | if (object->get_geometry()->get_has_volume() && | ||||
| viewplane_boundbox.intersects(object->bounds)) { | viewplane_boundbox.intersects(object->get_bounds())) { | ||||
| /* TODO(sergey): Consider adding more grained check. */ | /* TODO(sergey): Consider adding more grained check. */ | ||||
| VLOG(1) << "Detected camera inside volume."; | VLOG(1) << "Detected camera inside volume."; | ||||
| kcam->is_inside_volume = 1; | kcam->is_inside_volume = 1; | ||||
| parallel_for_cancel(); | parallel_for_cancel(); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| if (!kcam->is_inside_volume) { | if (!kcam->is_inside_volume) { | ||||
| VLOG(1) << "Camera is outside of the volume."; | VLOG(1) << "Camera is outside of the volume."; | ||||
| } | } | ||||
| } | } | ||||
| need_device_update = false; | need_device_update = false; | ||||
| need_flags_update = false; | need_flags_update = false; | ||||
| } | } | ||||
| void Camera::device_free(Device * /*device*/, DeviceScene *dscene, Scene *scene) | void Camera::device_free(Device * /*device*/, DeviceScene *dscene, Scene *scene) | ||||
| { | { | ||||
| scene->lookup_tables->remove_table(&shutter_table_offset); | scene->get_lookup_tables()->remove_table(&shutter_table_offset); | ||||
| dscene->camera_motion.free(); | dscene->camera_motion.free(); | ||||
| } | } | ||||
| float3 Camera::transform_raster_to_world(float raster_x, float raster_y) | float3 Camera::transform_raster_to_world(float raster_x, float raster_y) | ||||
| { | { | ||||
| float3 D, P; | float3 D, P; | ||||
| if (camera_type == CAMERA_PERSPECTIVE) { | if (camera_type == CAMERA_PERSPECTIVE) { | ||||
| D = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f)); | D = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f)); | ||||
| ▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines | |||||