27 lines
624 B
C++
27 lines
624 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));
|
|
}
|
|
}
|
|
}
|