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)
|
2016-09-27 18:13:09 +00:00
|
|
|
: position(missile->position)
|
|
|
|
, speed(glm::length(missile->velocity))
|
2016-09-27 17:43:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-09-27 18:13:09 +00:00
|
|
|
Trace::Trace(const Missile *missile) : missile(missile), fidelityCounter(0)
|
2016-09-27 17:43:40 +00:00
|
|
|
{
|
|
|
|
points.push_back(TracePoint(missile));
|
|
|
|
}
|
|
|
|
|
2016-09-27 18:13:09 +00:00
|
|
|
void Trace::addPointFromMissile(bool forceAdd)
|
2016-09-27 17:43:40 +00:00
|
|
|
{
|
2016-09-27 18:13:09 +00:00
|
|
|
fidelityCounter++;
|
|
|
|
if (forceAdd || fidelityCounter >= 20) {
|
|
|
|
fidelityCounter = 0;
|
|
|
|
points.push_back(TracePoint(missile));
|
|
|
|
}
|
2016-09-27 17:43:40 +00:00
|
|
|
}
|
|
|
|
}
|