From 68c06775c8c255ce861a2dc5d0810017af66716a Mon Sep 17 00:00:00 2001 From: timoore Date: Wed, 26 Nov 2008 09:02:48 +0000 Subject: [PATCH] Make computeIntersections work with the near and far cameras --- src/Main/CameraGroup.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Main/CameraGroup.cxx b/src/Main/CameraGroup.cxx index bd1783b66..4e968fc2d 100644 --- a/src/Main/CameraGroup.cxx +++ b/src/Main/CameraGroup.cxx @@ -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 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)->accept(iv); if (picker->containsIntersections()) {