mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-21 03:01:36 +00:00
- simplified slope sprite code a bit and got rid of clipinsidebox overload.
This commit is contained in:
parent
0a3bd7a3a3
commit
b9d0c9d6ba
6 changed files with 15 additions and 43 deletions
|
@ -21,12 +21,7 @@ typedef struct
|
|||
|
||||
extern int clipsectorlist[MAXCLIPSECTORS];
|
||||
|
||||
int clipinsidebox(vec2_t *vect, int wallnum, int walldist);
|
||||
inline int clipinsidebox(int x, int y, int wall, int dist)
|
||||
{
|
||||
vec2_t v = { x, y };
|
||||
return clipinsidebox(&v, wall, dist);
|
||||
}
|
||||
int clipinsidebox(const vec2_t &vect, int wallnum, int walldist);
|
||||
int clipinsideboxline(int x, int y, int x1, int y1, int x2, int y2, int walldist);
|
||||
|
||||
struct CollisionBase;
|
||||
|
|
|
@ -62,15 +62,15 @@ static inline void get_floorspr_points(DCoreActor *spr, int32_t px, int32_t py,
|
|||
//
|
||||
// clipinsidebox
|
||||
//
|
||||
int clipinsidebox(vec2_t *vect, int wallnum, int walldist)
|
||||
int clipinsidebox(const vec2_t &vect, int wallnum, int walldist)
|
||||
{
|
||||
int const r = walldist << 1;
|
||||
|
||||
auto const wal1 = &wall[wallnum];
|
||||
auto const wal2 = wal1->point2Wall();
|
||||
|
||||
vec2_t const v1 = { wal1->wall_int_pos().X + walldist - vect->X, wal1->wall_int_pos().Y + walldist - vect->Y };
|
||||
vec2_t v2 = { wal2->wall_int_pos().X + walldist - vect->X, wal2->wall_int_pos().Y + walldist - vect->Y };
|
||||
vec2_t const v1 = { wal1->wall_int_pos().X + walldist - vect.X, wal1->wall_int_pos().Y + walldist - vect.Y };
|
||||
vec2_t v2 = { wal2->wall_int_pos().X + walldist - vect.X, wal2->wall_int_pos().Y + walldist - vect.Y };
|
||||
|
||||
if (((v1.X < 0) && (v2.X < 0)) || ((v1.Y < 0) && (v2.Y < 0)) || ((v1.X >= r) && (v2.X >= r)) || ((v1.Y >= r) && (v2.Y >= r)))
|
||||
return 0;
|
||||
|
@ -89,17 +89,6 @@ int clipinsidebox(vec2_t *vect, int wallnum, int walldist)
|
|||
return (v2.X >= v2.Y) << 1;
|
||||
}
|
||||
|
||||
static int32_t spriteGetZOfSlope(DCoreActor* actor, int32_t dax, int32_t day)
|
||||
{
|
||||
int16_t const heinum = spriteGetSlope(actor);
|
||||
if (heinum == 0)
|
||||
return actor->int_pos().Z;
|
||||
|
||||
int const j = DMulScale(bsin(actor->int_ang() + 1024), day - actor->int_pos().Y, -bsin(actor->int_ang() + 512), dax - actor->int_pos().X, 4);
|
||||
return actor->int_pos().Z + MulScale(heinum, j, 18);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// clipinsideboxline
|
||||
//
|
||||
|
@ -621,18 +610,8 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
|||
case CSTAT_SPRITE_ALIGNMENT_FLOOR:
|
||||
case CSTAT_SPRITE_ALIGNMENT_SLOPE:
|
||||
{
|
||||
int heinum, sz;
|
||||
|
||||
if ((cstat & (CSTAT_SPRITE_ALIGNMENT_MASK)) == CSTAT_SPRITE_ALIGNMENT_SLOPE)
|
||||
{
|
||||
heinum = spriteGetSlope(actor);
|
||||
sz = spriteGetZOfSlope(actor, pos->X, pos->Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
heinum = 0;
|
||||
sz = actor->int_pos().Z;
|
||||
}
|
||||
int heinum = spriteGetSlope(actor);
|
||||
int sz = spriteGetZOfSlope(&actor->spr, pos->X, pos->Y, heinum);
|
||||
|
||||
if (pos->Z > sz - flordist && pos->Z < sz + ceildist)
|
||||
{
|
||||
|
@ -917,7 +896,7 @@ int pushmove_(vec3_t *const vect, int *const sectnum,
|
|||
int i;
|
||||
|
||||
for (i=startwall, wal=&wall[startwall]; i!=endwall; i+=dir, wal+=dir)
|
||||
if (clipinsidebox(&vect->vec2, i, walldist-4) == 1)
|
||||
if (clipinsidebox(vect->vec2, i, walldist-4) == 1)
|
||||
{
|
||||
int j = 0;
|
||||
if (wal->nextsector < 0 || wal->cstat & EWallFlags::FromInt(dawalclipmask)) j = 1;
|
||||
|
@ -939,7 +918,7 @@ int pushmove_(vec3_t *const vect, int *const sectnum,
|
|||
{
|
||||
vect->X = (vect->X) + dx; vect->Y = (vect->Y) + dy;
|
||||
bad2--; if (bad2 == 0) break;
|
||||
} while (clipinsidebox(&vect->vec2, i, walldist-4) != 0);
|
||||
} while (clipinsidebox(vect->vec2, i, walldist-4) != 0);
|
||||
bad = -1;
|
||||
k--; if (k <= 0) return bad;
|
||||
clipupdatesector(vect->vec2, sectnum, walldist);
|
||||
|
@ -1123,8 +1102,7 @@ void getzrange(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBas
|
|||
case CSTAT_SPRITE_ALIGNMENT_FLOOR:
|
||||
case CSTAT_SPRITE_ALIGNMENT_SLOPE:
|
||||
{
|
||||
if ((cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FLOOR) daz = actor->int_pos().Z;
|
||||
else daz = spriteGetZOfSlope(actor, pos.X, pos.Y);
|
||||
daz = spriteGetZOfSlope(&actor->spr, pos.X, pos.Y, spriteGetSlope(actor));
|
||||
daz2 = daz;
|
||||
|
||||
if ((cstat & CSTAT_SPRITE_ONE_SIDE) != 0 && (pos.Z > daz) == ((cstat & CSTAT_SPRITE_YFLIP)==0))
|
||||
|
|
|
@ -434,9 +434,8 @@ inline int tspriteGetSlope(const tspritetype* spr)
|
|||
return !(spr->clipdist & TSPR_SLOPESPRITE) ? 0 : uint8_t(spr->xoffset) + (int8_t(spr->yoffset) << 8);
|
||||
}
|
||||
|
||||
inline int32_t tspriteGetZOfSlope(const tspritetype* tspr, int dax, int day)
|
||||
inline int32_t spriteGetZOfSlope(const spritetypebase* tspr, int dax, int day, int heinum)
|
||||
{
|
||||
int heinum = tspriteGetSlope(tspr);
|
||||
if (heinum == 0) return tspr->int_pos().Z;
|
||||
|
||||
int const j = DMulScale(bsin(tspr->int_ang() + 1024), day - tspr->int_pos().Y, -bsin(tspr->int_ang() + 512), dax - tspr->int_pos().X, 4);
|
||||
|
|
|
@ -139,7 +139,7 @@ void HWFlat::MakeVertices(HWDrawInfo* di)
|
|||
|
||||
// Make adjustments for poorly aligned slope sprites on floors or ceilings
|
||||
constexpr float ONPLANE_THRESHOLD = 3.f;
|
||||
if (tspriteGetZOfSlope(Sprite, posx, posy) < posz)
|
||||
if (spriteGetZOfSlope(Sprite, posx, posy, tspriteGetSlope(Sprite)) < posz)
|
||||
{
|
||||
float maxofs = -FLT_MAX, minofs = FLT_MAX;
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
@ -436,7 +436,7 @@ void HWFlat::ProcessFlatSprite(HWDrawInfo* di, tspritetype* sprite, sectortype*
|
|||
if ((sprite->cstat & CSTAT_SPRITE_ONE_SIDE) != 0)
|
||||
{
|
||||
double myz = !(sprite->clipdist & TSPR_SLOPESPRITE) ? z :
|
||||
tspriteGetZOfSlope(sprite, int(di->Viewpoint.Pos.X * 16), int(di->Viewpoint.Pos.Y * -16)) * -(1. / 256.);
|
||||
spriteGetZOfSlope(sprite, int(di->Viewpoint.Pos.X * 16), int(di->Viewpoint.Pos.Y * -16), tspriteGetSlope(sprite)) * -(1. / 256.);
|
||||
if ((di->Viewpoint.Pos.Z < myz) == ((sprite->cstat & CSTAT_SPRITE_YFLIP) == 0))
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3537,7 +3537,7 @@ void handle_se11(DDukeActor *actor)
|
|||
DukeStatIterator it(STAT_ACTOR);
|
||||
while (auto ac = it.Next())
|
||||
{
|
||||
if (ac->spr.extra > 0 && badguy(ac) && clipinsidebox(ac->int_pos().X, ac->int_pos().Y, wallnum(&wal), 256) == 1)
|
||||
if (ac->spr.extra > 0 && badguy(ac) && clipinsidebox(ac->int_pos().vec2, wallnum(&wal), 256) == 1)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -3553,7 +3553,7 @@ void handle_se11(DDukeActor *actor)
|
|||
DukeStatIterator it(STAT_PLAYER);
|
||||
while (auto ac = it.Next())
|
||||
{
|
||||
if (ac->GetOwner() && clipinsidebox(ac->int_pos().X, ac->int_pos().Y, wallnum(&wal), 144) == 1)
|
||||
if (ac->GetOwner() && clipinsidebox(ac->int_pos().vec2, wallnum(&wal), 144) == 1)
|
||||
{
|
||||
actor->temp_data[5] = 8; // Delay
|
||||
actor->temp_data[2] -= k;
|
||||
|
|
|
@ -264,7 +264,7 @@ int BelowNear(DExhumedActor* pActor, int x, int y, int walldist)
|
|||
if (!search.Check(wal.nextSector()))
|
||||
{
|
||||
vec2_t pos = { x, y };
|
||||
if (clipinsidebox(&pos, wallnum(&wal), walldist))
|
||||
if (clipinsidebox(pos, wallnum(&wal), walldist))
|
||||
{
|
||||
search.Add(wal.nextSector());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue