From 629a4a950e2e3215cab2acfacf05247d424480e4 Mon Sep 17 00:00:00 2001 From: fredb Date: Fri, 25 Aug 2006 19:25:56 +0000 Subject: [PATCH] Better encapsulation for personality --- simgear/scene/model/modellib.cxx | 18 ------------------ simgear/scene/model/personality.cxx | 27 +++++++++++++++++++++++++++ simgear/scene/model/personality.hxx | 1 + 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/simgear/scene/model/modellib.cxx b/simgear/scene/model/modellib.cxx index bd28d43d..f5f15784 100644 --- a/simgear/scene/model/modellib.cxx +++ b/simgear/scene/model/modellib.cxx @@ -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. diff --git a/simgear/scene/model/personality.cxx b/simgear/scene/model/personality.cxx index a1374165..60b8a987 100755 --- a/simgear/scene/model/personality.cxx +++ b/simgear/scene/model/personality.cxx @@ -2,7 +2,34 @@ * $Id$ */ +#ifdef HAVE_CONFIG_H +# include +#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 ) { diff --git a/simgear/scene/model/personality.hxx b/simgear/scene/model/personality.hxx index e5392b2d..6a314e7c 100755 --- a/simgear/scene/model/personality.hxx +++ b/simgear/scene/model/personality.hxx @@ -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; -- 2.39.5