1
0
Fork 0

Merge branch 'next' into attenuation

This commit is contained in:
adrian 2011-12-09 18:57:38 +02:00
commit b796df3bd7
13 changed files with 69 additions and 49 deletions

View file

@ -126,7 +126,11 @@ void FGAIBallistic::readFromScenario(SGPropertyNode* scFileNode) {
bool FGAIBallistic::init(bool search_in_AI_path) { bool FGAIBallistic::init(bool search_in_AI_path) {
FGAIBase::init(search_in_AI_path); FGAIBase::init(search_in_AI_path);
reinit();
return true;
}
void FGAIBallistic::reinit() {
_impact_reported = false; _impact_reported = false;
_collision_reported = false; _collision_reported = false;
_expiry_reported = false; _expiry_reported = false;
@ -179,7 +183,7 @@ bool FGAIBallistic::init(bool search_in_AI_path) {
setParentNodes(_selected_ac); setParentNodes(_selected_ac);
return true; FGAIBase::reinit();
} }
void FGAIBallistic::bind() { void FGAIBallistic::bind() {

View file

@ -46,10 +46,10 @@ public:
bool init(bool search_in_AI_path=false); bool init(bool search_in_AI_path=false);
virtual void bind(); virtual void bind();
virtual void unbind(); virtual void unbind();
virtual void reinit();
virtual void update(double dt);
void update(double dt); virtual const char* getTypeString(void) const { return "ballistic"; }
FGAIBallistic *ballistic;
void Run(double dt); void Run(double dt);
@ -114,7 +114,8 @@ public:
// bool getFormate() const; // bool getFormate() const;
bool getSlavedLoad() const; bool getSlavedLoad() const;
virtual const char* getTypeString(void) const { return "ballistic"; } FGAIBallistic *ballistic;
static const double slugs_to_kgs; //conversion factor static const double slugs_to_kgs; //conversion factor
static const double slugs_to_lbs; //conversion factor static const double slugs_to_lbs; //conversion factor
@ -170,8 +171,6 @@ public:
private: private:
virtual void reinit() { init(); }
bool _aero_stabilised; // if true, object will align with trajectory bool _aero_stabilised; // if true, object will align with trajectory
double _drag_area; // equivalent drag area in ft2 double _drag_area; // equivalent drag area in ft2
double _life_timer; // seconds double _life_timer; // seconds

View file

@ -145,7 +145,7 @@ FGAIBase::~FGAIBase() {
model_removed->setStringValue(props->getPath()); model_removed->setStringValue(props->getPath());
} }
if (_refID != 0 && _refID != 1) { if (_fx && _refID != 0 && _refID != 1) {
SGSoundMgr *smgr = globals->get_soundmgr(); SGSoundMgr *smgr = globals->get_soundmgr();
stringstream name; stringstream name;
name << "aifx:"; name << "aifx:";
@ -153,7 +153,8 @@ FGAIBase::~FGAIBase() {
smgr->remove(name.str()); smgr->remove(name.str());
} }
delete fp; if (fp)
delete fp;
fp = 0; fp = 0;
} }
@ -163,6 +164,9 @@ FGAIBase::~FGAIBase() {
void void
FGAIBase::removeModel() FGAIBase::removeModel()
{ {
if (!_model.valid())
return;
FGScenery* pSceneryManager = globals->get_scenery(); FGScenery* pSceneryManager = globals->get_scenery();
if (pSceneryManager) if (pSceneryManager)
{ {
@ -287,8 +291,14 @@ void FGAIBase::Transform() {
} }
bool FGAIBase::init(bool search_in_AI_path) { bool FGAIBase::init(bool search_in_AI_path)
{
if (_model.valid())
{
SG_LOG(SG_AI, SG_ALERT, "AIBase: Cannot initialize a model multiple times! " << model_path);
return false;
}
string f; string f;
if(search_in_AI_path) if(search_in_AI_path)
{ {
@ -317,12 +327,6 @@ bool FGAIBase::init(bool search_in_AI_path) {
_aimodel = new FGAIModelData(props); _aimodel = new FGAIModelData(props);
osg::Node * mdl = SGModelLib::loadDeferredModel(f, props, _aimodel); osg::Node * mdl = SGModelLib::loadDeferredModel(f, props, _aimodel);
if (_model.valid())
{
// reinit, dump the old model
removeModel();
}
_model = new osg::LOD; _model = new osg::LOD;
_model->setName("AI-model range animation node"); _model->setName("AI-model range animation node");

View file

@ -230,7 +230,7 @@ private:
bool _initialized; bool _initialized;
osg::ref_ptr<osg::LOD> _model; //The 3D model LOD object osg::ref_ptr<osg::LOD> _model; //The 3D model LOD object
FGAIModelData* _aimodel; osg::ref_ptr<FGAIModelData> _aimodel;
string _fxpath; string _fxpath;
SGSharedPtr<FGFX> _fx; SGSharedPtr<FGFX> _fx;

View file

@ -134,7 +134,11 @@ void FGAIEscort::unbind() {
bool FGAIEscort::init(bool search_in_AI_path) { bool FGAIEscort::init(bool search_in_AI_path) {
if (!FGAIShip::init(search_in_AI_path)) if (!FGAIShip::init(search_in_AI_path))
return false; return false;
reinit();
return true;
}
void FGAIEscort::reinit() {
invisible = false; invisible = false;
no_roll = false; no_roll = false;
@ -147,7 +151,7 @@ bool FGAIEscort::init(bool search_in_AI_path) {
hdg = _parent_hdg; hdg = _parent_hdg;
} }
return true; FGAIShip::reinit();
} }
void FGAIEscort::update(double dt) { void FGAIEscort::update(double dt) {

View file

@ -39,17 +39,16 @@ public:
virtual ~FGAIEscort(); virtual ~FGAIEscort();
virtual void readFromScenario(SGPropertyNode* scFileNode); virtual void readFromScenario(SGPropertyNode* scFileNode);
virtual void bind();
virtual void unbind();
virtual const char* getTypeString(void) const { return "escort"; }
bool init(bool search_in_AI_path=false); bool init(bool search_in_AI_path=false);
virtual void bind();
private: virtual void unbind();
virtual void reinit();
virtual void reinit() { init(); }
virtual void update (double dt); virtual void update (double dt);
virtual const char* getTypeString(void) const { return "escort"; }
private:
void setStnRange(double r); void setStnRange(double r);
void setStnBrg(double y); void setStnBrg(double y);
void setStationSpeed(); void setStationSpeed();

View file

@ -142,7 +142,11 @@ void FGAIGroundVehicle::unbind() {
bool FGAIGroundVehicle::init(bool search_in_AI_path) { bool FGAIGroundVehicle::init(bool search_in_AI_path) {
if (!FGAIShip::init(search_in_AI_path)) if (!FGAIShip::init(search_in_AI_path))
return false; return false;
reinit();
return true;
}
void FGAIGroundVehicle::reinit() {
invisible = false; invisible = false;
_limit = 200; _limit = 200;
no_roll = true; no_roll = true;
@ -162,7 +166,7 @@ bool FGAIGroundVehicle::init(bool search_in_AI_path) {
setParent(); setParent();
} }
return true; FGAIShip::reinit();
} }
void FGAIGroundVehicle::update(double dt) { void FGAIGroundVehicle::update(double dt) {

View file

@ -37,17 +37,17 @@ public:
virtual ~FGAIGroundVehicle(); virtual ~FGAIGroundVehicle();
virtual void readFromScenario(SGPropertyNode* scFileNode); virtual void readFromScenario(SGPropertyNode* scFileNode);
virtual void bind();
virtual void unbind();
virtual const char* getTypeString(void) const { return "groundvehicle"; }
bool init(bool search_in_AI_path=false); bool init(bool search_in_AI_path=false);
virtual void bind();
virtual void unbind();
virtual void reinit();
virtual void update (double dt);
virtual const char* getTypeString(void) const { return "groundvehicle"; }
private: private:
virtual void reinit() { init(); }
virtual void update (double dt);
void setNoRoll(bool nr); void setNoRoll(bool nr);
void setContactX1offset(double x1); void setContactX1offset(double x1);
void setContactX2offset(double x2); void setContactX2offset(double x2);

View file

@ -113,6 +113,12 @@ void FGAIShip::readFromScenario(SGPropertyNode* scFileNode) {
} }
bool FGAIShip::init(bool search_in_AI_path) { bool FGAIShip::init(bool search_in_AI_path) {
reinit();
return FGAIBase::init(search_in_AI_path);
}
void FGAIShip::reinit()
{
prev = 0; // the one behind you prev = 0; // the one behind you
curr = 0; // the one ahead curr = 0; // the one ahead
next = 0; // the next plus 1 next = 0; // the next plus 1
@ -134,7 +140,7 @@ bool FGAIShip::init(bool search_in_AI_path) {
if (fp) if (fp)
_fp_init = initFlightPlan(); _fp_init = initFlightPlan();
return FGAIBase::init(search_in_AI_path); FGAIBase::reinit();
} }
void FGAIShip::bind() { void FGAIShip::bind() {

View file

@ -41,8 +41,9 @@ public:
virtual void bind(); virtual void bind();
virtual void unbind(); virtual void unbind();
virtual void update(double dt); virtual void update(double dt);
virtual void reinit();
void setFlightPlan(FGAIFlightPlan* f); void setFlightPlan(FGAIFlightPlan* f);
// void setName(const string&);
void setRudder(float r); void setRudder(float r);
void setRoll(double rl); void setRoll(double rl);
void ProcessFlightPlan( double dt); void ProcessFlightPlan( double dt);
@ -90,14 +91,9 @@ public:
protected: protected:
// string _name; // The name of this ship.
private: private:
virtual void reinit() { init(); }
void setRepeat(bool r); void setRepeat(bool r);
void setRestart(bool r); void setRestart(bool r);
void setMissed(bool m); void setMissed(bool m);

View file

@ -203,7 +203,11 @@ void FGAIWingman::unbind() {
bool FGAIWingman::init(bool search_in_AI_path) { bool FGAIWingman::init(bool search_in_AI_path) {
if (!FGAIBallistic::init(search_in_AI_path)) if (!FGAIBallistic::init(search_in_AI_path))
return false; return false;
reinit();
return true;
}
void FGAIWingman::reinit() {
invisible = false; invisible = false;
_tgt_x_offset = _x_offset; _tgt_x_offset = _x_offset;
@ -223,7 +227,8 @@ bool FGAIWingman::init(bool search_in_AI_path) {
props->setStringValue("submodels/path", _path.c_str()); props->setStringValue("submodels/path", _path.c_str());
user_WoW_node = fgGetNode("gear/gear[1]/wow", true); user_WoW_node = fgGetNode("gear/gear[1]/wow", true);
return true;
FGAIBallistic::reinit();
} }
void FGAIWingman::update(double dt) { void FGAIWingman::update(double dt) {

View file

@ -35,17 +35,16 @@ public:
virtual ~FGAIWingman(); virtual ~FGAIWingman();
virtual void readFromScenario(SGPropertyNode* scFileNode); virtual void readFromScenario(SGPropertyNode* scFileNode);
virtual void bind();
virtual void unbind();
virtual const char* getTypeString(void) const { return "wingman"; }
bool init(bool search_in_AI_path=false); bool init(bool search_in_AI_path=false);
virtual void bind();
private: virtual void unbind();
virtual void reinit();
virtual void reinit() { init(); }
virtual void update (double dt); virtual void update (double dt);
virtual const char* getTypeString(void) const { return "wingman"; }
private:
void formateToAC(double dt); void formateToAC(double dt);
void Break(double dt); void Break(double dt);
void Join(double dt); void Join(double dt);

View file

@ -469,7 +469,7 @@ void FGLinuxEventInput::postinit()
dev = udev_device_get_parent( dev ); dev = udev_device_get_parent( dev );
const char * name = udev_device_get_sysattr_value(dev,"name"); const char * name = udev_device_get_sysattr_value(dev,"name");
SG_LOG(SG_INPUT,SG_ALERT, "name=" << (name?name:"<null>") << ", node=" << (node?node:"<null>")); SG_LOG(SG_INPUT,SG_DEBUG, "name=" << (name?name:"<null>") << ", node=" << (node?node:"<null>"));
if( name && node ) if( name && node )
AddDevice( new FGLinuxInputDevice(name, node) ); AddDevice( new FGLinuxInputDevice(name, node) );