From 044b9e555b5941d8182476b9fa77e42a248b3ae6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Sep 2022 15:56:21 +0200 Subject: [PATCH] - floatified a bit more of nnExtProcessSuperSprites --- source/core/maptypes.h | 1 + source/games/blood/src/gameutil.h | 2 +- source/games/blood/src/nnexts.cpp | 26 +++++++++++--------------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 48f9462fb..c9144df42 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -426,6 +426,7 @@ struct walltype walltype* point2Wall() const; DVector2 delta() const { return point2Wall()->pos - pos; } DVector2 center() const { return(point2Wall()->pos + pos) / 2; } + DAngle normalAngle() const { return delta().Angle() + DAngle90; } bool twoSided() const { return nextsector >= 0; } double Length(); void calcLength(); // this is deliberately not inlined and stored in a file where it can't be found at compile time. diff --git a/source/games/blood/src/gameutil.h b/source/games/blood/src/gameutil.h index eb60dfa3a..16f6148d5 100644 --- a/source/games/blood/src/gameutil.h +++ b/source/games/blood/src/gameutil.h @@ -34,7 +34,7 @@ enum { bool CheckProximity(DBloodActor* pSprite, const DVector3& pos, sectortype* pSector, int nDist); bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist); -int GetWallAngle(walltype* pWall); +[[deprecated]] int GetWallAngle(walltype* pWall); bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int x2, int y2, int z2, int* ix, int* iy, int* iz); int HitScan(DBloodActor* pSprite, int z, int dx, int dy, int dz, unsigned int nMask, int a8); inline int HitScan(DBloodActor* pSprite, double z, int dx, int dy, int dz, unsigned int nMask, int a8) diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 4120b4f29..314acfac7 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1301,19 +1301,17 @@ void nnExtProcessSuperSprites() if ((uwater = pXSector->Underwater) != 0) airVel <<= 6; if (pXSector->panVel != 0 && getflorzofslopeptr(debrisactor->sector(), debrisactor->spr.pos) <= bottom) { - int angle = pXSector->panAngle.Buildang(); int speed = 0; + DAngle angle = pXSector->panAngle; + double speed = 0; if (pXSector->panAlways || pXSector->state || pXSector->busy) { - speed = pXSector->panVel << 9; + speed = pXSector->panVel / 128.; if (!pXSector->panAlways && pXSector->busy) - speed = MulScale(speed, pXSector->busy, 16); + speed = MulScaleF(speed, pXSector->busy, 16); } if (debrisactor->sector()->floorstat & CSTAT_SECTOR_ALIGN) - angle = (angle + GetWallAngle(debrisactor->sector()->firstWall()) + 512) & 2047; - int dx = MulScale(speed, Cos(angle), 30); - int dy = MulScale(speed, Sin(angle), 30); - debrisactor->add_int_bvel_x(dx); - debrisactor->add_int_bvel_y(dy); + angle += debrisactor->sector()->firstWall()->normalAngle(); + debrisactor->vel += angle.ToVector() * speed; } } @@ -1329,22 +1327,20 @@ void nnExtProcessSuperSprites() if (pact && pact->hit.hit.type == kHitSprite && pact->hit.hit.actor() == debrisactor) { - int nSpeed = approxDist(pact->int_vel().X, pact->int_vel().Y); - nSpeed = ClipLow(nSpeed - MulScale(nSpeed, mass, 6), 0x9000 - (mass << 3)); - - debrisactor->add_int_bvel_x(MulScale(nSpeed, Cos(pPlayer->actor->int_ang()), 30)); - debrisactor->add_int_bvel_y(MulScale(nSpeed, Sin(pPlayer->actor->int_ang()), 30)); + double nSpeed = pact->vel.XY().Length(); + nSpeed = max(nSpeed - MulScaleF(nSpeed, mass, 6), FixedToFloat(0x9000 - (mass << 3))); // very messy math (TM)... + debrisactor->vel += pPlayer->actor->spr.angle.ToVector() * nSpeed; debrisactor->hit.hit.setSprite(pPlayer->actor); } } } if (debrisactor->xspr.physAttr & kPhysGravity) debrisactor->xspr.physAttr |= kPhysFalling; - if ((debrisactor->xspr.physAttr & kPhysFalling) || debrisactor->vel.X != 0 || debrisactor->vel.Y != 0 || debrisactor->vel.Z != 0 || debrisactor->sector()->velFloor || debrisactor->sector()->velCeil) + if ((debrisactor->xspr.physAttr & kPhysFalling) || !debrisactor->vel.isZero() || debrisactor->sector()->velFloor || debrisactor->sector()->velCeil) debrisMove(i); - if (debrisactor->vel.X != 0 || debrisactor->int_vel().Y) + if (!debrisactor->vel.XY().isZero()) debrisactor->xspr.goalAng = VecToAngle(debrisactor->vel); debrisactor->norm_ang();