mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
Ref T681, fixed handling of CG from DB
* consider settings * remember DB CG data correctly
This commit is contained in:
@@ -864,7 +864,11 @@ namespace BlackCore
|
||||
const CLength cgOvr = this->overriddenCGorDefault(simulatorCG, modelString);
|
||||
if (!cgOvr.isNull() && !this->hasSameSimulatorCG(cgOvr, callsign))
|
||||
{
|
||||
this->insertCG(cgOvr, modelString, callsign); // per model string and CG
|
||||
const CSimulatorSettings::CGSource source = this->getSimulatorSettings().getSimulatorSettings().getCGSource();
|
||||
if (source != CSimulatorSettings::CGFromDBOnly)
|
||||
{
|
||||
this->insertCG(cgOvr, modelString, callsign); // per model string and CG
|
||||
}
|
||||
|
||||
// here we know we have a valid model and CG did change
|
||||
const CSimulatorInfo sim = this->getSimulatorInfo();
|
||||
|
||||
@@ -56,10 +56,22 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
CLength CInterpolator<Derived>::getAndFetchModelCG()
|
||||
CLength CInterpolator<Derived>::getAndFetchModelCG(const CLength &dbCG)
|
||||
{
|
||||
const CLength cgDB = this->getRemoteAircraftProvider() ? this->getRemoteAircraftProvider()->getCGFromDB(m_callsign) : CLength::null();
|
||||
const CLength cg = this->getSimulatorOrDbCG(m_callsign, cgDB); // simulation environment
|
||||
CLength cgDb = dbCG;
|
||||
if (cgDb.isNull())
|
||||
{
|
||||
// no input DB value, try to find one
|
||||
cgDb = this->getRemoteAircraftProvider() ? this->getRemoteAircraftProvider()->getCGFromDB(m_callsign) : CLength::null();
|
||||
}
|
||||
else if (this->getRemoteAircraftProvider())
|
||||
{
|
||||
// if a value has been passed, remember it
|
||||
if (m_model.hasModelString()) { this->getRemoteAircraftProvider()->rememberCGFromDB(cgDb, m_model.getModelString()); }
|
||||
if (!m_model.getCallsign().isEmpty()) { this->getRemoteAircraftProvider()->rememberCGFromDB(cgDb, m_model.getCallsign()); }
|
||||
}
|
||||
|
||||
const CLength cg = this->getSimulatorOrDbCG(m_callsign, cgDb); // simulation environment
|
||||
m_model.setCG(cg);
|
||||
m_model.setCallsign(m_callsign);
|
||||
return cg;
|
||||
@@ -511,7 +523,7 @@ namespace BlackMisc
|
||||
|
||||
if (!m_model.hasCG() || slowUpdateStep)
|
||||
{
|
||||
this->getAndFetchModelCG(); // update CG
|
||||
this->getAndFetchModelCG(CLength::null()); // update CG
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
@@ -584,7 +596,7 @@ namespace BlackMisc
|
||||
m_model = model;
|
||||
}
|
||||
}
|
||||
this->getAndFetchModelCG();
|
||||
this->getAndFetchModelCG(model.getCG());
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace BlackMisc
|
||||
Aviation::CAircraftSituationList remoteAircraftSituationsAndChange(const CInterpolationAndRenderingSetupPerCallsign &setup);
|
||||
|
||||
//! Center of gravity, fetched from provider in case needed
|
||||
PhysicalQuantities::CLength getAndFetchModelCG();
|
||||
PhysicalQuantities::CLength getAndFetchModelCG(const PhysicalQuantities::CLength &dbCG);
|
||||
|
||||
//! Deferred init
|
||||
void deferredInit();
|
||||
|
||||
Reference in New Issue
Block a user