void
TerrainEngineNode::traverse( osg::NodeVisitor& nv )
{
    if ( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
    {
        // see if we need to set up the Terrain object with an update ops queue.
        if ( !_terrainInterface->_updateOperationQueue.valid() )
        {
            static Threading::Mutex s_opqlock;
            Threading::ScopedMutexLock lock(s_opqlock);
            if ( !_terrainInterface->_updateOperationQueue.valid() ) // double check pattern
            {
                //TODO: think, will this work with >1 view?
                osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>( &nv );
                if ( cv->getCurrentCamera() )
                {
                    osgViewer::View* view = dynamic_cast<osgViewer::View*>(cv->getCurrentCamera()->getView());
                    if ( view && view->getViewerBase() )
                    {
                        osg::OperationQueue* q = view->getViewerBase()->getUpdateOperations();
                        if ( !q ) {
                            q = new osg::OperationQueue();
                            view->getViewerBase()->setUpdateOperations( q );
                        }
                        _terrainInterface->_updateOperationQueue = q;
                    }
                }                        
            }
        }


        if ( Registry::instance()->getCapabilities().supportsGLSL() )
        {
            _updateLightingUniformsHelper.cullTraverse( this, &nv );

            osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>( &nv );
            if ( cv )
            {
                osg::Vec3d eye = cv->getEyePoint();

                float elevation;
                if ( _map->isGeocentric() )
                    elevation = eye.length() - osg::WGS_84_RADIUS_EQUATOR;
                else
                    elevation = eye.z();

                _cameraElevationUniform->set( elevation );
            }
        }
    }

    else if ( nv.getVisitorType() == osg::NodeVisitor::EVENT_VISITOR )
    {
        _dirtyCount = 0;
    }

    osg::CoordinateSystemNode::traverse( nv );
}
Beispiel #2
0
void ElevationLOD::traverse( osg::NodeVisitor& nv)
{
    if (nv.getVisitorType()   == osg::NodeVisitor::CULL_VISITOR &&
        nv.getTraversalMode() == osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN )
    {
        bool rangeOK     = true;
        bool altitudeOK  = true;

        // first test the range:
        if ( _minRange.isSet() || _maxRange.isSet() )
        {
            float range = nv.getDistanceToViewPoint( getBound().center(), true );
            rangeOK =
                (!_minRange.isSet() || (range >= *_minRange)) &&
                (!_maxRange.isSet() || (range <= *_maxRange));
        }

        if ( rangeOK )
        {
            if ( _minElevation.isSet() || _maxElevation.isSet() )
            {
                double alt;

                // first see if we have a precalculated elevation:
                osgUtil::CullVisitor* cv = Culling::asCullVisitor(nv);

                osg::Vec3d eye = cv->getViewPoint();

                if ( _srs && !_srs->isProjected() )
                {
                    GeoPoint mapPoint;
                    mapPoint.fromWorld( _srs.get(), eye );
                    alt = mapPoint.z();
                }
                else
                {
                    alt = eye.z();
                }

                // account for the LOD scale
                alt *= cv->getLODScale();

                altitudeOK =
                    (!_minElevation.isSet() || (alt >= *_minElevation)) &&
                    (!_maxElevation.isSet() || (alt <= *_maxElevation));
            }

            if ( altitudeOK )
            {
                std::for_each(_children.begin(),_children.end(),osg::NodeAcceptOp(nv));
            }
        }
    }
    else
    {
        osg::Group::traverse( nv );
    }
}
Beispiel #3
0
void
HTMNode::traverse(osg::NodeVisitor& nv)
{
    if ( nv.getVisitorType() == nv.CULL_VISITOR )
    {
        //OE_INFO << getName() << std::endl;
#if 0
        if ( _isLeaf )
        {
            if (_settings._debugFrame != nv.getFrameStamp()->getFrameNumber())
            {
                OE_NOTICE << "Frame " << _settings._debugFrame << ": " << _settings._debugCount << std::endl;
                _settings._debugCount = 0;
                _settings._debugFrame = nv.getFrameStamp()->getFrameNumber();
            }
            _settings._debugCount += getNumChildren();
        }
#endif

        const osg::BoundingSphere& bs = getBound();

        float range = nv.getDistanceToViewPoint(bs.center(), true);
        bool inRange = false;

        if (_settings._maxRange.isSet() == false)
        {
            inRange = range < (bs.radius() * _settings._rangeFactor.get());
        }
        else
        {
            inRange = range < (bs.radius() + _settings._maxRange.get());
        }

        if ( inRange )
        {
            osg::Group::traverse( nv );
            
            if (_debug.valid() && _isLeaf)
            {
                _debug->accept(nv);
            }
        }
        else if (_debug.valid())
        {
            _debug->accept(nv);
        }
    }
    else
    {
        if (_debug.valid())
        {
            _debug->accept(nv);
        }

        osg::Group::traverse( nv );        
    }
}
Beispiel #4
0
void
OrthoNode::traverse( osg::NodeVisitor& nv )
{
    osgUtil::CullVisitor* cv = 0L;

    if ( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
    {
        cv = Culling::asCullVisitor(nv);

        // make sure that we're NOT using the AutoTransform if this node is in the decluttering bin;
        // the decluttering bin automatically manages screen space transformation.
        bool declutter = cv->getCurrentRenderBin()->getName() == OSGEARTH_DECLUTTER_BIN;
        if ( declutter && _switch->getValue(0) == 1 )
        {
            _switch->setSingleChildOn( 1 );
        }
        else if ( !declutter && _switch->getValue(0) == 0 )
        {
            _switch->setSingleChildOn( 0 );
        }

        // If decluttering is enabled, update the auto-transform but not its children.
        // This is necessary to support picking/selection. An optimization would be to
        // disable this pass when picking is not in use
        if ( declutter )
        {
            static_cast<AnnotationUtils::OrthoNodeAutoTransform*>(_autoxform)->acceptCullNoTraverse( cv );
        }

        // turn off small feature culling
        cv->setSmallFeatureCullingPixelSize(0.0f);

        AnnotationNode::traverse( nv );

        if ( this->getCullingActive() == false )
            this->setCullingActive( true );
    }
    
    // For an intersection visitor, ALWAYS traverse the autoxform instead of the 
    // matrix transform. The matrix transform is only used in combination with the 
    // decluttering engine, so it cannot properly support picking of decluttered
    // objects
    else if ( 
        nv.getVisitorType() == osg::NodeVisitor::NODE_VISITOR &&
        dynamic_cast<osgUtil::IntersectionVisitor*>( &nv ) )
    {
        if ( static_cast<AnnotationUtils::OrthoNodeAutoTransform*>(_autoxform)->okToIntersect() )
        {
            _autoxform->accept( nv );
        }
    }

    else
    {
        AnnotationNode::traverse( nv );
    }
}
Beispiel #5
0
void
OverlayDecorator::traverse( osg::NodeVisitor& nv )
{
    if ( _overlayGraph.valid() && _textureUnit.isSet() )
    {
        // in the CULL traversal, find the per-view data associated with the 
        // cull visitor's current camera view and work with that:
        if ( nv.getVisitorType() == nv.CULL_VISITOR )
        {
            osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>( &nv );
            osg::Camera* camera = cv->getCurrentCamera();
            if ( camera != 0L && (_rttTraversalMask & nv.getTraversalMask()) != 0 )
            {
                PerViewData& pvd = getPerViewData( camera );

                if (checkNeedsUpdate(pvd))
                {
                    updateRTTCamera(pvd);
                }

                if ( pvd._texGen.valid() )
                {
                    // FFP path only
                    cv->getCurrentRenderBin()->getStage()->addPositionedTextureAttribute(
                        *_textureUnit, cv->getModelViewMatrix(), pvd._texGen.get() );
                }

                cull( cv, pvd );

                pvd._rttCamera->accept( nv );
            }
            else
            {
                osg::Group::traverse(nv);
            }

            // debug-- (draws the overlay at its native location as well)
            //_overlayGraph->accept(nv);
        }

        else
        {
            // Some other type of visitor (like update or intersection). Skip the RTT camera
            // and traverse the overlay graph directly.
            if ( _overlayGraph.valid() )
            {
                _overlayGraph->accept( nv );
            }

            osg::Group::traverse( nv );
        }
    }
    else
    {
        osg::Group::traverse( nv );
    }
}
void
SilverLiningContextNode::traverse(osg::NodeVisitor& nv)
{
    if ( _SL && _SL->ready() )
    {
        if ( nv.getVisitorType() == nv.UPDATE_VISITOR )
        {
			int frameNumber = nv.getFrameStamp()->getFrameNumber();
            _skyDrawable->dirtyBound();

            if( _cloudsDrawable )
            {
                if ( _lastAltitude <= *_options.cloudsMaxAltitude() )
                {
                    if ( _cloudsDrawable->getNumParents() == 0 )
                        _geode->addDrawable( _cloudsDrawable.get() );

                    _cloudsDrawable->dirtyBound();
                }
                else
                {
                    if ( _cloudsDrawable->getNumParents() > 0 )
                        _geode->removeDrawable( _cloudsDrawable.get() );
                }
            }
        }

        else if ( nv.getVisitorType() == nv.CULL_VISITOR )
        {
			osgUtil::CullVisitor* cv = Culling::asCullVisitor(nv);
			osg::Camera* camera  = cv->getCurrentCamera();
			if ( camera )
			{
#ifndef SL_USE_CULL_MASK
				//Check if this is the target camera for this context
				if(getTargetCamera() == camera)
#endif
     			{
					// TODO: make this multi-camera safe
					_SL->setCameraPosition( nv.getEyePoint() );

					_lastAltitude = _SL->getSRS()->isGeographic() ?
						cv->getEyePoint().length() - _SL->getSRS()->getEllipsoid()->getRadiusEquator() :
					cv->getEyePoint().z();

					_SL->updateLocation();
					_SL->updateLight();
				}
			}
        }
    }

    if ( _geode.valid() )
    {
        _geode->accept(nv);
    }
}
Beispiel #7
0
void
TritonNode::traverse(osg::NodeVisitor& nv)
{
    if ( nv.getVisitorType() == nv.UPDATE_VISITOR && _TRITON->ready() )
    {
        _TRITON->update(nv.getFrameStamp()->getSimulationTime());
    }
    osgEarth::Util::OceanNode::traverse(nv);
}
void
GeoCell::traverse( osg::NodeVisitor& nv )
{
    bool isCull = nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR;

    if ( _depth > 0 )
    {
        if ( isCull )
        {
            // process boundary geometry, if present.
            if ( _boundaryGeode.valid() ) 
            {
                if ( _count > 0 )
                    (*_boundaryColor)[0].set(1,0,0,0.35);
                else
                    (*_boundaryColor)[0].set(1,1,1,0.25);
                _boundaryColor->dirty();

                _boundaryGeode->accept( nv );
            }

            // custom BSP culling function. this checks that the set of boundary points
            // for this cell intersects the viewing frustum.
            osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>( &nv );
            if ( cv && !intersects( cv->getCurrentCullingSet().getFrustum() ) )
            {
                return;
            }

            // passed cull, so record the framestamp.
            _frameStamp = cv->getFrameStamp()->getFrameNumber();
        }

        if ( _objects.size() > 0 )
        {
            for( GeoObjectCollection::iterator i = _objects.begin(); i != _objects.end(); ++i )
            {
                osg::Node* node = i->second->getNode();
                if ( node )
                    node->accept( nv );
            }
        }

        if ( _clusterGeode.valid() )
            _clusterGeode->accept( nv );
    }

    else
    {
        if ( isCull )
            _frameStamp = nv.getFrameStamp()->getFrameNumber();
    }

    osg::LOD::traverse( nv );
}
Beispiel #9
0
void Terrain::traverse(osg::NodeVisitor &nv)
{
    if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
    {
        // need to check if any TerrainTechniques need to have their update called on them.
        osgUtil::UpdateVisitor *uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
        if (uv)
        {
            typedef std::list<osg::ref_ptr<TerrainTile> >  TerrainTileList;
            TerrainTileList tiles;
            {
                OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_mutex);

                for (TerrainTileSet::iterator itr = _updateTerrainTileSet.begin(); itr != _updateTerrainTileSet.end(); ++itr)
                {
                    // take a reference first to make sure that the referenceCount can be safely read without another thread decrementing it to zero.
                    (*itr)->ref();

                    // only if referenceCount is 2 or more indicating there is still a reference held elsewhere is it safe to add it to list of tiles to be updated
                    if ((*itr)->referenceCount() > 1)
                        tiles.push_back(*itr);

                    // use unref_nodelete to avoid any issues when the *itr TerrainTile has been deleted by another thread while this for loop has been running.
                    (*itr)->unref_nodelete();
                }

                _updateTerrainTileSet.clear();
            }

            for (TerrainTileList::iterator itr = tiles.begin();
                 itr != tiles.end();
                 ++itr)
            {
                TerrainTile *tile = itr->get();
                tile->traverse(nv);
            }
        }
    }

    if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
    {
        osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
        osg::StateSet        *ss = _geometryPool.valid() ? _geometryPool->getRootStateSetForTerrain(this) : 0;
        if (cv && ss)
        {
            cv->pushStateSet(ss);
            Group::traverse(nv);
            cv->popStateSet();
            return;
        }
    }

    Group::traverse(nv);
}
Beispiel #10
0
void
TilePagedLOD::traverse(osg::NodeVisitor& nv)
{
    if (_progress.valid() && 
        nv.getVisitorType() == nv.CULL_VISITOR && 
        nv.getFrameStamp() )
    {
        _progress->update( nv.getFrameStamp()->getFrameNumber() );
    }
    
    osg::PagedLOD::traverse(nv);
}
Beispiel #11
0
void VisibilityGroup::traverse(osg::NodeVisitor &nv)
{
    if (nv.getTraversalMode() == osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN && nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
    {
        // cast to cullvisitor
        osgUtil::CullVisitor &cv = (osgUtil::CullVisitor&) nv;

        // here we test if we are inside the visibilityvolume

        // first get the eyepoint and in local coordinates
        osg::Vec3 eye  = cv.getEyeLocal();
        osg::Vec3 look = cv.getLookVectorLocal();

        // now scale the segment to the segment length - if 0 use the group bounding sphere radius
        float length = _segmentLength;
        if (length == 0.f)
            length = 2.0f * getBound().radius();

        look *= length;
        osg::Vec3 center = eye + look;

        osg::Vec3 seg = center - eye;

        // perform the intersection using the given mask
        osgUtil::IntersectVisitor      iv;
        osg::ref_ptr<osg::LineSegment> lineseg = new osg::LineSegment;
        lineseg->set(eye, center);
        iv.addLineSegment(lineseg.get());
        iv.setTraversalMask(_volumeIntersectionMask);

        if (_visibilityVolume.valid())
            _visibilityVolume->accept(iv);

        // now examine the hit record
        if (iv.hits())
        {
            osgUtil::IntersectVisitor::HitList &hitList = iv.getHitList(lineseg.get());
            if (!hitList.empty()) // we actually hit something
            {
                //                OSG_INFO << "Hit obstruction"<< std::endl;
                osg::Vec3 normal = hitList.front().getWorldIntersectNormal();
                if ((normal * seg) > 0.f) // we are inside
                    Group::traverse(nv);
            }
        }
    }
    else
    {
        Group::traverse(nv);
    }
}
Beispiel #12
0
void
GeoCell::traverse( osg::NodeVisitor& nv )
{
    bool isCull = nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR;

    if ( _depth > 0 )
    {
        if ( isCull )
        {
            // process boundary geometry, if present.
            if ( _boundaryGeode.valid() )
            {
                if ( _count > 0 )
                    (*_boundaryColor)[0].set(1,0,0,0.35);
                else
                    (*_boundaryColor)[0].set(1,1,1,0.25);
                _boundaryColor->dirty();

                _boundaryGeode->accept( nv );
            }

            osgUtil::CullVisitor* cv = Culling::asCullVisitor(nv);
            if ( cv )
            {
                // passed cull, so record the framestamp.
                _frameStamp = cv->getFrameStamp()->getFrameNumber();
            }
        }

        if ( _objects.size() > 0 )
        {
            for( GeoObjectCollection::iterator i = _objects.begin(); i != _objects.end(); ++i )
            {
                osg::Node* node = i->second->getNode();
                if ( node )
                    node->accept( nv );
            }
        }

        if ( _clusterGeode.valid() )
            _clusterGeode->accept( nv );
    }

    else
    {
        if ( isCull )
            _frameStamp = nv.getFrameStamp()->getFrameNumber();
    }

    osg::LOD::traverse( nv );
}
Beispiel #13
0
void Widget::traverseImplementation(osg::NodeVisitor& nv)
{
    if (!_graphicsInitialized && nv.getVisitorType()!=osg::NodeVisitor::CULL_VISITOR) createGraphics();

    osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
    if (ev)
    {
        if (_visible && _enabled)
        {

            updateFocus(nv);

            // OSG_NOTICE<<"EventTraversal getHasEventFocus()="<<getHasEventFocus()<<std::endl;

            // signify that event has been taken by widget with focus

            osgGA::EventQueue::Events& events = ev->getEvents();
            for(osgGA::EventQueue::Events::iterator itr = events.begin();
                itr != events.end();
                ++itr)
            {
                if (handle(ev, itr->get()))
                {
                    (*itr)->setHandled(true);
                    ev->setEventHandled(true);
                }
            }

            osg::Group::traverse(nv);
        }
    }
    else if (_visible ||
            (nv.getVisitorType()!=osg::NodeVisitor::UPDATE_VISITOR && nv.getVisitorType()!=osg::NodeVisitor::CULL_VISITOR && nv.getVisitorType()!=osg::NodeVisitor::INTERSECTION_VISITOR) )
    {
        GraphicsSubgraphMap::iterator itr = _graphicsSubgraphMap.begin();
        while(itr!= _graphicsSubgraphMap.end() && itr->first<=0)
        {
            itr->second->accept(nv);
            ++itr;
        }

        Group::traverse(nv);

        while(itr!= _graphicsSubgraphMap.end())
        {
            itr->second->accept(nv);
            ++itr;
        }
    }
}
Beispiel #14
0
void
TileNode::load(osg::NodeVisitor& nv)
{
    // Access the context:
    EngineContext* context = static_cast<EngineContext*>( nv.getUserData() );

    // Create a new load request on demand:
    if ( !_loadRequest.valid() )
    {
        Threading::ScopedMutexLock lock(_mutex);
        if ( !_loadRequest.valid() )
        {
            _loadRequest = new LoadTileData( this, context );
            _loadRequest->setName( _key.str() );
            _loadRequest->setTileKey( _key );
        }
    }

#if 0
    double range0, range1;
    int lod = getTileKey().getLOD();
    if ( lod > context->getOptions().firstLOD().get() )
        range0 = context->getSelectionInfo().visParameters(lod-1)._visibilityRange;
    else
        range0 = 0.0;
    double range1 = context->getSelectionInfo().visParameters(lod)._visibilityRange;

    priority = 
#endif

    // Prioritize by LOD. (negated because lower order gets priority)
    float priority = - (float)getTileKey().getLOD();

    if ( context->getOptions().highResolutionFirst() == true )
    {
        priority = context->getSelectionInfo().numLods() - priority;
        //priority = -priority;
    }

    // then sort by distance within each LOD.
    float distance = nv.getDistanceToViewPoint( getBound().center(), true );
    priority = 10.0f*priority - log10(distance);

    // testing intermediate loading idea...
    //if ( getTileKey().getLOD() == 5 )
    //    priority += 100.0f;

    // Submit to the loader.
    context->getLoader()->load( _loadRequest.get(), priority, nv );
}
Beispiel #15
0
void
DrapeableNode::traverse( osg::NodeVisitor& nv )
{
    if ( !_overlayProxyContainer.valid() )
    {
        osg::Group::traverse( nv );
    }
    else
    {
        if ( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
        {
            if ( _draped )
            {
                // for a draped node, inform the proxy that we are visible. But do NOT traverse the
                // child graph (since it will be traversed by the OverlayDecorator).
                CullNodeByFrameNumber* cb = static_cast<CullNodeByFrameNumber*>(_overlayProxyContainer->getCullCallback());
                if (cb)
                {
                    cb->_frame = nv.getFrameStamp()->getFrameNumber();
                }
            }
            else
            {
                // for a non-draped node, just traverse children as usual.
                osg::Group::traverse( nv );
            }
        }

        else if ( nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR )
        {
            if ( _dirty )
            {
                applyChanges();
                _dirty = false;
                ADJUST_UPDATE_TRAV_COUNT( this, -1 );
            }
            
            // traverse children directly, regardles of draped status
            osg::Group::traverse( nv );
        }

        // handle other visitor types (like intersections, etc) by simply
        // traversing the child graph.
        else // if ( nv.getNodeVisitor() == osg::NodeVisitor::NODE_VISITOR )
        {
            osg::Group::traverse( nv );
        }
    }
}
void MultiPassTerrainTechnique::traverse(osg::NodeVisitor& nv)
{
    if (!_tile) return;

    // initialize the terrain tile on startup
    if (_tile->getDirty() && !_terrainTileInitialized) 
    {
        _tile->init();
        _terrainTileInitialized = true;

#if 0
#if OSG_MIN_VERSION_REQUIRED(2,9,8)
        _terrainTile->init(~0x0, true);
#else
        _terrainTile->init();
#endif

        _terrainTileInitialized = true;
#endif
    }
    
    if ( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
    {
        updateTransparency();
    }

    // traverse the dynamically-generated geometry.
    if (_transform.valid()) 
        _transform->accept(nv);
}
Beispiel #17
0
void
TerrainNode::traverse( osg::NodeVisitor &nv )
{
    if ( nv.getVisitorType() == nv.UPDATE_VISITOR )
    {
        // if the terrain engine requested "quick release", install the quick release
        // draw callback now.
        if ( !_quickReleaseCallbackInstalled && _tilesToQuickRelease.valid() )
        {
            osg::Camera* cam = findFirstParentOfType<osg::Camera>( this );
            if ( cam )
            {
                // get the installed PDC so we can nest them:
                osg::Camera::DrawCallback* cbToNest = cam->getPostDrawCallback();

                // if it's another QR callback, we'll just replace it.
                QuickReleaseGLObjects* previousQR = dynamic_cast<QuickReleaseGLObjects*>(cbToNest);
                if ( previousQR )
                    cbToNest = previousQR->_next.get();

                cam->setPostDrawCallback( new QuickReleaseGLObjects(
                                              _tilesToQuickRelease.get(),
                                              cbToNest ) );

                _quickReleaseCallbackInstalled = true;
                OE_INFO << LC << "Quick release enabled" << std::endl;

                // knock down the trav count set in the constructor.
                ADJUST_UPDATE_TRAV_COUNT( this, -1 );
            }
        }
    }

    osg::Group::traverse( nv );
}
void ossimPlanetAnnotationLayer::traverse(osg::NodeVisitor& nv)
{
   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theGraphMutex);
   switch(nv.getVisitorType())
	{
		case osg::NodeVisitor::UPDATE_VISITOR:
		{
         {
				OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theNodesToRemoveListMutex);
           ossimPlanetNode::NodeListType::iterator iter = theNodesToRemoveList.begin();
            while(iter != theNodesToRemoveList.end())
            {
               ossimPlanetNode::remove((*iter).get());
               ++iter;
            }
            theNodesToRemoveList.clear();
         }
			break;
		}
		default:
		{
			break;
		}
	}
	ossimPlanetLayer::traverse(nv);
}
Beispiel #19
0
void
TilePagedLOD::traverse(osg::NodeVisitor& nv)
{
    // Only traverse the TileNode if our neighbors (the other members of
    // our group of four) are ready as well.
    if ( _children.size() > 0 )
    {
        _children[0]->setNodeMask( _familyReady ? ~0 : 0 );

        // find our tile node:
        TileNode* tilenode = dynamic_cast<TileGroup*>(_children[0].get()) ? 
            static_cast<TileGroup*>(_children[0].get())->getTileNode() :
            static_cast<TileNode*>(_children[0].get());

        // Check whether the TileNode is marked dirty. If so, install a new pager request 
        // to reload and replace the TileNode.
        if (nv.getVisitorType() == nv.CULL_VISITOR &&
            this->getNumFileNames() < 2 && 
            tilenode->isOutOfDate() )
        {
            // lock keeps multiple CullVisitors from doing the same thing
            Threading::ScopedMutexLock exclusive( _updateMutex );

            if ( this->getNumFileNames() < 2 ) // double-check pattern
            {
                //OE_WARN << LC << "Queuing request for replacement: " << _container->getTileNode()->getKey().str() << std::endl;
                this->setFileName( 1, Stringify() << _prefix << ".osgearth_engine_mp_standalone_tile" );
                this->setRange( 1, 0, FLT_MAX );
            }
        }
    }

    osg::PagedLOD::traverse( nv );
}
Beispiel #20
0
void ossimPlanetLayer::traverse(osg::NodeVisitor& nv)
{
   switch(nv.getVisitorType())
   {
      case osg::NodeVisitor::EVENT_VISITOR:
      {
         if(redrawFlag())
         {
            osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
            if(ev)
            {
               if(ev->getActionAdapter())
               {
                  ev->getActionAdapter()->requestRedraw();
                  setRedrawFlag(false);
               }
            }
         }
         return;
      }
      case osg::NodeVisitor::UPDATE_VISITOR:
      {
         if(!thePlanet)
         {
            setPlanet(ossimPlanet::findPlanet(this));
         }
         break;
      }
      default:
      {
         
      }
   }
   ossimPlanetNode::traverse(nv);
}
void
AnnotationNode::traverse(osg::NodeVisitor& nv)
{
    if (nv.getVisitorType() == nv.UPDATE_VISITOR)
    {
        // MapNode auto discovery.
        if (_mapNodeRequired)
        {
            if (getMapNode() == 0L)
            {
                MapNode* mapNode = osgEarth::findInNodePath<MapNode>(nv);
                if (mapNode)
                {
                    setMapNode(mapNode);
                }
            }

            if (getMapNode() != 0L)
            {
                _mapNodeRequired = false;
                ADJUST_UPDATE_TRAV_COUNT(this, -1);
            }
        }
    }
    osg::Group::traverse(nv);
}
Beispiel #22
0
void
TerrainEngineNode::traverse( osg::NodeVisitor& nv )
{
    if ( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
    {
        if ( Registry::instance()->getCapabilities().supportsGLSL() )
        {
            _updateLightingUniformsHelper.cullTraverse( this, &nv );

            osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>( &nv );
            if ( cv )
            {
                osg::Vec3d eye = cv->getEyePoint();

                float elevation;
                if ( _map->isGeocentric() )
                    elevation = eye.length() - osg::WGS_84_RADIUS_EQUATOR;
                else
                    elevation = eye.z();

                _cameraElevationUniform->set( elevation );
            }
        }
    }

    //else if ( nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR )
    //{
    //    if ( Registry::instance()->getCapabilities().supportsGLSL() )
    //        _updateLightingUniformsHelper.updateTraverse( this );
    //}

    osg::CoordinateSystemNode::traverse( nv );
}
Beispiel #23
0
void Technique::traverse_implementation(osg::NodeVisitor& nv, Effect* fx)
{
    // define passes if necessary
    if (_passes.empty()) {
        define_passes();
    }

    // special actions must be taken if the node visitor is actually a CullVisitor
    osgUtil::CullVisitor* cv = nv.asCullVisitor();
    if (cv)
    {
        // traverse all passes
        for (int i=0; i<getNumPasses(); ++i)
        {
            // push the i-th pass' StateSet
            cv->pushStateSet(_passes[i].get());

            // traverse the override node if defined, otherwise
            // traverse children as a Group would do
            osg::Node *override = getOverrideChild(i);
            if (override) {
                override->accept(nv);
            } else {
                fx->inherited_traverse(nv);
            }

            // pop the StateSet
            cv->popStateSet();
        }
void
StreamingTerrainNode::updateTraversal( osg::NodeVisitor& nv )
{
    // this stamp keeps track of when requests are dispatched. If a request's stamp gets too
    // old, it is considered "expired" and subject to cancelation
    int stamp = nv.getFrameStamp()->getFrameNumber();

    // update the frame stamp on the task services. This is necessary to support 
    // automatic request cancelation for image requests.
    {
        ScopedLock<Mutex> lock( _taskServiceMutex );
        for (TaskServiceMap::iterator i = _taskServices.begin(); i != _taskServices.end(); ++i)
        {
            i->second->setStamp( stamp );
        }
    }

    // next, go through the live tiles and process update-traversal requests. This
    // requires a read-lock on the master tiles table.
    {
        Threading::ScopedReadLock tileTableReadLock( _tilesMutex );

        for( TileTable::const_iterator i = _tiles.begin(); i != _tiles.end(); ++i )
        {
            StreamingTile* tile = static_cast<StreamingTile*>( i->second.get() );

            // update the neighbor list for each tile.
            refreshFamily( _update_mapf.getMapInfo(), tile->getKey(), tile->getFamily(), true );

            tile->servicePendingElevationRequests( _update_mapf, stamp, true );                   
            tile->serviceCompletedRequests( _update_mapf, true );
        }
    }
}
void
GraticuleLabelingEngine::traverse(osg::NodeVisitor& nv)
{
    if (nv.getVisitorType() == nv.CULL_VISITOR)
    {
        osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
        if (cv)
        {
            // Find the data corresponding to this camera:
            CameraData& data = _cameraDataMap.get(cv->getCurrentCamera());
            bool visible = cullTraverse(*cv, data);
            data.visible = visible;
            if (visible)
            {
                // traverse all the labels for this camera:
                AcceptCameraData accept(nv);
                accept(data);
            }
        }
    }
    else
    {
        AcceptCameraData accept(nv);
        _cameraDataMap.forEach(accept);
    }
    
    osg::Group::traverse(nv);
}
Beispiel #26
0
void
LabelNode::traverse(osg::NodeVisitor &nv)
{
    if(_followFixedCourse)
    {
        osgUtil::CullVisitor* cv = NULL;
        if ( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
        {
            cv = Culling::asCullVisitor(nv);
            osg::Camera* camera = cv->getCurrentCamera();

            osg::Matrix matrix;
            matrix.postMult(camera->getViewMatrix());
            matrix.postMult(camera->getProjectionMatrix());
            if (camera->getViewport())
                matrix.postMult(camera->getViewport()->computeWindowMatrix());

            GeoPoint pos( osgEarth::SpatialReference::get("wgs84"),
                          getPosition().x(),
                          getPosition().y(),
                          0,
                          osgEarth::ALTMODE_ABSOLUTE );

            osg::Vec3d refOnWorld; pos.toWorld(refOnWorld);
            osg::Vec3d projOnWorld; _geoPointProj.toWorld(projOnWorld);
            osg::Vec3d refOnScreen = refOnWorld * matrix;
            osg::Vec3d projOnScreen = projOnWorld * matrix;
            projOnScreen -= refOnScreen;
            _labelRotationRad = atan2 (projOnScreen.y(), projOnScreen.x());
            if (_dataLayout.valid())
                _dataLayout->setRotationRad(_labelRotationRad);
        }
    }
    GeoPositionNode::traverse(nv);
}
Beispiel #27
0
void
TileNode::traverse(osg::NodeVisitor& nv)
{
    // Cull only:
    if ( nv.getVisitorType() == nv.CULL_VISITOR )
    {
        cull(nv);
    }

    // Everything else: update, GL compile, intersection, compute bound, etc.
    else
    {
        // If there are child nodes, traverse them:
        int numChildren = getNumChildren();
        if ( numChildren > 0 )
        {
            for(int i=0; i<numChildren; ++i)
            {
                _children[i]->accept( nv );
            }
        }

        // Otherwise traverse the surface.
        // TODO: in what situations should we traverse the landcover as well? GL compile?
        else 
        {
            _surface->accept( nv );
        }
    }
}
Beispiel #28
0
void Horizon3DTileNode2::traverse(osg::NodeVisitor &nv)
{
    if(nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
    {
        _nodes.at(0)->accept(nv);
    }
}
Beispiel #29
0
void
GeometryPool::traverse(osg::NodeVisitor& nv)
{
    if (nv.getVisitorType() == nv.UPDATE_VISITOR && _releaser.valid() && _enabled)
    {
        // look for usused pool objects and push them to the resource releaser.
        ResourceReleaser::ObjectList objects;
        {
            Threading::ScopedMutexLock exclusive( _geometryMapMutex );

            std::vector<GeometryKey> keys;

            for (GeometryMap::iterator i = _geometryMap.begin(); i != _geometryMap.end(); ++i)
            {
                if (i->second.get()->referenceCount() == 1)
                {
                    keys.push_back(i->first);
                    objects.push_back(i->second.get());
                }
            }
            for (std::vector<GeometryKey>::iterator key = keys.begin(); key != keys.end(); ++key)
            {
                _geometryMap.erase(*key);
            }
        }

        if (!objects.empty())
        {
            _releaser->push(objects);
        }
    }

    osg::Group::traverse(nv);
}
void ShadowMap::traverse( osg::NodeVisitor& nv )
{
    if( ( nv.getVisitorType() != osg::NodeVisitor::CULL_VISITOR ) )
    {
        // Not the cull visitor. Traverse as a Group and return.
        osg::Group::traverse( nv );
        return;
    }

    // Dealing with cull traversal from this point onwards.
    osgUtil::CullVisitor* cv = static_cast< osgUtil::CullVisitor* >( &nv );

    // BackdropCommon cull processing.
    processCull( cv );


    //
    // Basic idea of what follows was derived from CullVisitor::apply( Camera& ).
    //

    osgUtil::RenderStage* previousStage = cv->getCurrentRenderBin()->getStage();
    osg::Camera* camera = previousStage->getCamera();

    osg::ref_ptr< RenderStageCache > rsCache = dynamic_cast< RenderStageCache* >( getRenderingCache() );
    if( !rsCache )
    {
        rsCache = new RenderStageCache;
        UTIL_MEMORY_CHECK( rsCache, "ShadowMap ShadowMapStage Cache", );
        setRenderingCache( rsCache.get() );
    }