From d9398af3006d2a9ec61ea6cf795a2aa765fbd0ec Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 10 Feb 2002 17:16:43 +0000 Subject: [PATCH] Fixed a bug in the drive manipulator which was due to it using the local coords of the intersection point with the scene rather than the world coord value for that point. The code now uses osgUtil::Hit::getWorldIntersectionPoint() method for getting the world coords. Added support for getWorldIntersectionPoint to Viewer.cpp. Put and #ifdef around the setting of the default display list visitor so it nolonger sets in under IRIX. This is a world around to the IR graphics imbending lighting info into display lists, if the display lists are created before state is set up it produces lighting artifacts such as flickering. Remove the the default display list init visitor removes these problems, display lists are then built on the fly and drawables a drawn for the first time. --- src/osgGLUT/Viewer.cpp | 8 ++++---- src/osgUtil/DriveManipulator.cpp | 26 +++++++++++++------------- src/osgUtil/SceneView.cpp | 6 ++++++ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/osgGLUT/Viewer.cpp b/src/osgGLUT/Viewer.cpp index 6c50584f7..229a34d64 100644 --- a/src/osgGLUT/Viewer.cpp +++ b/src/osgGLUT/Viewer.cpp @@ -1053,14 +1053,14 @@ void Viewer::keyboard(unsigned char key, int x, int y) hitr!=hitList.end(); ++hitr) { - osg::Vec3 ip = hitr->_intersectPoint; - osg::Vec3 in = hitr->_intersectNormal; + osg::Vec3 ip = hitr->getLocalIntersectPoint(); + osg::Vec3 in = hitr->getLocalIntersectNormal(); osg::Geode* geode = hitr->_geode.get(); osg::notify(osg::NOTICE) << " Itersection Point ("<_matrix.valid()) { - osg::Vec3 ipEye = ip*(*(hitr->_matrix)); - osg::Vec3 inEye = (in+ip)*(*(hitr->_matrix))-ipEye; + osg::Vec3 ipEye = hitr->getWorldIntersectPoint(); + osg::Vec3 inEye = hitr->getWorldIntersectNormal(); inEye.normalize(); if (geode) osg::notify(osg::NOTICE) << "Geode '"<getName()<< std::endl; osg::notify(osg::NOTICE) << " Eye Itersection Point ("<0.0f) uv = np; @@ -111,8 +111,8 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us) if (!hitList.empty()) { // notify(INFO) << "Hit terrain ok"<< std::endl; - osg::Vec3 ip = hitList.front()._intersectPoint; - osg::Vec3 np = hitList.front()._intersectNormal; + osg::Vec3 ip = hitList.front().getWorldIntersectPoint(); + osg::Vec3 np = hitList.front().getWorldIntersectNormal(); osg::Vec3 uv; if (np.z()>0.0f) uv = np; @@ -187,8 +187,8 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us) if (!hitList.empty()) { // notify(INFO) << "Hit terrain ok"<< std::endl; - osg::Vec3 ip = hitList.front()._intersectPoint; - osg::Vec3 np = hitList.front()._intersectNormal; + osg::Vec3 ip = hitList.front().getWorldIntersectPoint(); + osg::Vec3 np = hitList.front().getWorldIntersectNormal(); osg::Vec3 uv; if (np.z()>0.0f) uv = np; @@ -226,8 +226,8 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us) if (!hitList.empty()) { // notify(INFO) << "Hit terrain ok"<< std::endl; - osg::Vec3 ip = hitList.front()._intersectPoint; - osg::Vec3 np = hitList.front()._intersectNormal; + osg::Vec3 ip = hitList.front().getWorldIntersectPoint(); + osg::Vec3 np = hitList.front().getWorldIntersectNormal(); osg::Vec3 uv; if (np.z()>0.0f) uv = np; @@ -464,7 +464,7 @@ bool DriveManipulator::calcMovement() if (!hitList.empty()) { // notify(INFO) << "Hit obstruction"<< std::endl; - osg::Vec3 ip = hitList.front()._intersectPoint; + osg::Vec3 ip = hitList.front().getWorldIntersectPoint(); distanceToMove = (ip-ep).length()-_buffer; _velocity = 0.0f; } @@ -489,8 +489,8 @@ bool DriveManipulator::calcMovement() if (!hitList.empty()) { // notify(INFO) << "Hit terrain ok"<< std::endl; - osg::Vec3 ip = hitList.front()._intersectPoint; - osg::Vec3 np = hitList.front()._intersectNormal; + osg::Vec3 ip = hitList.front().getWorldIntersectPoint(); + osg::Vec3 np = hitList.front().getWorldIntersectNormal(); if (uv*np>0.0f) uv = np; else uv = -np; @@ -528,8 +528,8 @@ bool DriveManipulator::calcMovement() { notify(INFO) << "Hit terrain on decent ok"<< std::endl; - osg::Vec3 ip = hitList.front()._intersectPoint; - osg::Vec3 np = hitList.front()._intersectNormal; + osg::Vec3 ip = hitList.front().getWorldIntersectPoint(); + osg::Vec3 np = hitList.front().getWorldIntersectNormal(); if (uv*np>0.0f) uv = np; else uv = -np; diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 9f656b44c..b888d00cd 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -61,9 +61,15 @@ void SceneView::setDefaults() _renderStage = new RenderStage; +#ifndef __sgi + // sgi's IR graphics has a problem with lighting and display lists, as it seems to store + // lighting state with the display list, and the display list visitor doesn't currently apply + // state before creating display lists. So will disable the init visitor default, this won't + // affect functionality since the display lists will be created as and when needed. DisplayListVisitor* dlv = new DisplayListVisitor(); dlv->setState(_state.get()); _initVisitor = dlv; +#endif _appVisitor = new AppVisitor;