From 0ee28fb45ea1fdee9cdff11632851c2c3b1fc0c1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Apr 2021 13:38:23 +0200 Subject: [PATCH] - also handle SW's voxels. --- source/build/src/polymost.cpp | 2 +- source/core/gamestruct.h | 2 +- source/core/precache.cpp | 4 +++- source/core/precache.h | 1 + source/games/sw/src/game.cpp | 4 ++-- source/games/sw/src/game.h | 8 ++++---- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index a4b04a143..4901b8155 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -2202,7 +2202,7 @@ void polymost_scansector(int32_t sectnum) { if ((spr->cstat&(64+48))!=(64+16) || (r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) || - (r_voxels && gi->Voxelize(spr->picnum)) || + (r_voxels && gi->Voxelize(spr->picnum) > -1) || DMulScale(bcos(spr->ang), -s.x, bsin(spr->ang), -s.y, 6) > 0) if (renderAddTsprite(z, sectnum)) break; diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 664c878d3..f6a0dd697 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -101,7 +101,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 bool Voxelize(int sprnum) { return false; } + virtual int Voxelize(int sprnum) { return -1; } virtual FString statFPS() { diff --git a/source/core/precache.cpp b/source/core/precache.cpp index 0a4bc0b58..ed660c7cd 100644 --- a/source/core/precache.cpp +++ b/source/core/precache.cpp @@ -72,8 +72,9 @@ static void doprecache(int picnum, int palette) if (r_voxels) { int vox = tiletovox[picnum]; + if (vox == -1) vox = gi->Voxelize(picnum); if (vox == -1 && isBlood()) vox = Blood::voxelIndex[picnum]; - if (vox != -1 && voxmodels[vox] && voxmodels[vox]->model) + if (vox >= 0 && vox < MAXVOXELS && voxmodels[vox] && voxmodels[vox]->model) { FHWModelRenderer mr(*screen->RenderState(), 0); voxmodels[vox]->model->BuildVertexBuffer(&mr); @@ -127,5 +128,6 @@ void precacheMarkedTiles() int dapalnum = pair->Key >> 32; doprecache(dapicnum, dapalnum); } + cachemap.Clear(); } diff --git a/source/core/precache.h b/source/core/precache.h index 30c6cea27..bcf40813f 100644 --- a/source/core/precache.h +++ b/source/core/precache.h @@ -2,4 +2,5 @@ void PrecacheHardwareTextures(int nTile); void markTileForPrecache(int tilenum, int palnum); +void markVoxelForPrecache(int voxnum); void precacheMarkedTiles(); diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 064cfc44f..e77e64f6c 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -798,9 +798,9 @@ void GameInterface::FreeLevelData() ::GameInterface::FreeLevelData(); } -bool GameInterface::Voxelize(int sprnum) +int GameInterface::Voxelize(int sprnum) { - return (aVoxelArray[sprnum].Voxel >= 0); + return (aVoxelArray[sprnum].Voxel); } END_SW_NS diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 799aa2065..e9ab4c651 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2252,10 +2252,10 @@ struct GameInterface : ::GameInterface void WarpToCoords(int x, int y, int z, int a, int h) override; void ToggleThirdPerson() override; void SwitchCoopView() override; - int chaseCamX(binangle ang) { return -ang.bcos(-3); } - int chaseCamY(binangle ang) { return -ang.bsin(-3); } - int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 8; } - bool Voxelize(int sprnum); + int chaseCamX(binangle ang) override { return -ang.bcos(-3); } + int chaseCamY(binangle ang) override { return -ang.bsin(-3); } + int chaseCamZ(fixedhoriz horiz) override { return horiz.asq16() >> 8; } + int Voxelize(int sprnum) override; GameStats getStats() override;