]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/personality.cxx
Better encapsulation for personality
[simgear.git] / simgear / scene / model / personality.cxx
index 622137e81e13b1cf852e1f094926a5633e88fabc..60b8a987cf7bfa0c2f57cb97e22d4877aa9b7983 100755 (executable)
@@ -2,9 +2,34 @@
  * $Id$
  */
 
-#include <simgear/compiler.h>
+#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 )
 {