mirror of
https://github.com/ZDoom/Raze.git
synced 2024-12-01 16:42:16 +00:00
- use BFSSectorSearch to drive the clipmove collection loop.
This gets rid of another bunch of both code and data.
This commit is contained in:
parent
3da1966cc7
commit
bac866e772
7 changed files with 18 additions and 81 deletions
|
@ -26,7 +26,6 @@ typedef int64_t coord_t;
|
||||||
|
|
||||||
|
|
||||||
#include "maptypes.h"
|
#include "maptypes.h"
|
||||||
#include "clip.h"
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ENGINECOMPATIBILITY_NONE = 0,
|
ENGINECOMPATIBILITY_NONE = 0,
|
||||||
|
|
|
@ -11,12 +11,6 @@
|
||||||
#ifndef clip_h_
|
#ifndef clip_h_
|
||||||
#define clip_h_
|
#define clip_h_
|
||||||
|
|
||||||
#define MAXCLIPSECTORS 512
|
|
||||||
#define CLIPCURBHEIGHT (1)
|
|
||||||
struct CollisionBase;
|
|
||||||
|
|
||||||
CollisionBase clipmove_(vec3_t *const pos, int *const sectnum, int32_t xvect, int32_t yvect, int32_t const walldist, int32_t const ceildist,
|
|
||||||
int32_t const flordist, uint32_t const cliptype, int clipmoveboxtracenum = 3) ATTRIBUTE((nonnull(1, 2)));
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// by the EDuke32 team (development@voidpoint.com)
|
// by the EDuke32 team (development@voidpoint.com)
|
||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "clip.h"
|
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
#include "gamefuncs.h"
|
#include "gamefuncs.h"
|
||||||
#include "coreactor.h"
|
#include "coreactor.h"
|
||||||
|
@ -16,27 +15,6 @@
|
||||||
|
|
||||||
enum { MAXCLIPDIST = 1024 };
|
enum { MAXCLIPDIST = 1024 };
|
||||||
|
|
||||||
static int32_t clipsectnum, origclipsectnum, clipspritenum;
|
|
||||||
int clipsectorlist[MAXCLIPSECTORS];
|
|
||||||
static int origclipsectorlist[MAXCLIPSECTORS];
|
|
||||||
|
|
||||||
BitArray clipsectormap;
|
|
||||||
|
|
||||||
int32_t quickloadboard=0;
|
|
||||||
|
|
||||||
static inline int bsin(const int ang)
|
|
||||||
{
|
|
||||||
return int(g_sinbam(ang * (1 << 21)) * 16384);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int bcos(const int ang)
|
|
||||||
{
|
|
||||||
return int(g_cosbam(ang * (1 << 21)) * 16384);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////// CLIPMOVE //////////
|
|
||||||
inline uint8_t bitmap_test(uint8_t const* const ptr, int const n) { return ptr[n >> 3] & (1 << (n & 7)); }
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// clipinsideboxline
|
// clipinsideboxline
|
||||||
//
|
//
|
||||||
|
@ -46,24 +24,6 @@ static int clipinsideboxline(int x, int y, int x1, int y1, int x2, int y2, int w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void addclipsect(int const sectnum)
|
|
||||||
{
|
|
||||||
if (clipsectnum < MAXCLIPSECTORS)
|
|
||||||
{
|
|
||||||
clipsectormap.Set(sectnum);
|
|
||||||
clipsectorlist[clipsectnum++] = sectnum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void addClipSect(MoveClipper& clip, int sec)
|
|
||||||
{
|
|
||||||
if (!clipsectormap[sec])
|
|
||||||
addclipsect(sec);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// raytrace (internal)
|
// raytrace (internal)
|
||||||
//
|
//
|
||||||
|
@ -153,7 +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 dawalclipmask = (cliptype & 65535); // CLIPMASK0 = 0x00010001 (in desperate need of getting fixed!)
|
|
||||||
int32_t const dasprclipmask = (cliptype >> 16); // CLIPMASK1 = 0x01000040
|
int32_t const dasprclipmask = (cliptype >> 16); // CLIPMASK1 = 0x01000040
|
||||||
|
|
||||||
vec2_t const move = { xvect, yvect };
|
vec2_t const move = { xvect, yvect };
|
||||||
|
@ -166,12 +125,12 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
||||||
vec2_t const clipMin = { cent.X - rad, cent.Y - rad };
|
vec2_t const clipMin = { cent.X - rad, cent.Y - rad };
|
||||||
vec2_t const clipMax = { cent.X + rad, cent.Y + rad };
|
vec2_t const clipMax = { cent.X + rad, cent.Y + rad };
|
||||||
|
|
||||||
MoveClipper clip;
|
MoveClipper clip(§or[initialsectnum]);
|
||||||
|
|
||||||
clip.moveDelta = { (xvect >> 14) * inttoworld, (yvect >> 14) * inttoworld }; // beware of excess precision here!
|
clip.moveDelta = { (xvect >> 14) * inttoworld, (yvect >> 14) * inttoworld }; // beware of excess precision here!
|
||||||
clip.rect.min = { clipMin.X * inttoworld, clipMin.Y * inttoworld };
|
clip.rect.min = { clipMin.X * inttoworld, clipMin.Y * inttoworld };
|
||||||
clip.rect.max = { clipMax.X * inttoworld, clipMax.Y * inttoworld };
|
clip.rect.max = { clipMax.X * inttoworld, clipMax.Y * inttoworld };
|
||||||
clip.wallflags = EWallFlags::FromInt(dawalclipmask);
|
clip.wallflags = EWallFlags::FromInt(cliptype & 65535);
|
||||||
clip.ceilingdist = ceildist * zinttoworld;
|
clip.ceilingdist = ceildist * zinttoworld;
|
||||||
clip.floordist = flordist * zinttoworld;
|
clip.floordist = flordist * zinttoworld;
|
||||||
clip.walldist = walldist * inttoworld;
|
clip.walldist = walldist * inttoworld;
|
||||||
|
@ -180,30 +139,14 @@ 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;
|
||||||
|
|
||||||
int clipsectcnt = 0;
|
while (auto sect = clip.search.GetNext())
|
||||||
int clipspritecnt = 0;
|
|
||||||
|
|
||||||
clipsectorlist[0] = *sectnum;
|
|
||||||
|
|
||||||
clipsectnum = 1;
|
|
||||||
clipspritenum = 0;
|
|
||||||
|
|
||||||
clipsectormap.Zero();
|
|
||||||
clipsectormap.Set(*sectnum);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
int const dasect = clipsectorlist[clipsectcnt++];
|
processClipWalls(clip, sect);
|
||||||
|
|
||||||
////////// Walls //////////
|
|
||||||
processClipWalls(clip, §or[dasect]);
|
|
||||||
|
|
||||||
////////// Sprites //////////
|
|
||||||
|
|
||||||
if (dasprclipmask==0)
|
if (dasprclipmask==0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TSectIterator<DCoreActor> it(dasect);
|
TSectIterator<DCoreActor> it(sect);
|
||||||
while (auto actor = it.Next())
|
while (auto actor = it.Next())
|
||||||
{
|
{
|
||||||
int cstat = actor->spr.cstat;
|
int cstat = actor->spr.cstat;
|
||||||
|
@ -230,7 +173,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
||||||
processClipSlopeSprite(clip, actor);
|
processClipSlopeSprite(clip, actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (clipsectcnt < clipsectnum || clipspritecnt < clipspritenum);
|
}
|
||||||
|
|
||||||
int32_t hitwalls[4], hitwall;
|
int32_t hitwalls[4], hitwall;
|
||||||
CollisionBase clipReturn{};
|
CollisionBase clipReturn{};
|
||||||
|
@ -321,10 +264,11 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
||||||
{
|
{
|
||||||
DVector3 fpos(pos->X* inttoworld, pos->Y* inttoworld, pos->Z* zinttoworld);
|
DVector3 fpos(pos->X* inttoworld, pos->Y* inttoworld, pos->Z* zinttoworld);
|
||||||
|
|
||||||
for (int j=0; j<clipsectnum; j++)
|
clip.search.Rewind();
|
||||||
if (inside(fpos.X, fpos.Y, §or[clipsectorlist[j]]) == 1)
|
while (auto sect = clip.search.GetNext())
|
||||||
|
if (inside(fpos.X, fpos.Y, sect) == 1)
|
||||||
{
|
{
|
||||||
*sectnum = clipsectorlist[j];
|
*sectnum = sectindex(sect);
|
||||||
return clipReturn;
|
return clipReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -482,6 +482,9 @@ void InitSpriteLists();
|
||||||
void SetActorZ(DCoreActor* actor, const DVector3& newpos);
|
void SetActorZ(DCoreActor* actor, const DVector3& newpos);
|
||||||
void SetActor(DCoreActor* actor, const DVector3& newpos);
|
void SetActor(DCoreActor* actor, const DVector3& newpos);
|
||||||
|
|
||||||
|
CollisionBase clipmove_(vec3_t* const pos, int* const sectnum, int32_t xvect, int32_t yvect, int32_t const walldist, int32_t const ceildist,
|
||||||
|
int32_t const flordist, uint32_t const cliptype, int clipmoveboxtracenum = 3);
|
||||||
|
|
||||||
inline int clipmove(DVector3& pos, sectortype** const sect, const DVector2& mvec,
|
inline int clipmove(DVector3& pos, sectortype** const sect, const DVector2& mvec,
|
||||||
double const walldist, double const ceildist, double const flordist, unsigned const cliptype, CollisionBase& result, int clipmoveboxtracenum = 3)
|
double const walldist, double const ceildist, double const flordist, unsigned const cliptype, CollisionBase& result, int clipmoveboxtracenum = 3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1230,7 +1230,7 @@ int pushmove(DVector3& pos, sectortype** pSect, double walldist, double ceildist
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void addClipLine(MoveClipper& clip, const DVector2& start, const DVector2& end, const CollisionBase& daoval, int nofix)
|
void addClipLine(MoveClipper& clip, const DVector2& start, const DVector2& end, const CollisionBase& daoval, int nofix = false)
|
||||||
{
|
{
|
||||||
clip.clipobjects.Reserve(1);
|
clip.clipobjects.Reserve(1);
|
||||||
auto& c = clip.clipobjects.Last();
|
auto& c = clip.clipobjects.Last();
|
||||||
|
@ -1342,7 +1342,7 @@ void processClipWalls(MoveClipper& clip, sectortype* sec)
|
||||||
}
|
}
|
||||||
else if (result == 0)
|
else if (result == 0)
|
||||||
{
|
{
|
||||||
addClipSect(clip, wal.nextsector);
|
clip.search.Add(wal.nextSector());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,10 +270,10 @@ struct MoveClipper
|
||||||
double walldist;
|
double walldist;
|
||||||
double movedist;
|
double movedist;
|
||||||
TArray<ClipObject> clipobjects;
|
TArray<ClipObject> clipobjects;
|
||||||
};
|
BFSSectorSearch search;
|
||||||
|
|
||||||
void addClipLine(MoveClipper& clip, const DVector2& start, const DVector2& end, const CollisionBase& daoval, int nofix = false);
|
MoveClipper(sectortype* start) : search(start) {}
|
||||||
void addClipSect(MoveClipper& clip, int sec);
|
};
|
||||||
|
|
||||||
void processClipWalls(MoveClipper& clip, sectortype* sec);
|
void processClipWalls(MoveClipper& clip, sectortype* sec);
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,6 @@
|
||||||
#include "buildtiles.h"
|
#include "buildtiles.h"
|
||||||
#include "m_swap.h"
|
#include "m_swap.h"
|
||||||
|
|
||||||
extern BitArray clipsectormap;
|
|
||||||
|
|
||||||
TArray<sectortype> sector;
|
TArray<sectortype> sector;
|
||||||
TArray<walltype> wall;
|
TArray<walltype> wall;
|
||||||
|
|
||||||
|
@ -418,7 +416,6 @@ void allocateMapArrays(int numwall, int numsector, int numsprites)
|
||||||
show2dsector.Resize(numsector);
|
show2dsector.Resize(numsector);
|
||||||
show2dwall.Resize(numwall);
|
show2dwall.Resize(numwall);
|
||||||
gotsector.Resize(numsector);
|
gotsector.Resize(numsector);
|
||||||
clipsectormap.Resize(numsector);
|
|
||||||
|
|
||||||
mapDataArena.FreeAll();
|
mapDataArena.FreeAll();
|
||||||
sector.Resize(numsector);
|
sector.Resize(numsector);
|
||||||
|
|
Loading…
Reference in a new issue