]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/persparam.hxx
Provide something more sensible for the properties root
[simgear.git] / simgear / scene / model / persparam.hxx
index 8cf7283ecc498fda0e38e7e11cd1ccec96f9d4fc..e8b571fcf133f02b9c6c695a7a2e615552f16d23 100755 (executable)
 template <class T>
 class SGPersonalityParameter {
 public:
-  SGPersonalityParameter( SGPropertyNode *props, const char *name, T defval )
+  SGPersonalityParameter(const SGPropertyNode *props, const char *name, T defval )
     : _var( defval ), _min( defval ), _max( defval ) {
-    SGPropertyNode_ptr node = props->getNode( name );
+    const SGPropertyNode* node = props->getNode( name );
     if ( node != 0 ) {
-      SGPropertyNode_ptr rand_n = node->getNode( "random" );
+      const SGPropertyNode* rand_n = node->getNode( "random" );
       if ( rand_n != 0 ) {
-        _min = rand_n->getDoubleValue( "min", 0.0 );
-        _max = rand_n->getDoubleValue( "max", 1.0 );
+        _min = getNodeValue( rand_n, "min", (T)0 );
+        _max = getNodeValue( rand_n, "max", (T)1 );
         shuffle();
       } else {
         _var = _min = _max = getNodeValue( props, name, defval );
@@ -30,7 +30,7 @@ public:
   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( SGPropertyNode *props, const char *name, T defval ) const;
+  T getNodeValue(const SGPropertyNode *props, const char *name, T defval ) const;
   operator T() const { return _var; }
 
 private:
@@ -40,7 +40,7 @@ private:
 };
 
 template <> double
-SGPersonalityParameter<double>::getNodeValue( SGPropertyNode *props,
+SGPersonalityParameter<double>::getNodeValue( const SGPropertyNode *props,
                                               const char *name,
                                               double defval ) const;