1
0
Fork 0

Make computeIntersections work with the near and far cameras

This commit is contained in:
timoore 2008-11-26 09:02:48 +00:00
parent 5f7441f778
commit 68c06775c8

View file

@ -507,9 +507,22 @@ bool computeIntersections(const CameraGroup* cgroup,
&& y >= viewport->y() - epsilon && y >= viewport->y() - epsilon
&& y < viewport->y() + viewport->height() -1.0 + epsilon)) && y < viewport->y() + viewport->height() -1.0 + epsilon))
continue; 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 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()); osgUtil::IntersectionVisitor iv(picker.get());
const_cast<Camera*>(camera)->accept(iv); const_cast<Camera*>(camera)->accept(iv);
if (picker->containsIntersections()) { if (picker->containsIntersections()) {