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:
parent
4de2c7619a
commit
b727604591
4 changed files with 19 additions and 3 deletions
|
@ -48,6 +48,7 @@ FGAIBallistic::FGAIBallistic() :
|
|||
_load_resistance(0),
|
||||
_solid(false),
|
||||
_impact_data(false),
|
||||
_impact_report_node(0),
|
||||
_impact_energy(0),
|
||||
_impact_speed(0),
|
||||
_impact_lat(0),
|
||||
|
@ -82,6 +83,7 @@ void FGAIBallistic::readFromScenario(SGPropertyNode* scFileNode) {
|
|||
setNoRoll(scFileNode->getBoolValue("no-roll", false));
|
||||
setRandom(scFileNode->getBoolValue("random", false));
|
||||
setImpact(scFileNode->getBoolValue("impact", false));
|
||||
setImpactReportNode(scFileNode->getStringValue("impact-reports"));
|
||||
setName(scFileNode->getStringValue("name", "Bomb"));
|
||||
}
|
||||
|
||||
|
@ -202,6 +204,13 @@ void FGAIBallistic::setImpact(bool 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) {
|
||||
_name = n;
|
||||
}
|
||||
|
@ -326,6 +335,8 @@ void FGAIBallistic::handle_impact() {
|
|||
|
||||
// report impact by setting tied variables
|
||||
if (_ht_agl_ft <= 0) {
|
||||
_impact_data = true;
|
||||
|
||||
_impact_lat = pos.getLatitudeDeg();
|
||||
_impact_lon = pos.getLongitudeDeg();
|
||||
_impact_elev = elevation_m;
|
||||
|
@ -333,8 +344,8 @@ void FGAIBallistic::handle_impact() {
|
|||
_impact_energy = (_mass * slugs_to_kgs) * _impact_speed
|
||||
* _impact_speed / (2 * 1000);
|
||||
|
||||
props->setBoolValue("impact/signal", true); // for listeners
|
||||
_impact_data = true;
|
||||
if (_impact_report_node)
|
||||
_impact_report_node->setStringValue(props->getPath());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
void setRandom( bool r );
|
||||
void setName(const string&);
|
||||
void setImpact(bool i);
|
||||
void setImpactReportNode(const string&);
|
||||
|
||||
double _getTime() const;
|
||||
|
||||
|
@ -82,7 +83,8 @@ private:
|
|||
bool _solid; // if true ground is solid for FDMs
|
||||
bool _impact; // if true an impact point on the terrain is calculated
|
||||
bool _impact_data; // if true impact data have been set
|
||||
|
||||
SGPropertyNode_ptr _impact_report_node;
|
||||
|
||||
double _impact_energy;
|
||||
double _impact_speed;
|
||||
double _impact_lat;
|
||||
|
|
|
@ -211,6 +211,7 @@ bool FGSubmodelMgr::release(submodel* sm, double dt)
|
|||
ballist->setNoRoll(sm->no_roll);
|
||||
ballist->setName(sm->name);
|
||||
ballist->setImpact(sm->impact);
|
||||
ballist->setImpactReportNode(sm->impact_reports);
|
||||
ai->attach(ballist);
|
||||
|
||||
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->no_roll = entry_node->getBoolValue("no-roll", 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->speed_node = fgGetNode(entry_node->getStringValue("speed-node", "none"), false);
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
bool no_roll;
|
||||
bool serviceable;
|
||||
bool impact;
|
||||
string impact_reports;
|
||||
}
|
||||
submodel;
|
||||
|
||||
|
|
Loading…
Reference in a new issue