Revision: 41389
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41389
Author:   nazgul
Date:     2011-10-30 22:13:52 +0000 (Sun, 30 Oct 2011)
Log Message:
-----------
Camera tracking integration
===========================

Update rest of places to reflect sensor height and fov mode.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_view.c

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c  
2011-10-30 21:38:01 UTC (rev 41388)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c  
2011-10-30 22:13:52 UTC (rev 41389)
@@ -3090,6 +3090,14 @@
 
        /* viewplane fully centered, zbuffer fills in jittered between -.5 and 
+.5 */
        winside= MAX2(winx, winy);
+
+       if(cam) {
+               if(cam->fov_mode==CAMERA_FOV_HOR)
+                       winside= winx;
+               else if(cam->fov_mode==CAMERA_FOV_VERT)
+                       winside= winy;
+       }
+
        viewplane->xmin= -0.5f*(float)winx + shiftx*winside;
        viewplane->ymin= -0.5f*(*ycor)*(float)winy + shifty*winside;
        viewplane->xmax=  0.5f*(float)winx + shiftx*winside;
@@ -3133,7 +3141,17 @@
                float aspx= (float) scene->r.xsch*scene->r.xasp;
                float aspy= (float) scene->r.ysch*scene->r.yasp;
 
-               if(aspx < aspy) {
+               if(camera->fov_mode==CAMERA_FOV_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;
+                       }
+               }
+               else if(camera->fov_mode==CAMERA_FOV_AUTO) {
                        r_asp[0]= aspx / aspy;
                        r_asp[1]= 1.0;
                }
@@ -3159,16 +3177,18 @@
        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));
+
                *r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 
3.0f);
 
                if(do_clip) {
                        /* fixed depth, variable size (avoids exceeding 
clipping range) */
                        depth = -(camera->clipsta + 0.1f);
-                       fac = depth / (camera->lens/-16.0f * scale[2]);
+                       fac = depth / (camera->lens/(-half_sensor) * scale[2]);
                }
                else {
                        /* fixed size, variable depth (stays a reasonable size 
in the 3D view) */
-                       depth= *r_drawsize * camera->lens/-16.0f * scale[2];
+                       depth= *r_drawsize * camera->lens/(-half_sensor) * 
scale[2];
                        fac= *r_drawsize;
                }
 

Modified: 
branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c  
2011-10-30 21:38:01 UTC (rev 41388)
+++ branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c  
2011-10-30 22:13:52 UTC (rev 41389)
@@ -1227,18 +1227,15 @@
                }
                if (ca && (ca->flag & CAM_SHOWSENSOR)) {
                        /* assume fixed sensor width for now */
-                       float aspx = (float) scene->r.xsch*scene->r.xasp;
-                       float aspy = (float) scene->r.ysch*scene->r.yasp;
+
+                       float sensor_aspect = ca->sensor_x / ca->sensor_y;
                        float sensor_scale = (x2i-x1i) / ca->sensor_x;
-                       float sensor_height, ymid, sy1, sy2;
+                       float sensor_height = sensor_scale * ca->sensor_y;
 
-                       if(aspx < aspy) sensor_height = ca->sensor_x * 
sensor_scale * aspx / aspy;
-                       else sensor_height = ca->sensor_x * sensor_scale * aspy 
/ aspx;
+                       float ymid = y1i + (y2i-y1i)/2.f;
+                       float sy1= ymid - sensor_height/2.f;
+                       float sy2= ymid + sensor_height/2.f;
 
-                       ymid = y1i + (y2i-y1i)/2.f;
-                       sy1= ymid - sensor_height/2.f;
-                       sy2= ymid + sensor_height/2.f;
-
                        UI_ThemeColorShade(TH_WIRE, 100);
 
                        uiDrawBox(GL_LINE_LOOP, x1i, sy1, x2i, sy2, 2.0);

Modified: 
branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_view.c  
2011-10-30 21:38:01 UTC (rev 41388)
+++ branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_view.c  
2011-10-30 22:13:52 UTC (rev 41389)
@@ -970,7 +970,10 @@
        float winx= (float)winxi, winy= (float)winyi;
        int orth= 0;
        short fov_mode= CAMERA_FOV_AUTO;
-       
+
+       /* currnetly using sensor size (depends on fov calculating method) */
+       float sensor= DEFAULT_SENSOR_WIDTH;
+
        lens= v3d->lens;        
        
        *clipsta= v3d->near;
@@ -998,6 +1001,8 @@
                                *clipsta= cam->clipsta;
                                *clipend= cam->clipend;
                                fov_mode= cam->fov_mode;
+
+                               sensor= (cam->fov_mode==CAMERA_FOV_VERT) ? 
(cam->sensor_y) : (cam->sensor_x);
                        }
                }
        }
@@ -1084,8 +1089,8 @@
                                dy += cam->shifty * cam->ortho_scale;
                        }
                        else {
-                               dx += cam->shiftx * (cam->clipsta / cam->lens) 
* sensor_x;
-                               dy += cam->shifty * (cam->clipsta / cam->lens) 
* sensor_x;
+                               dx += cam->shiftx * (cam->clipsta / cam->lens) 
* sensor;
+                               dy += cam->shifty * (cam->clipsta / cam->lens) 
* sensor;
                        }
 
                        x1+= dx;
@@ -1103,7 +1108,14 @@
                        *pixsize= 1.0f/viewfac;
                }
                else {
-                       viewfac= (((winx >= winy)? winx: winy)*lens)/32.0f;
+                       float size= ((winx >= winy)? winx: winy);
+
+                       if(fov_mode==CAMERA_FOV_HOR)
+                               size= winx;
+                       else if(fov_mode==CAMERA_FOV_VERT)
+                               size= winy;
+
+                       viewfac= (size*lens)/sensor;
                        *pixsize= *clipsta/viewfac;
                }
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to