This file is indexed.

/usr/include/osgEarth/CullingUtils 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
/* -*-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_CULLING_UTILS_H
#define OSGEARTH_CULLING_UTILS_H 1

#include <osgEarth/Common>
#include <osgEarth/optional>
#include <osgEarth/SpatialReference>
#include <osgEarth/Horizon>
#include <osgEarth/GeoTransform>

#include <osg/NodeCallback>
#include <osg/ClusterCullingCallback>
#include <osg/CoordinateSystemNode>
#include <osg/MatrixTransform>
#include <osg/Vec3d>
#include <osg/Vec3>
#include <osg/ClipPlane>
#include <osgUtil/CullVisitor>

namespace osgEarth
{    
    /**
     * A customized CCC that works correctly under an RTT camera and also with 
     * an orthographic projection matrix.
     */
    class SuperClusterCullingCallback : public osg::ClusterCullingCallback
    {
    public:
        bool cull(osg::NodeVisitor* nv, osg::Drawable* , osg::State*) const;
    };


    /**
     * Utility functions for creating cluster cullers
     */
    class OSGEARTH_EXPORT ClusterCullingFactory
    {
    public:
        /**
         * Creates a cluster culling callback based on the data in a node graph.
         * NOTE! Never put a CCC somewhere where it will be under a transform. They
         * only work in absolute world space.
         */
        static osg::NodeCallback* create( osg::Node* node, const osg::Vec3d& ecefControlPoint );

        /**
         * Same as above, but uses another method to compute the parameters. There should only
         * be one, but we need to investigate to see which is the better algorithm. Keeping this
         * for now since it works with the feature setup..
         */
        static osg::NodeCallback* create2( osg::Node* node, const osg::Vec3d& ecefControlPoint );

        /**
         * Creates a cluster culling callback and installs it on the node. If the node is
         * a transform, it will create a group above the transform and install the callback
         * on that group instead.
         */
        static osg::Node* createAndInstall( osg::Node* node, const osg::Vec3d& ecefControlPoint );

        /**
         * Creates a cluster culling callback with the standard parameters.
         */
        static osg::NodeCallback* create(const osg::Vec3& controlPoint, const osg::Vec3& normal, float deviation, float radius);        

        /**
         * Creates a cluster culling callback based on an extent (for geocentric tiles).
         */
        static osg::NodeCallback* create(const class GeoExtent& extent);
    };

    
    /**
     * A simple culling-plane callback (a simpler version of ClusterCullingCallback)
     * @deprecated
     */
    struct OSGEARTH_EXPORT CullNodeByNormal : public osg::NodeCallback {
        osg::Vec3d _normal;
        CullNodeByNormal( const osg::Vec3d& normal );
        void operator()(osg::Node* node, osg::NodeVisitor* nv);
    };

    // @deprecated
    struct CullDrawableByNormal : public osg::Drawable::CullCallback {
        osg::Vec3d _normal;
        CullDrawableByNormal( const osg::Vec3d& normal ) : _normal(normal) { }
        bool cull(osg::NodeVisitor* nv, osg::Drawable* drawable, osg::State* state) const {
            return nv && nv->getEyePoint() * _normal <= 0;
        }
    };

    // @deprecated
    struct OSGEARTH_EXPORT CullNodeByFrameNumber : public osg::NodeCallback {
        unsigned _frame;
        CullNodeByFrameNumber() : _frame(0) { }
        void operator()( osg::Node* node, osg::NodeVisitor* nv ) {
            if ( nv->getFrameStamp()->getFrameNumber() - _frame <= 1 )
                traverse(node, nv);
        }
    };

    // @deprecated
    struct DisableSubgraphCulling : public osg::NodeCallback {
        void operator()(osg::Node* n, osg::NodeVisitor* v);
    };

    // @deprecated
    struct StaticBound : public osg::Node::ComputeBoundingSphereCallback {
        osg::BoundingSphere _bs;
        StaticBound(const osg::BoundingSphere& bs) : _bs(bs) { }
        osg::BoundingSphere computeBound(const osg::Node&) const { return _bs; }
    };

    // a cull callback that prevents objects from being included in the near/fear clip
    // plane calculates that OSG does.
    // @deprecated
    struct OSGEARTH_EXPORT DoNotComputeNearFarCullCallback : public osg::NodeCallback
    {
        void operator()(osg::Node* node, osg::NodeVisitor* nv);
    };

    /**
     * Simple occlusion culling callback that does a ray interseciton between the eyepoint
     * and a A GeoTransform node.
     */
    struct OSGEARTH_EXPORT OcclusionCullingCallback : public osg::NodeCallback
    {
        OcclusionCullingCallback(GeoTransform* xform);

        /** Maximum eye altitude at which to perform the occlusion culling test */
        double getMaxAltitude() const;
        void setMaxAltitude( double value);

        /**
        * Gets the maximum number of ms that the OcclusionCullingCallback can run on each frame.
        */
        static double getMaxFrameTime();

        /**
        * Sets the maximum number of ms that the OcclusionCullingCallback can run on each frame.
        * @param ms
        *     The maximum number of milliseconds to run the OcclusionCullingCallback on each frame. 
        */
        static void setMaxFrameTime( double ms );

    public: //NodeCallback
        
        void operator()(osg::Node* node, osg::NodeVisitor* nv);

    private:

        osg::observer_ptr<GeoTransform> _xform;
        osg::Vec3d _prevEye;
        bool _visible;
        double _maxAltitude;
        static double _maxFrameTime;
    };

    /**
     * Culling utilities.
     */
    struct OSGEARTH_EXPORT Culling
    {
        static osgUtil::CullVisitor* asCullVisitor(osg::NodeVisitor* nv);
        static osgUtil::CullVisitor* asCullVisitor(osg::NodeVisitor& nv) { return asCullVisitor(&nv); }
    };

    /**
     * Node Visitor that proxies the CullVisitor but uses a separate
     * frustum for bounds-culling.
     */
    class ProxyCullVisitor : public osg::NodeVisitor, public osg::CullStack
    {
    private:
        osgUtil::CullVisitor* _cv;
        osg::Polytope         _proxyFrustum;
        osg::Polytope         _proxyProjFrustum;
        osg::Matrix           _proxyModelViewMatrix;
        osg::Matrix           _proxyProjMatrix;

    public:
        ProxyCullVisitor( osgUtil::CullVisitor* cv, const osg::Matrix& proj, const osg::Matrix& view );

        // access to the underlying cull visitor.
        osgUtil::CullVisitor* getCullVisitor() { return _cv; }

        bool isCulledByProxyFrustum(osg::Node& node);
        bool isCulledByProxyFrustum(const osg::BoundingBox& bbox);

    public: // proxy functions:
        osg::Vec3 getEyePoint() const;
        osg::Vec3 getViewPoint() const;
        float getDistanceToEyePoint(const osg::Vec3& pos, bool useLODScale) const;
        float getDistanceFromEyePoint(const osg::Vec3& pos, bool useLODScale) const;
        float getDistanceToViewPoint(const osg::Vec3& pos, bool useLODScale) const;

    protected:
        
        osgUtil::CullVisitor::value_type distance(const osg::Vec3& coord,const osg::Matrix& matrix);

        void handle_cull_callbacks_and_traverse(osg::Node& node);

        void apply(osg::Node& node);
        void apply(osg::Transform& xform);
        void apply(osg::Geode& geode);
        void apply(osg::Drawable& drawable);
        void apply(osg::LOD& lod);
    };


    /**
     * Horizon culling in a shader program.
     */
    class OSGEARTH_EXPORT HorizonCullingProgram
    {
    public:
        static void install( osg::StateSet* stateset );
        static void remove ( osg::StateSet* stateset );
    };


    /**
     * Group that lets you adjust the LOD scale on its children.
     */
    class OSGEARTH_EXPORT LODScaleGroup : public osg::Group
    {
    public:
        LODScaleGroup();

        /**
         * Factor by which to multiply the camera's LOD scale.
         */
        void setLODScaleFactor( float value ) { _scaleFactor = value; }
        float getLODScaleFactor() const { return _scaleFactor; }

    public: // osg::Group
        virtual void traverse(osg::NodeVisitor& nv);

    protected:
        virtual ~LODScaleGroup() { }

    private:
        float _scaleFactor;
    };


    
    /**
     * Cull callback that sets a clip plane at the visible horizon
     * of the Ellipsoid.
     */
    class OSGEARTH_EXPORT ClipToGeocentricHorizon : public osg::NodeCallback
    {
    public:
        ClipToGeocentricHorizon(
            const osgEarth::SpatialReference* srs,
            osg::ClipPlane*                   clipPlane);
        
        void operator()(osg::Node* node, osg::NodeVisitor* nv);

    protected:
        osg::ref_ptr<Horizon>             _horizon;
        osg::observer_ptr<osg::ClipPlane> _clipPlane;
    };


    struct OSGEARTH_EXPORT CullDebugger
    {
        Config dumpRenderBin(osgUtil::RenderBin* bin) const;
    };


    /**
     * Cull callback for cameras that sets the oe_ViewportSize uniform.
     */
    class OSGEARTH_EXPORT InstallViewportSizeUniform : public osg::NodeCallback
    {
    public:
        void operator()(osg::Node* node, osg::NodeVisitor* nv) {
            osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
            const osg::Camera* camera = cv->getCurrentCamera();
            osg::ref_ptr<osg::StateSet> ss;
            if (camera && camera->getViewport()) {
                ss = new osg::StateSet();
                ss->addUniform(new osg::Uniform("oe_ViewportSize", osg::Vec2f(
                    camera->getViewport()->width(),
                    camera->getViewport()->height())));
                cv->pushStateSet(ss.get());
            }
            traverse(node, nv);
            if (ss.valid())
                cv->popStateSet();
        }
    };
}

#endif // OSGEARTH_CULLING_UTILS_H