From cb7181b7a5e9690f3bbd542e0045608c513c6afd Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 26 Jan 2010 14:57:44 +0000 Subject: [PATCH] Removal of redundant spaces at ends of lines --- include/osgViewer/View | 51 ++++--- src/osgViewer/View.cpp | 293 +++++++++++++++++++++-------------------- 2 files changed, 172 insertions(+), 172 deletions(-) diff --git a/include/osgViewer/View b/include/osgViewer/View index a8669fb21..e9b41b2c2 100644 --- a/include/osgViewer/View +++ b/include/osgViewer/View @@ -1,13 +1,13 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ @@ -40,11 +40,11 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter View(const osgViewer::View& view, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); META_Object(osgViewer,View); - + /** Provide a mechanism for getting the osg::View associated from the GUIActionAdapter. * One would use this to case view to osgViewer::View(er) if supported by the subclass.*/ virtual osg::View* asView() { return this; } - + /** Provide a mechanism for getting the viewer object from this osgViewer::View. * In the case of a osgViewer::Viewer the ViewerBase will effectively point to this object as Viewer subclasses from View. * In the case of a osgViewer::CompsoiteViewer the ViewerBase will point to the CompositeViewer that owns this View. */ @@ -110,10 +110,10 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter /** Set the view to the CameraManipulator's home position, if non is attached home() is does nothing. * Note, to set the home position use getCamaraManipulator()->setHomePosition(...). */ void home(); - + typedef std::list< osg::ref_ptr > EventHandlers; - + /** Add an EventHandler that adds handling of events to the View.*/ void addEventHandler(osgGA::GUIEventHandler* eventHandler); @@ -125,7 +125,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter /** Get the const View's list of EventHandlers.*/ const EventHandlers& getEventHandlers() const { return _eventHandlers; } - + /** Set the NodePath to any active CoordinateSystemNode present in the Scene. * The CoordinateSystemNode path is used to help applications and CamaraManipualtors handle geocentric coordinates systems, @@ -138,13 +138,13 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter /** Compute the NodePath to any active CoordinateSystemNode present in the Scene.*/ void computeActiveCoordinateSystemNodePath(); - + /** Set the DisplaySettings object associated with this view.*/ void setDisplaySettings(osg::DisplaySettings* ds) { _displaySettings = ds; } - + /** Set the DisplaySettings object associated with this view.*/ osg::DisplaySettings* getDisplaySettings() { return _displaySettings.get(); } - + /** Set the DisplaySettings object associated with this view.*/ const osg::DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); } @@ -161,7 +161,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter /** Get the FusionDistanceValue. Note, only used for USE_FUSION_DISTANCE_VALUE & PROPORTIONAL_TO_SCREEN_DISTANCE modes.*/ float getFusionDistanceValue() const { return _fusionDistanceValue; } - + /** Convenience method for creating slave Cameras and associated GraphicsWindows across all screens.*/ void setUpViewAcrossAllScreens(); @@ -170,7 +170,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter /** Convenience method for a single camera associated with a single full screen GraphicsWindow.*/ void setUpViewOnSingleScreen(unsigned int screenNum=0); - + /** Convenience method for spherical display using 6 slave cameras rendering the 6 sides of a cube map, and 7th camera doing distortion correction to present on a spherical display.*/ void setUpViewFor3DSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd()); @@ -181,38 +181,38 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter /** Convenience method for autostereoscopic Philips WoWvx display.*/ void setUpViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_content, unsigned char wow_factor, unsigned char wow_offset, float wow_disparity_Zd, float wow_disparity_vz, float wow_disparity_M, float wow_disparity_C); - + /** Return true if this view contains a specified camera.*/ bool containsCamera(const osg::Camera* camera) const; - + /** Get the camera which contains the pointer position x,y specified master cameras window/eye coords. * Also passes back the local window coords for the graphics context associated with the camera passed back. */ const osg::Camera* getCameraContainingPosition(float x, float y, float& local_x, float& local_y) const; /** Compute intersections between a ray through the specified master cameras window/eye coords and a specified node. * Note, when a master cameras has slaves and no viewport itself its coordinate frame will be in clip space i.e. -1,-1 to 1,1, - * while if its has a viewport the coordintates will be relative to its viewport dimensions. + * while if its has a viewport the coordintates will be relative to its viewport dimensions. * Mouse events handled by the view will automatically be attached into the master camera window/clip coords so can be passed * directly on to the computeIntersections method. */ bool computeIntersections(float x,float y, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff); - + /** Compute intersections between a ray through the specified master cameras window/eye coords and a specified nodePath's subgraph. */ bool computeIntersections(float x,float y, const osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff); - + virtual void requestRedraw(); virtual void requestContinuousUpdate(bool needed=true); virtual void requestWarpPointer(float x,float y); - + public: - + void assignSceneDataToCameras(); void init(); protected: - + friend class CompositeViewer; - + virtual ~View(); virtual osg::GraphicsOperation* createRenderer(osg::Camera* camera); @@ -226,14 +226,13 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter osg::ref_ptr _eventQueue; osg::ref_ptr _cameraManipulator; EventHandlers _eventHandlers; - + typedef std::vector< osg::observer_ptr > ObserverNodePath; ObserverNodePath _coordinateSystemNodePath; osg::ref_ptr _displaySettings; osgUtil::SceneView::FusionDistanceMode _fusionDistanceMode; float _fusionDistanceValue; - }; } diff --git a/src/osgViewer/View.cpp b/src/osgViewer/View.cpp index 1846358d6..a547e232f 100644 --- a/src/osgViewer/View.cpp +++ b/src/osgViewer/View.cpp @@ -1,13 +1,13 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ @@ -36,7 +36,7 @@ public: CollectedCoordinateSystemNodesVisitor(): NodeVisitor(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN) {} - + META_NodeVisitor("osgViewer","CollectedCoordinateSystemNodesVisitor") virtual void apply(osg::Node& node) @@ -59,7 +59,7 @@ public: } traverse(node); } - + osg::NodePath _pathToCoordinateSystemNode; }; @@ -71,22 +71,22 @@ public: ViewerCoordinateFrameCallback(osgViewer::View* view): _view(view) {} - + virtual osg::CoordinateFrame getCoordinateFrame(const osg::Vec3d& position) const { osg::notify(osg::INFO)<<"getCoordinateFrame("<getCoordinateSystemNodePath(); - + if (!tmpPath.empty()) - { + { osg::Matrixd coordinateFrame; osg::CoordinateSystemNode* csn = dynamic_cast(tmpPath.back()); if (csn) { osg::Vec3 local_position = position*osg::computeWorldToLocal(tmpPath); - + // get the coordinate frame in world coords. coordinateFrame = csn->computeLocalCoordinateFrame(local_position)* osg::computeLocalToWorld(tmpPath); @@ -121,10 +121,10 @@ public: return osg::Matrixd::translate(position); } } - + protected: virtual ~ViewerCoordinateFrameCallback() {} - + osg::observer_ptr _view; }; @@ -146,12 +146,12 @@ View::View(): // make sure View is safe to reference multi-threaded. setThreadSafeRefUnref(true); - + // need to attach a Renderer to the master camera which has been default constructed getCamera()->setRenderer(createRenderer(getCamera())); setEventQueue(new osgGA::EventQueue); - + setStats(new osg::Stats("View")); } @@ -182,10 +182,10 @@ void View::take(osg::View& rhs) osg::View::take(rhs); #if 1 - osgViewer::View* rhs_osgViewer = dynamic_cast(&rhs); + osgViewer::View* rhs_osgViewer = dynamic_cast(&rhs); if (rhs_osgViewer) { - + // copy across rhs _startTick = rhs_osgViewer->_startTick; _frameStamp = rhs_osgViewer->_frameStamp; @@ -194,12 +194,12 @@ void View::take(osg::View& rhs) { _scene = rhs_osgViewer->_scene; } - + if (rhs_osgViewer->_cameraManipulator.valid()) { _cameraManipulator = rhs_osgViewer->_cameraManipulator; } - + _eventHandlers.insert(_eventHandlers.end(), rhs_osgViewer->_eventHandlers.begin(), rhs_osgViewer->_eventHandlers.end()); _coordinateSystemNodePath = rhs_osgViewer->_coordinateSystemNodePath; @@ -207,16 +207,16 @@ void View::take(osg::View& rhs) _displaySettings = rhs_osgViewer->_displaySettings; _fusionDistanceMode = rhs_osgViewer->_fusionDistanceMode; _fusionDistanceValue = rhs_osgViewer->_fusionDistanceValue; - - + + // clear rhs rhs_osgViewer->_frameStamp = 0; rhs_osgViewer->_scene = 0; rhs_osgViewer->_cameraManipulator = 0; rhs_osgViewer->_eventHandlers.clear(); - + rhs_osgViewer->_coordinateSystemNodePath.clear(); - + rhs_osgViewer->_displaySettings = 0; } #endif @@ -235,10 +235,10 @@ osg::GraphicsOperation* View::createRenderer(osg::Camera* camera) void View::init() { osg::notify(osg::INFO)<<"View::init()"< initEvent = _eventQueue->createEvent(); initEvent->setEventType(osgGA::GUIEventAdapter::FRAME); - + if (_cameraManipulator.valid()) { _cameraManipulator->init(*initEvent, *this); @@ -289,18 +289,18 @@ void View::setSceneData(osg::Node* node) // the scene graph from being run in parallel. osgUtil::Optimizer::StaticObjectDetectionVisitor sodv; getSceneData()->accept(sodv); - + // make sure that existing scene graph objects are allocated with thread safe ref/unref - if (getViewerBase() && - getViewerBase()->getThreadingModel()!=ViewerBase::SingleThreaded) + if (getViewerBase() && + getViewerBase()->getThreadingModel()!=ViewerBase::SingleThreaded) { getSceneData()->setThreadSafeRefUnref(true); } - + // update the scene graph so that it has enough GL object buffer memory for the graphics contexts that will be using it. getSceneData()->resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts()); } - + computeActiveCoordinateSystemNodePath(); assignSceneDataToCameras(); @@ -341,13 +341,13 @@ const osgDB::ImagePager* View::getImagePager() const void View::setCameraManipulator(osgGA::MatrixManipulator* manipulator) { _cameraManipulator = manipulator; - + if (_cameraManipulator.valid()) { _cameraManipulator->setCoordinateFrameCallback(new ViewerCoordinateFrameCallback(this)); if (getSceneData()) _cameraManipulator->setNode(getSceneData()); - + osg::ref_ptr dummyEvent = _eventQueue->createEvent(); _cameraManipulator->home(*dummyEvent, *this); @@ -406,10 +406,10 @@ void View::computeActiveCoordinateSystemNodePath() { // now search for CoordinateSystemNode's for which we want to track. osg::Node* subgraph = getSceneData(); - + if (subgraph) { - + CollectedCoordinateSystemNodesVisitor ccsnv; subgraph->accept(ccsnv); @@ -418,7 +418,7 @@ void View::computeActiveCoordinateSystemNodePath() setCoordinateSystemNodePath(ccsnv._pathToCoordinateSystemNode); return; } - } + } // otherwise no node path found so reset to empty. setCoordinateSystemNodePath(osg::NodePath()); @@ -427,28 +427,28 @@ void View::computeActiveCoordinateSystemNodePath() void View::setUpViewAcrossAllScreens() { osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); - if (!wsi) + if (!wsi) { osg::notify(osg::NOTICE)<<"View::setUpViewAcrossAllScreens() : Error, no WindowSystemInterface available, cannot create windows."<getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); osg::GraphicsContext::ScreenIdentifier si; si.readDISPLAY(); - + // displayNum has not been set so reset it to 0. if (si.displayNum<0) si.displayNum = 0; - + unsigned int numScreens = wsi->getNumScreens(si); if (numScreens==1) { if (si.screenNum<0) si.screenNum = 0; - + unsigned int width, height; wsi->getScreenResolution(si, width, height); @@ -467,7 +467,7 @@ void View::setUpViewAcrossAllScreens() osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); _camera->setGraphicsContext(gc.get()); - + osgViewer::GraphicsWindow* gw = dynamic_cast(gc.get()); if (gw) { @@ -507,15 +507,15 @@ void View::setUpViewAcrossAllScreens() wsi->getScreenResolution(si, width, height); translate_x += double(width) / (double(height) * aspectRatio); } - + bool stereoSlitScreens = numScreens==2 && ds->getStereoMode()==osg::DisplaySettings::HORIZONTAL_SPLIT && ds->getStereo(); - + for(unsigned int i=0; igetScreenResolution(si, width, height); @@ -558,11 +558,11 @@ void View::setUpViewAcrossAllScreens() if (stereoSlitScreens) { unsigned int leftCameraNum = (ds->getSplitStereoHorizontalEyeMapping()==osg::DisplaySettings::LEFT_EYE_LEFT_VIEWPORT) ? 0 : 1; - + osg::ref_ptr ds_local = new osg::DisplaySettings(*ds); ds_local->setStereoMode(leftCameraNum==i ? osg::DisplaySettings::LEFT_EYE : osg::DisplaySettings::RIGHT_EYE); camera->setDisplaySettings(ds_local.get()); - + addSlave(camera.get(), osg::Matrixd(), osg::Matrixd() ); } else @@ -587,7 +587,7 @@ void View::setUpViewInWindow(int x, int y, int width, int height, unsigned int s traits->readDISPLAY(); if (traits->displayNum<0) traits->displayNum = 0; - + traits->screenNum = screenNum; traits->x = x; traits->y = y; @@ -612,7 +612,7 @@ void View::setUpViewInWindow(int x, int y, int width, int height, unsigned int s osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."<getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); double newAspectRatio = double(traits->width) / double(traits->height); @@ -633,7 +633,7 @@ void View::setUpViewInWindow(int x, int y, int width, int height, unsigned int s void View::setUpViewOnSingleScreen(unsigned int screenNum) { osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); - if (!wsi) + if (!wsi) { osg::notify(osg::NOTICE)<<"View::setUpViewOnSingleScreen() : Error, no WindowSystemInterface available, cannot create windows."<getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); double newAspectRatio = double(traits->width) / double(traits->height); @@ -701,13 +701,13 @@ static osg::Geometry* create3DSphericalDisplayDistortionMesh(const osg::Vec3& or { osg::Vec3d center(0.0,0.0,0.0); osg::Vec3d eye(0.0,0.0,0.0); - + double distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius); - + bool centerProjection = false; osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, distance); - + osg::notify(osg::INFO)<<"create3DSphericalDisplayDistortionMesh : Projector position = "<windowDecoration = false; traits->doubleBuffer = true; traits->sharedContext = 0; - + osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); if (!gc) @@ -892,7 +892,7 @@ void View::setUpViewFor3DSphericalDisplay(double radius, double collar, unsigned osg::notify(osg::NOTICE)<<"GraphicsWindow has not been created successfully."<setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE); texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE); texture->setWrap(osg::Texture::WRAP_R,osg::Texture::CLAMP_TO_EDGE); - -#if 0 + +#if 0 osg::Camera::RenderTargetImplementation renderTargetImplementation = osg::Camera::SEPERATE_WINDOW; GLenum buffer = GL_FRONT; #else @@ -937,7 +937,7 @@ void View::setUpViewFor3DSphericalDisplay(double radius, double collar, unsigned addSlave(camera.get(), osg::Matrixd(), osg::Matrixd()); } - + // top face { osg::ref_ptr camera = new osg::Camera; @@ -1033,7 +1033,7 @@ void View::setUpViewFor3DSphericalDisplay(double radius, double collar, unsigned addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(180.0f), 1.0,0.0,0.0)); } - + getCamera()->setProjectionMatrixAsPerspective(90.0f, 1.0, 1, 1000.0); // distortion correction set up. @@ -1041,7 +1041,7 @@ void View::setUpViewFor3DSphericalDisplay(double radius, double collar, unsigned osg::Geode* geode = new osg::Geode(); geode->addDrawable(create3DSphericalDisplayDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), radius, collar, applyIntensityMapAsColours ? intensityMap : 0, projectorMatrix)); - // new we need to add the texture to the mesh, we do so by creating a + // new we need to add the texture to the mesh, we do so by creating a // StateSet to contain the Texture StateAttribute. osg::StateSet* stateset = geode->getOrCreateStateSet(); stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON); @@ -1064,20 +1064,20 @@ void View::setUpViewFor3DSphericalDisplay(double radius, double collar, unsigned camera->setAllowEventFocus(false); camera->setInheritanceMask(camera->getInheritanceMask() & ~osg::CullSettings::CLEAR_COLOR & ~osg::CullSettings::COMPUTE_NEAR_FAR_MODE); //camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); - + camera->setProjectionMatrixAsOrtho2D(0,width,0,height); camera->setViewMatrix(osg::Matrix::identity()); // add subgraph to render camera->addChild(geode); - + camera->setName("DistortionCorrectionCamera"); addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false); } - + getCamera()->setNearFarRatio(0.0001f); - + if (getLightingMode()==osg::View::HEADLIGHT) { // set a local light source for headlight to ensure that lighting is consistent across sides of cube. @@ -1089,14 +1089,14 @@ static osg::Geometry* createParoramicSphericalDisplayDistortionMesh(const osg::V { osg::Vec3d center(0.0,0.0,0.0); osg::Vec3d eye(0.0,0.0,0.0); - + double distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius); bool flip = false; bool texcoord_flip = false; osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, distance); - - + + osg::notify(osg::INFO)<<"createParoramicSphericalDisplayDistortionMesh : Projector position = "<windowDecoration = false; traits->doubleBuffer = true; traits->sharedContext = 0; - + bool applyIntensityMapAsColours = true; @@ -1282,8 +1282,8 @@ void View::setUpViewForPanoramicSphericalDisplay(double radius, double collar, u texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); texture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE); texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE); - -#if 0 + +#if 0 osg::Camera::RenderTargetImplementation renderTargetImplementation = osg::Camera::SEPERATE_WINDOW; GLenum buffer = GL_FRONT; #else @@ -1314,7 +1314,7 @@ void View::setUpViewForPanoramicSphericalDisplay(double radius, double collar, u osg::Geode* geode = new osg::Geode(); geode->addDrawable(createParoramicSphericalDisplayDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), radius, collar, applyIntensityMapAsColours ? intensityMap : 0, projectorMatrix)); - // new we need to add the texture to the mesh, we do so by creating a + // new we need to add the texture to the mesh, we do so by creating a // StateSet to contain the Texture StateAttribute. osg::StateSet* stateset = geode->getOrCreateStateSet(); stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON); @@ -1341,13 +1341,13 @@ void View::setUpViewForPanoramicSphericalDisplay(double radius, double collar, u camera->setAllowEventFocus(false); camera->setInheritanceMask(camera->getInheritanceMask() & ~osg::CullSettings::CLEAR_COLOR & ~osg::CullSettings::COMPUTE_NEAR_FAR_MODE); //camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); - + camera->setProjectionMatrixAsOrtho2D(0,width,0,height); camera->setViewMatrix(osg::Matrix::identity()); // add subgraph to render camera->addChild(geode); - + camera->setName("DistortionCorrectionCamera"); addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false); @@ -1359,7 +1359,7 @@ void View::setUpViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_co osg::notify(osg::INFO)<<"View::setUpViewForWoWVxDisplay(...)"<windowDecoration = false; traits->doubleBuffer = true; traits->sharedContext = 0; - + osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); if (!gc) @@ -1414,7 +1414,7 @@ void View::setUpViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_co textureD->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); textureD->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); -#if 0 +#if 0 osg::Camera::RenderTargetImplementation renderTargetImplementation = osg::Camera::SEPERATE_WINDOW; GLenum buffer = GL_FRONT; #else @@ -1481,11 +1481,11 @@ void View::setUpViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_co } for (int x=0; x<=9; ++x){ for (int y=7; y>=0; --y){ - int i = 2*(7-y)+16*x; + int i = 2*(7-y)+16*x; cheader[i] = (((1<<(y))&(header[x])) << (7-(y))); } } - } + } textureHeader->setImage(imageheader.get()); } @@ -1530,7 +1530,7 @@ void View::setUpViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_co stateset->addUniform(new osg::Uniform("wow_header", 0)); stateset->addUniform(new osg::Uniform("wow_tcolor", 1)); stateset->addUniform(new osg::Uniform("wow_tdepth", 2)); - + osg::Shader *frag = new osg::Shader(osg::Shader::FRAGMENT); frag->setShaderSource(" "\ " uniform sampler1D wow_header; " \ @@ -1588,13 +1588,13 @@ void View::setUpViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_co camera->setAllowEventFocus(false); camera->setInheritanceMask(camera->getInheritanceMask() & ~osg::CullSettings::CLEAR_COLOR & ~osg::CullSettings::COMPUTE_NEAR_FAR_MODE); //camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); - + camera->setProjectionMatrixAsOrtho2D(0,width,0,height); camera->setViewMatrix(osg::Matrix::identity()); // add subgraph to render camera->addChild(geode); - + camera->setName("WoWCamera"); addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false); @@ -1609,11 +1609,11 @@ void View::assignSceneDataToCameras() // osg::notify(osg::NOTICE)<<"View::assignSceneDataToCameras()"<getSceneData() : 0; - + if (_cameraManipulator.valid()) { _cameraManipulator->setNode(sceneData); - + osg::ref_ptr dummyEvent = _eventQueue->createEvent(); _cameraManipulator->home(*dummyEvent, *this); @@ -1623,7 +1623,7 @@ void View::assignSceneDataToCameras() { _camera->removeChildren(0,_camera->getNumChildren()); if (sceneData) _camera->addChild(sceneData); - + Renderer* renderer = dynamic_cast(_camera->getRenderer()); if (renderer) renderer->setCompileOnNextDraw(true); @@ -1636,11 +1636,11 @@ void View::assignSceneDataToCameras() { slave._camera->removeChildren(0,slave._camera->getNumChildren()); if (sceneData) slave._camera->addChild(sceneData); - + Renderer* renderer = dynamic_cast(slave._camera->getRenderer()); if (renderer) renderer->setCompileOnNextDraw(true); } - } + } } void View::requestRedraw() @@ -1670,7 +1670,7 @@ void View::requestContinuousUpdate(bool flag) void View::requestWarpPointer(float x,float y) { osg::notify(osg::INFO)<<"View::requestWarpPointer("<getCurrentEventState(); + const osgGA::GUIEventAdapter* eventState = getEventQueue()->getCurrentEventState(); const osgViewer::GraphicsWindow* gw = dynamic_cast(eventState->getGraphicsContext()); bool view_invert_y = eventState->getMouseYOrientation()==osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS; @@ -1719,7 +1719,7 @@ const osg::Camera* View::getCameraContainingPosition(float x, float y, float& lo _camera->getViewport()) { const osg::Viewport* viewport = _camera->getViewport(); - + double new_x = x; double new_y = y; @@ -1730,8 +1730,8 @@ const osg::Camera* View::getCameraContainingPosition(float x, float y, float& lo static_cast(_camera->getGraphicsContext()->getTraits()->height) * (1.0 - (y- eventState->getYmin())/(eventState->getYmax()-eventState->getYmin())) : static_cast(_camera->getGraphicsContext()->getTraits()->height) * (y - eventState->getYmin())/(eventState->getYmax()-eventState->getXmin()); } - - if (viewport && + + if (viewport && new_x >= (viewport->x()-epsilon) && new_y >= (viewport->y()-epsilon) && new_x < (viewport->x()+viewport->width()-1.0+epsilon) && new_y <= (viewport->y()+viewport->height()-1.0+epsilon) ) { @@ -1745,17 +1745,17 @@ const osg::Camera* View::getCameraContainingPosition(float x, float y, float& lo } osg::Matrix masterCameraVPW = getCamera()->getViewMatrix() * getCamera()->getProjectionMatrix(); - + // convert to non dimensional x = (x - eventState->getXmin()) * 2.0 / (eventState->getXmax()-eventState->getXmin()) - 1.0; y = (y - eventState->getYmin())* 2.0 / (eventState->getYmax()-eventState->getYmin()) - 1.0; if (view_invert_y) y = - y; - + for(int i=getNumSlaves()-1; i>=0; --i) { const Slave& slave = getSlave(i); - if (slave._camera.valid() && + if (slave._camera.valid() && slave._camera->getAllowEventFocus() && slave._camera->getRenderTargetImplementation()==osg::Camera::FRAME_BUFFER) { @@ -1775,12 +1775,12 @@ const osg::Camera* View::getCameraContainingPosition(float x, float y, float& lo //osg::notify(osg::NOTICE)<<" eventState->getXmin()="<getXmin()<<" eventState->getXmax()="<getXmax()<= (viewport->x()-epsilon) && new_coord.y() >= (viewport->y()-epsilon) && new_coord.x() < (viewport->x()+viewport->width()-1.0+epsilon) && new_coord.y() <= (viewport->y()+viewport->height()-1.0+epsilon) ) { // osg::notify(osg::NOTICE)<<" in viewport "<getViewport() ? osgUtil::Intersector::WINDOW : osgUtil::Intersector::PROJECTION; osg::ref_ptr< osgUtil::LineSegmentIntersector > picker = new osgUtil::LineSegmentIntersector(cf, local_x, local_y); @@ -1825,11 +1825,11 @@ bool View::computeIntersections(float x,float y, osgUtil::LineSegmentIntersector osgUtil::IntersectionVisitor iv(picker.get()); iv.setTraversalMask(traversalMask); - - + + #if 1 const_cast(camera)->accept(iv); -#else +#else // timing test code paths for comparing KdTree based intersections vs conventional intersections @@ -1837,7 +1837,7 @@ bool View::computeIntersections(float x,float y, osgUtil::LineSegmentIntersector iv.setDoDummyTraversal(true); const_cast(camera)->accept(iv); - + osg::Timer_t before = osg::Timer::instance()->tick(); const_cast(camera)->accept(iv); @@ -1855,13 +1855,13 @@ bool View::computeIntersections(float x,float y, osgUtil::LineSegmentIntersector iv.setUseKdTreeWhenAvailable(false); const_cast(camera)->accept(iv); osg::Timer_t after = osg::Timer::instance()->tick(); - + int intersectsAfterConventional = picker->getIntersections().size(); double timeDummy = osg::Timer::instance()->delta_m(before, after_dummy); double timeKdTree = osg::Timer::instance()->delta_m(after_dummy, after_kdTree_2); double timeConventional = osg::Timer::instance()->delta_m(after_kdTree_2, after); - + osg::notify(osg::NOTICE)<<"Using Dummy "<containsIntersections()) { @@ -1889,18 +1889,18 @@ bool View::computeIntersections(float x,float y, osgUtil::LineSegmentIntersector bool View::computeIntersections(float x,float y, const osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask) { if (!_camera.valid() || nodePath.empty()) return false; - - float local_x, local_y = 0.0; + + float local_x, local_y = 0.0; const osg::Camera* camera = getCameraContainingPosition(x, y, local_x, local_y); if (!camera) camera = _camera.get(); - + osg::Matrixd matrix; if (nodePath.size()>1) { osg::NodePath prunedNodePath(nodePath.begin(),nodePath.end()-1); matrix = osg::computeLocalToWorld(prunedNodePath); } - + matrix.postMult(camera->getViewMatrix()); matrix.postMult(camera->getProjectionMatrix()); @@ -1918,9 +1918,9 @@ bool View::computeIntersections(float x,float y, const osg::NodePath& nodePath, osg::Vec3d startVertex = osg::Vec3d(local_x,local_y,zNear) * inverse; osg::Vec3d endVertex = osg::Vec3d(local_x,local_y,zFar) * inverse; - + osg::ref_ptr< osgUtil::LineSegmentIntersector > picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::MODEL, startVertex, endVertex); - + osgUtil::IntersectionVisitor iv(picker.get()); iv.setTraversalMask(traversalMask); nodePath.back()->accept(iv); @@ -1937,3 +1937,4 @@ bool View::computeIntersections(float x,float y, const osg::NodePath& nodePath, } } +