mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-29 07:21:54 +00:00
- move the clip object collection loop into its own function.
This commit is contained in:
parent
bac866e772
commit
5bfe62d7b6
3 changed files with 52 additions and 48 deletions
|
@ -113,8 +113,6 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
||||||
|
|
||||||
int const initialsectnum = *sectnum;
|
int const initialsectnum = *sectnum;
|
||||||
|
|
||||||
int32_t const dasprclipmask = (cliptype >> 16); // CLIPMASK1 = 0x01000040
|
|
||||||
|
|
||||||
vec2_t const move = { xvect, yvect };
|
vec2_t const move = { xvect, yvect };
|
||||||
vec2_t goal = { pos->X + (xvect >> 14), pos->Y + (yvect >> 14) };
|
vec2_t goal = { pos->X + (xvect >> 14), pos->Y + (yvect >> 14) };
|
||||||
vec2_t const cent = { (pos->X + goal.X) >> 1, (pos->Y + goal.Y) >> 1 };
|
vec2_t const cent = { (pos->X + goal.X) >> 1, (pos->Y + goal.Y) >> 1 };
|
||||||
|
@ -139,41 +137,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
||||||
clip.center = (clip.pos.XY() + clip.dest) * 0.5;
|
clip.center = (clip.pos.XY() + clip.dest) * 0.5;
|
||||||
clip.movedist = clip.moveDelta.Length() + clip.walldist + 0.5 + MAXCLIPDIST * inttoworld;
|
clip.movedist = clip.moveDelta.Length() + clip.walldist + 0.5 + MAXCLIPDIST * inttoworld;
|
||||||
|
|
||||||
while (auto sect = clip.search.GetNext())
|
collectClipObjects(clip, (cliptype >> 16));
|
||||||
{
|
|
||||||
processClipWalls(clip, sect);
|
|
||||||
|
|
||||||
if (dasprclipmask==0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
TSectIterator<DCoreActor> it(sect);
|
|
||||||
while (auto actor = it.Next())
|
|
||||||
{
|
|
||||||
int cstat = actor->spr.cstat;
|
|
||||||
|
|
||||||
if (actor->spr.cstat2 & CSTAT2_SPRITE_NOFIND) continue;
|
|
||||||
if ((cstat & dasprclipmask) == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
switch (cstat & (CSTAT_SPRITE_ALIGNMENT_MASK))
|
|
||||||
{
|
|
||||||
case CSTAT_SPRITE_ALIGNMENT_FACING:
|
|
||||||
processClipFaceSprite(clip, actor);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CSTAT_SPRITE_ALIGNMENT_WALL:
|
|
||||||
processClipWallSprite(clip, actor);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CSTAT_SPRITE_ALIGNMENT_FLOOR:
|
|
||||||
processClipFloorSprite(clip, actor);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CSTAT_SPRITE_ALIGNMENT_SLOPE:
|
|
||||||
processClipSlopeSprite(clip, actor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t hitwalls[4], hitwall;
|
int32_t hitwalls[4], hitwall;
|
||||||
CollisionBase clipReturn{};
|
CollisionBase clipReturn{};
|
||||||
|
|
|
@ -1330,7 +1330,7 @@ static void addWallToClipSet(MoveClipper& clip, walltype* wal)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void processClipWalls(MoveClipper& clip, sectortype* sec)
|
static void processClipWalls(MoveClipper& clip, sectortype* sec)
|
||||||
{
|
{
|
||||||
for(auto& wal : sec->walls)
|
for(auto& wal : sec->walls)
|
||||||
{
|
{
|
||||||
|
@ -1353,7 +1353,7 @@ void processClipWalls(MoveClipper& clip, sectortype* sec)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void processClipFaceSprite(MoveClipper& clip, DCoreActor* actor)
|
static void processClipFaceSprite(MoveClipper& clip, DCoreActor* actor)
|
||||||
{
|
{
|
||||||
auto spos = actor->spr.pos;
|
auto spos = actor->spr.pos;
|
||||||
if (!PointInRect(spos.XY(), clip.rect.min, clip.rect.max)) return; // are we outside this sprite's bounding box?
|
if (!PointInRect(spos.XY(), clip.rect.min, clip.rect.max)) return; // are we outside this sprite's bounding box?
|
||||||
|
@ -1377,7 +1377,7 @@ void processClipFaceSprite(MoveClipper& clip, DCoreActor* actor)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void processClipWallSprite(MoveClipper& clip, DCoreActor* actor)
|
static void processClipWallSprite(MoveClipper& clip, DCoreActor* actor)
|
||||||
{
|
{
|
||||||
auto spos = actor->spr.pos;
|
auto spos = actor->spr.pos;
|
||||||
double height, z = spos.Z + actor->GetOffsetAndHeight(height);
|
double height, z = spos.Z + actor->GetOffsetAndHeight(height);
|
||||||
|
@ -1424,7 +1424,7 @@ void processClipWallSprite(MoveClipper& clip, DCoreActor* actor)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool processClipFloorSprite(MoveClipper& clip, DCoreActor* actor, DVector2* points, double* heights)
|
static bool processClipFloorSprite(MoveClipper& clip, DCoreActor* actor, DVector2* points, double* heights)
|
||||||
{
|
{
|
||||||
int heinum = spriteGetSlope(actor);
|
int heinum = spriteGetSlope(actor);
|
||||||
double sprz = spriteGetZOfSlopef(&actor->spr, actor->spr.pos.XY(), heinum);
|
double sprz = spriteGetZOfSlopef(&actor->spr, actor->spr.pos.XY(), heinum);
|
||||||
|
@ -1479,7 +1479,7 @@ bool processClipFloorSprite(MoveClipper& clip, DCoreActor* actor, DVector2* poin
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void processClipSlopeSprite(MoveClipper& clip, DCoreActor* actor)
|
static void processClipSlopeSprite(MoveClipper& clip, DCoreActor* actor)
|
||||||
{
|
{
|
||||||
auto spos = actor->spr.pos;
|
auto spos = actor->spr.pos;
|
||||||
DVector2 points[4];
|
DVector2 points[4];
|
||||||
|
@ -1528,6 +1528,51 @@ void processClipSlopeSprite(MoveClipper& clip, DCoreActor* actor)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
void collectClipObjects(MoveClipper& clip, int spritemask)
|
||||||
|
{
|
||||||
|
while (auto sect = clip.search.GetNext())
|
||||||
|
{
|
||||||
|
processClipWalls(clip, sect);
|
||||||
|
|
||||||
|
if (spritemask == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TSectIterator<DCoreActor> it(sect);
|
||||||
|
while (auto actor = it.Next())
|
||||||
|
{
|
||||||
|
int cstat = actor->spr.cstat;
|
||||||
|
|
||||||
|
if (actor->spr.cstat2 & CSTAT2_SPRITE_NOFIND) continue;
|
||||||
|
if ((cstat & spritemask) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (cstat & (CSTAT_SPRITE_ALIGNMENT_MASK))
|
||||||
|
{
|
||||||
|
case CSTAT_SPRITE_ALIGNMENT_FACING:
|
||||||
|
processClipFaceSprite(clip, actor);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CSTAT_SPRITE_ALIGNMENT_WALL:
|
||||||
|
processClipWallSprite(clip, actor);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CSTAT_SPRITE_ALIGNMENT_FLOOR:
|
||||||
|
processClipFloorSprite(clip, actor, nullptr, nullptr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CSTAT_SPRITE_ALIGNMENT_SLOPE:
|
||||||
|
processClipSlopeSprite(clip, actor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
int FindBestSector(const DVector3& pos)
|
int FindBestSector(const DVector3& pos)
|
||||||
{
|
{
|
||||||
int bestnum = -1;
|
int bestnum = -1;
|
||||||
|
|
|
@ -275,15 +275,10 @@ struct MoveClipper
|
||||||
MoveClipper(sectortype* start) : search(start) {}
|
MoveClipper(sectortype* start) : search(start) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
void processClipWalls(MoveClipper& clip, sectortype* sec);
|
void collectClipObjects(MoveClipper& clip, int spritemask);
|
||||||
|
|
||||||
void processClipFaceSprite(MoveClipper& clip, DCoreActor* actor);
|
|
||||||
void processClipWallSprite(MoveClipper& clip, DCoreActor* actor);
|
|
||||||
bool processClipFloorSprite(MoveClipper& clip, DCoreActor* actor, DVector2* points = nullptr, double* heights = nullptr);
|
|
||||||
void processClipSlopeSprite(MoveClipper& clip, DCoreActor* actor);
|
|
||||||
int FindBestSector(const DVector3& pos);
|
int FindBestSector(const DVector3& pos);
|
||||||
|
|
||||||
|
|
||||||
void setWallSectors();
|
void setWallSectors();
|
||||||
void GetWallSpritePosition(const spritetypebase* spr, const DVector2& pos, DVector2* out, bool render = false);
|
void GetWallSpritePosition(const spritetypebase* spr, const DVector2& pos, DVector2* out, bool render = false);
|
||||||
void GetFlatSpritePosition(DCoreActor* spr, const DVector2& pos, DVector2* out, double* outz = nullptr, bool render = false);
|
void GetFlatSpritePosition(DCoreActor* spr, const DVector2& pos, DVector2* out, double* outz = nullptr, bool render = false);
|
||||||
|
|
Loading…
Reference in a new issue