- use floats for sprite depth sorting in the hardware renderer.

Fixed point is clearly insufficient here.
This commit is contained in:
Christoph Oelckers 2020-02-15 09:22:30 +01:00
parent a056307218
commit 617b6cd987
3 changed files with 7 additions and 8 deletions

View File

@ -585,10 +585,9 @@ inline int HWDrawList::CompareSprites(SortNode * a,SortNode * b)
HWSprite * s1= sprites[drawitems[a->itemindex].index];
HWSprite * s2= sprites[drawitems[b->itemindex].index];
int res = s1->depth - s2->depth;
if (res != 0) return -res;
else return reverseSort? s2->index-s1->index : s1->index-s2->index;
if (s1->depth < s2->depth) return 1;
if (s1->depth > s2->depth) return -1;
return reverseSort? s2->index-s1->index : s1->index-s2->index;
}
//==========================================================================

View File

@ -354,7 +354,7 @@ public:
int translation;
int index;
int depth;
float depth;
int vertexindex;
float topclip;
@ -366,15 +366,15 @@ public:
float vt,vb;
float x1,y1,z1;
float x2,y2,z2;
float trans;
int dynlightindex;
FMaterial *gltexture;
float trans;
AActor * actor;
particle_t * particle;
TArray<lightlist_t> *lightlist;
DRotator Angles;
int dynlightindex;
void SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool translucent);
void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight);

View File

@ -903,7 +903,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
gltexture = nullptr;
}
depth = FloatToFixed((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
depth = (float)((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
// light calculation