141 BL::Object b_dof_object = b_camera.dof().focus_object();
144 return b_camera.dof().focus_distance();
148 string focus_subtarget = b_camera.dof().focus_subtarget();
149 if (b_dof_object.pose() && !focus_subtarget.empty()) {
150 BL::PoseBone b_bone = b_dof_object.pose().bones[focus_subtarget];
157 BL::Array<float, 16> b_ob_matrix;
162 return fabsf(
dot(view_dir, dof_dir));
168 bool skip_panorama =
false)
170 BL::ID b_ob_data = b_ob.data();
172 if (b_ob_data.is_a(&RNA_Camera)) {
176 bcam->
nearclip = b_camera.clip_start();
177 bcam->
farclip = b_camera.clip_end();
179 switch (b_camera.type()) {
180 case BL::Camera::type_ORTHO:
183 case BL::Camera::type_PANO:
189 case BL::Camera::type_PERSP:
212 if (b_camera.stereo().convergence_mode() == BL::CameraStereoData::convergence_mode_PARALLEL) {
226 bcam->
lens = b_camera.lens();
228 bcam->
passepartout_alpha = b_camera.show_passepartout() ? b_camera.passepartout_alpha() : 0.0f;
230 if (b_camera.dof().use_dof()) {
233 float fstop = b_camera.dof().aperture_fstop();
234 fstop =
max(fstop, 1e-5f);
256 bcam->
shift.
y = b_camera.shift_y();
261 if (b_camera.sensor_fit() == BL::Camera::sensor_fit_AUTO)
263 else if (b_camera.sensor_fit() == BL::Camera::sensor_fit_HORIZONTAL)
268 else if (b_ob_data.is_a(&RNA_Light)) {
270 BL::SpotLight b_light(b_ob_data);
271 float lens = 16.0f /
tanf(b_light.spot_size() * 0.5f);
292 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
300 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f);
323 float xaspect, yaspect;
328 horizontal_fit = (xratio > yratio);
329 if (sensor_size !=
NULL) {
334 horizontal_fit =
true;
335 if (sensor_size !=
NULL) {
340 horizontal_fit =
false;
341 if (sensor_size !=
NULL) {
346 if (horizontal_fit) {
347 if (aspectratio !=
NULL) {
348 *aspectratio = xratio / yratio;
350 xaspect = *aspectratio;
354 if (aspectratio !=
NULL) {
355 *aspectratio = yratio / xratio;
358 yaspect = *aspectratio;
363 xaspect = xaspect * bcam->
ortho_scale / (*aspectratio * 2.0f);
364 yaspect = yaspect * bcam->
ortho_scale / (*aspectratio * 2.0f);
365 if (aspectratio !=
NULL) {
372 if (viewplane !=
NULL) {
379 const float dx = bcam->
shift.
x * shift_factor;
380 const float dy = bcam->
shift.
y * shift_factor;
382 viewplane->
left += dx;
383 viewplane->
right += dx;
385 viewplane->
top += dy;
390 if (viewplane !=
NULL) {
391 viewplane->
left = -xaspect;
392 viewplane->
right = xaspect;
393 viewplane->
bottom = -yaspect;
394 viewplane->
top = yaspect;
397 *viewplane = (*viewplane) * bcam->
zoom;
400 const float dx = 2.0f * (*aspectratio * bcam->
shift.
x + bcam->
offset.
x * xaspect * 2.0f);
401 const float dy = 2.0f * (*aspectratio * bcam->
shift.
y + bcam->
offset.
y * yaspect * 2.0f);
403 viewplane->
left += dx;
404 viewplane->
right += dx;
406 viewplane->
top += dy;
415 const char *viewname,
418 float aspectratio, sensor_size;
424 cam->set_viewplane_left(viewplane.
left);
425 cam->set_viewplane_right(viewplane.
right);
426 cam->set_viewplane_top(viewplane.
top);
427 cam->set_viewplane_bottom(viewplane.
bottom);
429 cam->set_full_width(
width);
430 cam->set_full_height(
height);
441 horizontal_fit = (fit_xratio > fit_yratio);
445 horizontal_fit =
true;
449 horizontal_fit =
false;
453 if (horizontal_fit) {
454 cam->set_sensorwidth(sensor_size);
455 cam->set_sensorheight(sensor_size * fit_yratio / fit_xratio);
458 cam->set_sensorwidth(sensor_size * fit_xratio / fit_yratio);
459 cam->set_sensorheight(sensor_size);
465 cam->set_farclip(bcam->
farclip);
468 cam->set_camera_type(bcam->
type);
491 if (cam->get_use_spherical_stereo()) {
492 if (strcmp(viewname,
"left") == 0)
494 else if (strcmp(viewname,
"right") == 0)
508 cam->set_fov(2.0f *
atanf((0.5f * sensor_size) / bcam->
lens / aspectratio));
519 cam->set_motion(motion);
520 cam->set_use_perspective_motion(
false);
523 cam->set_fov_pre(cam->get_fov());
524 cam->set_fov_post(cam->get_fov());
553 const char *viewname)
571 "rolling_shutter_type",
577 if (b_render.use_border()) {
581 bcam.
border.
top = b_render.border_max_y();
591 BL::Array<float, 16> b_ob_matrix;
604 BL::Array<float, 16> b_ob_matrix;
616 void BlenderSync::sync_camera_motion(
623 BL::Array<float, 16> b_ob_matrix;
624 b_engine.camera_model_matrix(b_ob, cam->get_use_spherical_stereo(), b_ob_matrix);
628 if (motion_time == 0.0f) {
630 cam->set_matrix(tfm);
635 if (motion_step >= 0) {
637 motion[motion_step] = tfm;
638 cam->set_motion(motion);
643 float aspectratio, sensor_size;
653 float fov = 2.0f *
atanf((0.5f * sensor_size) / bcam.
lens / aspectratio);
654 if (fov != cam->get_fov()) {
655 VLOG_WORK <<
"Camera " << b_ob.name() <<
" FOV change detected.";
656 if (motion_time == 0.0f) {
659 else if (motion_time == -1.0f) {
660 cam->set_fov_pre(fov);
661 cam->set_use_perspective_motion(
true);
663 else if (motion_time == 1.0f) {
664 cam->set_fov_post(fov);
665 cam->set_use_perspective_motion(
true);
674 BL::RenderSettings &b_render,
677 BL::SpaceView3D &b_v3d,
688 BL::SpaceView3D &b_v3d,
692 bool skip_panorama =
false)
695 bcam->
nearclip = b_v3d.clip_start();
696 bcam->
farclip = b_v3d.clip_end();
697 bcam->
lens = b_v3d.lens();
698 bcam->
shuttertime = b_scene.render().motion_blur_shutter();
700 BL::CurveMapping b_shutter_curve(b_scene.render().motion_blur_shutter_curve());
703 if (b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA) {
705 BL::Object b_ob = (b_v3d.use_local_camera()) ? b_v3d.camera() : b_scene.camera();
715 BL::RenderSettings b_render_settings(b_scene.render());
733 bcam->
zoom = (
float)b_rv3d.view_camera_zoom();
734 bcam->
zoom = (1.41421f + bcam->
zoom / 50.0f);
743 else if (b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_ORTHO) {
755 bcam->
ortho_scale = b_rv3d.view_distance() * sensor_size / b_v3d.lens();
769 BL::RenderSettings &b_render,
772 BL::SpaceView3D &b_v3d,
781 float cam_aspect, sensor_size;
803 *view_box =
view * (1.0f / *view_aspect);
804 *cam_box = cam * (1.0f / cam_aspect);
808 BL::RenderSettings &b_render,
810 BL::SpaceView3D &b_v3d,
840 BL::RenderSettings &b_render,
842 BL::SpaceView3D &b_v3d,
850 is_camera_view = b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA;
852 if (!is_camera_view) {
857 if (b_v3d.use_render_border()) {
858 bcam->
border.
left = b_v3d.render_border_min_x();
861 bcam->
border.
top = b_v3d.render_border_max_y();
866 BL::Object b_ob = (b_v3d.use_local_camera()) ? b_v3d.camera() : b_scene.camera();
884 if (b_render.use_border()) {
888 bcam->
border.
top = b_render.border_max_y();
891 bcam->
border = full_border;
917 BL::RenderSettings b_render_settings(b_scene.render());
927 BL::Array<float, 16> b_ob_matrix;
943 bool use_border =
false;
948 if (b_v3d && b_rv3d && b_rv3d.view_perspective() != BL::RegionView3D::view_perspective_CAMERA)
949 use_border = b_v3d.use_render_border();
typedef float(TangentPoint)[2]
struct CurveMapping CurveMapping
struct RegionView3D RegionView3D
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
struct RenderEngine RenderEngine
static void blender_camera_border(BlenderCamera *bcam, BL::RenderEngine &b_engine, BL::RenderSettings &b_render, BL::Scene &b_scene, BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, int width, int height)
static float blender_camera_focal_distance(BL::RenderEngine &b_engine, BL::Object &b_ob, BL::Camera &b_camera, BlenderCamera *bcam)
static void blender_camera_border_subset(BL::RenderEngine &b_engine, BL::RenderSettings &b_render, BL::Scene &b_scene, BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, BL::Object &b_ob, int width, int height, const BoundBox2D &border, BoundBox2D *result)
static void blender_camera_from_view(BlenderCamera *bcam, BL::RenderEngine &b_engine, BL::Scene &b_scene, BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, int width, int height, bool skip_panorama=false)
static void blender_camera_view_subset(BL::RenderEngine &b_engine, BL::RenderSettings &b_render, BL::Scene &b_scene, BL::Object &b_ob, BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, int width, int height, BoundBox2D *view_box, BoundBox2D *cam_box, float *view_aspect)
static void blender_camera_from_object(BlenderCamera *bcam, BL::RenderEngine &b_engine, BL::Object &b_ob, bool skip_panorama=false)
static void blender_camera_viewplane(BlenderCamera *bcam, int width, int height, BoundBox2D *viewplane, float *aspectratio, float *sensor_size)
static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int height, const char *viewname, PointerRNA *cscene)
static Transform blender_camera_matrix(const Transform &tfm, const CameraType type, const PanoramaType panorama_type)
static void blender_camera_init(BlenderCamera *bcam, BL::RenderSettings &b_render)
void sync_camera(BL::RenderSettings &b_render, BL::Object &b_override, int width, int height, const char *viewname)
static BufferParams get_buffer_params(BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, Camera *cam, int width, int height)
void sync_view(BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, int width, int height)
BoundBox2D clamp(float mn=0.0f, float mx=1.0f)
BoundBox2D make_relative_to(const BoundBox2D &other) const
BoundBox2D subset(const BoundBox2D &other) const
T * resize(size_t newsize)
#define CCL_NAMESPACE_END
static uint object_motion_steps(BL::Object &b_parent, BL::Object &b_ob, const int max_steps=INT_MAX)
static int render_resolution_x(BL::RenderSettings &b_render)
static void curvemapping_to_array(BL::CurveMapping &cumap, array< float > &data, int size)
static int render_resolution_y(BL::RenderSettings &b_render)
static int get_enum(PointerRNA &ptr, const char *name, int num_values=-1, int default_value=-1)
static float2 get_float2(const BL::Array< float, 2 > &array)
static Transform get_transform(const BL::Array< float, 16 > &array)
IconTextureDrawCall border
@ PANORAMA_FISHEYE_EQUISOLID
@ PANORAMA_FISHEYE_LENS_POLYNOMIAL
@ PANORAMA_EQUIRECTANGULAR
ccl_device_inline float2 one_float2()
T dot(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
vec_base< T, Size > normalize(const vec_base< T, Size > &v)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
float rolling_shutter_duration
MotionPosition motion_position
bool use_spherical_stereo
float fisheye_polynomial_k2
float fisheye_polynomial_k1
array< float > shutter_curve
float fisheye_polynomial_k0
float offscreen_dicing_scale
enum BlenderCamera::@1226 sensor_fit
float fisheye_polynomial_k4
BoundBox2D pano_viewplane
Camera::RollingShutterType rolling_shutter_type
float convergence_distance
float pole_merge_angle_from
float fisheye_polynomial_k3
PanoramaType panorama_type
float pole_merge_angle_to
float interocular_distance
BoundBox2D viewport_camera_border
@ ROLLING_SHUTTER_NUM_TYPES
int motion_step(float time) const