diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/camera.c | 19 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 40 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_camera.c | 8 |
3 files changed, 39 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 29770e37ea1..a8b1c2aa04f 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -364,25 +364,16 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh if (scene) { float aspx= (float) scene->r.xsch*scene->r.xasp; float aspy= (float) scene->r.ysch*scene->r.yasp; + int sensor_fit= camera_sensor_fit(camera->sensor_fit, aspx, aspy); - if(camera->sensor_fit==CAMERA_SENSOR_FIT_AUTO) { - if(aspx < aspy) { - r_asp[0]= aspx / aspy; - r_asp[1]= 1.0; - } - else { - r_asp[0]= 1.0; - r_asp[1]= aspy / aspx; - } + if(sensor_fit==CAMERA_SENSOR_FIT_HOR) { + r_asp[0]= 1.0; + r_asp[1]= aspy / aspx; } - else if(camera->sensor_fit==CAMERA_SENSOR_FIT_HOR) { + else { r_asp[0]= aspx / aspy; r_asp[1]= 1.0; } - else { - r_asp[0]= 1.0; - r_asp[1]= aspy / aspx; - } } else { r_asp[0]= 1.0f; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 82f60ac639b..cdd90b38d0a 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1228,19 +1228,39 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); } if (ca && (ca->flag & CAM_SHOWSENSOR)) { - /* assume fixed sensor width for now */ - - /* float sensor_aspect = ca->sensor_x / ca->sensor_y; */ /* UNUSED */ - float sensor_scale = (x2i-x1i) / ca->sensor_x; - float sensor_height = sensor_scale * ca->sensor_y; + /* determine sensor fit, and get sensor x/y, for auto fit we + assume and square sensor and only use sensor_x */ + float sizex= scene->r.xsch*scene->r.xasp; + float sizey= scene->r.ysch*scene->r.yasp; + int sensor_fit = camera_sensor_fit(ca->sensor_fit, sizex, sizey); + float sensor_x= ca->sensor_x; + float sensor_y= (ca->sensor_fit == CAMERA_SENSOR_FIT_AUTO)? ca->sensor_x: ca->sensor_y; + + /* determine sensor plane */ + rctf rect; + + if(sensor_fit == CAMERA_SENSOR_FIT_HOR) { + float sensor_scale = (x2i-x1i) / sensor_x; + float sensor_height = sensor_scale * sensor_y; + + rect.xmin= x1i; + rect.xmax= x2i; + rect.ymin= (y1i + y2i)*0.5f - sensor_height*0.5f; + rect.ymax= rect.ymin + sensor_height; + } + else { + float sensor_scale = (y2i-y1i) / sensor_y; + float sensor_width = sensor_scale * sensor_x; - float ymid = y1i + (y2i-y1i)/2.f; - float sy1= ymid - sensor_height/2.f; - float sy2= ymid + sensor_height/2.f; + rect.xmin= (x1i + x2i)*0.5f - sensor_width*0.5f; + rect.xmax= rect.xmin + sensor_width; + rect.ymin= y1i; + rect.ymax= y2i; + } + /* draw */ UI_ThemeColorShade(TH_WIRE, 100); - - uiDrawBox(GL_LINE_LOOP, x1i, sy1, x2i, sy2, 2.0f); + uiDrawBox(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f); } } diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 77b41b507c6..6f6a4baec92 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -113,9 +113,9 @@ void RNA_def_camera(BlenderRNA *brna) {CAM_ANGLETOGGLE, "DEGREES", 0, "Degrees", ""}, {0, NULL, 0, NULL, NULL}}; 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"}, + {CAMERA_SENSOR_FIT_AUTO, "AUTO", 0, "Auto", "Fit to the sensor width or height depending on image resolution"}, + {CAMERA_SENSOR_FIT_HOR, "HORIZONTAL", 0, "Horizontal", "Fit to the sensor width"}, + {CAMERA_SENSOR_FIT_VERT, "VERTICAL", 0, "Vertical", "Fit to the sensor height"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Camera", "ID"); @@ -138,7 +138,7 @@ void RNA_def_camera(BlenderRNA *brna) 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_ui_text(prop, "Sensor Fit", "Method to fit image and field of view angle inside the sensor"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update"); /* Number values */ |