]> git.mxchange.org Git - simgear.git/commitdiff
Better encapsulation for personality
authorfredb <fredb>
Fri, 25 Aug 2006 19:25:56 +0000 (19:25 +0000)
committerfredb <fredb>
Fri, 25 Aug 2006 19:25:56 +0000 (19:25 +0000)
simgear/scene/model/modellib.cxx
simgear/scene/model/personality.cxx
simgear/scene/model/personality.hxx

index bd28d43d23eed91899a3bf90b8e388f587f46188..f5f15784c299ce434736f0600096c97f3a8a7adc 100644 (file)
@@ -61,22 +61,6 @@ SGModelLib::flush1()
     }
 }
 
-static int
-personality_pretrav_callback(ssgEntity * entity, int mask)
-{
-    ((SGPersonalityBranch *)entity)->_old_current = SGAnimation::current_object;
-    SGAnimation::current_object = (SGPersonalityBranch *)entity;
-    return 1;
-}
-
-static int
-personality_posttrav_callback(ssgEntity * entity, int mask)
-{
-    SGAnimation::current_object = ((SGPersonalityBranch *)entity)->_old_current;
-    ((SGPersonalityBranch *)entity)->_old_current = 0;
-    return 1;
-}
-
 ssgEntity *
 SGModelLib::load_model( const string &fg_root,
                            const string &path,
@@ -86,8 +70,6 @@ SGModelLib::load_model( const string &fg_root,
                            SGModelData *data )
 {
     ssgBranch *personality_branch = new SGPersonalityBranch;
-    personality_branch->setTravCallback(SSG_CALLBACK_PRETRAV, personality_pretrav_callback);
-    personality_branch->setTravCallback(SSG_CALLBACK_POSTTRAV, personality_posttrav_callback);
 
                                 // FIXME: normalize path to
                                 // avoid duplicates.
index a1374165f003e9b7129bb1589169d8dce908897e..60b8a987cf7bfa0c2f57cb97e22d4877aa9b7983 100755 (executable)
@@ -2,7 +2,34 @@
  * $Id$
  */
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+
 #include "personality.hxx"
+#include "animation.hxx"
+
+static int
+personality_pretrav_callback(ssgEntity * entity, int mask)
+{
+    ((SGPersonalityBranch *)entity)->_old_current = SGAnimation::current_object;
+    SGAnimation::current_object = (SGPersonalityBranch *)entity;
+    return 1;
+}
+
+static int
+personality_posttrav_callback(ssgEntity * entity, int mask)
+{
+    SGAnimation::current_object = ((SGPersonalityBranch *)entity)->_old_current;
+    ((SGPersonalityBranch *)entity)->_old_current = 0;
+    return 1;
+}
+
+SGPersonalityBranch::SGPersonalityBranch()
+{
+    setTravCallback(SSG_CALLBACK_PRETRAV, personality_pretrav_callback);
+    setTravCallback(SSG_CALLBACK_POSTTRAV, personality_posttrav_callback);
+}
 
 void SGPersonalityBranch::setDoubleValue( double value, SGAnimation *anim, int var_id, int var_num )
 {
index e5392b2d0786fee82da9dfabd08ff0fda37c5cb6..6a314e7cd433fb224b50a71a9917494ae4a3c641 100755 (executable)
@@ -16,6 +16,7 @@ class SGAnimation;
 
 class SGPersonalityBranch : public ssgBranch {
 public:
+    SGPersonalityBranch();
     void setDoubleValue( double value, SGAnimation *anim, int var_id, int var_num = 0 );
     void setIntValue( int value, SGAnimation *anim, int var_id, int var_num = 0 );
     double getDoubleValue( SGAnimation *anim, int var_id, int var_num = 0 ) const;