Better encapsulation for personality

This commit is contained in:
fredb
2006-08-25 19:25:56 +00:00
parent aebb1f6ec8
commit 629a4a950e
3 changed files with 28 additions and 18 deletions

View 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.

View File

@@ -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 )
{

View File

@@ -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;