- Major cleanup of Q16.16 utilisation within games and engine.

* Remove fix16.h/cpp and utilise library from m_fixed.h.
* Extend m_fixed.h with two inline functions for int to/from float operations.
* Replace fix16_floor operations with those from xs_Float.h
* Replace multiple Q16.16 conversions from 0 to just be 0.
* Replaced all found in-game bit-shifts and multiplications/divisions with inline functions from m_fixed.h
* Replaced many casts of FRACUNIT as double in SW's panel.cpp as it is converted to double by way of type promotion.
* Fixed missed precision fixes in SW's panel.cpp where some types weren't declared correctly.
* Replaced 100+ `Cos()/Sin() >> 16` operations for Blood with inline functions `CosScale16()/SinScale16()`.
This commit is contained in:
Mitchell Richters 2020-09-01 23:00:35 +10:00
parent d40e53eb53
commit 1354d52c05
104 changed files with 906 additions and 1579 deletions

View file

@ -90,7 +90,7 @@ public:
return binangle(value - other.value);
}
void interpolate(binangle a1, binangle a2, fix16_t smoothratio)
void interpolate(binangle a1, binangle a2, fixed_t smoothratio)
{
// Calculate in floating point to reduce the error caused by overflows which are to be expected here and then downconvert using a method that is safe to overflow.
// We do not want fixed point multiplications here to trash the result.
@ -115,7 +115,7 @@ public:
fixedhoriz(const fixedhoriz &other) = default;
// This class intentionally makes no allowances for implicit type conversions because those would render it ineffective.
short asbuild() const { return value >> 16; }
short asbuild() const { return FixedToInt(value); }
constexpr fixed_t asq16() const { return value; }
bool operator< (fixedhoriz other) const
@ -184,5 +184,5 @@ inline binangle radang(double v) { return binangle(xs_CRoundToUInt(v * (0x800000
inline binangle degang(double v) { return binangle(xs_CRoundToUInt(v * (0x40000000 / 90.))); }
inline constexpr fixedhoriz q16horiz(int v) { return fixedhoriz(v); }
inline constexpr fixedhoriz buildhoriz(int v) { return fixedhoriz(v << 16); }
inline constexpr fixedhoriz buildhoriz(int v) { return fixedhoriz(IntToFixed(v)); }