mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
- Added an alternate 2D sprite sorting comparison function which seems to work better with
large voxels than the standard 1D sprite sort. SVN r4229 (trunk)
This commit is contained in:
parent
b845fdb5d5
commit
2dfb1dd92f
2 changed files with 18 additions and 1 deletions
|
@ -139,6 +139,7 @@ vissprite_t **firstvissprite;
|
|||
vissprite_t **vissprite_p;
|
||||
vissprite_t **lastvissprite;
|
||||
int newvissprite;
|
||||
bool DrewAVoxel;
|
||||
|
||||
static vissprite_t **spritesorter;
|
||||
static int spritesortersize = 0;
|
||||
|
@ -186,6 +187,7 @@ void R_DeinitSprites()
|
|||
void R_ClearSprites (void)
|
||||
{
|
||||
vissprite_p = firstvissprite;
|
||||
DrewAVoxel = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -782,6 +784,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
vis->gz = fz;
|
||||
vis->gzb = gzb; // [RH] use gzb, not thing->z
|
||||
vis->gzt = gzt; // killough 3/27/98
|
||||
vis->deltax = fx - viewx;
|
||||
vis->deltay = fy - viewy;
|
||||
vis->renderflags = thing->renderflags;
|
||||
if(thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D
|
||||
vis->Style.RenderStyle = thing->RenderStyle;
|
||||
|
@ -798,6 +802,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
{
|
||||
vis->voxel = voxel->Voxel;
|
||||
vis->bIsVoxel = true;
|
||||
DrewAVoxel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1330,11 +1335,22 @@ void R_DrawRemainingPlayerSprites()
|
|||
// gain compared to the old function.
|
||||
//
|
||||
// Sort vissprites by depth, far to near
|
||||
|
||||
// This is the standard version, which does a simple test based on depth.
|
||||
static bool sv_compare(vissprite_t *a, vissprite_t *b)
|
||||
{
|
||||
return a->idepth > b->idepth;
|
||||
}
|
||||
|
||||
// This is an alternate version, for when one or more voxel is in view.
|
||||
// It does a 2D distance test based on whichever one is furthest from
|
||||
// the viewpoint.
|
||||
static bool sv_compare2d(vissprite_t *a, vissprite_t *b)
|
||||
{
|
||||
return TVector2<double>(a->deltax, a->deltay).LengthSquared() <
|
||||
TVector2<double>(b->deltax, b->deltay).LengthSquared();
|
||||
}
|
||||
|
||||
#if 0
|
||||
static drawseg_t **drawsegsorter;
|
||||
static int drawsegsortersize = 0;
|
||||
|
@ -1965,7 +1981,7 @@ void R_DrawHeightPlanes(fixed_t height); // kg3D - fake planes
|
|||
|
||||
void R_DrawMasked (void)
|
||||
{
|
||||
R_SortVisSprites (sv_compare, firstvissprite - vissprites);
|
||||
R_SortVisSprites (DrewAVoxel ? sv_compare2d : sv_compare, firstvissprite - vissprites);
|
||||
|
||||
if (height_top == NULL)
|
||||
{ // kg3D - no visible 3D floors, normal rendering
|
||||
|
|
|
@ -38,6 +38,7 @@ struct vissprite_t
|
|||
fixed_t xscale, yscale;
|
||||
fixed_t depth;
|
||||
fixed_t idepth; // 1/z
|
||||
fixed_t deltax, deltay;
|
||||
DWORD FillColor;
|
||||
fixed_t floorclip;
|
||||
union
|
||||
|
|
Loading…
Reference in a new issue