Skip to content

Commit

Permalink
- function for checking wall sprites’ need for recalculation
Browse files Browse the repository at this point in the history
Preparation for overhauling their rendering
  • Loading branch information
coelckers committed May 23, 2022
1 parent af89c25 commit 4278f01
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/core/rendering/scene/hw_drawstructs.h
Expand Up @@ -233,6 +233,7 @@ class HWWall
void RenderMirrorSurface(HWDrawInfo *di, FRenderState &state);
void RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags);
void RenderTranslucentWall(HWDrawInfo *di, FRenderState &state);
int CheckWallSprite(tspritetype* spr, tspritetype* last);

public:
void Process(HWDrawInfo* di, walltype* seg, sectortype* frontsector, sectortype* backsector);
Expand Down
34 changes: 33 additions & 1 deletion source/core/rendering/scene/hw_walls.cpp
Expand Up @@ -1086,6 +1086,38 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
}
}

//==========================================================================
//
// checks if the wall sprite has changed since the last call.
// Returns:
// 0 if identical or only render style changed
// 1 if vertical orientation changed
// 2 if horizontal orientation changed
// 3 if positioning changed
//
//==========================================================================

int HWWall::CheckWallSprite(tspritetype* spr, tspritetype* last)
{
// If the position changed we need to recalculate everything.
if (spr->pos.X != last->pos.X || spr->pos.Y != last->pos.Y || spr->sectp != last->sectp || spr->ang != last->ang) return 3;

// if the horizontal orientation changes we need to recalculate the walls this attaches to, but not the positioning.
if (spr->xrepeat != last->xrepeat || spr->xoffset != last->xoffset || spr->picnum != last->picnum || ((spr->cstat ^ last->cstat) & CSTAT_SPRITE_XFLIP)) return 2;

// only y-positioning changed - we need to re-check the wall tiers this sprite attaches to
if(spr->yrepeat != last->yrepeat || spr->yoffset != last->yoffset || ((spr->cstat ^ last->cstat) & (CSTAT_SPRITE_YFLIP|CSTAT_SPRITE_YCENTER))) return 1;

// all remaining properties only affect the render style which is not relevant for positioning a wall sprite
return 0;
}

//==========================================================================
//
//
//
//==========================================================================

void HWWall::ProcessWallSprite(HWDrawInfo* di, tspritetype* spr, sectortype* sector)
{
auto tex = tileGetTexture(spr->picnum);
Expand Down Expand Up @@ -1217,4 +1249,4 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, tspritetype* spr, sectortype* sec
}

PutWall(di, spriteHasTranslucency(Sprite));
}
}

0 comments on commit 4278f01

Please sign in to comment.