- Blood: Floatify remaining gib interfaces.

This commit is contained in:
Mitchell Richters 2022-09-18 22:22:37 +10:00 committed by Christoph Oelckers
parent d92fda4312
commit f2be65777b
6 changed files with 26 additions and 36 deletions

View file

@ -2965,7 +2965,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
double top, bottom;
GetActorExtents(actor, &top, &bottom);
DVector3 gibPos(actor->spr.pos.XY(), top);
CGibVelocity gibVel(actor->int_vel().X >> 1, actor->int_vel().Y >> 1, -0xccccc);
DVector3 gibVel(actor->vel.XY() * 0.5, -FixedToFloat(0xccccc));
GibSprite(actor, nGibType, &gibPos, &gibVel);
}
}
@ -3198,12 +3198,12 @@ static int checkDamageType(DBloodActor* actor, DAMAGE_TYPE damageType)
//
//---------------------------------------------------------------------------
static void spawnGibs(DBloodActor* actor, int type, int velz)
static void spawnGibs(DBloodActor* actor, int type, fixed_t velz)
{
double top, bottom;
GetActorExtents(actor, &top, &bottom);
DVector3 gibPos(actor->spr.pos.XY(), top);
CGibVelocity gibVel(actor->int_vel().X >> 1, actor->int_vel().Y >> 1, velz);
DVector3 gibVel(actor->vel.XY() * 0.5, FixedToFloat(velz));
GibSprite(actor, GIBTYPE_27, &gibPos, &gibVel);
}

View file

@ -543,12 +543,12 @@ inline unsigned int Random(int a1)
return MulScale(wrand(), a1, 15);
}
inline double RandomF(int a1)
inline double RandomF(int a1, int scale = 16)
{
return FixedToFloat(Random(a1));
return FixedToFloat(Random(a1), scale);
}
inline double RandomF(double val, int scale)
inline double RandomD(double val, int scale)
{
return FixedToFloat(Random(FloatToFixed(val, scale)), scale);
}
@ -564,12 +564,12 @@ inline int Random2(int a1)
return MulScale(wrand(), a1, 14) - a1;
}
inline double Random2F(int a1)
inline double Random2F(int a1, int scale = 16)
{
return FixedToFloat(Random2(a1));
return FixedToFloat(Random2(a1), scale);
}
inline double Random2F(double val, int scale)
inline double Random2D(double val, int scale)
{
return FixedToFloat(Random2(FloatToFixed(val, scale)), scale);
}

View file

@ -269,7 +269,7 @@ int ChanceToCount(int a1, int a2)
//
//---------------------------------------------------------------------------
void GibFX(DBloodActor* actor, GIBFX* pGFX, DVector3* pPos, CGibVelocity* pVel)
void GibFX(DBloodActor* actor, GIBFX* pGFX, DVector3* pPos, DVector3* pVel)
{
auto pSector = actor->sector();
if (adult_lockout && gGameOptions.nGameType == 0 && pGFX->fxId == FX_13)
@ -300,9 +300,7 @@ void GibFX(DBloodActor* actor, GIBFX* pGFX, DVector3* pPos, CGibVelocity* pVel)
pFX->spr.pal = actor->spr.pal;
if (pVel)
{
pFX->set_int_bvel_x(pVel->vx + Random2(pGFX->atd));
pFX->set_int_bvel_y(pVel->vy + Random2(pGFX->atd));
pFX->set_int_bvel_z(pVel->vz - Random(pGFX->at11));
pFX->vel = *pVel + DVector3(Random2F(pGFX->atd, 4), Random2F(pGFX->atd, 4), -RandomF(pGFX->at11, 8));
}
else
{
@ -342,7 +340,7 @@ void GibFX(DBloodActor* actor, GIBFX* pGFX, DVector3* pPos, CGibVelocity* pVel)
//
//---------------------------------------------------------------------------
void GibThing(DBloodActor* actor, GIBTHING* pGThing, DVector3* pPos, CGibVelocity* pVel)
void GibThing(DBloodActor* actor, GIBTHING* pGThing, DVector3* pPos, DVector3* pVel)
{
if (adult_lockout && gGameOptions.nGameType <= 0)
switch (pGThing->type) {
@ -381,9 +379,7 @@ void GibThing(DBloodActor* actor, GIBTHING* pGThing, DVector3* pPos, CGibVelocit
gibactor->spr.picnum = pGThing->Kills;
if (pVel)
{
gibactor->set_int_bvel_x(pVel->vx + Random2(pGThing->atc));
gibactor->set_int_bvel_y(pVel->vy + Random2(pGThing->atc));
gibactor->set_int_bvel_z(pVel->vz - Random(pGThing->at10));
gibactor->vel = *pVel + DVector3(Random2F(pGThing->atc, 4), Random2F(pGThing->atc, 4), -RandomF(pGThing->at10, 8));
}
else
{
@ -419,7 +415,7 @@ void GibThing(DBloodActor* actor, GIBTHING* pGThing, DVector3* pPos, CGibVelocit
//
//---------------------------------------------------------------------------
void GibSprite(DBloodActor* actor, GIBTYPE nGibType, DVector3* pPos, CGibVelocity* pVel)
void GibSprite(DBloodActor* actor, GIBTYPE nGibType, DVector3* pPos, DVector3* pVel)
{
assert(actor != NULL);
assert(nGibType >= 0 && nGibType < kGibMax);
@ -447,7 +443,7 @@ void GibSprite(DBloodActor* actor, GIBTYPE nGibType, DVector3* pPos, CGibVelocit
//
//---------------------------------------------------------------------------
void GibFX(walltype* pWall, GIBFX* pGFX, double ceilZ, const DVector3& spread, CGibVelocity* pVel)
void GibFX(walltype* pWall, GIBFX* pGFX, double ceilZ, const DVector3& spread, DVector3* pVel)
{
assert(pWall);
int nCount = ChanceToCount(pGFX->chance, pGFX->at9);
@ -455,9 +451,9 @@ void GibFX(walltype* pWall, GIBFX* pGFX, double ceilZ, const DVector3& spread, C
for (int i = 0; i < nCount; i++)
{
DVector3 r;
r.Z = RandomF(spread.Z, 8) + ceilZ;
r.Y = RandomF(spread.Y, 4) + pWall->pos.Y;
r.X = RandomF(spread.X, 4) + pWall->pos.X;
r.Z = RandomD(spread.Z, 8) + ceilZ;
r.Y = RandomD(spread.Y, 4) + pWall->pos.Y;
r.X = RandomD(spread.X, 4) + pWall->pos.X;
auto pGib = gFX.fxSpawnActor(pGFX->fxId, pSector, r, 0);
if (pGib)
{
@ -471,9 +467,9 @@ void GibFX(walltype* pWall, GIBFX* pGFX, double ceilZ, const DVector3& spread, C
}
else
{
pGib->vel.X = Random2F((pVel->vx << 18) / 120);
pGib->vel.Y = Random2F((pVel->vy << 18) / 120);
pGib->vel.Z = -Random2F((pVel->vz << 18) / 120);
pGib->vel.X = Random2F((pVel->X * 17179869184.) / 120);
pGib->vel.Y = Random2F((pVel->Y * 17179869184.) / 120);
pGib->vel.Z = -Random2F((pVel->Z * 17179869184.) / 120);
}
}
}
@ -485,7 +481,7 @@ void GibFX(walltype* pWall, GIBFX* pGFX, double ceilZ, const DVector3& spread, C
//
//---------------------------------------------------------------------------
void GibWall(walltype* pWall, GIBTYPE nGibType, CGibVelocity* pVel)
void GibWall(walltype* pWall, GIBTYPE nGibType, DVector3* pVel)
{
assert(pWall);
assert(nGibType >= 0 && nGibType < kGibMax);

View file

@ -60,12 +60,6 @@ enum GIBTYPE {
};
class CGibVelocity {
public:
int vx, vy, vz;
CGibVelocity(int _vx, int _vy, int _vz) : vx(_vx), vy(_vy), vz(_vz) {}
};
void GibSprite(DBloodActor* pSprite, GIBTYPE nGibType, DVector3* pPos, CGibVelocity* pVel);
void GibWall(walltype* pWall, GIBTYPE nGibType, CGibVelocity* pVel);
void GibSprite(DBloodActor* pSprite, GIBTYPE nGibType, DVector3* pPos, DVector3* pVel);
void GibWall(walltype* pWall, GIBTYPE nGibType, DVector3* pVel);
END_BLD_NS

View file

@ -2131,7 +2131,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER* pPlayer, DAMAGE_TYPE nDamage
double top, bottom;
GetActorExtents(pActor, &top, &bottom);
DVector3 gibPos(pActor->spr.pos.XY(), top);
CGibVelocity gibVel(pActor->int_vel().X >> 1, pActor->int_vel().Y >> 1, -0xccccc);
DVector3 gibVel(pActor->vel.XY() * 0.5, -FixedToFloat(0xccccc));
GibSprite(pActor, GIBTYPE_27, &gibPos, &gibVel);
GibSprite(pActor, GIBTYPE_7, NULL, NULL);
fxSpawnBlood(pActor, nDamage << 4);

View file

@ -740,7 +740,7 @@ void OperateWall(walltype* pWall, EVENT event)
if (bStatus) {
SetupGibWallState(pWall, pXWall);
if (pXWall->state) {
CGibVelocity vel(100, 100, 250);
auto vel = DVector3(100, 100, 250) * (1. / FRACUNIT);
int nType = ClipRange(pXWall->data, 0, 31);
if (nType > 0)
GibWall(pWall, (GIBTYPE)nType, &vel);