fix 2 bugs in project from view from a camera object
authorCampbell Barton <ideasman42@gmail.com>
Sun, 3 Jul 2011 10:48:18 +0000 (10:48 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 3 Jul 2011 10:48:18 +0000 (10:48 +0000)
- panorama mode was scaled 2x too high.
- scaled camera objects would incorrectly effect the result.

source/blender/blenlib/intern/uvproject.c

index ecb42315ee3a4c33a3007dad76138784915fdcf7..be7682a63d415829b260cbfcb87b3849f90306fc 100644 (file)
@@ -70,7 +70,7 @@ void project_from_camera(float target[2], float source[3], UvCameraInfo *uci)
                        vec2d[0]= pv4[0];
                        vec2d[1]= pv4[2];
                        target[0]= angle * ((float)M_PI / uci->camangle);
-                       target[1]= pv4[1] / (len_v2(vec2d) * uci->camsize);
+                       target[1]= pv4[1] / (len_v2(vec2d) * (uci->camsize * 2.0f));
                }
        }
        else {
@@ -146,7 +146,11 @@ UvCameraInfo *project_camera_info(Object *ob, float (*rotmat)[4], float winx, fl
        uci.camangle= lens_to_angle(camera->lens) / 2.0f;
        uci.camsize= uci.do_persp ? tanf(uci.camangle) : camera->ortho_scale;
 
-       if (invert_m4_m4(uci.caminv, ob->obmat)) {
+       /* account for scaled cameras */
+       copy_m4_m4(uci.caminv, ob->obmat);
+       normalize_m4(uci.caminv);
+
+       if (invert_m4(uci.caminv)) {
                UvCameraInfo *uci_pt;
 
                /* normal projection */