- refactored actWallBounceVector as well

This completes the abstraction of velocity in Blood.
This commit is contained in:
Christoph Oelckers 2022-09-03 09:37:52 +02:00
parent 92532bb007
commit f2d89b7609
5 changed files with 10 additions and 27 deletions

View file

@ -2589,15 +2589,13 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, const DVector
//
//---------------------------------------------------------------------------
int actWallBounceVector(int* x, int* y, walltype* pWall, int a4)
void actWallBounceVector(DBloodActor* actor, walltype* pWall, double factor)
{
int wx, wy;
GetWallNormal(pWall, &wx, &wy);
int t = DMulScale(*x, wx, *y, wy, 16);
int t2 = mulscale16r(t, a4 + 0x10000);
*x -= MulScale(wx, t2, 16);
*y -= MulScale(wy, t2, 16);
return mulscale16r(t, 0x10000 - a4);
auto delta = pWall->delta().Unit();
auto vel = actor->fVel().XY();
double t = vel.X * -delta.Y + vel.Y * delta.X;
double t2 = t * (factor+1);
actor->set_float_bvel_xy(vel - DVector2(-delta.Y * t2, delta.X * t2));
}
//---------------------------------------------------------------------------
@ -4548,7 +4546,7 @@ static Collision MoveThing(DBloodActor* actor)
auto& coll = actor->hit.hit;
if (coll.type == kHitWall)
{
actWallBounceVector(&actor->__int_vel.X, &actor->__int_vel.Y, coll.hitWall, pThingInfo->elastic);
actWallBounceVector(actor, coll.hitWall, FixedToFloat(pThingInfo->elastic));
switch (actor->spr.type)
{
case kThingZombieHead:
@ -4829,7 +4827,7 @@ void MoveDude(DBloodActor* actor)
// ???
}
}
actWallBounceVector((int*)&actor->__int_vel.X, (int*)&actor->__int_vel.Y, pHitWall, 0);
actWallBounceVector(actor, pHitWall, 0);
break;
}
}

View file

@ -210,7 +210,7 @@ void TreeToGibCallback(int, int);
bool IsUnderwaterSector(sectortype* pSector);
void actInit(TArray<DBloodActor*>& actors);
int actWallBounceVector(int *x, int *y, walltype* pWall, int a4);
void actWallBounceVector(DBloodActor* actor, walltype* pWall, double factor);
DVector4 actFloorBounceVector(DBloodActor* actor, double oldz, sectortype* pSector, double factor);
void actRadiusDamage(DBloodActor* source, const DVector3& pos, sectortype* pSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11);
DBloodActor *actDropObject(DBloodActor *pSprite, int nType);

View file

@ -239,20 +239,6 @@ int GetWallAngle(walltype* pWall)
return getangle(pWall->delta());
}
void GetWallNormal(walltype* pWall, int* pX, int* pY)
{
auto delta = pWall->int_delta();
int dX = -delta.Y >> 4;
int dY = delta.X >> 4;
int nLength = ksqrt(dX * dX + dY * dY);
if (nLength <= 0)
nLength = 1;
*pX = DivScale(dX, nLength, 16);
*pY = DivScale(dY, nLength, 16);
}
//---------------------------------------------------------------------------
//
//

View file

@ -35,7 +35,6 @@ 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);
void GetWallNormal(walltype* pWall, int* pX, int* pY);
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)

View file

@ -1689,7 +1689,7 @@ void debrisMove(int listIndex)
if (actor->hit.hit.type == kHitWall)
{
moveHit = actor->hit.hit;
actWallBounceVector(&actor->__int_vel.X, &actor->__int_vel.Y, moveHit.hitWall, tmpFraction);
actWallBounceVector(actor, moveHit.hitWall, FixedToFloat(tmpFraction));
}
}