From be7bca8e9e5a351f42c7a793487d8a72b15cb13b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Mar 2021 01:35:23 +0100 Subject: [PATCH] - expose animatesprite set of functions to new renderer as a callback. --- source/core/gamestruct.h | 2 +- source/core/rendering/scene/hw_bunchdrawer.cpp | 5 +++-- source/games/duke/src/duke3d.h | 1 + source/games/duke/src/render.cpp | 4 ++++ source/games/exhumed/src/exhumed.h | 1 + source/games/exhumed/src/view.cpp | 15 ++++++++------- source/games/sw/src/_polymost.cpp | 4 ++-- source/games/sw/src/draw.cpp | 12 +++++++++--- source/games/sw/src/game.h | 5 +++-- source/games/sw/src/jsector.cpp | 2 +- 10 files changed, 33 insertions(+), 18 deletions(-) diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index f32c9ac1d..fac4003c2 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -102,7 +102,7 @@ struct GameInterface virtual int chaseCamX(binangle ang) { return 0; } virtual int chaseCamY(binangle ang) { return 0; } virtual int chaseCamZ(fixedhoriz horiz) { return 0; } - virtual void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) {} + virtual void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) = 0; virtual FString statFPS() { diff --git a/source/core/rendering/scene/hw_bunchdrawer.cpp b/source/core/rendering/scene/hw_bunchdrawer.cpp index f49f70170..4a1450e1d 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.cpp +++ b/source/core/rendering/scene/hw_bunchdrawer.cpp @@ -441,9 +441,10 @@ void BunchDrawer::ProcessSector(int sectnum) int sx = spr->x - iview.x, sy = spr->y - int(iview.y); - if ((spr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) || (hw_models && tile2model[spr->picnum].modelid >= 0) || ((sx * gcosang) + (sy * gsinang) > 0)) // is it behind the camera? (fixme!) + // this checks if the sprite is it behind the camera, which will not work if the pitch is high enough to necessitate a FOV of more than 180°. + //if ((spr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) || (hw_models && tile2model[spr->picnum].modelid >= 0) || ((sx * gcosang) + (sy * gsinang) > 0)) { - if ((spr->cstat & (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_MASK)) != (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_WALL + 16) || + if ((spr->cstat & (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_MASK)) != (CSTAT_SPRITE_ONE_SIDED | CSTAT_SPRITE_ALIGNMENT_WALL) || (r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) || DMulScale(bcos(spr->ang), -sx, bsin(spr->ang), -sy, 6) > 0) if (renderAddTsprite(z, sectnum)) diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index d117348d0..9c697f5ab 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -65,6 +65,7 @@ struct GameInterface : public ::GameInterface int chaseCamX(binangle ang) { return -ang.bcos(-4); } int chaseCamY(binangle ang) { return -ang.bsin(-4); } int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 9; } + void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override; }; diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index a82fc7280..810672e88 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -414,6 +414,10 @@ bool GameInterface::GenerateSavePic() return true; } +void GameInterface::processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) +{ + fi.animatesprites(viewx, viewy, viewz, int(smoothRatio)); +} END_DUKE_NS diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index cb4ae4118..b3541211f 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -255,6 +255,7 @@ struct GameInterface : ::GameInterface int chaseCamX(binangle ang) { return -ang.bcos() / 12; } int chaseCamY(binangle ang) { return -ang.bsin() / 12; } int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() / 384; } + void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override; ::GameStats getStats() override; }; diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 885cc49a5..17c0e8932 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -66,7 +66,7 @@ short enemy; short nEnemyPal = 0; // NOTE - not to be confused with Ken's analyzesprites() -static void analyzesprites(double const smoothratio) +static void analyzesprites(int x, int y, int z, double const smoothratio) { tspritetype *pTSprite; @@ -90,11 +90,6 @@ static void analyzesprites(double const smoothratio) besttarget = -1; - int x = pPlayerSprite->x; - int y = pPlayerSprite->y; - - int z = pPlayerSprite->z - (GetSpriteHeight(nPlayerSprite) / 2); - short nSector = pPlayerSprite->sectnum; int nAngle = (2048 - pPlayerSprite->ang) & kAngleMask; @@ -362,7 +357,7 @@ void DrawView(double smoothRatio, bool sceneonly) { renderSetRollAngle(rotscrnang.asbuildf()); renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), nSector); - analyzesprites(smoothRatio); + analyzesprites(nCamerax, nCameray, viewz, smoothRatio); renderDrawMasks(); } else @@ -467,6 +462,12 @@ bool GameInterface::GenerateSavePic() return true; } +void GameInterface::processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) +{ + analyzesprites(viewx, viewy, viewz, smoothRatio); +} + + void NoClip() { } diff --git a/source/games/sw/src/_polymost.cpp b/source/games/sw/src/_polymost.cpp index e62edaefa..1bcca9888 100644 --- a/source/games/sw/src/_polymost.cpp +++ b/source/games/sw/src/_polymost.cpp @@ -177,7 +177,7 @@ void polymost_drawscreen(PLAYERp pp, int tx, int ty, int tz, binangle tang, fixe if (!FAF_DebugView) FAF_DrawRooms(tx, ty, tz, tang.asq16(), thoriz.asq16(), tsectnum); - analyzesprites(tx, ty, tz, false); + analyzesprites(tx, ty, tz, tang.asbuild()); post_analyzesprites(); renderDrawMasks(); @@ -323,7 +323,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed renderDrawRoomsQ16(tposx, tposy, tz, (tang), tpq16horiz, mirror[cnt].mirrorsector + MAXSECTORS); - analyzesprites(tposx, tposy, tz, true); + analyzesprites(tposx, tposy, tz, tang >> 16); renderDrawMasks(); renderCompleteMirror(); // Reverse screen x-wise in this diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index a2c38e6d7..f6c85d43e 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -265,7 +265,7 @@ DoShadowFindGroundPoint(tspriteptr_t sp) } void -DoShadows(tspriteptr_t tsp, int viewz, bool mirror) +DoShadows(tspriteptr_t tsp, int viewz, int camang) { tspriteptr_t New = &tsprite[spritesortcnt]; USERp tu = User[tsp->owner]; @@ -553,7 +553,7 @@ void DoStarView(tspriteptr_t tsp, USERp tu, int viewz) } void -analyzesprites(int viewx, int viewy, int viewz, bool mirror) +analyzesprites(int viewx, int viewy, int viewz, int camang) { int tSpriteNum; short SpriteNum; @@ -645,7 +645,7 @@ analyzesprites(int viewx, int viewy, int viewz, bool mirror) if (r_shadows && TEST(tu->Flags, SPR_SHADOW)) { - DoShadows(tsp, viewz, mirror); + DoShadows(tsp, viewz, camang); } //#define UK_VERSION 1 @@ -1869,6 +1869,12 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, return true; } +void GameInterface::processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) +{ + analyzesprites(viewx, viewy, viewz, viewang.asbuild()); + post_analyzesprites(); +} + END_SW_NS diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 9d9c1115d..6c477ac2a 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1967,7 +1967,7 @@ int DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets); void change_sprite_stat(short, short); void SetOwner(short, short); void SetAttach(short, short); -void analyzesprites(int,int,int,bool); +void analyzesprites(int,int,int,int); void ChangeState(short SpriteNum, STATEp statep); void CollectPortals(); @@ -2248,7 +2248,8 @@ struct GameInterface : ::GameInterface int chaseCamX(binangle ang) { return -ang.bcos(-3); } int chaseCamY(binangle ang) { return -ang.bsin(-3); } int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 8; } - + void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override; + GameStats getStats() override; }; diff --git a/source/games/sw/src/jsector.cpp b/source/games/sw/src/jsector.cpp index 990cf6175..309f1e2a4 100644 --- a/source/games/sw/src/jsector.cpp +++ b/source/games/sw/src/jsector.cpp @@ -476,7 +476,7 @@ void drawroomstotile(int daposx, int daposy, int daposz, if (!testnewrenderer) { renderDrawRoomsQ16(daposx, daposy, daposz, ang.asq16(), horiz.asq16(), dacursectnum); - analyzesprites(daposx, daposy, daposz, false); + analyzesprites(daposx, daposy, daposz, ang.asbuild()); renderDrawMasks(); } else