Execute load/unload Nasal for both detailed and AI
Previously only the first of a detailed/bare AI model tuple's Nasal would be executed when the model is loaded. This loads both.
This commit is contained in:
parent
f011d5f567
commit
ff12994554
1 changed files with 33 additions and 28 deletions
|
@ -62,7 +62,7 @@ using namespace simgear;
|
|||
class FGAIModelData : public simgear::SGModelData {
|
||||
public:
|
||||
FGAIModelData(SGPropertyNode *root = nullptr)
|
||||
: _nasal( new FGNasalModelDataProxy(root) )
|
||||
: _root (root)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,6 @@ public:
|
|||
return;
|
||||
|
||||
_modelLoaded[path] = true;
|
||||
_ready = true;
|
||||
|
||||
if(prop->hasChild("interior-path")){
|
||||
_interiorPath = prop->getStringValue("interior-path");
|
||||
|
@ -89,9 +88,10 @@ public:
|
|||
}
|
||||
|
||||
_fxpath = prop->getStringValue("sound/path");
|
||||
_nasal->modelLoaded(path, prop, n);
|
||||
|
||||
|
||||
_nasal[path] = std::unique_ptr<FGNasalModelDataProxy>(new FGNasalModelDataProxy(_root));
|
||||
_nasal[path]->modelLoaded(path, prop, n);
|
||||
_ready = true;
|
||||
_initialized = false;
|
||||
}
|
||||
|
||||
/** init hook to be called after model is loaded.
|
||||
|
@ -107,15 +107,16 @@ public:
|
|||
bool hasInteriorPath(void) { return _hasInteriorPath;}
|
||||
inline std::string& getInteriorPath() { return _interiorPath; }
|
||||
private:
|
||||
std::unique_ptr<FGNasalModelDataProxy> _nasal;
|
||||
std::string _fxpath;
|
||||
std::string _interiorPath;
|
||||
|
||||
std::map<string, bool> _modelLoaded;
|
||||
std::map<string, std::unique_ptr<FGNasalModelDataProxy>> _nasal;
|
||||
bool _ready = false;
|
||||
bool _initialized = false;
|
||||
bool _hasInteriorPath = false;
|
||||
bool _interiorLoaded = false;
|
||||
SGPropertyNode* _root;
|
||||
};
|
||||
|
||||
FGAIBase::FGAIBase(object_type ot, bool enableHot) :
|
||||
|
@ -281,20 +282,7 @@ void FGAIBase::update(double dt) {
|
|||
ft_per_deg_lat = 366468.96 - 3717.12 * cos(pos.getLatitudeRad());
|
||||
ft_per_deg_lon = 365228.16 * cos(pos.getLatitudeRad());
|
||||
|
||||
if ( _fx )
|
||||
{
|
||||
// update model's audio sample values
|
||||
_fx->set_position_geod( pos );
|
||||
|
||||
SGQuatd orient = SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll);
|
||||
_fx->set_orientation( orient );
|
||||
|
||||
SGVec3d velocity;
|
||||
velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec,
|
||||
pitch*speed );
|
||||
_fx->set_velocity( velocity );
|
||||
}
|
||||
else if ((_modeldata)&&(_modeldata->needInitilization()))
|
||||
if ((_modeldata)&&(_modeldata->needInitilization()))
|
||||
{
|
||||
// process deferred nasal initialization,
|
||||
// which must be done in main thread
|
||||
|
@ -308,6 +296,9 @@ void FGAIBase::update(double dt) {
|
|||
{
|
||||
props->setStringValue("sim/sound/path", fxpath.c_str());
|
||||
|
||||
// Remove any existing sound FX (e.g. from another model)
|
||||
removeSoundFx();
|
||||
|
||||
// initialize the sound configuration
|
||||
std::stringstream name;
|
||||
name << "aifx:";
|
||||
|
@ -318,6 +309,20 @@ void FGAIBase::update(double dt) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( _fx )
|
||||
{
|
||||
// update model's audio sample values
|
||||
_fx->set_position_geod( pos );
|
||||
|
||||
SGQuatd orient = SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll);
|
||||
_fx->set_orientation( orient );
|
||||
|
||||
SGVec3d velocity;
|
||||
velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec,
|
||||
pitch*speed );
|
||||
_fx->set_velocity( velocity );
|
||||
}
|
||||
|
||||
updateInterior();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue