From 462368b61d5033316040e390522a74d807a19748 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Feb 2020 09:22:30 +0100 Subject: [PATCH] - use floats for sprite depth sorting in the hardware renderer. Fixed point is clearly insufficient here. # Conflicts: # src/hwrenderer/scene/hw_drawlist.cpp # src/hwrenderer/scene/hw_drawstructs.h # Conflicts: # src/hwrenderer/scene/hw_drawlist.cpp # src/hwrenderer/scene/hw_sprites.cpp --- src/gl/scene/gl_drawinfo.cpp | 7 +++---- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_wall.h | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 60191ebaf..32f5d462b 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -602,10 +602,9 @@ inline int GLDrawList::CompareSprites(SortNode * a,SortNode * b) GLSprite * s1=&sprites[drawitems[a->itemindex].index]; GLSprite * s2=&sprites[drawitems[b->itemindex].index]; - int res = s1->depth - s2->depth; - - if (res != 0) return -res; - else return (i_compatflags & COMPATF_SPRITESORT)? s2->index-s1->index : s1->index-s2->index; + if (s1->depth < s2->depth) return 1; + if (s1->depth > s2->depth) return -1; + return (i_compatflags & COMPATF_SPRITESORT)? s2->index-s1->index : s1->index-s2->index; } //========================================================================== diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 2205adba4..2cbdb0694 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -952,7 +952,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) gltexture = NULL; } - depth = FloatToFixed((x - r_viewpoint.Pos.X) * r_viewpoint.TanCos + (y - r_viewpoint.Pos.Y) * r_viewpoint.TanSin); + depth = (float)((x - r_viewpoint.Pos.X) * r_viewpoint.TanCos + (y - r_viewpoint.Pos.Y) * r_viewpoint.TanSin); // light calculation diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index cdb561c4b..5b9609517 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -374,7 +374,7 @@ public: int translation; int index; - int depth; + float depth; float topclip; float bottomclip; @@ -385,15 +385,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; DRotator Angles; - int dynlightindex; void SplitSprite(sector_t * frontsector, bool translucent); void SetLowerParam();