window_to_3d_vector was incorrect but dolly view operator was accounting for it....
authorCampbell Barton <ideasman42@gmail.com>
Thu, 12 May 2011 06:52:24 +0000 (06:52 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 12 May 2011 06:52:24 +0000 (06:52 +0000)
release/scripts/modules/view3d_utils.py
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_view.c

index a4e05e7e1c0685f6c5ffe8b922fbe4e5dcad4449..15f5aaa20b7090b75c71fc77667c84d1c3e485b7 100644 (file)
@@ -65,7 +65,7 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location):
     from mathutils.geometry import intersect_point_line
     origin_start = rv3d.view_matrix.inverted()[3].to_3d()
     origin_end = origin_start + region_2d_to_vector_3d(region, rv3d, coord)
-    return intersect_point_line(depth_vector, origin_start, origin_end)[0]
+    return intersect_point_line(depth_location, origin_start, origin_end)[0]
 
 
 def location_3d_to_region_2d(region, rv3d, coord):
index 30bfc35548081999951e13b437d58658c359107f..fb0a33674f74e673c58f50650eda7889d4972688 100644 (file)
@@ -396,7 +396,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event)
        }
 
        /* for dolly */
-       window_to_3d_vector(vod->ar, vod->mousevec, (vod->oldx - vod->ar->winrct.xmin)-(vod->ar->winx)/2, (vod->oldy - vod->ar->winrct.ymin)-(vod->ar->winy)/2);
+       window_to_3d_vector(vod->ar, vod->mousevec, vod->oldx - vod->ar->winrct.xmin, vod->oldy - vod->ar->winrct.ymin);
 
        /* lookup, we dont pass on v3d to prevent confusement */
        vod->grid= v3d->grid;
@@ -1349,7 +1349,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
 static void view_dolly_mouseloc(ARegion *ar, float orig_ofs[3], float dvec[3], float dfac)
 {
        RegionView3D *rv3d= ar->regiondata;
-       madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, 1.0 - dfac);
+       madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0 - dfac));
 }
 
 static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_invert)
@@ -1444,7 +1444,8 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
        else {
                sa= CTX_wm_area(C);
                ar= CTX_wm_region(C);
-               normalize_v3_v3(mousevec, ((RegionView3D *)ar->regiondata)->viewinv[2]);
+               negate_v3_v3(mousevec, ((RegionView3D *)ar->regiondata)->viewinv[2]);
+               normalize_v3(mousevec);
        }
 
        /* v3d= sa->spacedata.first; */ /* UNUSED */
@@ -1498,7 +1499,8 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
                /* overwrite the mouse vector with the view direction (zoom into the center) */
                if((U.uiflag & USER_ZOOM_TO_MOUSEPOS) == 0) {
-                       normalize_v3_v3(vod->mousevec, vod->rv3d->viewinv[2]);
+                       negate_v3_v3(vod->mousevec, vod->rv3d->viewinv[2]);
+                       normalize_v3(vod->mousevec);
                }
 
                if (event->type == MOUSEZOOM) {
index b46c7236170c9ec2f15ef7be18ea1f165f102e91..f8a5a5ad78aa30fdd4a4074dd05a04c083c9a644 100644 (file)
@@ -687,15 +687,15 @@ void window_to_3d_vector(ARegion *ar, float out[3], short mx, short my)
        float dx, dy;
        float viewvec[3];
 
-       dx= 2.0f*mx/ar->winx;
-       dy= 2.0f*my/ar->winy;
+       dx= (2.0f * mx / ar->winx) - 1.0f;
+       dy= (2.0f * my / ar->winy) - 1.0f;
 
        /* normalize here so vecs are proportional to eachother */
        normalize_v3_v3(viewvec, rv3d->viewinv[2]);
 
-       out[0]= viewvec[0] - (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy);
-       out[1]= viewvec[1] - (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy);
-       out[2]= viewvec[2] - (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy);
+       out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy) - viewvec[0];
+       out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy) - viewvec[1];
+       out[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy) - viewvec[2];
 
        normalize_v3(out);
 }