diff --git a/source/build/include/buildtypes.h b/source/build/include/buildtypes.h index ba52cb80c..98b6bb7f4 100644 --- a/source/build/include/buildtypes.h +++ b/source/build/include/buildtypes.h @@ -79,14 +79,14 @@ struct sectortype int ceilingypan() const { return int(ceilingypan_); } int floorxpan() const { return int(floorxpan_); } int floorypan() const { return int(floorypan_); } - void setfloorxpan(float val) { floorxpan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void setfloorypan(float val) { floorypan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void setceilingxpan(float val) { ceilingxpan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void setceilingypan(float val) { ceilingypan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void addfloorxpan(float add) { floorxpan_ = fmod(floorxpan_ + add + 512, 256); } // +512 is for handling negative offsets - void addfloorypan(float add) { floorypan_ = fmod(floorypan_ + add + 512, 256); } // +512 is for handling negative offsets - void addceilingxpan(float add) { ceilingxpan_ = fmod(ceilingxpan_ + add + 512, 256); } // +512 is for handling negative offsets - void addceilingypan(float add) { ceilingypan_ = fmod(ceilingypan_ + add + 512, 256); } // +512 is for handling negative offsets + void setfloorxpan(float val) { floorxpan_ = fmodf(val + 512, 256); } // +512 is for handling negative offsets + void setfloorypan(float val) { floorypan_ = fmodf(val + 512, 256); } // +512 is for handling negative offsets + void setceilingxpan(float val) { ceilingxpan_ = fmodf(val + 512, 256); } // +512 is for handling negative offsets + void setceilingypan(float val) { ceilingypan_ = fmodf(val + 512, 256); } // +512 is for handling negative offsets + void addfloorxpan(float add) { floorxpan_ = fmodf(floorxpan_ + add + 512, 256); } // +512 is for handling negative offsets + void addfloorypan(float add) { floorypan_ = fmodf(floorypan_ + add + 512, 256); } // +512 is for handling negative offsets + void addceilingxpan(float add) { ceilingxpan_ = fmodf(ceilingxpan_ + add + 512, 256); } // +512 is for handling negative offsets + void addceilingypan(float add) { ceilingypan_ = fmodf(ceilingypan_ + add + 512, 256); } // +512 is for handling negative offsets }; //cstat: @@ -130,10 +130,10 @@ struct walltype int xpan() const { return int(xpan_); } int ypan() const { return int(ypan_); } - void setxpan(float add) { xpan_ = fmod(add + 512, 256); } // +512 is for handling negative offsets - void setypan(float add) { ypan_ = fmod(add + 512, 256); } // +512 is for handling negative offsets - void addxpan(float add) { xpan_ = fmod(xpan_ + add + 512, 256); } // +512 is for handling negative offsets - void addypan(float add) { ypan_ = fmod(ypan_ + add + 512, 256); } // +512 is for handling negative offsets + void setxpan(float add) { xpan_ = fmodf(add + 512, 256); } // +512 is for handling negative offsets + void setypan(float add) { ypan_ = fmodf(add + 512, 256); } // +512 is for handling negative offsets + void addxpan(float add) { xpan_ = fmodf(xpan_ + add + 512, 256); } // +512 is for handling negative offsets + void addypan(float add) { ypan_ = fmodf(ypan_ + add + 512, 256); } // +512 is for handling negative offsets #if 0 // make sure we do not accidentally copy this diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index b843b1688..4b033c31a 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -362,22 +362,37 @@ inline binangle bvectangbam(int32_t x, int32_t y) // //--------------------------------------------------------------------------- -inline int32_t interpolatedvalue(int32_t oval, int32_t val, double const smoothratio, int const scale = 16) +inline constexpr int32_t interpolatedvalue(int32_t oval, int32_t val, double const smoothratio, int const scale = 16) +{ + return oval + MulScale(val - oval, int(smoothratio), scale); +} + +inline constexpr int32_t interpolatedvalue(int32_t oval, int32_t val, int const smoothratio, int const scale = 16) { return oval + MulScale(val - oval, smoothratio, scale); } -inline double interpolatedvaluef(double oval, double val, double const smoothratio, int const scale = 16) +inline constexpr double interpolatedvaluef(double oval, double val, double const smoothratio, int const scale = 16) { return oval + MulScaleF(val - oval, smoothratio, scale); } -inline int32_t interpolatedangle(int32_t oang, int32_t ang, double const smoothratio, int const scale = 16) +inline constexpr int32_t interpolatedangle(int32_t oang, int32_t ang, double const smoothratio, int const scale = 16) +{ + return oang + MulScale(((ang + 1024 - oang) & 2047) - 1024, int(smoothratio), scale); +} + +inline constexpr int32_t interpolatedangle(int32_t oang, int32_t ang, int const smoothratio, int const scale = 16) { return oang + MulScale(((ang + 1024 - oang) & 2047) - 1024, smoothratio, scale); } -inline binangle interpolatedangle(binangle oang, binangle ang, double const smoothratio, int const scale = 16) +inline constexpr binangle interpolatedangle(binangle oang, binangle ang, double const smoothratio, int const scale = 16) +{ + return bamang(oang.asbam() + MulScale(((ang.asbam() + 0x80000000 - oang.asbam()) & 0xFFFFFFFF) - 0x80000000, int(smoothratio), scale)); +} + +inline constexpr binangle interpolatedangle(binangle oang, binangle ang, int const smoothratio, int const scale = 16) { return bamang(oang.asbam() + MulScale(((ang.asbam() + 0x80000000 - oang.asbam()) & 0xFFFFFFFF) - 0x80000000, smoothratio, scale)); }