This file is indexed.

/usr/include/osgEarth/TerrainEngineNode is in libosgearth-dev 2.9.0+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2016 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
#ifndef OSGEARTH_TERRAIN_ENGINE_NODE_H
#define OSGEARTH_TERRAIN_ENGINE_NODE_H 1

#include <osgEarth/Map>
#include <osgEarth/MapFrame>
#include <osgEarth/Terrain>
#include <osgEarth/TerrainEffect>
#include <osgEarth/TerrainTileModelFactory>
#include <osgEarth/TerrainTileNode>
#include <osgEarth/TerrainEngineRequirements>
#include <osgEarth/TerrainResources>
#include <osgEarth/ShaderUtils>
#include <osgEarth/Progress>
#include <osg/CoordinateSystemNode>
#include <osg/Geode>
#include <osg/NodeCallback>
#include <osgUtil/RenderBin>
#include <set>

#define OSGEARTH_ENV_TERRAIN_ENGINE_DRIVER "OSGEARTH_TERRAIN_ENGINE"


namespace osgUtil {
    class CullVisitor;
}

namespace osgEarth
{
    class TerrainEffect;
    class VirtualProgram;

    /**
     * Interface for and object that can create a new terrain tile models
     */
    class /*interface*/ TerrainEngine
    {
    public:
        /**
         * Callback for new node creation.
         */
        class NodeCallback : public osg::Referenced
        {
        public:
            virtual void operator()(const TileKey& key, osg::Node* node) =0;

        protected:
            NodeCallback() { }
            virtual ~NodeCallback() { }
        };

    public:
        /**
         * Unique ID of this engine.
         */
        virtual UID getUID() const =0;

        /**
         * Creates a new data model for a terrain tile, calling any registered
         * CreateTileModelCallbacks before returning the new object.
         *
         * @param frame  Map frame from which to create the new tile model
         * @param key    Key for which to create the new tile model
         * @param layers UIDs of layers to fetch data for; NULL => all layers
         * @param progress Optional progress/stats tracking callback
         */
        virtual TerrainTileModel* createTileModel(
            const MapFrame&              frame,
            const TileKey&               key,
            const CreateTileModelFilter& filter,
            ProgressCallback*            progress ) =0;

        
        /**
         * Notify the engine of a completed tile node creation, so it can 
         * activate callbacks. (This might happen in a pager thread.)
         *
         * @param key  TileKey corresponding to the new Node
         * @param node The new terrain node.
         */
        virtual void notifyOfTerrainTileNodeCreation(
            const TileKey& key,
            osg::Node*     node) =0;
    };



    /**
     * A callback that lets you customize the computed range for a terrain tile.
     * Providing a custom range can let applications better control how paging behaves.
     */
    struct ComputeRangeCallback : public osg::Referenced
    {
        virtual float operator()(osg::Node* node, osg::NodeVisitor& nv) = 0;
    };


    /**
     * TerrainEngineNode is the base class and interface for map engine implementations.
     *
     * A map engine lives under a MapNode and is responsible for generating the
     * actual geometry representing the Earth.
     */
    class OSGEARTH_EXPORT TerrainEngineNode : public osg::CoordinateSystemNode,
                                              public TerrainEngine,
                                              public TerrainEngineRequirements
    {
    public:
        /** Gets the map that this engine is rendering. */
        const Map* getMap() const { return _map.get(); }

        /** Gets the Terrain interface for interacting with the scene graph */
        Terrain* getTerrain() { return _terrainInterface.get(); }
        const Terrain* getTerrain() const { return _terrainInterface.get(); }

        /** Gets the property set in use by this map engine. */
        virtual const TerrainOptions& getTerrainOptions() const =0;

        /** Accesses the object that keeps track of GPU resources in use */
        TerrainResources* getResources() const;

        /** Adds a terrain effect */
        void addEffect( TerrainEffect* effect );

        /** Removes a terrain effect */
        void removeEffect( TerrainEffect* effect );

        /**
         * Marks the terrain tiles intersecting the provied extent as invalid.
         * If the terrain engine supports incremental update, it will reload
         * invalid tiles. If not, it will simple regenerate all tiles in the 
         * terrain (which might be slow).
         */
        virtual void invalidateRegion(
            const GeoExtent& extent,
            unsigned         minLevel,
            unsigned         maxLevel) { }

        // See invalidateRegion() above.
        void invalidateRegion(const GeoExtent& extent) {
            invalidateRegion(extent, 0u, INT_MAX);
        }

        /** Whether the implementation should generate normal map rasters. */
        void requireNormalTextures();
        
        /** Whether the implementation should generate elevation map rasters. */
        void requireElevationTextures();

        /** Whether the implementation should generate parent color textures. */
        void requireParentTextures();

        /** Access the stateset used to render the terrain. */
        virtual osg::StateSet* getSurfaceStateSet() { return getOrCreateStateSet(); }

        /** Gets the ComputeRangeCallback for this TerrainEngineNode */
        ComputeRangeCallback* getComputeRangeCallback() const;

        /** Sets the ComputeRangeCallback for this TerrainEngineNode */
        void setComputeRangeCallback(ComputeRangeCallback* computeRangeCallback);

        // Request that the terrain tiles be rebuilt.
        virtual void dirtyTerrain();



    public: // TerrainEngine

        TerrainTileModel* createTileModel(
            const MapFrame&              frame,
            const TileKey&               key,
            const CreateTileModelFilter& filter,
            ProgressCallback*            progress);

        void notifyOfTerrainTileNodeCreation(
            const TileKey& key, 
            osg::Node*     node);

    public:

        /**
         * Callback for customizing the TileModel.
         */
        class CreateTileModelCallback : public osg::Referenced
        {
        public:
            virtual void onCreateTileModel(
                TerrainEngineNode* engine,
                TerrainTileModel*  model) = 0;
        };

        /**
         * Adds a TileModel creation callback, so you can add custom data
         * to the TileModel after it's created.
         */
        void addCreateTileModelCallback(CreateTileModelCallback* callback);
        void removeCreateTileModelCallback(CreateTileModelCallback* callback);


    public: // TerrainEngineRequirements

        bool normalTexturesRequired() const { return _requireNormalTextures; }
        bool elevationTexturesRequired() const { return _requireElevationTextures; }
        bool parentTexturesRequired() const { return _requireParentTextures; }
        bool elevationBorderRequired() const { return _requireElevationBorder; }
        bool fullDataAtFirstLodRequired() const { return _requireFullDataAtFirstLOD; }

    protected:
        TerrainEngineNode();
        virtual ~TerrainEngineNode();

    public: // osg::Node overrides
        virtual osg::BoundingSphere computeBound() const;
        virtual void traverse( osg::NodeVisitor& );

    protected:
        friend class MapNode;
        friend class TerrainEngineNodeFactory;

        virtual void setMap(const Map* map, const TerrainOptions& options);

        // signals that a redraw is needed because something changed.
        virtual void requestRedraw();

        // Request the state setup be refreshed because something has changed that requires new
        // shaders, state, etc.
        virtual void dirtyState() { }

        osg::ref_ptr<TerrainResources> _textureResourceTracker;

        bool _requireElevationTextures;
        bool _requireNormalTextures;
        bool _requireParentTextures;
        bool _requireElevationBorder;
        bool _requireFullDataAtFirstLOD;

        // called by addTileNodeCallback to notify any already-existing nodes
        // of the new callback.
        virtual void notifyExistingNodes(TerrainEngine::NodeCallback* cb) { }

    public: // utility

        /**
         * Utility function that will return an osg::Node representing the geometry
         * for a tile key. The node is standalone; it has no ability to load children
         * or receive updates.
         *
         * TODO: deprecate in favor of a separate utility for creating simple
         * geometry out of a TerrainTileModel. -gw
         */
        virtual osg::Node* createTile(const TileKey& key) =0;

        //! Flags that affect the createTile behavior.
        enum CreateTileFlags
        {
            CREATE_TILE_INCLUDE_TILES_WITH_MASKS     = 1,
            CREATE_TILE_INCLUDE_TILES_WITHOUT_MASKS  = 2,
            CREATE_TILE_DEFAULT_FLAGS                = ~0 /* all */
        };

        /**
         * Utility for creating standalone tile geometry from a tile model.
         * Note: experimental.
         * @param model Tile model for which to build a tile
         * @param flags OR of the CreateTileFlags enums
         * @param referenceLOD If non-zero, adjust the vertex dimensions of the returned tile
         *        to match this LOD. Example: ask for a tile at tileKey.lod=15, tile is 17x17.
         *        Specific a referenceLOD=16, tile will be 33x33.
         */
        virtual osg::Node* createTile(
            const TerrainTileModel* model,
            int createTileFlags =CREATE_TILE_DEFAULT_FLAGS,
            unsigned referenceLOD =0u) { return 0L; }

    private:
        friend struct TerrainEngineNodeCallbackProxy;
        friend struct MapNodeMapLayerController;

        void ctor();
        void onMapInfoEstablished( const MapInfo& mapInfo ); // not virtual!
        void onMapModelChanged( const MapModelChange& change );
        virtual void updateTextureCombining() { }

    private:
        
        struct ImageLayerController : public ImageLayerCallback
        {
            ImageLayerController( const Map* map, TerrainEngineNode* engine );
            void onColorFiltersChanged( ImageLayer* layer ); 

        private:
            MapFrame           _mapf;
            TerrainEngineNode* _engine;
            friend class TerrainEngineNode;
        };

        osg::ref_ptr<ImageLayerController> _imageLayerController;
        osg::ref_ptr<const Map>            _map;
        bool                               _redrawRequired;
        float                              _verticalScale;
        osg::ref_ptr<Terrain>              _terrainInterface;
        unsigned                           _dirtyCount;
        bool                               _updateScheduled;
        
        enum InitStage {
            INIT_NONE,
            INIT_PREINIT_COMPLETE,
            INIT_POSTINIT_COMPLETE
        };
        InitStage _initStage;

        typedef std::vector<osg::ref_ptr<TerrainEffect> > TerrainEffectVector;
        TerrainEffectVector effects_;

        typedef std::vector<osg::ref_ptr<TerrainEngine::NodeCallback> > NodeCallbackVector;
        NodeCallbackVector _tileNodeCallbacks;
        mutable Threading::Mutex _tileNodeCallbacksMutex;
        
        typedef std::vector<osg::ref_ptr<CreateTileModelCallback> > CreateTileModelCallbacks;
        CreateTileModelCallbacks _createTileModelCallbacks;
        mutable Threading::ReadWriteMutex _createTileModelCallbacksMutex;

        osg::ref_ptr<TerrainTileModelFactory> _tileModelFactory;

        osg::ref_ptr<ComputeRangeCallback> _computeRangeCallback;


    public:

        /** Access a typed effect. */
        template<typename T>
        T* getEffect() {
            for(TerrainEffectVector::iterator i = effects_.begin(); i != effects_.end(); ++i ) {
                T* e = dynamic_cast<T*>(i->get());
                if ( e ) return e;
            }
            return 0L;
        }
    };

    /**
     * Factory class for creating terrain engine instances.
     */
    class TerrainEngineNodeFactory
    {
    public:
        static TerrainEngineNode* create(const TerrainOptions& options );
    };

} // namespace osgEarth

#endif // OSGEARTH_TERRAIN_ENGINE_NODE_H