Cycles: make cycles work with new camera sensor size.
This commit is contained in:
@@ -712,6 +712,7 @@ def get_panels():
|
|||||||
bpy.types.DATA_PT_vertex_colors,
|
bpy.types.DATA_PT_vertex_colors,
|
||||||
bpy.types.DATA_PT_camera,
|
bpy.types.DATA_PT_camera,
|
||||||
bpy.types.DATA_PT_camera_display,
|
bpy.types.DATA_PT_camera_display,
|
||||||
|
bpy.types.DATA_PT_lens,
|
||||||
bpy.types.DATA_PT_custom_props_mesh,
|
bpy.types.DATA_PT_custom_props_mesh,
|
||||||
bpy.types.DATA_PT_custom_props_camera,
|
bpy.types.DATA_PT_custom_props_camera,
|
||||||
bpy.types.DATA_PT_custom_props_lamp,
|
bpy.types.DATA_PT_custom_props_lamp,
|
||||||
|
@@ -47,6 +47,10 @@ struct BlenderCamera {
|
|||||||
|
|
||||||
float2 pixelaspect;
|
float2 pixelaspect;
|
||||||
|
|
||||||
|
enum { AUTO, HORIZONTAL, VERTICAL } sensor_fit;
|
||||||
|
float sensor_width;
|
||||||
|
float sensor_height;
|
||||||
|
|
||||||
Transform matrix;
|
Transform matrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,6 +60,9 @@ static void blender_camera_init(BlenderCamera *bcam)
|
|||||||
|
|
||||||
bcam->zoom = 1.0f;
|
bcam->zoom = 1.0f;
|
||||||
bcam->pixelaspect = make_float2(1.0f, 1.0f);
|
bcam->pixelaspect = make_float2(1.0f, 1.0f);
|
||||||
|
bcam->sensor_width = 32.0f;
|
||||||
|
bcam->sensor_height = 18.0f;
|
||||||
|
bcam->sensor_fit = BlenderCamera::AUTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float blender_camera_focal_distance(BL::Object b_ob, BL::Camera b_camera)
|
static float blender_camera_focal_distance(BL::Object b_ob, BL::Camera b_camera)
|
||||||
@@ -100,6 +107,16 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::Object b_ob)
|
|||||||
|
|
||||||
bcam->shift.x = b_camera.shift_x();
|
bcam->shift.x = b_camera.shift_x();
|
||||||
bcam->shift.y = b_camera.shift_y();
|
bcam->shift.y = b_camera.shift_y();
|
||||||
|
|
||||||
|
bcam->sensor_width = b_camera.sensor_width();
|
||||||
|
bcam->sensor_height = b_camera.sensor_height();
|
||||||
|
|
||||||
|
if(b_camera.sensor_fit() == BL::Camera::sensor_fit_AUTO)
|
||||||
|
bcam->sensor_fit = BlenderCamera::AUTO;
|
||||||
|
else if(b_camera.sensor_fit() == BL::Camera::sensor_fit_HORIZONTAL)
|
||||||
|
bcam->sensor_fit = BlenderCamera::HORIZONTAL;
|
||||||
|
else
|
||||||
|
bcam->sensor_fit = BlenderCamera::VERTICAL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* from lamp not implemented yet */
|
/* from lamp not implemented yet */
|
||||||
@@ -118,7 +135,24 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
|
|||||||
/* compute x/y aspect and ratio */
|
/* compute x/y aspect and ratio */
|
||||||
float aspectratio, xaspect, yaspect;
|
float aspectratio, xaspect, yaspect;
|
||||||
|
|
||||||
if(xratio > yratio) {
|
/* sensor fitting */
|
||||||
|
bool horizontal_fit;
|
||||||
|
float sensor_size;
|
||||||
|
|
||||||
|
if(bcam->sensor_fit == BlenderCamera::AUTO) {
|
||||||
|
horizontal_fit = (xratio > yratio);
|
||||||
|
sensor_size = bcam->sensor_width;
|
||||||
|
}
|
||||||
|
else if(bcam->sensor_fit == BlenderCamera::HORIZONTAL) {
|
||||||
|
horizontal_fit = true;
|
||||||
|
sensor_size = bcam->sensor_width;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
horizontal_fit = false;
|
||||||
|
sensor_size = bcam->sensor_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(horizontal_fit) {
|
||||||
aspectratio= xratio/yratio;
|
aspectratio= xratio/yratio;
|
||||||
xaspect= aspectratio;
|
xaspect= aspectratio;
|
||||||
yaspect= 1.0f;
|
yaspect= 1.0f;
|
||||||
@@ -165,7 +199,7 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
|
|||||||
cam->ortho = bcam->ortho;
|
cam->ortho = bcam->ortho;
|
||||||
|
|
||||||
/* perspective */
|
/* perspective */
|
||||||
cam->fov = 2.0f*atan(16.0f/bcam->lens/aspectratio);
|
cam->fov = 2.0f*atan((0.5f*sensor_size)/bcam->lens/aspectratio);
|
||||||
cam->focaldistance = bcam->focaldistance;
|
cam->focaldistance = bcam->focaldistance;
|
||||||
cam->aperturesize = bcam->aperturesize;
|
cam->aperturesize = bcam->aperturesize;
|
||||||
cam->blades = bcam->apertureblades;
|
cam->blades = bcam->apertureblades;
|
||||||
|
Reference in New Issue
Block a user