132 return b_camera.dof.focus_distance;
135 Transform dofmat = get_transform(b_dof_object->object_to_world());
137 const string focus_subtarget = b_camera.dof.focus_subtarget;
138 if (b_dof_object->
pose && !focus_subtarget.empty()) {
140 focus_subtarget.c_str()))
148 RE_engine_get_camera_model_matrix(
153 return fabsf(
dot(view_dir, dof_dir));
187 if (!b_v3d || !b_rv3d) {
205 !BKE_scene_multiview_is_stereo3d(&b_render))
226 bool skip_panorama =
false)
234 blender::Camera &b_camera = blender::id_cast<blender::Camera &>(*b_ob_data);
236 bcam->
nearclip = b_camera.clip_start;
237 bcam->
farclip = b_camera.clip_end;
239 switch (b_camera.type) {
290 bcam->
lens = b_camera.lens;
295 float fstop = b_camera.dof.aperture_fstop;
296 fstop =
max(fstop, 1e-5f);
328 bcam->
shift.
x = BKE_camera_multiview_shift_x(&b_render, &b_ob, viewname);
333 bcam->
shift.
y = b_camera.shifty;
350 bcam->
custom_props = RNA_pointer_get(&camera_rna_ptr,
"cycles_custom");
357 b_data, &b_camera.id, b_camera.custom_filepath);
364 const float lens = 16.0f /
tanf(b_light.spotsize * 0.5f);
387 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
395 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f);
426 height / frame_size.y;
452 if (horizontal_fit) {
453 aspectratio = xratio / yratio;
457 aspectratio = yratio / xratio;
463 aspect *= bcam->
ortho_scale / (aspectratio * 2.0f);
479 const float2 shift = 2.0f * (aspectratio * bcam->
shift + bcam->
offset * aspect * 2.0f);
499 if (RNA_property_array_check(prop)) {
500 data.resize(RNA_property_array_length(&custom_props, prop));
501 RNA_property_float_get_array(&custom_props, prop, data.data());
505 data[0] = RNA_property_float_get(&custom_props, prop);
517 if (RNA_property_array_check(prop)) {
518 array_len = RNA_property_array_length(&custom_props, prop);
527 RNA_property_boolean_get_array(&custom_props, prop, bool_data.
data());
528 std::copy(bool_data.
begin(), bool_data.
end(), std::back_inserter(data));
531 data.push_back(RNA_property_boolean_get(&custom_props, prop));
535 const char *identifier =
"";
536 const int value = RNA_property_enum_get(&custom_props, prop);
537 if (RNA_property_enum_identifier(
nullptr, &custom_props, prop, value, &identifier)) {
538 data.push_back(atoi(identifier));
541 data.push_back(value);
546 data.resize(array_len);
547 RNA_property_int_get_array(&custom_props, prop, data.data());
550 data.push_back(RNA_property_int_get(&custom_props, prop));
562 data = RNA_property_string_get(&custom_props, prop);
572 return RNA_struct_find_property(&custom_props, name.c_str());
581 const char *viewname,
591 cam->set_viewplane_left(viewplane.
left);
592 cam->set_viewplane_right(viewplane.
right);
593 cam->set_viewplane_top(viewplane.
top);
594 cam->set_viewplane_bottom(viewplane.
bottom);
596 cam->set_full_width(width);
597 cam->set_full_height(height);
611 horizontal_fit = (fit_xratio > fit_yratio);
615 horizontal_fit =
true;
619 horizontal_fit =
false;
623 if (horizontal_fit) {
624 cam->set_sensorwidth(sensor_size);
625 cam->set_sensorheight(sensor_size * fit_yratio / fit_xratio);
628 cam->set_sensorwidth(sensor_size * fit_xratio / fit_yratio);
629 cam->set_sensorheight(sensor_size);
634 if (scene !=
nullptr) {
647 cam->set_farclip(bcam->
farclip);
650 cam->set_camera_type(bcam->
type);
680 if (cam->get_use_spherical_stereo()) {
681 if (strcmp(viewname,
"left") == 0) {
684 else if (strcmp(viewname,
"right") == 0) {
700 cam->set_fov(2.0f *
atanf((0.5f * sensor_size) / bcam->
lens / aspectratio));
714 cam->set_motion(motion);
715 cam->set_use_perspective_motion(
false);
718 cam->set_fov_pre(cam->get_fov());
719 cam->set_fov_post(cam->get_fov());
761 const char *viewname)
779 "rolling_shutter_type",
798 RE_engine_get_camera_model_matrix(
800 bcam.
matrix = get_transform(b_ob_matrix);
801 scene->bake_manager->set_use_camera(b_render.
bake.
view_from ==
805 scene->bake_manager->set_use_camera(
false);
809 Camera *cam = scene->camera;
817 RE_engine_get_camera_model_matrix(
819 bcam.
matrix = get_transform(b_ob_matrix);
821 blender_camera_sync(scene->dicing_camera,
nullptr, &bcam, width, height, viewname, &cscene);
824 *scene->dicing_camera = *cam;
845 if (b_camera_override) {
846 return b_camera_override;
853 return b_scene->camera;
860 blender::PointerRNA cscene =
RNA_pointer_get(&scene_rna_ptr,
"cycles");
866 return get_camera_object(b_v3d, b_rv3d);
873 const float motion_time)
879 Camera *cam = scene->camera;
882 b_engine, b_ob, cam->get_use_spherical_stereo(), b_ob_matrix.
base_ptr());
883 Transform tfm = get_transform(b_ob_matrix);
886 if (motion_time == 0.0f) {
888 cam->set_matrix(tfm);
892 const int motion_step = cam->
motion_step(motion_time);
893 if (motion_step >= 0) {
894 array<Transform> motion = cam->get_motion();
895 motion[motion_step] = tfm;
896 cam->set_motion(motion);
900 BlenderCamera bcam(b_render);
903 bcam.pixelaspect.x = b_render.
xasp;
904 bcam.pixelaspect.y = b_render.
yasp;
908 BoundBox2D viewplane;
913 const float fov = 2.0f *
atanf((0.5f * sensor_size) / bcam.lens / aspectratio);
914 if (fov != cam->get_fov()) {
916 if (motion_time == 0.0f) {
919 else if (motion_time == -1.0f) {
920 cam->set_fov_pre(fov);
921 cam->set_use_perspective_motion(
true);
923 else if (motion_time == 1.0f) {
924 cam->set_fov_post(fov);
925 cam->set_use_perspective_motion(
true);
955 bool skip_panorama =
false)
972 bcam, b_engine, b_render, b_v3d, b_rv3d, *b_ob, b_data, skip_panorama);
978 (
float(b_render.
xsch) * b_render.
xasp);
1005 bcam->
zoom = (1.41421f + bcam->
zoom / 50.0f);
1016 bcam->
zoom *= frame_fit;
1017 bcam->
offset *= frame_fit;
1069 &view_bcam, b_engine, b_render, b_scene, b_data, b_v3d, b_rv3d, width, height,
true);
1085 view_box = view * (1.0f / view_aspect);
1086 cam_box = cam * (1.0f / cam_aspect);
1096 result.left = border.
xmin / (
float)width;
1097 result.right = border.
xmax / (
float)width;
1098 result.bottom = border.
ymin / (
float)height;
1099 result.top = border.
ymax / (
float)height;
1105 const blender::Depsgraph *b_depsgraph,
1115 &b_scene, b_depsgraph, b_v3d, b_rv3d, width, height,
false,
false,
true);
1121 if (BKE_camera_view_render_border(
1122 &b_scene, b_depsgraph, b_v3d, b_rv3d, width, height, &border,
nullptr))
1138 &bcam, *b_engine, b_render_settings, *b_scene, *b_data, b_v3d, b_rv3d, width, height);
1150 &bcam, *b_engine, b_render_settings,
nullptr,
nullptr, *b_ob, *b_data);
1151 RE_engine_get_camera_model_matrix(
1153 bcam.
matrix = get_transform(b_ob_matrix);
1158 *scene->dicing_camera = *scene->camera;
1169 bool use_border =
false;
1186 params.
full_x = (int)(border.
left * (
float)width);
1196 params.
width = width;
Blender kernel action and pose functionality.
Camera data-block and utility functions.
#define STEREO_RIGHT_NAME
static blender::Object * camera_override_get(blender::RenderEngine *engine)
static void blender_camera_from_view(BlenderCamera *bcam, blender::RenderEngine &b_engine, const blender::RenderData &b_render, blender::Scene &b_scene, blender::Main &b_data, blender::View3D *&b_v3d, blender::RegionView3D *b_rv3d, const int width, const int height, bool skip_panorama=false)
static void blender_camera_sync(Camera *cam, Scene *scene, BlenderCamera *bcam, const int width, const int height, const char *viewname, blender::PointerRNA *cscene)
static void blender_camera_from_object(BlenderCamera *bcam, blender::RenderEngine &b_engine, const blender::RenderData &b_render, blender::View3D *b_v3d, blender::RegionView3D *b_rv3d, blender::Object &b_ob, blender::Main &b_data, bool skip_panorama=false)
static float blender_camera_frame_fit(const BlenderCamera *bcam, const int width, const int height)
static void blender_camera_border(BlenderCamera *bcam, const blender::Depsgraph *b_depsgraph, blender::Scene &b_scene, blender::View3D *b_v3d, blender::RegionView3D *b_rv3d, const int width, const int height)
static float blender_camera_focal_distance(blender::RenderEngine &b_engine, blender::Object &b_ob, blender::Camera &b_camera, BlenderCamera *bcam)
static bool is_viewport_stereo3d_active(const blender::RenderData &b_render, const blender::View3D *b_v3d, const blender::RegionView3D *b_rv3d)
static void blender_camera_viewplane(BlenderCamera *bcam, const int width, const int height, BoundBox2D &viewplane, float &aspectratio, float &sensor_size)
static BoundBox2D blender_camera_border_normalized(const blender::rctf &border, const int width, const int height)
static MotionPosition blender_motion_blur_position_type_to_cycles(const int type)
static void blender_camera_view_subset(blender::RenderEngine &b_engine, const blender::RenderData &b_render, blender::Scene &b_scene, blender::Main &b_data, blender::Object &b_ob, blender::View3D *&b_v3d, blender::RegionView3D *b_rv3d, const int width, const int height, BoundBox2D &view_box, BoundBox2D &cam_box, float &view_aspect)
static Transform blender_camera_matrix(const Transform &tfm, const CameraType type, const PanoramaType panorama_type)
static PanoramaType blender_panorama_type_to_cycles(const int type)
static bool blender_camera_horizontal_fit(const BlenderCamera *bcam, const int width, const int height)
~BlenderCameraParamQuery() override=default
BlenderCameraParamQuery(blender::PointerRNA custom_props)
bool get_string(ustring name, string &data) override
bool get_float(ustring name, vector< float > &data) override
bool get_int(ustring name, vector< int > &data) override
float central_cylindrical_radius
float rolling_shutter_duration
float central_cylindrical_range_u_min
MotionPosition motion_position
enum BlenderCamera::@245243132277217025050234337126046075336211064127 sensor_fit
string custom_bytecode_hash
bool use_spherical_stereo
float fisheye_polynomial_k2
float fisheye_polynomial_k1
array< float > shutter_curve
float fisheye_polynomial_k0
float offscreen_dicing_scale
float central_cylindrical_range_v_min
blender::PointerRNA custom_props
float fisheye_polynomial_k4
BoundBox2D pano_viewplane
Camera::RollingShutterType rolling_shutter_type
float convergence_distance
float central_cylindrical_range_v_max
float pole_merge_angle_from
float fisheye_polynomial_k3
PanoramaType panorama_type
float central_cylindrical_range_u_max
float pole_merge_angle_to
BlenderCamera(const blender::RenderData &b_render)
float interocular_distance
BoundBox2D viewport_camera_border
static BufferParams get_buffer_params(blender::View3D *b_v3d, blender::RegionView3D *b_rv3d, Camera *cam, const int width, const int height)
void sync_view(const blender::Depsgraph *b_depsgraph, blender::View3D *b_v3d, blender::RegionView3D *b_rv3d, const int width, const int height)
void sync_camera(const blender::RenderData &b_render, const int width, const int height, const char *viewname)
BoundBox2D clamp(const float mn=0.0f, const float mx=1.0f)
BoundBox2D make_relative_to(const BoundBox2D &other) const
BoundBox2D offset(const float2 offset) const
@ ROLLING_SHUTTER_NUM_TYPES
int motion_step(const float time) const
void clear_osl_camera(Scene *scene)
void set_osl_camera(Scene *scene, OSLCameraParamQuery ¶ms, const std::string &filepath, const std::string &bytecode_hash="", const std::string &bytecode="")
OSLCameraParamQuery()=default
@ MOTION_PASS_INTERACTIVE
T * resize(const size_t newsize)
#define CCL_NAMESPACE_END
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
@ PANORAMA_FISHEYE_EQUISOLID
@ PANORAMA_CENTRAL_CYLINDRICAL
@ PANORAMA_EQUIANGULAR_CUBEMAP_FACE
@ PANORAMA_FISHEYE_EQUIDISTANT
@ PANORAMA_FISHEYE_LENS_POLYNOMIAL
@ PANORAMA_EQUIRECTANGULAR
ccl_device_inline float2 one_float2()
CCL_NAMESPACE_BEGIN ccl_device_inline float2 zero_float2()
PointerRNA RNA_id_pointer_create(ID *id)
float2 BKE_camera_viewplane_offset_transform(float roll, bool is_flipped_x, float2 offset)
MatBase< float, 4, 4 > float4x4
const char * BKE_id_name(const ID &id)
@ R_BAKE_VIEW_FROM_ACTIVE_CAMERA
float2 BKE_camera_frame_size(float winx, float winy, float frame_aspect)
@ CAM_PANORAMA_CENTRAL_CYLINDRICAL
@ CAM_PANORAMA_EQUIRECTANGULAR
@ CAM_PANORAMA_MIRRORBALL
@ CAM_PANORAMA_FISHEYE_EQUISOLID
@ CAM_PANORAMA_EQUIANGULAR_CUBEMAP_FACE
@ CAM_PANORAMA_FISHEYE_LENS_POLYNOMIAL
@ CAM_PANORAMA_FISHEYE_EQUIDISTANT
VecBase< float, 2 > float2
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
void RE_engine_get_camera_model_matrix(RenderEngine *engine, Object *camera, bool use_spherical_stereo, float r_modelmat[16])
@ SCE_VIEWS_FORMAT_MULTIVIEW
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
const T * base_ptr() const
eRegionView3D_Persp persp
struct CurveMapping mblur_shutter_curve
float motion_blur_shutter
eSceneViews_Format views_format
struct Depsgraph * depsgraph
struct Object * camera_override