Files
pilotclient/src/blackmisc/simulation/interpolatormulti.cpp
Klaus Basan 181ed36f3d Ref T270, interpolator optimization by passing aircraft number
Rational: Except for FS9 we interpolate all aircraft in one loop at the same time. This can cause that some steps are always done at the same time for all aircraft of that loop. By passing the number we can more equally distribute such tasks, avoiding peaks.
2018-06-13 13:59:39 +02:00

81 lines
3.3 KiB
C++

/* Copyright (C) 2017
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#include "blackmisc/simulation/interpolatormulti.h"
using namespace BlackMisc::Aviation;
namespace BlackMisc
{
namespace Simulation
{
CInterpolatorMulti::CInterpolatorMulti(const CCallsign &callsign, ISimulationEnvironmentProvider *p1, IInterpolationSetupProvider *p2, IRemoteAircraftProvider *p3, CInterpolationLogger *logger) :
m_spline(callsign, p1, p2, p3, logger),
m_linear(callsign, p1, p2, p3, logger)
{}
CInterpolationResult CInterpolatorMulti::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber)
{
switch (setup.getInterpolatorMode())
{
case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolation(currentTimeSinceEpoc, setup, aircraftNumber);
case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolation(currentTimeSinceEpoc, setup, aircraftNumber);
default: break;
}
return CInterpolationResult();
}
const CAircraftSituation &CInterpolatorMulti::getLastInterpolatedSituation(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
{
switch (mode)
{
case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getLastInterpolatedSituation();
case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getLastInterpolatedSituation();
default: break;
}
return CAircraftSituation::null();
}
void CInterpolatorMulti::attachLogger(CInterpolationLogger *logger)
{
m_linear.attachLogger(logger);
m_spline.attachLogger(logger);
}
void CInterpolatorMulti::initCorrespondingModel(const CAircraftModel &model)
{
m_linear.initCorrespondingModel(model);
m_spline.initCorrespondingModel(model);
}
QString CInterpolatorMulti::getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
{
switch (mode)
{
case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolatorInfo();
case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolatorInfo();
default: break;
}
return ("Illegal mode");
}
CInterpolatorMultiWrapper::CInterpolatorMultiWrapper()
{ }
CInterpolatorMultiWrapper::CInterpolatorMultiWrapper(const Aviation::CCallsign &callsign, ISimulationEnvironmentProvider *p1, IInterpolationSetupProvider *p2, IRemoteAircraftProvider *p3, CInterpolationLogger *logger)
{
m_interpolator.reset(new CInterpolatorMulti(callsign, p1, p2, p3));
m_interpolator->attachLogger(logger);
}
} // ns
} // ns