- voxel management cleanup.

Moving the voxel index into the texExtInfo array and removing most of Blood's and SW's special handling.
This commit is contained in:
Christoph Oelckers 2022-12-08 18:26:09 +01:00
parent be2112a507
commit 8a789b9015
25 changed files with 109 additions and 138 deletions

View file

@ -225,11 +225,12 @@ void processTileImport(FScanner& sc, const char* cmd, FScriptPosition& pos, Tile
imp.alphacut = clamp(imp.alphacut, 0, 255); imp.alphacut = clamp(imp.alphacut, 0, 255);
gi->SetTileProps(imp.tile, imp.surface, imp.vox, imp.shade);
if (imp.fn.IsNotEmpty() && tileImportFromTexture(sc, imp.fn, imp.tile, imp.alphacut, imp.istexture) < 0) return; if (imp.fn.IsNotEmpty() && tileImportFromTexture(sc, imp.fn, imp.tile, imp.alphacut, imp.istexture) < 0) return;
tbuild->tile[imp.tile].extinfo.picanm.sf |= imp.flags; tbuild->tile[imp.tile].extinfo.picanm.sf |= imp.flags;
gi->SetTileProps(imp.tile, imp.surface, imp.shade);
// This is not quite the same as originally, for two reasons: // This is not quite the same as originally, for two reasons:
// 1: Since these are texture properties now, there's no need to clear them. // 1: Since these are texture properties now, there's no need to clear them.
// 2: The original code assumed that an imported texture cannot have an offset. But this can import Doom patches and PNGs with grAb, so the situation is very different. // 2: The original code assumed that an imported texture cannot have an offset. But this can import Doom patches and PNGs with grAb, so the situation is very different.
@ -889,7 +890,7 @@ void parseDefineVoxelTiles(FScanner& sc, FScriptPosition& pos)
pos.Message(MSG_WARNING, "Warning: Ignoring voxel tiles definition without valid voxel.\n"); pos.Message(MSG_WARNING, "Warning: Ignoring voxel tiles definition without valid voxel.\n");
return; return;
} }
for (int i = tilestart; i <= tileend; i++) tiletovox[i] = lastvoxid; for (int i = tilestart; i <= tileend; i++) tbuild->tile[i].extinfo.tiletovox = lastvoxid;
} }
//=========================================================================== //===========================================================================
@ -931,7 +932,7 @@ void parseVoxel(FScanner& sc, FScriptPosition& pos)
sc.GetNumber(true); sc.GetNumber(true);
if (ValidateTilenum("voxel", sc.Number, pos)) if (ValidateTilenum("voxel", sc.Number, pos))
{ {
if (!error) tiletovox[sc.Number] = lastvoxid; if (!error) tbuild->tile[sc.Number].extinfo.tiletovox = lastvoxid;
} }
} }
if (sc.Compare("tile0")) sc.GetNumber(tile0, true); if (sc.Compare("tile0")) sc.GetNumber(tile0, true);
@ -940,7 +941,7 @@ void parseVoxel(FScanner& sc, FScriptPosition& pos)
sc.GetNumber(tile1, true); sc.GetNumber(tile1, true);
if (ValidateTileRange("voxel", tile0, tile1, pos) && !error) if (ValidateTileRange("voxel", tile0, tile1, pos) && !error)
{ {
for (int i = tile0; i <= tile1; i++) tiletovox[i] = lastvoxid; for (int i = tile0; i <= tile1; i++) tbuild->tile[i].extinfo.tiletovox = lastvoxid;
} }
} }
if (sc.Compare("scale")) if (sc.Compare("scale"))

View file

@ -512,7 +512,7 @@ void FMapInfoParser::ParseTextureFlags()
} }
else else
{ {
texExtInfo[tex.GetIndex()].flags |= num; AccessExtInfo(tex).flags |= num;
} }
} while (sc.CheckString(",")); } while (sc.CheckString(","));

View file

@ -110,7 +110,7 @@ struct GameInterface
virtual void NewGame(MapRecord* map, int skill, bool special = false) {} virtual void NewGame(MapRecord* map, int skill, bool special = false) {}
virtual void LevelCompleted(MapRecord* map, int skill) {} virtual void LevelCompleted(MapRecord* map, int skill) {}
virtual bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) { return false; } virtual bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) { return false; }
virtual void SetTileProps(int tile, int surf, int vox, int shade) {} virtual void SetTileProps(int tile, int surf, int shade) {}
virtual DAngle playerPitchMin() { return DAngle::fromDeg(57.375); } virtual DAngle playerPitchMin() { return DAngle::fromDeg(57.375); }
virtual DAngle playerPitchMax() { return DAngle::fromDeg(-57.375); } virtual DAngle playerPitchMax() { return DAngle::fromDeg(-57.375); }
virtual void WarpToCoords(double x, double y, double z, DAngle a) {} virtual void WarpToCoords(double x, double y, double z, DAngle a) {}

View file

@ -186,6 +186,7 @@ enum ESpriteBits2
CSTAT2_SPRITE_DECAL = 8, // always attached to a wall. CSTAT2_SPRITE_DECAL = 8, // always attached to a wall.
CSTAT2_SPRITE_FULLBRIGHT = 16, // always draw fullbright with shade -127 CSTAT2_SPRITE_FULLBRIGHT = 16, // always draw fullbright with shade -127
CSTAT2_SPRITE_NOANIMATE = 32, // disable texture animation CSTAT2_SPRITE_NOANIMATE = 32, // disable texture animation
CSTAT2_SPRITE_NOMODEL = 64, // disable models and voxels for this tsprite
}; };
// tsprite flags use the otherwise unused clipdist field. // tsprite flags use the otherwise unused clipdist field.

View file

@ -230,16 +230,3 @@ void updateModelInterpolation()
} }
#endif #endif
//==========================================================================
//
//
//
//==========================================================================
int tilehasmodelorvoxel(int const tilenume, int pal)
{
return
(hw_models && modelManager.CheckModel(tilenume, pal)) ||
(r_voxels && tiletovox[tilenume] != -1);
}

View file

@ -81,5 +81,4 @@ struct ModelManager
}; };
int tilehasmodelorvoxel(int const tilenume, int pal);
inline ModelManager modelManager; inline ModelManager modelManager;

View file

@ -49,10 +49,6 @@
#include "buildtiles.h" #include "buildtiles.h"
BEGIN_BLD_NS
extern short voxelIndex[MAXTILES];
END_BLD_NS
static void PrecacheTex(FGameTexture* tex, int palid) static void PrecacheTex(FGameTexture* tex, int palid)
{ {
if (!tex || !tex->isValid()) return; if (!tex || !tex->isValid()) return;
@ -71,17 +67,13 @@ static void doprecache(int picnum, int palette)
auto tex = tileGetTexture(picnum); auto tex = tileGetTexture(picnum);
PrecacheTex(tex, palid); PrecacheTex(tex, palid);
if (!hw_models) return; int const mid = -1;// hw_models ? modelManager.CheckModel(picnum, palette) : -1;
int const mid = modelManager.CheckModel(picnum, palette);
if (mid < 0) if (mid < 0)
{ {
if (r_voxels) if (r_voxels)
{ {
int vox = tiletovox[picnum]; int vox = GetExtInfo(tileGetTextureID(picnum)).tiletovox;
if (vox == -1) vox = gi->Voxelize(picnum);
if (vox == -1 && isBlood()) vox = Blood::voxelIndex[picnum];
if (vox >= 0 && vox < MAXVOXELS && voxmodels[vox] && voxmodels[vox]->model) if (vox >= 0 && vox < MAXVOXELS && voxmodels[vox] && voxmodels[vox]->model)
{ {
FHWModelRenderer mr(*screen->RenderState(), 0); FHWModelRenderer mr(*screen->RenderState(), 0);

View file

@ -32,7 +32,6 @@
#include "tiletexture.h" #include "tiletexture.h"
#include "gamecontrol.h" #include "gamecontrol.h"
int16_t tiletovox[MAXTILES];
static int voxlumps[MAXVOXELS]; static int voxlumps[MAXVOXELS];
float voxscale[MAXVOXELS]; float voxscale[MAXVOXELS];
voxmodel_t* voxmodels[MAXVOXELS]; voxmodel_t* voxmodels[MAXVOXELS];
@ -41,7 +40,6 @@ FixedBitArray<MAXVOXELS> voxrotate;
void voxInit() void voxInit()
{ {
for (auto& v : tiletovox) v = -1;
for (auto& v : voxscale) v = 1.f; for (auto& v : voxscale) v = 1.f;
voxrotate.Zero(); voxrotate.Zero();
} }

View file

@ -18,7 +18,6 @@ struct voxmodel_t // : public mdmodel_t
extern int16_t tiletovox[];
extern float voxscale[]; extern float voxscale[];
extern voxmodel_t* voxmodels[MAXVOXELS]; extern voxmodel_t* voxmodels[MAXVOXELS];
extern FixedBitArray<MAXVOXELS> voxrotate; extern FixedBitArray<MAXVOXELS> voxrotate;

View file

@ -45,6 +45,7 @@
#include "gamecontrol.h" #include "gamecontrol.h"
#include "hw_sections.h" #include "hw_sections.h"
#include "coreactor.h" #include "coreactor.h"
#include "texinfo.h"
//#define DEBUG_CLIPPER //#define DEBUG_CLIPPER
//========================================================================== //==========================================================================
@ -684,8 +685,7 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal)
//if ((actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) || (hw_models && tile2model[actor->spr.picnum].modelid >= 0) || ((sx * gcosang) + (sy * gsinang) > 0)) //if ((actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) || (hw_models && tile2model[actor->spr.picnum].modelid >= 0) || ((sx * gcosang) + (sy * gsinang) > 0))
{ {
if ((actor->spr.cstat & (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_MASK)) != (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL) || if ((actor->spr.cstat & (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_MASK)) != (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL) ||
(r_voxels && tiletovox[actor->spr.picnum] >= 0 && voxmodels[tiletovox[actor->spr.picnum]]) || tilehasvoxel(actor->spr.spritetexture()) ||
(r_voxels && gi->Voxelize(actor->spr.picnum) > -1) ||
(actor->spr.Angles.Yaw.Cos() * viewvec.X) + (actor->spr.Angles.Yaw.Sin() * viewvec.Y) < 0) (actor->spr.Angles.Yaw.Cos() * viewvec.X) + (actor->spr.Angles.Yaw.Sin() * viewvec.Y) < 0)
if (!renderAddTsprite(di->tsprites, actor)) if (!renderAddTsprite(di->tsprites, actor))
break; break;

View file

@ -284,9 +284,11 @@ void HWDrawInfo::DispatchSprites()
if (actor == nullptr || tspr->scale.X == 0 || tspr->scale.Y == 0) if (actor == nullptr || tspr->scale.X == 0 || tspr->scale.Y == 0)
continue; continue;
if (!texid.isValid()) return;
actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED; actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED;
if ((tspr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLAB && !(tspr->cstat2 & CSTAT2_SPRITE_NOANIMATE)) if (!(tspr->cstat2 & CSTAT2_SPRITE_NOANIMATE))
{ {
tileUpdatePicnum(texid, (actor->GetIndex() & 16383)); tileUpdatePicnum(texid, (actor->GetIndex() & 16383));
} }
@ -295,7 +297,7 @@ void HWDrawInfo::DispatchSprites()
tspr->picnum = legacyTileNum(texid); tspr->picnum = legacyTileNum(texid);
int tilenum = tspr->picnum; int tilenum = tspr->picnum;
if (!(actor->sprext.renderflags & SPREXT_NOTMD)) if (!(actor->sprext.renderflags & SPREXT_NOTMD) && !(tspr->cstat2 & CSTAT2_SPRITE_NOMODEL))
{ {
auto pt = modelManager.GetModel(tspr->picnum, tspr->pal); auto pt = modelManager.GetModel(tspr->picnum, tspr->pal);
if (hw_models && pt && pt->modelid >= 0 && pt->framenum >= 0) if (hw_models && pt && pt->modelid >= 0 && pt->framenum >= 0)
@ -305,23 +307,15 @@ void HWDrawInfo::DispatchSprites()
} }
if (r_voxels) if (r_voxels)
{ {
if ((tspr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLAB && tiletovox[tilenum] >= 0 && voxmodels[tiletovox[tilenum]]) auto vox = GetExtInfo(texid).tiletovox;
if (vox >= 0 && voxmodels[vox])
{ {
HWSprite hwsprite; HWSprite hwsprite;
int num = tiletovox[tilenum]; if (hwsprite.ProcessVoxel(this, voxmodels[vox], tspr, tspr->sectp, voxrotate[vox]))
if (hwsprite.ProcessVoxel(this, voxmodels[num], tspr, tspr->sectp, voxrotate[num]))
continue; continue;
} }
else if ((tspr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_SLAB && tspr->picnum < MAXVOXELS && voxmodels[tilenum])
{
HWSprite hwsprite;
int num = tilenum;
hwsprite.ProcessVoxel(this, voxmodels[tspr->picnum], tspr, tspr->sectp, voxrotate[num]);
continue;
}
} }
} }
if (!texid.isValid()) return; // due to CSTAT_SPRITE_ALIGNMENT_SLAB this can only be checked here
if (actor->sprext.renderflags & SPREXT_AWAY1) if (actor->sprext.renderflags & SPREXT_AWAY1)
{ {

View file

@ -97,4 +97,26 @@ void tileUpdateAnimations()
} }
} }
//==========================================================================
//
//
//
//==========================================================================
int tilehasmodelorvoxel(FTextureID texid, int pal)
{
if (r_voxels)
{
auto x = GetExtInfo(texid);
if (x.tiletovox != -1) return true;
}
/*
if (hw_models)
{
return modelManager.CheckModel(tilenume, pal); // we have no models yet.
}
*/
return false;
}

View file

@ -60,8 +60,8 @@ struct TexExtInfo
// TexAnim *texanim // todo: extended texture animation like ZDoom's ANIMDEFS. // TexAnim *texanim // todo: extended texture animation like ZDoom's ANIMDEFS.
uint8_t terrain; // Contents depend on the game, e.g. this holds Blood's surfType. uint8_t terrain; // Contents depend on the game, e.g. this holds Blood's surfType.
uint8_t shadeinfo; // Blood's shade.dat uint8_t shadeinfo; // Blood's shade.dat
uint16_t voxindex; int16_t tiletovox; // engine-side voxel index
picanm_t picanm; picanm_t picanm; // tile-based animation data.
uint32_t flags; // contents are game dependent. uint32_t flags; // contents are game dependent.
TileOffs hiofs; TileOffs hiofs;
}; };
@ -89,7 +89,7 @@ bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wanti
void tileUpdatePicnum(FTextureID& tileptr, int randomize = -1); void tileUpdatePicnum(FTextureID& tileptr, int randomize = -1);
void tileUpdateAnimations(); void tileUpdateAnimations();
int tilehasmodelorvoxel(FTextureID tilenume, int pal);
inline const TexExtInfo& GetExtInfo(FTextureID tex) // this is only for reading, not for modifying! inline const TexExtInfo& GetExtInfo(FTextureID tex) // this is only for reading, not for modifying!
{ {
@ -98,6 +98,28 @@ inline const TexExtInfo& GetExtInfo(FTextureID tex) // this is only for reading,
return texExtInfo[index]; return texExtInfo[index];
} }
inline TexExtInfo& AccessExtInfo(FTextureID tex) // this is for modifying and should only be called by init code!
{
unsigned index = tex.GetIndex();
if (index >= texExtInfo.Size())
{
unsigned now = texExtInfo.Size();
texExtInfo.Resize(index + 1);
for (; now <= index; now++) texExtInfo[now] = texExtInfo[0];
}
return texExtInfo[index];
}
inline int tilehasvoxel(FTextureID texid)
{
if (r_voxels)
{
auto x = GetExtInfo(texid);
if (x.tiletovox != -1) return true;
}
return false;
}
inline FTextureID tileGetTextureID(int tilenum) inline FTextureID tileGetTextureID(int tilenum)
{ {
if ((unsigned)tilenum >= MAXTILES) return FNullTextureID(); if ((unsigned)tilenum >= MAXTILES) return FNullTextureID();

View file

@ -237,7 +237,11 @@ void ConstructTileset()
} }
images.Reset(); images.Reset();
rawpicanm.Reset(); rawpicanm.Reset();
for (auto& a : info.tile) a.alphathreshold = 0.5f; for (auto& a : info.tile)
{
a.alphathreshold = 0.5f;
a.extinfo.tiletovox = -1;
}
gi->LoadTextureInfo(info); // initialize game data that must be done before loading .DEF gi->LoadTextureInfo(info); // initialize game data that must be done before loading .DEF
LoadDefinitions(info); LoadDefinitions(info);
gi->SetupSpecialTextures(info); // initialize game data that needs .DEF being processed. gi->SetupSpecialTextures(info); // initialize game data that needs .DEF being processed.
@ -301,7 +305,7 @@ void ConstructTileset()
// Textures being added afterward will always see the default extinfo, even if they are not covered by this array. // Textures being added afterward will always see the default extinfo, even if they are not covered by this array.
texExtInfo.Resize(TexMan.NumTextures()); texExtInfo.Resize(TexMan.NumTextures());
memset(texExtInfo.Data(), 0, sizeof(texExtInfo[0]) * texExtInfo.Size()); memset(texExtInfo.Data(), 0, sizeof(texExtInfo[0]) * texExtInfo.Size());
for (auto& x : texExtInfo) x.voxindex = -1; for (auto& x : texExtInfo) x.tiletovox = -1;
// now copy all extinfo stuff that got parsed by .DEF or some game specific setup. // now copy all extinfo stuff that got parsed by .DEF or some game specific setup.
for (int i = 0; i <= maxarttile; i++) for (int i = 0; i <= maxarttile; i++)
{ {

View file

@ -39,6 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "hw_voxels.h" #include "hw_voxels.h"
#include "gamefuncs.h" #include "gamefuncs.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "texinfo.h"
#include "models/modeldata.h" #include "models/modeldata.h"
BEGIN_BLD_NS BEGIN_BLD_NS
@ -475,14 +476,12 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
pNSprite->picnum = nTile; pNSprite->picnum = nTile;
pNSprite->shade = pTSprite->shade; pNSprite->shade = pTSprite->shade;
pNSprite->scale = DVector2(0.5, 0.5); pNSprite->scale = DVector2(0.5, 0.5);
auto& nVoxel = voxelIndex[nTile]; int nVoxel = GetExtInfo(tileGetTextureID(nTile)).tiletovox;
if (cl_showweapon == 2 && r_voxels && nVoxel != -1) if (cl_showweapon == 2 && r_voxels && nVoxel != -1)
{ {
auto gView = &gPlayer[gViewIndex]; auto gView = &gPlayer[gViewIndex];
pNSprite->Angles.Yaw = gView->actor->spr.Angles.Yaw += DAngle90; // always face viewer pNSprite->Angles.Yaw = gView->actor->spr.Angles.Yaw += DAngle90; // always face viewer
pNSprite->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
pNSprite->cstat &= ~CSTAT_SPRITE_YFLIP; pNSprite->cstat &= ~CSTAT_SPRITE_YFLIP;
pNSprite->picnum = nVoxel;
if (pPlayer->curWeapon == kWeapLifeLeech) // position lifeleech behind player if (pPlayer->curWeapon == kWeapLifeLeech) // position lifeleech behind player
{ {
pNSprite->pos.XY() += gView->actor->spr.Angles.Yaw.ToVector() * 8; pNSprite->pos.XY() += gView->actor->spr.Angles.Yaw.ToVector() * 8;
@ -490,6 +489,10 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
if ((pPlayer->curWeapon == kWeapLifeLeech) || (pPlayer->curWeapon == kWeapVoodooDoll)) // make lifeleech/voodoo doll always face viewer like sprite if ((pPlayer->curWeapon == kWeapLifeLeech) || (pPlayer->curWeapon == kWeapVoodooDoll)) // make lifeleech/voodoo doll always face viewer like sprite
pNSprite->Angles.Yaw += DAngle90; pNSprite->Angles.Yaw += DAngle90;
} }
else
{
pNSprite->cstat2 |= CSTAT2_SPRITE_NOMODEL;
}
break; break;
} }
} }
@ -582,7 +585,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
break; break;
case 1: case 1:
{ {
if (tilehasmodelorvoxel(pTSprite->picnum, pTSprite->pal) && !(owneractor->sprext.renderflags & SPREXT_NOTMD)) if (tilehasmodelorvoxel(pTSprite->spritetexture(), pTSprite->pal) && !(owneractor->sprext.renderflags & SPREXT_NOTMD))
{ {
pTSprite->cstat &= ~CSTAT_SPRITE_XFLIP; pTSprite->cstat &= ~CSTAT_SPRITE_XFLIP;
break; break;
@ -601,7 +604,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
} }
case 2: case 2:
{ {
if (tilehasmodelorvoxel(pTSprite->picnum, pTSprite->pal) && !(owneractor->sprext.renderflags & SPREXT_NOTMD)) if (tilehasmodelorvoxel(pTSprite->spritetexture(), pTSprite->pal) && !(owneractor->sprext.renderflags & SPREXT_NOTMD))
{ {
pTSprite->cstat &= ~CSTAT_SPRITE_XFLIP; pTSprite->cstat &= ~CSTAT_SPRITE_XFLIP;
break; break;
@ -632,15 +635,13 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
break; break;
// Can be overridden by def script // Can be overridden by def script
if (r_voxels && tiletovox[pTSprite->picnum] == -1 && tprops[pTSprite->spritetexture()].voxelIndex != -1 && !(owneractor->sprext.renderflags & SPREXT_NOTMD)) if (tilehasvoxel(pTSprite->spritetexture()) && !(owneractor->sprext.renderflags & SPREXT_NOTMD))
{ {
if ((pTSprite->flags & kHitagRespawn) == 0) if ((pTSprite->flags & kHitagRespawn) == 0)
{ {
pTSprite->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
pTSprite->cstat &= ~(CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP); pTSprite->cstat &= ~(CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP);
auto tex = TexMan.GetGameTexture(pTSprite->spritetexture()); auto tex = TexMan.GetGameTexture(pTSprite->spritetexture());
pTSprite->yoffset += (uint8_t)tex->GetDisplayTopOffset(); pTSprite->yoffset += (uint8_t)tex->GetDisplayTopOffset();
pTSprite->picnum = tprops[pTSprite->spritetexture()].voxelIndex;
if ((picanm[nTile].extra & 7) == 7) if ((picanm[nTile].extra & 7) == 7)
{ {
pTSprite->Angles.Yaw = myclock.Normalized360(); pTSprite->Angles.Yaw = myclock.Normalized360();

View file

@ -132,7 +132,7 @@ struct GameInterface : public ::GameInterface
void NextLevel(MapRecord* map, int skill) override; void NextLevel(MapRecord* map, int skill) override;
void LevelCompleted(MapRecord* map, int skill) override; void LevelCompleted(MapRecord* map, int skill) override;
bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) override; bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) override;
void SetTileProps(int til, int surf, int vox, int shade) override; void SetTileProps(int til, int surf, int shade) override;
DAngle playerPitchMin() override { return DAngle::fromDeg(54.575); } DAngle playerPitchMin() override { return DAngle::fromDeg(54.575); }
DAngle playerPitchMax() override { return DAngle::fromDeg(-43.15); } DAngle playerPitchMax() override { return DAngle::fromDeg(-43.15); }
void WarpToCoords(double x, double y, double z, DAngle a) override; void WarpToCoords(double x, double y, double z, DAngle a) override;

View file

@ -93,8 +93,6 @@ enum SurfaceType {
kSurfMax kSurfMax
}; };
extern short voxelIndex[MAXTILES];
extern int nPrecacheCount; extern int nPrecacheCount;
inline FTextureID mirrortile; inline FTextureID mirrortile;
@ -106,7 +104,6 @@ struct TextureAttr
{ {
uint8_t surfType = kSurfNone; uint8_t surfType = kSurfNone;
int8_t tileShade = 0; int8_t tileShade = 0;
int16_t voxelIndex = -1;
}; };
class FTextureAttrArray class FTextureAttrArray

View file

@ -39,7 +39,6 @@ int nTileFiles = 0;
// these arrays get partially filled by .def, so they need to remain global. // these arrays get partially filled by .def, so they need to remain global.
static uint8_t surfType[kMaxTiles]; static uint8_t surfType[kMaxTiles];
static int8_t tileShade[kMaxTiles]; static int8_t tileShade[kMaxTiles];
short voxelIndex[kMaxTiles];
#define x(a, b) registerName(#a, b); #define x(a, b) registerName(#a, b);
static void SetTileNames(TilesetBuildInfo& info) static void SetTileNames(TilesetBuildInfo& info)
@ -76,22 +75,25 @@ void GameInterface::LoadTextureInfo(TilesetBuildInfo& info)
hFile = fileSystem.OpenFileReader("VOXEL.DAT"); hFile = fileSystem.OpenFileReader("VOXEL.DAT");
if (hFile.isOpen()) if (hFile.isOpen())
{ {
hFile.Read(voxelIndex, sizeof(voxelIndex)); int count = (int)hFile.GetLength() / 2;
#if WORDS_BIGENDIAN
for (int i = 0; i < kMaxTiles; i++) for (int i = 0; i < count; i++)
voxelIndex[i] = LittleShort(voxelIndex[i]); {
#endif int voxindex = hFile.ReadInt16();
// only insert into the table if they are flagged to be processed in viewProcessSprites, i.e. the type value is 6 or 7,
if (voxindex > -1 && (info.tile[i].extinfo.picanm.extra & 7) >= 6)
{
info.tile[i].extinfo.tiletovox = voxindex;
}
if (nextvoxid <= voxindex) nextvoxid = voxindex + 1;
}
} }
hFile = fileSystem.OpenFileReader("SHADE.DAT"); hFile = fileSystem.OpenFileReader("SHADE.DAT");
if (hFile.isOpen()) if (hFile.isOpen())
{ {
hFile.Read(tileShade, sizeof(tileShade)); hFile.Read(tileShade, sizeof(tileShade));
} }
for (int i = 0; i < kMaxTiles; i++)
{
if (voxelIndex[i] >= 0 && voxelIndex[i] < MAXVOXELS)
voxreserve.Set(voxelIndex[i]);
}
} }
void GameInterface::SetupSpecialTextures(TilesetBuildInfo& info) void GameInterface::SetupSpecialTextures(TilesetBuildInfo& info)
@ -110,7 +112,7 @@ void tileInitProps()
auto tex = tileGetTexture(i); auto tex = tileGetTexture(i);
if (tex) if (tex)
{ {
TextureAttr a = { surfType[i], tileShade[i], voxelIndex[i] }; TextureAttr a = { surfType[i], tileShade[i] };
tprops.Set(tex->GetID().GetIndex(), a); tprops.Set(tex->GetID().GetIndex(), a);
} }
} }
@ -142,10 +144,9 @@ int tileGetSurfType(CollisionBase& hit)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GameInterface::SetTileProps(int tile, int surf, int vox, int shade) void GameInterface::SetTileProps(int tile, int surf, int shade)
{ {
if (surf != INT_MAX) surfType[tile] = surf; if (surf != INT_MAX) surfType[tile] = surf;
if (vox != INT_MAX) voxelIndex[tile] = vox;
if (shade != INT_MAX) tileShade[tile] = shade; if (shade != INT_MAX) tileShade[tile] = shade;
mirrortile = tileGetTextureID(504); mirrortile = tileGetTextureID(504);

View file

@ -83,7 +83,7 @@ void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h)
void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAngle viewang) void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAngle viewang)
{ {
if (gs.actorinfo[h->spr.picnum].scriptaddress && !actorflag(h, SFLAG2_DONTANIMATE) && (t->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLAB) if (gs.actorinfo[h->spr.picnum].scriptaddress && !actorflag(h, SFLAG2_DONTANIMATE))// && (t->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLAB)
{ {
DAngle kang; DAngle kang;
int t4 = h->temp_data[4]; int t4 = h->temp_data[4];
@ -92,7 +92,7 @@ void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAn
{ {
l = ScriptCode[t4 + 2]; l = ScriptCode[t4 + 2];
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal)) if (tilehasmodelorvoxel(h->spr.spritetexture(), h->spr.pal))
{ {
k = 0; k = 0;
t->cstat &= ~CSTAT_SPRITE_XFLIP; t->cstat &= ~CSTAT_SPRITE_XFLIP;

View file

@ -302,7 +302,7 @@ inline int angletorotation2(DAngle sprang, DAngle viewang)
// 4 (8) frame rotation. // 4 (8) frame rotation.
inline void applyRotation1(DDukeActor* h, tspritetype* t, DAngle viewang) inline void applyRotation1(DDukeActor* h, tspritetype* t, DAngle viewang)
{ {
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal)) if (tilehasmodelorvoxel(h->spr.spritetexture(), h->spr.pal))
{ {
t->cstat &= ~CSTAT_SPRITE_XFLIP; t->cstat &= ~CSTAT_SPRITE_XFLIP;
return; return;
@ -321,7 +321,7 @@ inline void applyRotation1(DDukeActor* h, tspritetype* t, DAngle viewang)
// 6 (12) frame rotation. // 6 (12) frame rotation.
inline void applyRotation2(DDukeActor* h, tspritetype* t, DAngle viewang) inline void applyRotation2(DDukeActor* h, tspritetype* t, DAngle viewang)
{ {
if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal)) if (tilehasmodelorvoxel(h->spr.spritetexture(), h->spr.pal))
{ {
t->cstat &= ~CSTAT_SPRITE_XFLIP; t->cstat &= ~CSTAT_SPRITE_XFLIP;
return; return;

View file

@ -70,8 +70,6 @@ extern bool QuitFlag, SpriteInfo;
extern bool Voxel; extern bool Voxel;
extern int f_c; extern int f_c;
extern TILE_INFO_TYPE aVoxelArray[MAXTILES];
void PreDrawStackedWater(void); void PreDrawStackedWater(void);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -354,7 +352,7 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, double viewz)
scale.Y = clamp(scale.Y + scaleofs, 0.0625, 4.); scale.Y = clamp(scale.Y + scaleofs, 0.0625, 4.);
tSpr->scale = scale; tSpr->scale = scale;
if (tilehasmodelorvoxel(tsp->picnum,tsp->pal)) if (tilehasmodelorvoxel(tsp->spritetexture(), tsp->pal))
{ {
tSpr->scale.Y = (0); tSpr->scale.Y = (0);
// cstat: trans reverse // cstat: trans reverse

View file

@ -222,7 +222,7 @@ static void SetTileNames(TilesetBuildInfo& info)
void GameInterface::LoadTextureInfo(TilesetBuildInfo& info) void GameInterface::LoadTextureInfo(TilesetBuildInfo& info)
{ {
LoadKVXFromScript("swvoxfil.txt"); // Load voxels from script file LoadKVXFromScript(info, "swvoxfil.txt"); // Load voxels from script file
} }
enum enum
@ -853,9 +853,4 @@ void GameInterface::FreeLevelData()
::GameInterface::FreeLevelData(); ::GameInterface::FreeLevelData();
} }
int GameInterface::Voxelize(int sprnum)
{
return (aVoxelArray[sprnum].Voxel);
}
END_SW_NS END_SW_NS

View file

@ -1584,7 +1584,7 @@ double GetZadjustment(sectortype* sect,short hitag); // rooms.c
void InitSetup(void); // setup.c void InitSetup(void); // setup.c
void LoadKVXFromScript(const char *filename); // scrip2.c void LoadKVXFromScript(TilesetBuildInfo& info, const char *filename); // scrip2.c
void LoadCustomInfoFromScript(const char *filename); // scrip2.c void LoadCustomInfoFromScript(const char *filename); // scrip2.c
int PlayerInitChemBomb(PLAYER* pp); // jweapon.c int PlayerInitChemBomb(PLAYER* pp); // jweapon.c
@ -1689,7 +1689,6 @@ struct GameInterface : public ::GameInterface
void UpdateCameras(double smoothratio) override; void UpdateCameras(double smoothratio) override;
void EnterPortal(DCoreActor* viewer, int type) override; void EnterPortal(DCoreActor* viewer, int type) override;
void LeavePortal(DCoreActor* viewer, int type) override; void LeavePortal(DCoreActor* viewer, int type) override;
int Voxelize(int sprnum);
void ExitFromMenu() override; void ExitFromMenu() override;
int GetCurrentSkill() override; int GetCurrentSkill() override;
void StartSoundEngine() override; void StartSoundEngine() override;

View file

@ -69,8 +69,6 @@ bool bAutoSize = true; // Autosizing on/off
extern AMB_INFO ambarray[]; extern AMB_INFO ambarray[];
extern short NormalVisibility; extern short NormalVisibility;
extern TILE_INFO_TYPE aVoxelArray[MAXTILES];
// F U N C T I O N S ////////////////////////////////////////////////////////////////////////////// // F U N C T I O N S //////////////////////////////////////////////////////////////////////////////
@ -781,39 +779,9 @@ void JAnalyzeSprites(tspritetype* tspr)
// Take care of autosizing // Take care of autosizing
DoAutoSize(tspr); DoAutoSize(tspr);
if (hw_models && modelManager.CheckModel(tspr->picnum, 0)) return; if (tspr->picnum == 764 && !tilehasmodelorvoxel(tspr->spritetexture(), 0))
// Check for voxels
//if (bVoxelsOn)
if (r_voxels)
{ {
if (aVoxelArray[tspr->picnum].Voxel >= 0 && !(tspr->ownerActor->sprext.renderflags & SPREXT_NOTMD)) tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_WALL;
{
// Turn on voxels
tspr->picnum = aVoxelArray[tspr->picnum].Voxel; // Get the voxel number
tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB; // Set stat to voxelize sprite
}
}
else
{
switch (tspr->picnum)
{
case 764: // Gun barrel
if (!r_voxels || (tspr->ownerActor->sprext.renderflags & SPREXT_NOTMD))
{
tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_WALL;
break;
}
if (aVoxelArray[tspr->picnum].Voxel >= 0)
{
// Turn on voxels
tspr->picnum = aVoxelArray[tspr->picnum].Voxel; // Get the voxel number
tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB; // Set stat to voxelize sprite
}
break;
}
} }
} }

View file

@ -44,9 +44,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS BEGIN_SW_NS
TILE_INFO_TYPE aVoxelArray[MAXTILES];
/* /*
============================================================================= =============================================================================
@ -190,14 +187,11 @@ return;
// 1804 1 shotgun.kvx // 1804 1 shotgun.kvx
// etc.... // etc....
void LoadKVXFromScript(const char* filename) void LoadKVXFromScript(TilesetBuildInfo& info, const char* filename)
{ {
int lNumber = 0, lTile = 0; // lNumber is the voxel no. and lTile is the editart tile being int lNumber = 0, lTile = 0; // lNumber is the voxel no. and lTile is the editart tile being
// replaced. // replaced.
// zero out the array memory with -1's for pics not being voxelized
memset(&aVoxelArray[0], -1, sizeof(struct TILE_INFO_TYPE) * MAXTILES);
// Load the file // Load the file
auto buffer = LoadScriptFile(filename); auto buffer = LoadScriptFile(filename);
if (!buffer.Size()) if (!buffer.Size())
@ -224,8 +218,7 @@ void LoadKVXFromScript(const char* filename)
// Load the voxel file into memory // Load the voxel file into memory
if (!voxDefine(lNumber,token)) if (!voxDefine(lNumber,token))
{ {
// Store the sprite and voxel numbers for later use info.tile[lTile].extinfo.tiletovox = lNumber;
aVoxelArray[lTile].Voxel = lNumber; // Voxel num
} }
if (lNumber >= nextvoxid) // JBF: so voxels in the def file append to the list if (lNumber >= nextvoxid) // JBF: so voxels in the def file append to the list