- Blood: Floatified vector addition in ConcussSprite().

This commit is contained in:
Mitchell Richters 2022-09-18 19:21:12 +10:00 committed by Christoph Oelckers
parent bd9dfadf6d
commit 6efe565f7c
2 changed files with 10 additions and 8 deletions

View file

@ -80,11 +80,16 @@ bool ScanDirectory(TArray<FFileList> &list, const char *dirpath);
bool IsAbsPath(const char*);
FString M_ZLibError(int zerrnum);
inline int32_t Scale(int32_t a, int32_t b, int32_t c)
inline constexpr int32_t Scale(int32_t a, int32_t b, int32_t c)
{
return (int32_t)(((int64_t)a * b) / c);
}
inline constexpr double Scale(double a, double b, double c)
{
return (a * b) / c;
}
class FileReader;
struct MD5Context;

View file

@ -2550,7 +2550,7 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, const DVector
if (actor->spr.flags & kPhysMove)
{
int mass = 0;
double mass = 0;
if (actor->IsDudeActor())
{
mass = getDudeInfo(actor->spr.type)->mass;
@ -2573,14 +2573,11 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, const DVector
if (mass > 0)
{
int size = (tileWidth(actor->spr.picnum) * actor->spr.xrepeat * tileHeight(actor->spr.picnum) * actor->spr.yrepeat) >> 1;
int t = Scale(damage, size, mass);
actor->add_int_bvel_x((int)MulScaleF(t, vect.X, 12));
actor->add_int_bvel_y((int)MulScaleF(t, vect.Y, 12));
actor->add_int_bvel_z((int)MulScaleF(t, vect.Z, 12));
double size = FixedToFloat<29>(tileWidth(actor->spr.picnum) * actor->spr.xrepeat * tileHeight(actor->spr.picnum) * actor->spr.yrepeat);
actor->vel += vect * Scale(damage, size, mass);
}
}
actDamageSprite(source, actor, kDamageExplode, damage);
actDamageSprite(source, actor, kDamageExplode, int(damage));
}
//---------------------------------------------------------------------------