Added texture detection for walls and 3D floors; renamed some fields to more intuitive names

This commit is contained in:
ZZYZX 2018-01-20 15:49:46 +02:00 committed by Christoph Oelckers
parent a7ff62316d
commit 74b937620e
2 changed files with 30 additions and 6 deletions

View file

@ -959,7 +959,7 @@ IMPLEMENT_CLASS(DTracer, false, false)
DEFINE_FIELD_X(Tracer, DTracer, Results)
// define TraceResults fields
DEFINE_FIELD_NAMED_X(TraceResults, FTraceResults, Sector, Sec)
DEFINE_FIELD_NAMED_X(TraceResults, FTraceResults, Sector, HitSector)
DEFINE_FIELD_X(TraceResults, FTraceResults, HitTexture)
DEFINE_FIELD_X(TraceResults, FTraceResults, HitPos)
DEFINE_FIELD_X(TraceResults, FTraceResults, HitVector)
@ -967,8 +967,8 @@ DEFINE_FIELD_X(TraceResults, FTraceResults, SrcFromTarget)
DEFINE_FIELD_X(TraceResults, FTraceResults, SrcAngleFromTarget)
DEFINE_FIELD_X(TraceResults, FTraceResults, Distance)
DEFINE_FIELD_X(TraceResults, FTraceResults, Fraction)
DEFINE_FIELD_NAMED_X(TraceResults, FTraceResults, Actor, Thing)
DEFINE_FIELD_NAMED_X(TraceResults, FTraceResults, Line, Linedef)
DEFINE_FIELD_NAMED_X(TraceResults, FTraceResults, Actor, HitActor)
DEFINE_FIELD_NAMED_X(TraceResults, FTraceResults, Line, HitLine)
DEFINE_FIELD_X(TraceResults, FTraceResults, Side)
DEFINE_FIELD_X(TraceResults, FTraceResults, Tier)
DEFINE_FIELD_X(TraceResults, FTraceResults, unlinked)
@ -1006,6 +1006,30 @@ ETraceStatus DTracer::TraceCallback(FTraceResults& res, void* pthis)
{
DTracer* self = (DTracer*)pthis;
// "res" here should refer to self->Results anyway.
// patch results a bit. modders don't expect it to work like this most likely.
// code by MarisaKirisame
if (res.HitType == TRACE_HitWall)
{
int txpart;
switch (res.Tier)
{
case TIER_Middle:
res.HitTexture = res.Line->sidedef[res.Side]->textures[1].texture;
break;
case TIER_Upper:
res.HitTexture = res.Line->sidedef[res.Side]->textures[0].texture;
break;
case TIER_Lower:
res.HitTexture = res.Line->sidedef[res.Side]->textures[2].texture;
break;
case TIER_FFloor:
txpart = (res.ffloor->flags & FF_UPPERTEXTURE) ? 0 : (res.ffloor->flags & FF_LOWERTEXTURE) ? 2 : 1;
res.HitTexture = res.ffloor->master->sidedef[0]->textures[txpart].texture;
break;
}
}
return self->CallZScriptCallback();
}

View file

@ -498,7 +498,7 @@ enum ELineTier
struct TraceResults native
{
native Sector Sec; // originally called "Sector". cannot be named like this in ZScript.
native Sector HitSector; // originally called "Sector". cannot be named like this in ZScript.
native TextureID HitTexture;
native vector3 HitPos;
native vector3 HitVector;
@ -508,9 +508,9 @@ struct TraceResults native
native double Distance;
native double Fraction;
native Actor Thing; // valid if hit an actor. // originally called "Actor".
native Actor HitActor; // valid if hit an actor. // originally called "Actor".
native Line Linedef; // valid if hit a line // originally called "Line".
native Line HitLine; // valid if hit a line // originally called "Line".
native uint8 Side;
native uint8 Tier; // see Tracer.ELineTier
native bool unlinked; // passed through a portal without static offset.