svn merge ^/trunk/blender -r41961:41998
[blender-staging.git] / source / blender / modifiers / intern / MOD_uvproject.c
index 201747402152a3a25d5ef6f36f036f8a422e0be5..de43bdb8131c70cb5bbe2659bad2ff7e4e2b03dd 100644 (file)
@@ -46,6 +46,7 @@
 #include "BLI_utildefines.h"
 
 
+#include "BKE_camera.h"
 #include "BKE_DerivedMesh.h"
 
 #include "MOD_modifiertypes.h"
@@ -195,20 +196,12 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
                                free_uci= 1;
                        }
                        else {
-                               float sensor= (cam->sensor_fit == CAMERA_SENSOR_FIT_VERT) ? (cam->sensor_y) : cam->sensor_x;
+                               float sensor= camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
+                               int sensor_fit= camera_sensor_fit(cam->sensor_fit, aspx, aspy);
                                float scale= (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale;
                                float xmax, xmin, ymax, ymin;
 
-                               if(cam->sensor_fit==CAMERA_SENSOR_FIT_AUTO) {
-                                       if(aspect > 1.0f) {
-                                               xmax = 0.5f * scale;
-                                               ymax = xmax / aspect;
-                                       } else {
-                                               ymax = 0.5f * scale;
-                                               xmax = ymax * aspect;
-                                       }
-                               }
-                               else if(cam->sensor_fit==CAMERA_SENSOR_FIT_HOR) {
+                               if(sensor_fit==CAMERA_SENSOR_FIT_HOR) {
                                        xmax = 0.5f * scale;
                                        ymax = xmax / aspect;
                                }