2016-09-27 17:32:12 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <glm/vec2.hpp>
|
2016-09-27 17:43:40 +00:00
|
|
|
#include <vector>
|
2016-09-27 17:32:12 +00:00
|
|
|
|
|
|
|
namespace game {
|
2016-09-27 17:43:40 +00:00
|
|
|
class Missile;
|
|
|
|
|
2016-09-27 17:32:12 +00:00
|
|
|
/*
|
|
|
|
* Trace of a missile through the space.
|
|
|
|
* Useful for rendering sth. like a smoke trail to follow the rocket.
|
|
|
|
*/
|
|
|
|
class Trace {
|
|
|
|
public:
|
2016-09-27 17:43:40 +00:00
|
|
|
Trace(const Missile *missile);
|
|
|
|
|
2016-09-27 18:13:09 +00:00
|
|
|
// Add the current position of the missile as a new point on the
|
|
|
|
// trace.
|
|
|
|
// Parameters:
|
|
|
|
// forceAdd: set to true to add this point (good for the endpoint of
|
|
|
|
// the missile) in case the fidelityCounter would skip the current position.
|
|
|
|
void addPointFromMissile(bool forceAdd=false);
|
|
|
|
|
|
|
|
// TODO: add extendLastPointToPosition() method for saving points /
|
|
|
|
// optimization later on
|
2016-09-27 17:43:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Trace point data to be used when rendering.
|
|
|
|
*/
|
|
|
|
struct TracePoint {
|
|
|
|
TracePoint(const Missile *missile);
|
2016-09-27 17:32:12 +00:00
|
|
|
|
2016-09-27 18:13:09 +00:00
|
|
|
glm::vec2 position;
|
|
|
|
float speed;
|
2016-09-27 17:43:40 +00:00
|
|
|
};
|
2016-09-27 17:32:12 +00:00
|
|
|
|
2016-09-27 17:43:40 +00:00
|
|
|
std::vector<TracePoint> points;
|
2016-09-27 18:13:09 +00:00
|
|
|
const Missile *missile; // missile which creates this path.
|
|
|
|
|
|
|
|
// counter which is incremented each time addPointFromMissile() is called.
|
|
|
|
// when reaching a certain value the point is saved for
|
|
|
|
// optimization.
|
|
|
|
int fidelityCounter;
|
2016-09-27 17:32:12 +00:00
|
|
|
};
|
|
|
|
}
|