2016-09-27 17:43:40 +00:00
|
|
|
#include "trace.hpp"
|
|
|
|
|
|
|
|
#include <glm/gtx/norm.hpp>
|
|
|
|
|
|
|
|
#include "missile.hpp"
|
|
|
|
|
2016-09-27 21:07:11 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2016-09-27 17:43:40 +00:00
|
|
|
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 21:07:11 +00:00
|
|
|
Trace::~Trace()
|
|
|
|
{
|
|
|
|
//std::cout<<"~Trace()" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
Trace::Trace(Missile *missile)
|
|
|
|
: missile(missile)
|
|
|
|
, player(missile->player)
|
|
|
|
, fidelityCounter(0)
|
|
|
|
, age(0.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++;
|
2016-09-27 18:23:33 +00:00
|
|
|
if (forceAdd || fidelityCounter >= 10) {
|
2016-09-27 18:13:09 +00:00
|
|
|
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()
|
|
|
|
{
|
2016-09-27 21:07:11 +00:00
|
|
|
//std::cout<<"trace finished now!" << std::endl;
|
2016-09-27 20:35:16 +00:00
|
|
|
missile = nullptr;
|
|
|
|
}
|
2016-09-27 17:43:40 +00:00
|
|
|
}
|