KlassischeKeplerKriege/game/state/trace.cpp

33 lines
689 B
C++
Raw Normal View History

2016-09-27 17:43:40 +00:00
#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))
2016-09-27 17:43:40 +00:00
{
}
Trace::Trace(const Missile *missile) : missile(missile), fidelityCounter(0)
2016-09-27 17:43:40 +00:00
{
points.push_back(TracePoint(missile));
}
void Trace::addPointFromMissile(bool forceAdd)
2016-09-27 17:43:40 +00:00
{
fidelityCounter++;
if (forceAdd || fidelityCounter >= 10) {
fidelityCounter = 0;
points.push_back(TracePoint(missile));
}
2016-09-27 17:43:40 +00:00
}
2016-09-27 20:35:16 +00:00
void Trace::finish()
{
missile = nullptr;
}
2016-09-27 17:43:40 +00:00
}