]> git.mxchange.org Git - flightgear.git/commitdiff
Make computeIntersections work with the near and far cameras
authortimoore <timoore>
Wed, 26 Nov 2008 09:02:48 +0000 (09:02 +0000)
committertimoore <timoore>
Wed, 26 Nov 2008 09:02:48 +0000 (09:02 +0000)
src/Main/CameraGroup.cxx

index bd1783b66d28380c75f854ef08d8c81a95b9fe14..4e968fc2d812dcb2435f2a01905a3be46561f857 100644 (file)
@@ -507,9 +507,22 @@ bool computeIntersections(const CameraGroup* cgroup,
               && y >= viewport->y() - epsilon
               && y < viewport->y() + viewport->height() -1.0 + epsilon))
             continue;
-        LineSegmentIntersector::CoordinateFrame cf = Intersector::WINDOW;
+        Vec4d start(x, y, 0.0, 1.0);
+        Vec4d end(x, y, 1.0, 1.0);
+        Matrix windowMat = viewport->computeWindowMatrix();
+        Matrix startPtMat = Matrix::inverse(camera->getProjectionMatrix()
+                                            * windowMat);
+        Matrix endPtMat
+            = Matrix::inverse(cinfo->farCamera->getProjectionMatrix()
+                              * windowMat);
+        start = start * startPtMat;
+        start /= start.w();
+        end = end * endPtMat;
+        end /= end.w();
         ref_ptr<LineSegmentIntersector> picker
-            = new LineSegmentIntersector(cf, x, y);
+            = new LineSegmentIntersector(Intersector::VIEW,
+                                         Vec3d(start.x(), start.y(), start.z()),
+                                         Vec3d(end.x(), end.y(), end.z()));
         osgUtil::IntersectionVisitor iv(picker.get());
         const_cast<Camera*>(camera)->accept(iv);
         if (picker->containsIntersections()) {