Fix MSVS compile bug and add offset parameter for SprayDecal

This commit is contained in:
Mekboss 2020-04-07 23:11:49 +03:00 committed by Christoph Oelckers
commit 4807f4240b
4 changed files with 30 additions and 16 deletions

View file

@ -830,25 +830,36 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl
//
//----------------------------------------------------------------------------
void SprayDecal(AActor *shooter, const char *name, double distance, DVector3 Dir)
void SprayDecal(AActor *shooter, const char *name, double distance, DVector3 offset, DVector3 direction)
{
//just in case
if (!shooter)
return;
FTraceResults trace;
DVector3 vec;
//use new behavior only if directional vector not equal to zero vector
if (!Dir.isZero() )
{
vec = Dir;
}
DVector3 off(0, 0, 0), dir(0, 0, 0);
//use vanilla offset only if "custom" equal to zero
if (offset.isZero() )
off = shooter->PosPlusZ(shooter->Height / 2);
else
off = shooter->Pos() + offset;
//same for direction
if (direction.isZero() )
{
DAngle ang = shooter->Angles.Yaw;
DAngle pitch = shooter->Angles.Pitch;
double c = pitch.Cos();
vec = DVector3(c * ang.Cos(), c * ang.Sin(), -pitch.Sin());
dir = DVector3(c * ang.Cos(), c * ang.Sin(), -pitch.Sin());
}
else
dir = direction;
if (Trace(shooter->PosPlusZ(shooter->Height / 2), shooter->Sector, vec, distance, 0, ML_BLOCKEVERYTHING, shooter, trace, TRACE_NoSky))
if (Trace(off, shooter->Sector, dir, distance, 0, ML_BLOCKEVERYTHING, shooter, trace, TRACE_NoSky))
{
if (trace.HitType == TRACE_HitWall)
{