KlassischeKeplerKriege/game/state/trace.cpp
2016-09-27 22:35:16 +02:00

32 lines
689 B
C++

#include "trace.hpp"
#include <glm/gtx/norm.hpp>
#include "missile.hpp"
namespace game {
Trace::TracePoint::TracePoint(const Missile *missile)
: position(missile->position)
, speed(glm::length(missile->velocity))
{
}
Trace::Trace(const Missile *missile) : missile(missile), fidelityCounter(0)
{
points.push_back(TracePoint(missile));
}
void Trace::addPointFromMissile(bool forceAdd)
{
fidelityCounter++;
if (forceAdd || fidelityCounter >= 10) {
fidelityCounter = 0;
points.push_back(TracePoint(missile));
}
}
void Trace::finish()
{
missile = nullptr;
}
}