1
0
Fork 0

drop /ai/models/ballistic[]/impact/signal node, and allow instead to define

a report node in the submodels config:

  <impact-reports>/sim/model/cow/impact</impact-reports>

When an impact happens, then the path of the submodel will be written to
this node. An attached listener function can evaluate the impact properties.
This commit is contained in:
mfranz 2007-05-15 19:45:41 +00:00
parent 4de2c7619a
commit b727604591
4 changed files with 19 additions and 3 deletions

View file

@ -48,6 +48,7 @@ FGAIBallistic::FGAIBallistic() :
_load_resistance(0), _load_resistance(0),
_solid(false), _solid(false),
_impact_data(false), _impact_data(false),
_impact_report_node(0),
_impact_energy(0), _impact_energy(0),
_impact_speed(0), _impact_speed(0),
_impact_lat(0), _impact_lat(0),
@ -82,6 +83,7 @@ void FGAIBallistic::readFromScenario(SGPropertyNode* scFileNode) {
setNoRoll(scFileNode->getBoolValue("no-roll", false)); setNoRoll(scFileNode->getBoolValue("no-roll", false));
setRandom(scFileNode->getBoolValue("random", false)); setRandom(scFileNode->getBoolValue("random", false));
setImpact(scFileNode->getBoolValue("impact", false)); setImpact(scFileNode->getBoolValue("impact", false));
setImpactReportNode(scFileNode->getStringValue("impact-reports"));
setName(scFileNode->getStringValue("name", "Bomb")); setName(scFileNode->getStringValue("name", "Bomb"));
} }
@ -202,6 +204,13 @@ void FGAIBallistic::setImpact(bool i) {
_impact = i; _impact = i;
} }
void FGAIBallistic::setImpactReportNode(const string& path) {
if (path.empty())
_impact_report_node = 0;
else
_impact_report_node = fgGetNode(path.c_str(), true);
}
void FGAIBallistic::setName(const string& n) { void FGAIBallistic::setName(const string& n) {
_name = n; _name = n;
} }
@ -326,6 +335,8 @@ void FGAIBallistic::handle_impact() {
// report impact by setting tied variables // report impact by setting tied variables
if (_ht_agl_ft <= 0) { if (_ht_agl_ft <= 0) {
_impact_data = true;
_impact_lat = pos.getLatitudeDeg(); _impact_lat = pos.getLatitudeDeg();
_impact_lon = pos.getLongitudeDeg(); _impact_lon = pos.getLongitudeDeg();
_impact_elev = elevation_m; _impact_elev = elevation_m;
@ -333,8 +344,8 @@ void FGAIBallistic::handle_impact() {
_impact_energy = (_mass * slugs_to_kgs) * _impact_speed _impact_energy = (_mass * slugs_to_kgs) * _impact_speed
* _impact_speed / (2 * 1000); * _impact_speed / (2 * 1000);
props->setBoolValue("impact/signal", true); // for listeners if (_impact_report_node)
_impact_data = true; _impact_report_node->setStringValue(props->getPath());
} }
} }

View file

@ -55,6 +55,7 @@ public:
void setRandom( bool r ); void setRandom( bool r );
void setName(const string&); void setName(const string&);
void setImpact(bool i); void setImpact(bool i);
void setImpactReportNode(const string&);
double _getTime() const; double _getTime() const;
@ -82,6 +83,7 @@ private:
bool _solid; // if true ground is solid for FDMs bool _solid; // if true ground is solid for FDMs
bool _impact; // if true an impact point on the terrain is calculated bool _impact; // if true an impact point on the terrain is calculated
bool _impact_data; // if true impact data have been set bool _impact_data; // if true impact data have been set
SGPropertyNode_ptr _impact_report_node;
double _impact_energy; double _impact_energy;
double _impact_speed; double _impact_speed;

View file

@ -211,6 +211,7 @@ bool FGSubmodelMgr::release(submodel* sm, double dt)
ballist->setNoRoll(sm->no_roll); ballist->setNoRoll(sm->no_roll);
ballist->setName(sm->name); ballist->setName(sm->name);
ballist->setImpact(sm->impact); ballist->setImpact(sm->impact);
ballist->setImpactReportNode(sm->impact_reports);
ai->attach(ballist); ai->attach(ballist);
if (sm->count > 0) if (sm->count > 0)
@ -489,6 +490,7 @@ void FGSubmodelMgr::setData(int id, string& path, bool serviceable)
sm->aero_stabilised = entry_node->getBoolValue("aero-stabilised", true); sm->aero_stabilised = entry_node->getBoolValue("aero-stabilised", true);
sm->no_roll = entry_node->getBoolValue("no-roll", false); sm->no_roll = entry_node->getBoolValue("no-roll", false);
sm->impact = entry_node->getBoolValue("impact", false); sm->impact = entry_node->getBoolValue("impact", false);
sm->impact_reports = entry_node->getStringValue("impact-reports");
sm->contents_node = fgGetNode(entry_node->getStringValue("contents", "none"), false); sm->contents_node = fgGetNode(entry_node->getStringValue("contents", "none"), false);
sm->speed_node = fgGetNode(entry_node->getStringValue("speed-node", "none"), false); sm->speed_node = fgGetNode(entry_node->getStringValue("speed-node", "none"), false);

View file

@ -60,6 +60,7 @@ public:
bool no_roll; bool no_roll;
bool serviceable; bool serviceable;
bool impact; bool impact;
string impact_reports;
} }
submodel; submodel;