Files
FSCyborg a17f5031bf Fix the unique pointer and constructor
Unique pointers need to be constructed in very particular ways, but so did this NGON radar class, so we just had to put the constructor function inside unique pointer constructor.

And to keep that special pointer from going out of scope, we switched to the ternery operator.

Also made these changes:
Change to hypotf()
Fix Shadowing, Zero Vector macro not working at all.
Offset changed to offset_incoming
blip changed to blip_instance
Offset changed to = {} to initialize the struct without a problem.
clampBlip() required an override
Give offset a default initializer.
Switch to <cmath>
(Apparently <math.h> was deprecated and needs to be replaced with <cmath>.)
One last complaint from travis about a redundant default value.

Thank you Travis!
2019-11-10 13:49:31 -05:00

60 lines
1.6 KiB
C++

/*
* z64555's N-gon radar
*
* You may not sell or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#ifndef _RADAR_NGON_H
#define _RADAR_NGON_H
#include "radar/radarsetup.h"
#include "radar/radar.h"
const int RADAR_NGON_MIN_SIDES = 3; //!< Required, things break if n < 3
/**
* @brief Flavor of the standard radar gauge which has an polygonal plot surface (vs. the standard oval)
*/
class HudGaugeRadarNgon : public HudGaugeRadarStd
{
float arclen; // The arc length of each n-gon sector (radians)
float offset {0.0f}; // The angle offset of the plot area (+ is counter-clockwise) (radians),
float r_min; // The apothem of the ngon (0.0f < r_min <= 1.0f)
protected:
/**
* @brief Forms the N-gon edge/line that the blip will be clamped/projected to
* @param[out] p Reference point for the line
* @param[out] v Directional vector (not normalized) for the line
* @param[in] angle The azimuth of the blip on the plot surface;
*/
void formLine(vec3d* p, vec3d* v, float angle);
/**
* @brief Clamps and scales the blip to be within the plot area
* @param[in] vec The blip coordinates (only x and y are nonzero)
*/
void clampBlip(vec3d* blip) override;
public:
/**
* @brief Default constructor the Ngon radar.
*
* @note This shouldn't be actually used, but it breaks compiling if the default constructor isn't present
*/
HudGaugeRadarNgon();
/**
* @brief Constructor for the Ngon radar
*
* @param[in] num_sides Number of sides the n-gon should have
* @param[in] offset Offset angle, in degrees
*/
HudGaugeRadarNgon(int num_sides, float offset);
};
#endif