- Blood: Initial pass at floatifying actFloorBounceVector().

* Direct translation of the original code.
This commit is contained in:
Mitchell Richters 2022-09-18 21:10:37 +10:00 committed by Christoph Oelckers
parent cdf45103ad
commit 8e851c8b00
2 changed files with 14 additions and 15 deletions

View file

@ -9,7 +9,6 @@
__forceinline constexpr int32_t MulScale(int32_t a, int32_t b, int32_t shift) { return (int32_t)(((int64_t)a * b) >> shift); } __forceinline constexpr int32_t MulScale(int32_t a, int32_t b, int32_t shift) { return (int32_t)(((int64_t)a * b) >> shift); }
__forceinline constexpr double MulScaleF(double a, double b, int32_t shift) { return (a * b) * (1. / (uint32_t(1) << shift)); } __forceinline constexpr double MulScaleF(double a, double b, int32_t shift) { return (a * b) * (1. / (uint32_t(1) << shift)); }
__forceinline constexpr int32_t DMulScale(int32_t a, int32_t b, int32_t c, int32_t d, int32_t shift) { return (int32_t)(((int64_t)a * b + (int64_t)c * d) >> shift); } __forceinline constexpr int32_t DMulScale(int32_t a, int32_t b, int32_t c, int32_t d, int32_t shift) { return (int32_t)(((int64_t)a * b + (int64_t)c * d) >> shift); }
__forceinline constexpr int32_t TMulScale(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, int32_t shift) { return (int32_t)(((int64_t)a * b + (int64_t)c * d + (int64_t)e * f) >> shift); }
__forceinline constexpr int32_t DivScale(int32_t a, int32_t b, int shift) { return (int32_t)(((int64_t)a << shift) / b); } __forceinline constexpr int32_t DivScale(int32_t a, int32_t b, int shift) { return (int32_t)(((int64_t)a << shift) / b); }
__forceinline constexpr int64_t DivScaleL(int64_t a, int64_t b, int shift) { return ((a << shift) / b); } __forceinline constexpr int64_t DivScaleL(int64_t a, int64_t b, int shift) { return ((a << shift) / b); }

View file

@ -2612,20 +2612,20 @@ DVector4 actFloorBounceVector(DBloodActor* actor, double oldz, sectortype* pSect
} }
walltype* pWall = pSector->firstWall(); walltype* pWall = pSector->firstWall();
auto p = actor->int_vel(); DVector3 p(actor->vel.XY(), oldz);
int angle = getangle(pWall->delta()) + 512; DAngle angle = pWall->delta().Angle() + DAngle90;
int t2 = pSector->floorheinum << 4; auto t2 = pSector->floorheinum * (1. / 4096.);
int t3 = approxDist(-0x10000, t2); auto t3 = DVector2(-1, t2).Length();
int t4 = DivScale(-0x10000, t3, 16); auto t4 = -1 / t3;
int t5 = DivScale(t2, t3, 16); auto t5 = t2 / t3;
int t6 = MulScale(t5, Cos(angle), 30); auto t6 = t5 * angle.Cos();
int t7 = MulScale(t5, Sin(angle), 30); auto t7 = t5 * angle.Sin();
int t8 = TMulScale(p.X, t6, p.Y, t7, oldz, t4, 16); auto t8 = p.dot(DVector3(t6, t7, t4));
int t9 = MulScale(t8, 0x10000 + FloatToFixed(factor), 16); auto t9 = t8 * (1 + factor);
retval.X = FixedToFloat(p.X - MulScale(t6, t9, 16)); retval.X = p.X - (t6 * t9);
retval.Y = FixedToFloat(p.Y - MulScale(t7, t9, 16)); retval.Y = p.Y - (t7 * t9);
retval.Z = FixedToFloat(oldz - MulScale(t4, t9, 16)); retval.Z = p.Z - (t4 * t9);
retval.W = FixedToFloat(t8 * t); retval.W = t8 * t;
return retval; return retval;
} }