Skip to content

Commit

Permalink
- use floats for sprite depth sorting in the hardware renderer.
Browse files Browse the repository at this point in the history
Fixed point is clearly insufficient here.
  • Loading branch information
coelckers committed Feb 15, 2020
1 parent a056307 commit 617b6cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/rendering/hwrenderer/scene/hw_drawlist.cpp
Expand Up @@ -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;
}

//==========================================================================
Expand Down
6 changes: 3 additions & 3 deletions src/rendering/hwrenderer/scene/hw_drawstructs.h
Expand Up @@ -354,7 +354,7 @@ class HWSprite

int translation;
int index;
int depth;
float depth;
int vertexindex;

float topclip;
Expand All @@ -366,15 +366,15 @@ class HWSprite
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);
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_sprites.cpp
Expand Up @@ -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

Expand Down

0 comments on commit 617b6cd

Please sign in to comment.