This file is indexed.

/usr/include/simgear/bvh/BVHNearestPointVisitor.hxx is in libsimgear-dev 3.0.0-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
// Copyright (C) 2008 - 2009  Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// 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 GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//

#ifndef BVHNearestPointVisitor_hxx
#define BVHNearestPointVisitor_hxx

#include <simgear/math/SGGeometry.hxx>

#include "BVHVisitor.hxx"

#include "BVHNode.hxx"
#include "BVHGroup.hxx"
#include "BVHPageNode.hxx"
#include "BVHTransform.hxx"
#include "BVHLineGeometry.hxx"
#include "BVHStaticGeometry.hxx"

#include "BVHStaticData.hxx"

#include "BVHStaticNode.hxx"
#include "BVHStaticTriangle.hxx"
#include "BVHStaticBinary.hxx"

namespace simgear {

class BVHNearestPointVisitor : public BVHVisitor {
public:
    BVHNearestPointVisitor(const SGSphered& sphere, const double& t) :
        _sphere(sphere),
        _time(t),
        _material(0),
        _id(0),
        _havePoint(false)
    { }
    
    virtual void apply(BVHGroup& leaf)
    {
        if (!intersects(_sphere, leaf.getBoundingSphere()))
            return;
        leaf.traverse(*this);
    }
    virtual void apply(BVHPageNode& leaf)
    {
        if (!intersects(_sphere, leaf.getBoundingSphere()))
            return;
        leaf.traverse(*this);
    }
    virtual void apply(BVHTransform& transform)
    {
        if (!intersects(_sphere, transform.getBoundingSphere()))
            return;
        
        SGSphered sphere = _sphere;
        _sphere = transform.sphereToLocal(sphere);
        bool havePoint = _havePoint;
        _havePoint = false;
        
        transform.traverse(*this);
        
        if (_havePoint) {
            _point = transform.ptToWorld(_point);
            _linearVelocity = transform.vecToWorld(_linearVelocity);
            _angularVelocity = transform.vecToWorld(_angularVelocity);
        }
        _havePoint |= havePoint;
        _sphere.setCenter(sphere.getCenter());
    }
    virtual void apply(BVHMotionTransform& transform)
    {
        if (!intersects(_sphere, transform.getBoundingSphere()))
            return;
        
        SGSphered sphere = _sphere;
        _sphere = transform.sphereToLocal(sphere, _time);
        bool havePoint = _havePoint;
        _havePoint = false;
        
        transform.traverse(*this);
        
        if (_havePoint) {
            SGMatrixd toWorld = transform.getToWorldTransform(_time);
            SGVec3d localCenter = _sphere.getCenter();
            _linearVelocity += transform.getLinearVelocityAt(localCenter);
            _angularVelocity += transform.getAngularVelocity();
            _linearVelocity = toWorld.xformVec(_linearVelocity);
            _angularVelocity = toWorld.xformVec(_angularVelocity);
            _point = toWorld.xformPt(_point);
            if (!_id)
                _id = transform.getId();
        }
        _havePoint |= havePoint;
        _sphere.setCenter(sphere.getCenter());
    }
    virtual void apply(BVHLineGeometry& node)
    { }
    virtual void apply(BVHStaticGeometry& node)
    {
        if (!intersects(_sphere, node.getBoundingSphere()))
            return;
        node.traverse(*this);
    }
    
    virtual void apply(const BVHStaticBinary& node, const BVHStaticData& data)
    {
        if (!intersects(_sphere, node.getBoundingBox()))
            return;
        node.traverse(*this, data, _sphere.getCenter());
    }
    virtual void apply(const BVHStaticTriangle& node, const BVHStaticData& data)
    {
        SGVec3f center(_sphere.getCenter());
        SGVec3d closest(closestPoint(node.getTriangle(data), center));
        if (!intersects(_sphere, closest))
            return;
        _point = closest;
        _linearVelocity = SGVec3d::zeros();
        _angularVelocity = SGVec3d::zeros();
        _material = data.getMaterial(node.getMaterialIndex());
        // The trick is to decrease the radius of the search sphere.
        _sphere.setRadius(length(closest - _sphere.getCenter()));
        _havePoint = true;
        _id = 0;
    }
    
    void setSphere(const SGSphered& sphere)
    { _sphere = sphere; }
    const SGSphered& getSphere() const
    { return _sphere; }
    
    const SGVec3d& getPoint() const
    { return _point; }
    const SGVec3d& getLinearVelocity() const
    { return _linearVelocity; }
    const SGVec3d& getAngularVelocity() const
    { return _angularVelocity; }
    const BVHMaterial* getMaterial() const
    { return _material; }
    BVHNode::Id getId() const
    { return _id; }
    
    bool empty() const
    { return !_havePoint; }
    
private:
    SGSphered _sphere;
    double _time;

    SGVec3d _point;
    SGVec3d _linearVelocity;
    SGVec3d _angularVelocity;
    const BVHMaterial* _material;
    BVHNode::Id _id;

    bool _havePoint;
};

}

#endif