mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- undid the workarounds for undefined-ness of negative shifts.
For any mainstream platform that is totally irrelevant and besides, in C++20 it will be well defined and all current compilers on the relevant platforms treat it accordingly. This is not worth deoptimizing the code.
This commit is contained in:
parent
dfb6c0d6fa
commit
c957397573
1 changed files with 2 additions and 3 deletions
|
@ -55,8 +55,7 @@ inline fixed_t FloatToFixed(double f)
|
||||||
|
|
||||||
inline constexpr fixed_t IntToFixed(int32_t f)
|
inline constexpr fixed_t IntToFixed(int32_t f)
|
||||||
{
|
{
|
||||||
// Negative shifts are undefined, so multiply instead of shifting left.
|
return f << FRACBITS;
|
||||||
return f * FRACUNIT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr double FixedToFloat(fixed_t f)
|
inline constexpr double FixedToFloat(fixed_t f)
|
||||||
|
@ -66,7 +65,7 @@ inline constexpr double FixedToFloat(fixed_t f)
|
||||||
|
|
||||||
inline constexpr int32_t FixedToInt(fixed_t f)
|
inline constexpr int32_t FixedToInt(fixed_t f)
|
||||||
{
|
{
|
||||||
return xs_CRoundToInt(FixedToFloat(f));
|
return (f + FRACUNIT/2) >> FRACBITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr unsigned FloatToAngle(double f)
|
inline constexpr unsigned FloatToAngle(double f)
|
||||||
|
|
Loading…
Reference in a new issue