Ref T681, fixed handling of CG from DB

* consider settings
* remember DB CG data correctly
This commit is contained in:
Klaus Basan
2019-08-28 22:59:45 +02:00
parent 7831759a93
commit c26b6f7c85
3 changed files with 23 additions and 7 deletions

View File

@@ -864,7 +864,11 @@ namespace BlackCore
const CLength cgOvr = this->overriddenCGorDefault(simulatorCG, modelString); const CLength cgOvr = this->overriddenCGorDefault(simulatorCG, modelString);
if (!cgOvr.isNull() && !this->hasSameSimulatorCG(cgOvr, callsign)) 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 // here we know we have a valid model and CG did change
const CSimulatorInfo sim = this->getSimulatorInfo(); const CSimulatorInfo sim = this->getSimulatorInfo();

View File

@@ -56,10 +56,22 @@ namespace BlackMisc
} }
template<typename Derived> 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(); CLength cgDb = dbCG;
const CLength cg = this->getSimulatorOrDbCG(m_callsign, cgDB); // simulation environment 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.setCG(cg);
m_model.setCallsign(m_callsign); m_model.setCallsign(m_callsign);
return cg; return cg;
@@ -511,7 +523,7 @@ namespace BlackMisc
if (!m_model.hasCG() || slowUpdateStep) if (!m_model.hasCG() || slowUpdateStep)
{ {
this->getAndFetchModelCG(); // update CG this->getAndFetchModelCG(CLength::null()); // update CG
} }
bool success = false; bool success = false;
@@ -584,7 +596,7 @@ namespace BlackMisc
m_model = model; m_model = model;
} }
} }
this->getAndFetchModelCG(); this->getAndFetchModelCG(model.getCG());
} }
template<typename Derived> template<typename Derived>

View File

@@ -316,7 +316,7 @@ namespace BlackMisc
Aviation::CAircraftSituationList remoteAircraftSituationsAndChange(const CInterpolationAndRenderingSetupPerCallsign &setup); Aviation::CAircraftSituationList remoteAircraftSituationsAndChange(const CInterpolationAndRenderingSetupPerCallsign &setup);
//! Center of gravity, fetched from provider in case needed //! Center of gravity, fetched from provider in case needed
PhysicalQuantities::CLength getAndFetchModelCG(); PhysicalQuantities::CLength getAndFetchModelCG(const PhysicalQuantities::CLength &dbCG);
//! Deferred init //! Deferred init
void deferredInit(); void deferredInit();