Tomato: camera sensor changes
* Rename "FOV Mode" to "Sensor Fit" * Add sensor height back in presets, default to Horizontal fit for all presets except Blender, which uses Automatic. * Some UI tweaks
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 22.3
|
||||
bpy.context.object.data.sensor_height = 14.9
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 32
|
||||
bpy.context.object.data.sensor_height = 18
|
||||
bpy.context.object.data.sensor_fit = 'AUTO'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 22.2
|
||||
bpy.context.object.data.sensor_height = 14.7
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 27.9
|
||||
bpy.context.object.data.sensor_height = 18.6
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 36.0
|
||||
bpy.context.object.data.sensor_height = 24.0
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 22.3
|
||||
bpy.context.object.data.sensor_height = 14.9
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 22.3
|
||||
bpy.context.object.data.sensor_height = 14.9
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 36.0
|
||||
bpy.context.object.data.sensor_height = 24.0
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 22.3
|
||||
bpy.context.object.data.sensor_height = 14.9
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 22.3
|
||||
bpy.context.object.data.sensor_height = 14.9
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 22.3
|
||||
bpy.context.object.data.sensor_height = 14.9
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 23.6
|
||||
bpy.context.object.data.sensor_height = 15.8
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 23.1
|
||||
bpy.context.object.data.sensor_height = 15.4
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 36.0
|
||||
bpy.context.object.data.sensor_height = 23.9
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 23.6
|
||||
bpy.context.object.data.sensor_height = 15.8
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 23.6
|
||||
bpy.context.object.data.sensor_height = 15.6
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 23.6
|
||||
bpy.context.object.data.sensor_height = 15.6
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 23.6
|
||||
bpy.context.object.data.sensor_height = 15.8
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 30.0
|
||||
bpy.context.object.data.sensor_height = 15.0
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 11.1
|
||||
bpy.context.object.data.sensor_height = 6.24
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 16.65
|
||||
bpy.context.object.data.sensor_height = 9.36
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 22.2
|
||||
bpy.context.object.data.sensor_height = 12.6
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 36
|
||||
bpy.context.object.data.sensor_height = 24
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 17.3
|
||||
bpy.context.object.data.sensor_height = 13.0
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 12.52
|
||||
bpy.context.object.data.sensor_height = 7.41
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
import bpy
|
||||
bpy.context.object.data.sensor_width = 24.89
|
||||
bpy.context.object.data.sensor_height = 18.66
|
||||
bpy.context.object.data.sensor_fit = 'HORIZONTAL'
|
||||
|
||||
@@ -208,7 +208,7 @@ class AddPresetCamera(AddPresetBase, Operator):
|
||||
preset_values = [
|
||||
"cam.sensor_width",
|
||||
"cam.sensor_height",
|
||||
"cam.fov_mode"
|
||||
"cam.sensor_fit"
|
||||
]
|
||||
|
||||
preset_subdir = "camera"
|
||||
|
||||
@@ -129,12 +129,20 @@ class DATA_PT_camera(CameraButtonsPanel, Panel):
|
||||
row.operator("camera.preset_add", text="", icon="ZOOMIN")
|
||||
row.operator("camera.preset_add", text="", icon="ZOOMOUT").remove_active = True
|
||||
|
||||
layout.prop(cam, "fov_mode")
|
||||
layout.label(text="Sensor:")
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.prop(cam, "sensor_width")
|
||||
col.prop(cam, "sensor_height")
|
||||
split = layout.split()
|
||||
|
||||
col = split.column(align=True)
|
||||
if cam.sensor_fit == 'AUTO':
|
||||
col.prop(cam, "sensor_width", text="Size")
|
||||
else:
|
||||
col.prop(cam, "sensor_width", text="Width")
|
||||
col.prop(cam, "sensor_height", text="Height")
|
||||
|
||||
col = split.column(align=True)
|
||||
col.prop(cam, "sensor_fit", text="")
|
||||
|
||||
layout.label(text="Clipping:")
|
||||
row = layout.row(align=True)
|
||||
row.prop(cam, "clip_start", text="Start")
|
||||
|
||||
@@ -142,11 +142,11 @@ int object_is_modified(struct Scene *scene, struct Object *ob);
|
||||
|
||||
void object_camera_mode(struct RenderData *rd, struct Object *camera);
|
||||
void object_camera_intrinsics(struct Object *camera, struct Camera **cam_r, short *is_ortho, float *shiftx, float *shifty,
|
||||
float *clipsta, float *clipend, float *lens, float *sensor_x, float *sensor_y, short *fov_mode);
|
||||
float *clipsta, float *clipend, float *lens, float *sensor_x, float *sensor_y, short *sensor_fit);
|
||||
void object_camera_matrix(
|
||||
struct RenderData *rd, struct Object *camera, int winx, int winy, short field_second,
|
||||
float winmat[][4], struct rctf *viewplane, float *clipsta, float *clipend, float *lens,
|
||||
float *sensor_x, float *sensor_y, short *fov_mode, float *ycor,
|
||||
float *sensor_x, float *sensor_y, short *sensor_fit, float *ycor,
|
||||
float *viewdx, float *viewdy);
|
||||
|
||||
void camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float drawsize, const short do_clip, const float scale[3],
|
||||
|
||||
@@ -4008,7 +4008,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
|
||||
if(len>FLT_EPSILON) {
|
||||
float pos[2], rmat[4][4], shiftx= 0.0f, shifty= 0.0f, clipsta= 0.0f, clipend= 0.0f;
|
||||
short is_ortho= 0, fov_mode= CAMERA_FOV_AUTO;
|
||||
short is_ortho= 0, sensor_fit= CAMERA_SENSOR_FIT_AUTO;
|
||||
Camera *cam= NULL;
|
||||
|
||||
user.framenr= scene->r.cfra;
|
||||
@@ -4016,7 +4016,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
|
||||
|
||||
add_v2_v2v2(pos, marker->pos, track->offset);
|
||||
|
||||
object_camera_intrinsics(camob, &cam, &is_ortho, &shiftx, &shifty, &clipsta, &clipend, &lens, &sensor_x, &sensor_y, &fov_mode);
|
||||
object_camera_intrinsics(camob, &cam, &is_ortho, &shiftx, &shifty, &clipsta, &clipend, &lens, &sensor_x, &sensor_y, &sensor_fit);
|
||||
|
||||
if(is_ortho) {
|
||||
if(cam)
|
||||
|
||||
@@ -2977,7 +2977,7 @@ void object_camera_mode(RenderData *rd, Object *camera)
|
||||
}
|
||||
|
||||
void object_camera_intrinsics(Object *camera, Camera **cam_r, short *is_ortho, float *shiftx, float *shifty,
|
||||
float *clipsta, float *clipend, float *lens, float *sensor_x, float *sensor_y, short *fov_mode)
|
||||
float *clipsta, float *clipend, float *lens, float *sensor_x, float *sensor_y, short *sensor_fit)
|
||||
{
|
||||
Camera *cam= NULL;
|
||||
|
||||
@@ -2986,7 +2986,7 @@ void object_camera_intrinsics(Object *camera, Camera **cam_r, short *is_ortho, f
|
||||
|
||||
(*sensor_x)= DEFAULT_SENSOR_WIDTH;
|
||||
(*sensor_y)= DEFAULT_SENSOR_HEIGHT;
|
||||
(*fov_mode)= CAMERA_FOV_AUTO;
|
||||
(*sensor_fit)= CAMERA_SENSOR_FIT_AUTO;
|
||||
|
||||
if(camera->type==OB_CAMERA) {
|
||||
cam= camera->data;
|
||||
@@ -3012,7 +3012,7 @@ void object_camera_intrinsics(Object *camera, Camera **cam_r, short *is_ortho, f
|
||||
(*sensor_y)= cam->sensor_y;
|
||||
(*clipsta)= cam->clipsta;
|
||||
(*clipend)= cam->clipend;
|
||||
(*fov_mode)= cam->fov_mode;
|
||||
(*sensor_fit)= cam->sensor_fit;
|
||||
}
|
||||
else if(camera->type==OB_LAMP) {
|
||||
Lamp *la= camera->data;
|
||||
@@ -3042,7 +3042,7 @@ void object_camera_intrinsics(Object *camera, Camera **cam_r, short *is_ortho, f
|
||||
void object_camera_matrix(
|
||||
RenderData *rd, Object *camera, int winx, int winy, short field_second,
|
||||
float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens,
|
||||
float *sensor_x, float *sensor_y, short *fov_mode, float *ycor,
|
||||
float *sensor_x, float *sensor_y, short *sensor_fit, float *ycor,
|
||||
float *viewdx, float *viewdy)
|
||||
{
|
||||
Camera *cam=NULL;
|
||||
@@ -3055,15 +3055,15 @@ void object_camera_matrix(
|
||||
if(rd->mode & R_FIELDS)
|
||||
(*ycor) *= 2.0f;
|
||||
|
||||
object_camera_intrinsics(camera, &cam, &is_ortho, &shiftx, &shifty, clipsta, clipend, lens, sensor_x, sensor_y, fov_mode);
|
||||
object_camera_intrinsics(camera, &cam, &is_ortho, &shiftx, &shifty, clipsta, clipend, lens, sensor_x, sensor_y, sensor_fit);
|
||||
|
||||
/* ortho only with camera available */
|
||||
if(cam && is_ortho) {
|
||||
if((*fov_mode)==CAMERA_FOV_AUTO) {
|
||||
if((*sensor_fit)==CAMERA_SENSOR_FIT_AUTO) {
|
||||
if(rd->xasp*winx >= rd->yasp*winy) viewfac= winx;
|
||||
else viewfac= (*ycor) * winy;
|
||||
}
|
||||
else if((*fov_mode)==CAMERA_FOV_HOR) {
|
||||
else if((*sensor_fit)==CAMERA_SENSOR_FIT_HOR) {
|
||||
viewfac= winx;
|
||||
}
|
||||
else {
|
||||
@@ -3074,14 +3074,14 @@ void object_camera_matrix(
|
||||
pixsize= cam->ortho_scale/viewfac;
|
||||
}
|
||||
else {
|
||||
if((*fov_mode)==CAMERA_FOV_AUTO) {
|
||||
if((*sensor_fit)==CAMERA_SENSOR_FIT_AUTO) {
|
||||
if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx) / (*sensor_x);
|
||||
else viewfac= (*ycor) * ((*lens) * winy) / (*sensor_x);
|
||||
}
|
||||
else if((*fov_mode)==CAMERA_FOV_HOR) {
|
||||
else if((*sensor_fit)==CAMERA_SENSOR_FIT_HOR) {
|
||||
viewfac= ((*lens) * winx) / (*sensor_x);
|
||||
}
|
||||
else if((*fov_mode)==CAMERA_FOV_VERT) {
|
||||
else if((*sensor_fit)==CAMERA_SENSOR_FIT_VERT) {
|
||||
viewfac= ((*lens) * winy) / (*sensor_y);
|
||||
}
|
||||
|
||||
@@ -3092,9 +3092,9 @@ void object_camera_matrix(
|
||||
winside= MAX2(winx, winy);
|
||||
|
||||
if(cam) {
|
||||
if(cam->fov_mode==CAMERA_FOV_HOR)
|
||||
if(cam->sensor_fit==CAMERA_SENSOR_FIT_HOR)
|
||||
winside= winx;
|
||||
else if(cam->fov_mode==CAMERA_FOV_VERT)
|
||||
else if(cam->sensor_fit==CAMERA_SENSOR_FIT_VERT)
|
||||
winside= winy;
|
||||
}
|
||||
|
||||
@@ -3141,7 +3141,7 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh
|
||||
float aspx= (float) scene->r.xsch*scene->r.xasp;
|
||||
float aspy= (float) scene->r.ysch*scene->r.yasp;
|
||||
|
||||
if(camera->fov_mode==CAMERA_FOV_AUTO) {
|
||||
if(camera->sensor_fit==CAMERA_SENSOR_FIT_AUTO) {
|
||||
if(aspx < aspy) {
|
||||
r_asp[0]= aspx / aspy;
|
||||
r_asp[1]= 1.0;
|
||||
@@ -3151,7 +3151,7 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh
|
||||
r_asp[1]= aspy / aspx;
|
||||
}
|
||||
}
|
||||
else if(camera->fov_mode==CAMERA_FOV_AUTO) {
|
||||
else if(camera->sensor_fit==CAMERA_SENSOR_FIT_AUTO) {
|
||||
r_asp[0]= aspx / aspy;
|
||||
r_asp[1]= 1.0;
|
||||
}
|
||||
@@ -3177,7 +3177,7 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh
|
||||
else {
|
||||
/* that way it's always visible - clipsta+0.1 */
|
||||
float fac;
|
||||
float half_sensor= 0.5f*((camera->fov_mode==CAMERA_FOV_VERT) ? (camera->sensor_y) : (camera->sensor_x));
|
||||
float half_sensor= 0.5f*((camera->sensor_fit==CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x));
|
||||
|
||||
*r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
|
||||
|
||||
|
||||
@@ -3002,7 +3002,7 @@ static void project_paint_begin(ProjPaintState *ps)
|
||||
|
||||
/* dont actually use these */
|
||||
float _viewdx, _viewdy, _ycor, _lens=0.0f, _sensor_x=DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT;
|
||||
short _fov_mode= CAMERA_FOV_AUTO;
|
||||
short _sensor_fit= CAMERA_SENSOR_FIT_AUTO;
|
||||
rctf _viewplane;
|
||||
|
||||
/* viewmat & viewinv */
|
||||
@@ -3014,7 +3014,7 @@ static void project_paint_begin(ProjPaintState *ps)
|
||||
object_camera_mode(&ps->scene->r, camera);
|
||||
object_camera_matrix(&ps->scene->r, camera, ps->winx, ps->winy, 0,
|
||||
winmat, &_viewplane, &ps->clipsta, &ps->clipend,
|
||||
&_lens, &_sensor_x, &_sensor_x, &_fov_mode, &_ycor, &_viewdx, &_viewdy);
|
||||
&_lens, &_sensor_x, &_sensor_x, &_sensor_fit, &_ycor, &_viewdx, &_viewdy);
|
||||
|
||||
ps->is_ortho= (ps->scene->r.mode & R_ORTHO) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -924,14 +924,14 @@ static void draw_selected_name(Scene *scene, Object *ob)
|
||||
void view3d_viewborder_size_get(Scene *scene, Object *camob, ARegion *ar, float size_r[2])
|
||||
{
|
||||
float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp);
|
||||
short fov_mode= CAMERA_FOV_AUTO;
|
||||
short sensor_fit= CAMERA_SENSOR_FIT_AUTO;
|
||||
|
||||
if(camob && camob->type==OB_CAMERA) {
|
||||
Camera *cam= (Camera *)camob->data;
|
||||
fov_mode= cam->fov_mode;
|
||||
sensor_fit= cam->sensor_fit;
|
||||
}
|
||||
|
||||
if(fov_mode==CAMERA_FOV_AUTO) {
|
||||
if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) {
|
||||
float winmax= MAX2(ar->winx, ar->winy);
|
||||
|
||||
if(aspect > 1.0f) {
|
||||
@@ -942,7 +942,7 @@ void view3d_viewborder_size_get(Scene *scene, Object *camob, ARegion *ar, float
|
||||
size_r[1]= winmax;
|
||||
}
|
||||
}
|
||||
else if(fov_mode==CAMERA_FOV_HOR) {
|
||||
else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) {
|
||||
size_r[0]= ar->winx;
|
||||
size_r[1]= ar->winx/aspect;
|
||||
}
|
||||
@@ -2459,11 +2459,11 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in
|
||||
if(rv3d->persp==RV3D_CAMOB && v3d->camera) {
|
||||
float winmat[4][4];
|
||||
float _clipsta, _clipend, _lens, _yco, _dx, _dy, _sensor_x= DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT;
|
||||
short _fov_mode= CAMERA_FOV_AUTO;
|
||||
short _sensor_fit= CAMERA_SENSOR_FIT_AUTO;
|
||||
rctf _viewplane;
|
||||
|
||||
object_camera_matrix(&scene->r, v3d->camera, sizex, sizey, 0, winmat, &_viewplane, &_clipsta, &_clipend, &_lens,
|
||||
&_sensor_x, &_sensor_y, &_fov_mode, &_yco, &_dx, &_dy);
|
||||
&_sensor_x, &_sensor_y, &_sensor_fit, &_yco, &_dx, &_dy);
|
||||
|
||||
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat);
|
||||
}
|
||||
@@ -2519,9 +2519,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w
|
||||
|
||||
{
|
||||
float _yco, _dx, _dy, _sensor_x= DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT;
|
||||
short _fov_mode= CAMERA_FOV_AUTO;
|
||||
short _sensor_fit= CAMERA_SENSOR_FIT_AUTO;
|
||||
rctf _viewplane;
|
||||
object_camera_matrix(&scene->r, v3d.camera, width, height, 0, rv3d.winmat, &_viewplane, &v3d.near, &v3d.far, &v3d.lens, &_sensor_x, &_sensor_y, &_fov_mode, &_yco, &_dx, &_dy);
|
||||
object_camera_matrix(&scene->r, v3d.camera, width, height, 0, rv3d.winmat, &_viewplane, &v3d.near, &v3d.far, &v3d.lens, &_sensor_x, &_sensor_y, &_sensor_fit, &_yco, &_dx, &_dy);
|
||||
}
|
||||
|
||||
mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat);
|
||||
|
||||
@@ -969,7 +969,7 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy
|
||||
float lens, sensor_x =DEFAULT_SENSOR_WIDTH, sensor_y= DEFAULT_SENSOR_HEIGHT, fac, x1, y1, x2, y2;
|
||||
float winx= (float)winxi, winy= (float)winyi;
|
||||
int orth= 0;
|
||||
short fov_mode= CAMERA_FOV_AUTO;
|
||||
short sensor_fit= CAMERA_SENSOR_FIT_AUTO;
|
||||
|
||||
/* currnetly using sensor size (depends on fov calculating method) */
|
||||
float sensor= DEFAULT_SENSOR_WIDTH;
|
||||
@@ -1000,9 +1000,9 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy
|
||||
sensor_y= cam->sensor_y;
|
||||
*clipsta= cam->clipsta;
|
||||
*clipend= cam->clipend;
|
||||
fov_mode= cam->fov_mode;
|
||||
sensor_fit= cam->sensor_fit;
|
||||
|
||||
sensor= (cam->fov_mode==CAMERA_FOV_VERT) ? (cam->sensor_y) : (cam->sensor_x);
|
||||
sensor= (cam->sensor_fit==CAMERA_SENSOR_FIT_VERT) ? (cam->sensor_y) : (cam->sensor_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1034,7 +1034,7 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy
|
||||
/* ortho_scale == 1 means exact 1 to 1 mapping */
|
||||
float dfac= 2.0f*cam->ortho_scale/fac;
|
||||
|
||||
if(fov_mode==CAMERA_FOV_AUTO) {
|
||||
if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) {
|
||||
if(winx>winy) {
|
||||
x1= -dfac;
|
||||
y1= -winy*dfac/winx;
|
||||
@@ -1044,7 +1044,7 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy
|
||||
y1= -dfac;
|
||||
}
|
||||
}
|
||||
else if(fov_mode==CAMERA_FOV_HOR) {
|
||||
else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) {
|
||||
x1= -dfac;
|
||||
y1= -winy*dfac/winx;
|
||||
}
|
||||
@@ -1061,11 +1061,11 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy
|
||||
else {
|
||||
float dfac;
|
||||
|
||||
if(fov_mode==CAMERA_FOV_AUTO) {
|
||||
if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) {
|
||||
if(winx>winy) dfac= (sensor_x * 2.0) / (fac*winx*lens);
|
||||
else dfac= (sensor_x * 2.0) / (fac*winy*lens);
|
||||
}
|
||||
else if(fov_mode==CAMERA_FOV_HOR) {
|
||||
else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) {
|
||||
dfac= (sensor_x * 2.0) / (fac*winx*lens);
|
||||
}
|
||||
else {
|
||||
@@ -1110,9 +1110,9 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winy
|
||||
else {
|
||||
float size= ((winx >= winy)? winx: winy);
|
||||
|
||||
if(fov_mode==CAMERA_FOV_HOR)
|
||||
if(sensor_fit==CAMERA_SENSOR_FIT_HOR)
|
||||
size= winx;
|
||||
else if(fov_mode==CAMERA_FOV_VERT)
|
||||
else if(sensor_fit==CAMERA_SENSOR_FIT_VERT)
|
||||
size= winy;
|
||||
|
||||
viewfac= (size*lens)/sensor;
|
||||
|
||||
@@ -63,7 +63,7 @@ typedef struct Camera {
|
||||
|
||||
struct Object *dof_ob;
|
||||
|
||||
char fov_mode;
|
||||
char sensor_fit;
|
||||
char pad[7];
|
||||
} Camera;
|
||||
|
||||
@@ -97,10 +97,10 @@ typedef struct Camera {
|
||||
/* yafray: dof sampling switch */
|
||||
/* #define CAM_YF_NO_QMC 512 */ /* depreceated */
|
||||
|
||||
/* FOV mode */
|
||||
#define CAMERA_FOV_AUTO 0
|
||||
#define CAMERA_FOV_HOR 1
|
||||
#define CAMERA_FOV_VERT 2
|
||||
/* Sensor fit */
|
||||
#define CAMERA_SENSOR_FIT_AUTO 0
|
||||
#define CAMERA_SENSOR_FIT_HOR 1
|
||||
#define CAMERA_SENSOR_FIT_VERT 2
|
||||
|
||||
#define DEFAULT_SENSOR_WIDTH 32.0f
|
||||
#define DEFAULT_SENSOR_HEIGHT 18.0f
|
||||
|
||||
@@ -45,10 +45,10 @@
|
||||
/* only for rad/deg conversion! can remove later */
|
||||
static float get_camera_sensor(Camera *cam)
|
||||
{
|
||||
if(cam->fov_mode==CAMERA_FOV_AUTO) {
|
||||
if(cam->sensor_fit==CAMERA_SENSOR_FIT_AUTO) {
|
||||
return cam->sensor_x;
|
||||
}
|
||||
else if(cam->fov_mode==CAMERA_FOV_HOR) {
|
||||
else if(cam->sensor_fit==CAMERA_SENSOR_FIT_HOR) {
|
||||
return cam->sensor_x;
|
||||
}
|
||||
else {
|
||||
@@ -125,10 +125,10 @@ void RNA_def_camera(BlenderRNA *brna)
|
||||
{0, "MILLIMETERS", 0, "Millimeters", ""},
|
||||
{CAM_ANGLETOGGLE, "DEGREES", 0, "Degrees", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
static EnumPropertyItem fov_mode_items[] = {
|
||||
{CAMERA_FOV_AUTO, "AUTO", 0, "Auto", "Calculate FOV using sensor size direction depending on image resolution"},
|
||||
{CAMERA_FOV_HOR, "HORIZONTAL", 0, "Hoizontal", "Calculate FOV using sensor width"},
|
||||
{CAMERA_FOV_VERT, "VERTICAL", 0, "Vertical", "Calculate FOV using sensor height"},
|
||||
static EnumPropertyItem sensor_fit_items[] = {
|
||||
{CAMERA_SENSOR_FIT_AUTO, "AUTO", 0, "Auto", "Calculate field of view using sensor size, with direction depending on image resolution"},
|
||||
{CAMERA_SENSOR_FIT_HOR, "HORIZONTAL", 0, "Horizontal", "Calculate field of view using sensor width"},
|
||||
{CAMERA_SENSOR_FIT_VERT, "VERTICAL", 0, "Vertical", "Calculate field of view using sensor height"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
srna= RNA_def_struct(brna, "Camera", "ID");
|
||||
@@ -148,10 +148,10 @@ void RNA_def_camera(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Composition Guides", "Draw overlay");
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "fov_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "fov_mode");
|
||||
RNA_def_property_enum_items(prop, fov_mode_items);
|
||||
RNA_def_property_ui_text(prop, "FOV Mode", "Mode of calculating FOV from sensor imensions and focal length");
|
||||
prop= RNA_def_property(srna, "sensor_fit", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "sensor_fit");
|
||||
RNA_def_property_enum_items(prop, sensor_fit_items);
|
||||
RNA_def_property_ui_text(prop, "Sensor Fit", "Mode of calculating field of view from sensor dimensions and focal length");
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update");
|
||||
|
||||
/* Number values */
|
||||
|
||||
@@ -195,11 +195,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
free_uci= 1;
|
||||
}
|
||||
else {
|
||||
float sensor= (cam->fov_mode == CAMERA_FOV_VERT) ? (cam->sensor_y) : cam->sensor_x;
|
||||
float sensor= (cam->sensor_fit == CAMERA_SENSOR_FIT_VERT) ? (cam->sensor_y) : cam->sensor_x;
|
||||
float scale= (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale;
|
||||
float xmax, xmin, ymax, ymin;
|
||||
|
||||
if(cam->fov_mode==CAMERA_FOV_AUTO) {
|
||||
if(cam->sensor_fit==CAMERA_SENSOR_FIT_AUTO) {
|
||||
if(aspect > 1.0f) {
|
||||
xmax = 0.5f * scale;
|
||||
ymax = xmax / aspect;
|
||||
@@ -208,7 +208,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
xmax = ymax * aspect;
|
||||
}
|
||||
}
|
||||
else if(cam->fov_mode==CAMERA_FOV_HOR) {
|
||||
else if(cam->sensor_fit==CAMERA_SENSOR_FIT_HOR) {
|
||||
xmax = 0.5f * scale;
|
||||
ymax = xmax / aspect;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ struct Render
|
||||
float lens;
|
||||
float sensor_x, sensor_y; /* image sensor size, same variable in camera */
|
||||
float ycor; /* (scene->xasp / scene->yasp), multiplied with 'winy' */
|
||||
char fov_mode;
|
||||
char sensor_fit;
|
||||
|
||||
float panophi, panosi, panoco, panodxp, panodxv;
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ void RE_SetCamera(Render *re, Object *camera)
|
||||
|
||||
object_camera_matrix(&re->r, camera, re->winx, re->winy, re->flag & R_SEC_FIELD,
|
||||
re->winmat, &re->viewplane, &re->clipsta, &re->clipend,
|
||||
&re->lens, &re->sensor_x, &re->sensor_y, &re->fov_mode, &re->ycor, &re->viewdx, &re->viewdy);
|
||||
&re->lens, &re->sensor_x, &re->sensor_y, &re->sensor_fit, &re->ycor, &re->viewdx, &re->viewdy);
|
||||
}
|
||||
|
||||
void RE_SetPixelSize(Render *re, float pixsize)
|
||||
|
||||
@@ -1724,7 +1724,7 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l
|
||||
|
||||
static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_BlenderSceneConverter *converter) {
|
||||
Camera* ca = static_cast<Camera*>(ob->data);
|
||||
RAS_CameraData camdata(ca->lens, ca->ortho_scale, ca->sensor_x, ca->sensor_y, ca->fov_mode, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, ca->YF_dofdist);
|
||||
RAS_CameraData camdata(ca->lens, ca->ortho_scale, ca->sensor_x, ca->sensor_y, ca->sensor_fit, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, ca->YF_dofdist);
|
||||
KX_Camera *gamecamera;
|
||||
|
||||
gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata);
|
||||
|
||||
@@ -216,9 +216,9 @@ float KX_Camera::GetSensorHeight() const
|
||||
return m_camdata.m_sensor_y;
|
||||
}
|
||||
/** Gets the mode FOV is calculating from sensor dimensions */
|
||||
short KX_Camera::GetFOVMode() const
|
||||
short KX_Camera::GetSensorFit() const
|
||||
{
|
||||
return m_camdata.m_fov_mode;
|
||||
return m_camdata.m_sensor_fit;
|
||||
}
|
||||
|
||||
float KX_Camera::GetCameraNear() const
|
||||
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
/** Gets the vertical size of the sensor - for camera matching */
|
||||
float GetSensorHeight() const;
|
||||
/** Gets the mode FOV is calculating from sensor dimensions */
|
||||
short GetFOVMode() const;
|
||||
short GetSensorFit() const;
|
||||
/** Gets the near clip distance. */
|
||||
float GetCameraNear() const;
|
||||
/** Gets the far clip distance. */
|
||||
|
||||
@@ -1251,7 +1251,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
|
||||
cam->GetScale(),
|
||||
nearfrust,
|
||||
farfrust,
|
||||
cam->GetFOVMode(),
|
||||
cam->GetSensorFit(),
|
||||
frustum
|
||||
);
|
||||
if (!cam->GetViewport()) {
|
||||
@@ -1271,7 +1271,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
|
||||
cam->GetLens(),
|
||||
cam->GetSensorWidth(),
|
||||
cam->GetSensorHeight(),
|
||||
cam->GetFOVMode(),
|
||||
cam->GetSensorFit(),
|
||||
nearfrust,
|
||||
farfrust,
|
||||
frustum
|
||||
|
||||
@@ -38,7 +38,7 @@ struct RAS_CameraData
|
||||
float m_scale;
|
||||
float m_sensor_x;
|
||||
float m_sensor_y;
|
||||
short m_fov_mode;
|
||||
short m_sensor_fit;
|
||||
float m_clipstart;
|
||||
float m_clipend;
|
||||
bool m_perspective;
|
||||
@@ -49,7 +49,7 @@ struct RAS_CameraData
|
||||
int m_viewporttop;
|
||||
float m_focallength;
|
||||
|
||||
RAS_CameraData(float lens = 35.0, float scale = 6.0, float sensor_x = 32.0, float sensor_y = 18.0, short fov_mode = 0,
|
||||
RAS_CameraData(float lens = 35.0, float scale = 6.0, float sensor_x = 32.0, float sensor_y = 18.0, short sensor_fit = 0,
|
||||
float clipstart = 0.1, float clipend = 5000.0, bool perspective = true,
|
||||
float focallength = 3.0, bool viewport = false, int viewportleft = 0, int viewportbottom = 0,
|
||||
int viewportright = 0, int viewporttop = 0) :
|
||||
@@ -57,7 +57,7 @@ struct RAS_CameraData
|
||||
m_scale(scale),
|
||||
m_sensor_x(sensor_x),
|
||||
m_sensor_y(sensor_y),
|
||||
m_fov_mode(fov_mode),
|
||||
m_sensor_fit(sensor_fit),
|
||||
m_clipstart(clipstart),
|
||||
m_clipend(clipend),
|
||||
m_perspective(perspective),
|
||||
|
||||
@@ -40,7 +40,7 @@ ComputeDefaultFrustum(
|
||||
const float camfar,
|
||||
const float lens,
|
||||
const float sensor_x, const float sensor_y,
|
||||
const short fov_mode,
|
||||
const short sensor_fit,
|
||||
const float design_aspect_ratio,
|
||||
RAS_FrameFrustum & frustum
|
||||
){
|
||||
@@ -48,7 +48,7 @@ ComputeDefaultFrustum(
|
||||
float sizeX;
|
||||
float sizeY;
|
||||
|
||||
if(fov_mode==RAS_FOVMODE_AUTO) {
|
||||
if(sensor_fit==RAS_SENSORFIT_AUTO) {
|
||||
halfSize = (sensor_x / 2.f) * camnear / lens;
|
||||
|
||||
if (design_aspect_ratio > 1.f) {
|
||||
@@ -61,7 +61,7 @@ ComputeDefaultFrustum(
|
||||
sizeY = halfSize;
|
||||
}
|
||||
}
|
||||
else if(fov_mode==RAS_FOVMODE_HOR) {
|
||||
else if(sensor_fit==RAS_SENSORFIT_HOR) {
|
||||
halfSize = (sensor_x / 2.f) * camnear / lens;
|
||||
sizeX = halfSize;
|
||||
sizeY = halfSize/design_aspect_ratio;
|
||||
@@ -87,7 +87,7 @@ ComputeDefaultOrtho(
|
||||
const float camfar,
|
||||
const float scale,
|
||||
const float design_aspect_ratio,
|
||||
const short fov_mode,
|
||||
const short sensor_fit,
|
||||
RAS_FrameFrustum & frustum
|
||||
)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ ComputeDefaultOrtho(
|
||||
float sizeX;
|
||||
float sizeY;
|
||||
|
||||
if(fov_mode==RAS_FOVMODE_AUTO) {
|
||||
if(sensor_fit==RAS_SENSORFIT_AUTO) {
|
||||
if (design_aspect_ratio > 1.f) {
|
||||
// halfsize defines the width
|
||||
sizeX = halfSize;
|
||||
@@ -106,7 +106,7 @@ ComputeDefaultOrtho(
|
||||
sizeY = halfSize;
|
||||
}
|
||||
}
|
||||
else if(fov_mode==RAS_FOVMODE_HOR) {
|
||||
else if(sensor_fit==RAS_SENSORFIT_HOR) {
|
||||
sizeX = halfSize;
|
||||
sizeY = halfSize/design_aspect_ratio;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ ComputeFrustum(
|
||||
const RAS_Rect &availableViewport,
|
||||
const RAS_Rect &viewport,
|
||||
const float lens,
|
||||
const float sensor_x, const float sensor_y, const short fov_mode,
|
||||
const float sensor_x, const float sensor_y, const short sensor_fit,
|
||||
const float camnear,
|
||||
const float camfar,
|
||||
RAS_FrameFrustum &frustum
|
||||
@@ -248,7 +248,7 @@ ComputeFrustum(
|
||||
lens,
|
||||
sensor_x,
|
||||
sensor_y,
|
||||
fov_mode,
|
||||
sensor_fit,
|
||||
design_aspect_ratio,
|
||||
frustum
|
||||
);
|
||||
@@ -294,7 +294,7 @@ RAS_FramingManager::
|
||||
const float scale,
|
||||
const float camnear,
|
||||
const float camfar,
|
||||
const short fov_mode,
|
||||
const short sensor_fit,
|
||||
RAS_FrameFrustum &frustum
|
||||
)
|
||||
{
|
||||
@@ -319,7 +319,7 @@ RAS_FramingManager::
|
||||
camfar,
|
||||
scale,
|
||||
design_aspect_ratio,
|
||||
fov_mode,
|
||||
sensor_fit,
|
||||
frustum
|
||||
);
|
||||
|
||||
|
||||
@@ -184,12 +184,12 @@ enum RAS_CullingMode
|
||||
RAS_CULLING_NONE
|
||||
};
|
||||
|
||||
/* Should match CAMERA_FOV... from DNA_camera_types.h */
|
||||
enum RAS_FovMode
|
||||
/* Should match CAMERA_SENSOR_FIT... from DNA_camera_types.h */
|
||||
enum RAS_SensorFit
|
||||
{
|
||||
RAS_FOVMODE_AUTO = 0,
|
||||
RAS_FOVMODE_HOR,
|
||||
RAS_FOVMODE_VERT
|
||||
RAS_SENSORFIT_AUTO = 0,
|
||||
RAS_SENSORFIT_HOR,
|
||||
RAS_SENSORFIT_VERT
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -237,7 +237,7 @@ public :
|
||||
const float scale,
|
||||
const float camnear,
|
||||
const float camfar,
|
||||
const short fov_mode,
|
||||
const short sensor_fit,
|
||||
RAS_FrameFrustum &frustum
|
||||
);
|
||||
|
||||
@@ -248,7 +248,7 @@ public :
|
||||
const RAS_Rect &availableViewport,
|
||||
const RAS_Rect &viewport,
|
||||
const float lens,
|
||||
const float sensor_x, const float sensor_y, const short fov_mode,
|
||||
const float sensor_x, const float sensor_y, const short sensor_fit,
|
||||
const float camnear,
|
||||
const float camfar,
|
||||
RAS_FrameFrustum &frustum
|
||||
@@ -261,7 +261,7 @@ public :
|
||||
const float camfar,
|
||||
const float lens,
|
||||
const float sensor_x, const float sensor_y,
|
||||
const short fov_mode,
|
||||
const short sensor_fit,
|
||||
const float design_aspect_ratio,
|
||||
RAS_FrameFrustum & frustum
|
||||
);
|
||||
@@ -273,7 +273,7 @@ public :
|
||||
const float camfar,
|
||||
const float scale,
|
||||
const float design_aspect_ratio,
|
||||
const short fov_mode,
|
||||
const short sensor_fit,
|
||||
RAS_FrameFrustum & frustum
|
||||
);
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ void ImageRender::Render()
|
||||
farfrust,
|
||||
m_camera->GetScale(),
|
||||
aspect_ratio,
|
||||
m_camera->GetFOVMode(),
|
||||
m_camera->GetSensorFit(),
|
||||
frustrum
|
||||
);
|
||||
|
||||
@@ -249,7 +249,7 @@ void ImageRender::Render()
|
||||
lens,
|
||||
sensor_x,
|
||||
sensor_y,
|
||||
RAS_FOVMODE_AUTO,
|
||||
RAS_SENSORFIT_AUTO,
|
||||
aspect_ratio,
|
||||
frustrum);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user