/usr/include/simgear/scene/model/persparam.hxx is in libsimgear-dev 3.4.0-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 | /**
* $Id$
*/
#ifndef _SG_PERSPARAM_HXX
#define _SG_PERSPARAM_HXX 1
#include <simgear/math/sg_random.h>
template <class T>
class SGPersonalityParameter {
public:
SGPersonalityParameter(const SGPropertyNode *props, const char *name, T defval )
: _var( defval ), _min( defval ), _max( defval ) {
const SGPropertyNode* node = props->getNode( name );
if ( node != 0 ) {
const SGPropertyNode* rand_n = node->getNode( "random" );
if ( rand_n != 0 ) {
_min = getNodeValue( rand_n, "min", (T)0 );
_max = getNodeValue( rand_n, "max", (T)1 );
shuffle();
} else {
_var = _min = _max = getNodeValue( props, name, defval );
}
}
}
SGPersonalityParameter<T> &operator=( T v ) { _var = v; return *this; }
SGPersonalityParameter<T> &operator+=( T v ) { _var += v; return *this; }
SGPersonalityParameter<T> &operator-=( T v ) { _var -= v; return *this; }
T shuffle() { return ( _var = _min + sg_random() * ( _max - _min ) ); }
T value() const { return _var; }
T getNodeValue(const SGPropertyNode *props, const char *name, T defval ) const;
operator T() const { return _var; }
private:
T _var;
T _min;
T _max;
};
template <> double
SGPersonalityParameter<double>::getNodeValue( const SGPropertyNode *props,
const char *name,
double defval ) const;
#endif // _SG_PERSPARAM_HXX
|