This file is indexed.

/usr/include/Eris-1.3/Eris/TerrainMod_impl.h is in liberis-1.3-dev 1.3.14-3.

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
//
// C++ Interface: TerrainMod_impl
//
// Description:
//
//
// Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>, (C) 2008
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.//
//
#ifndef EMBEROGRE_TERRAINTERRAINMOD_IMPL_H
#define EMBEROGRE_TERRAINTERRAINMOD_IMPL_H

#include <Eris/Entity.h>
#include <Eris/Log.h>
#include <Mercator/TerrainMod.h>
#include <Mercator/TerrainMod_impl.h>
#include <wfmath/ball.h>
#include <wfmath/polygon.h>


namespace Eris
{

/**
 @brief Base class for the inner terrain mod implementations.
 We keep this separate from the TerrainMod classes because of the way these classes interacts with templated WFMath structures.
 The parseShapeAtlasData() method can also be used externally as it's a static public.
 @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
*/
class InnerTerrainMod_impl
{
public:

    /**
     *    @brief Ctor.
     */
    InnerTerrainMod_impl() {}

    /**
     *    @brief Dtor.
     */
    virtual ~InnerTerrainMod_impl() {}

    /**
     * @brief Common method for parsing shape data from Atlas.
     * Since each different shape expects different Atlas data this is a templated method with specialized implemtations for each available shape. If you call this and get error regarding missing implementations it probably means that there's no implementation for the type of shape you're calling it with.
     * Note that a new shape instance will be put on the heap if the parsing is successful, and it's up to the calling code to properly delete it when done.
     * @param shapeElement The atlas map element which contains the shape data. Often this is found with the key "shape" in the atlas data.
     * @param pos The original position of the entity to which this shape will belong. The shape will be positioned according to this.
     * @param shape The resulting shape is meant to be put here, if successfully created. That means that a new shape instance will be created, and it's then up to the calling method to properly delete it, to avoid memory leaks.
     * @return True if the atlas data was successfully parsed and a shape was created.
     */
    template <typename Shape>
    static bool parseShapeAtlasData(const Atlas::Message::Element& shapeElement, const WFMath::Point<3>& pos, const WFMath::Quaternion& orientation, Shape** shape);

    /**
     * @brief Gets the modifier which this instance represents.
     * @return A pointer to a terrain modifier, or null if none could be created.
     */
    virtual Mercator::TerrainMod* getModifier() = 0;

protected:

};

template<typename Shape>
bool InnerTerrainMod_impl::parseShapeAtlasData(const Atlas::Message::Element& shapeElement, const WFMath::Point<3>& pos, const WFMath::Quaternion& orientation, Shape** shape)
{
    try {
        *shape = new Shape(shapeElement);
    } catch (...) {
        ///Just log an error and return false, this isn't fatal.
        warning() << "Error when parsing shape from atlas.";
        return false;
    }

    /// rotation about Z axis
    WFMath::Vector<3> xVec = WFMath::Vector<3>(1.0, 0.0, 0.0).rotate(orientation);
    double theta = atan2(xVec.y(), xVec.x());
    WFMath::RotMatrix<2> rm;
    (*shape)->rotatePoint(rm.rotation(theta), WFMath::Point<2>(0, 0));

    (*shape)->shift(WFMath::Vector<2>(pos.x(), pos.y())); ///This of course depends on the assumption that we'll only ever use 2d shapes. If a 3d shape is used the shift method expects a Vector<3> instead...
    return true;
}

/**
 @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
 @brief Handles instances of Mercator::SlopeTerrainMod with arbitrary shapes.
*/
template <typename Shape>
class InnerTerrainModSlope_impl : public InnerTerrainMod_impl
{
public:
    /**
     * @brief Ctor.
     */
    InnerTerrainModSlope_impl() {}

    /**
     * @brief Dtor.
     */
    virtual ~InnerTerrainModSlope_impl() {
        delete mTerrainMod;
    }

    /**
     * @brief Tries to create a new instance from the passes in atlas data.
     * @param shapeElement The atlas data containing shape information.
     * @param pos The position where the mod should be created, in world space.
     * @param level The level where the slope should be created.
     * @param dx
     * @param dy
     * @return True if the atlas data could be successfully parsed an a mod created.
     */
    bool createInstance(const Atlas::Message::Element& shapeElement, const WFMath::Point<3>& pos, const WFMath::Quaternion& orientation, float level, float dx, float dy);

    /**
     * @copydoc InnerTerrainMod_impl::getModifier()
     */
    inline virtual Mercator::TerrainMod* getModifier();

protected:

    /**
     * @brief The actual terrain mod instance, owned by this instance.
     */
    Mercator::SlopeTerrainMod<Shape>* mTerrainMod;
};

template <typename Shape>
Mercator::TerrainMod* InnerTerrainModSlope_impl<Shape>::getModifier()
{
    return mTerrainMod;
}

template <typename Shape>
bool InnerTerrainModSlope_impl<Shape>::createInstance(const Atlas::Message::Element& shapeElement, const WFMath::Point<3>& pos, const WFMath::Quaternion& orientation, float level, float dx, float dy)
{
    Shape* shape(0);
    if (parseShapeAtlasData<Shape>(shapeElement, pos, orientation, &shape)) {
        mTerrainMod = new Mercator::SlopeTerrainMod<Shape>(level, dx, dy, *shape);
        delete shape;
        return true;
    }
    delete shape;
    return false;
}

/**
 @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
 @brief Handles instances of Mercator::LevelTerrainMod with arbitrary shapes.
*/
template <typename Shape>
class InnerTerrainModLevel_impl : public InnerTerrainMod_impl
{
public:
    /**
     * @brief Ctor.
     */
    InnerTerrainModLevel_impl() {}

    /**
     * @brief Dtor.
     */
    virtual ~InnerTerrainModLevel_impl() {
        delete mTerrainMod;
    }

    /**
     * @brief Tries to create a new instance from the passes in atlas data.
     * @param shapeElement The atlas data containing shape information.
     * @param pos The position where the mod should be created, in world space.
     * @param height The height where the level should be created.
     * @return True if the atlas data could be successfully parsed an a mod created.
     */
    bool createInstance(const Atlas::Message::Element& shapeElement, const WFMath::Point<3>& pos, const WFMath::Quaternion& orientation, float height);

    /**
     * @copydoc InnerTerrainMod_impl::getModifier()
     */
    inline virtual Mercator::TerrainMod* getModifier();

protected:

    /**
     * @brief The actual terrain mod instance, owned by this instance.
     */
    Mercator::LevelTerrainMod<Shape>* mTerrainMod;
};

template <typename Shape>
Mercator::TerrainMod* InnerTerrainModLevel_impl<Shape>::getModifier()
{
    return mTerrainMod;
}

template <typename Shape>
bool InnerTerrainModLevel_impl<Shape>::createInstance(const Atlas::Message::Element& shapeElement, const WFMath::Point<3>& pos, const WFMath::Quaternion& orientation, float height)
{
    Shape* shape(0);
    if (parseShapeAtlasData<Shape>(shapeElement, pos, orientation, &shape)) {
        mTerrainMod = new Mercator::LevelTerrainMod<Shape>(height, *shape);
        delete shape;
        return true;
    }
    delete shape;
    return false;
}

/**
 @author Erik Hjortsberg <erik.hjortsberg@iteam.se>
 @brief Handles instances of Mercator::AdjustTerrainMod with arbitrary shapes.
*/
template <typename Shape>
class InnerTerrainModAdjust_impl : public InnerTerrainMod_impl
{
public:
    /**
     * @brief Ctor.
     */
    InnerTerrainModAdjust_impl() {}

    /**
     * @brief Dtor.
     */
    virtual ~InnerTerrainModAdjust_impl() {
        delete mTerrainMod;
    }

    /**
     * @brief Tries to create a new instance from the passes in atlas data.
     * @param shapeElement The atlas data containing shape information.
     * @param pos The position where the mod should be created, in world space.
     * @param height The height where the level should be created.
     * @return True if the atlas data could be successfully parsed an a mod created.
     */
    bool createInstance(const Atlas::Message::Element& shapeElement, const WFMath::Point<3>& pos, const WFMath::Quaternion& orientation, float height);

    /**
     * @copydoc InnerTerrainMod_impl::getModifier()
     */
    inline virtual Mercator::TerrainMod* getModifier();

protected:

    /**
     * @brief The actual terrain mod instance, owned by this instance.
     */
    Mercator::AdjustTerrainMod<Shape>* mTerrainMod;
};

template <typename Shape>
Mercator::TerrainMod* InnerTerrainModAdjust_impl<Shape>::getModifier()
{
    return mTerrainMod;
}

template <typename Shape>
bool InnerTerrainModAdjust_impl<Shape>::createInstance(const Atlas::Message::Element& shapeElement, const WFMath::Point<3>& pos, const WFMath::Quaternion& orientation, float height)
{
    Shape* shape(0);
    if (parseShapeAtlasData<Shape>(shapeElement, pos, orientation, &shape)) {
        mTerrainMod = new Mercator::AdjustTerrainMod<Shape>(height, *shape);
        delete shape;
        return true;
    }
    delete shape;
    return false;
}





// template<>
// bool InnerTerrainModSlope_impl<WFMath::Ball<2> >::internalParseAtlasData(const Atlas::Message::MapType& shapeElement, WFMath::Point<3> pos)
// {
//  WFMath::Ball<2>* ball(0);
//  if (parseShapeAtlasData<WFMath::Ball<2> >(shapeElement, pos, &ball)) {
//   mTerrainMod = new Mercator::SlopeTerrainMod<WFMath::Ball<2> >(0, 0, 0, *ball);
//   return true;
//  }
//  return false;
// }


}

#endif