Skip to content

Commit f5ba29c

Browse files
committed
allow more granular background orientations
Since bitmaps, suns, and skyboxes store their coordinates as floating-point numbers, we can allow mission designers to specify floating-point numbers in the FRED UI. This PR modifies the dialogs in FRED and QtFRED to allow two decimal places for pitch, bank, and heading. Implements #7170.
1 parent 306f34a commit f5ba29c

12 files changed

Lines changed: 361 additions & 231 deletions

code/math/floating.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <cfloat>
1717
#include <limits>
1818

19+
#include "globalincs/pstypes.h" // for PI
20+
1921
extern float frand();
2022
extern int rand_chance(float frametime, float chance = 1.0f);
2123
float frand_range(float min, float max);
@@ -51,6 +53,20 @@ inline bool fl_is_nan(float fl) {
5153
// convert a measurement in radians to degrees
5254
#define fl_degrees(fl) (static_cast<float>((fl) * (180.0f / PI)))
5355

56+
constexpr float DEGREE_UB = 359.99f; // upper bound in degrees when rounding to 100ths place
57+
58+
// convert a measurement in radians to degrees, rounding to the nearest .01 (used in FRED)
59+
constexpr float fl_degrees_100ths(float fl)
60+
{
61+
float val = fl_degrees(fl);
62+
63+
float new_val = fl2ir(val * 100.0f) / 100.0f;
64+
if (new_val > DEGREE_UB)
65+
new_val -= 360.0f;
66+
67+
return new_val;
68+
}
69+
5470
// sees if a floating point number is within a certain threshold (by default, epsilon) of zero
5571
inline bool fl_near_zero(float a, float e = std::numeric_limits<float>::epsilon())
5672
{

0 commit comments

Comments
 (0)