mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 12:30:40 +00:00
- 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:
parent
be2112a507
commit
8a789b9015
25 changed files with 109 additions and 138 deletions
|
@ -225,11 +225,12 @@ void processTileImport(FScanner& sc, const char* cmd, FScriptPosition& pos, Tile
|
|||
|
||||
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;
|
||||
|
||||
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:
|
||||
// 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.
|
||||
|
@ -889,7 +890,7 @@ void parseDefineVoxelTiles(FScanner& sc, FScriptPosition& pos)
|
|||
pos.Message(MSG_WARNING, "Warning: Ignoring voxel tiles definition without valid voxel.\n");
|
||||
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);
|
||||
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);
|
||||
|
@ -940,7 +941,7 @@ void parseVoxel(FScanner& sc, FScriptPosition& pos)
|
|||
sc.GetNumber(tile1, true);
|
||||
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"))
|
||||
|
|
|
@ -512,7 +512,7 @@ void FMapInfoParser::ParseTextureFlags()
|
|||
}
|
||||
else
|
||||
{
|
||||
texExtInfo[tex.GetIndex()].flags |= num;
|
||||
AccessExtInfo(tex).flags |= num;
|
||||
}
|
||||
|
||||
} while (sc.CheckString(","));
|
||||
|
|
|
@ -110,7 +110,7 @@ struct GameInterface
|
|||
virtual void NewGame(MapRecord* map, int skill, bool special = false) {}
|
||||
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 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 playerPitchMax() { return DAngle::fromDeg(-57.375); }
|
||||
virtual void WarpToCoords(double x, double y, double z, DAngle a) {}
|
||||
|
|
|
@ -186,6 +186,7 @@ enum ESpriteBits2
|
|||
CSTAT2_SPRITE_DECAL = 8, // always attached to a wall.
|
||||
CSTAT2_SPRITE_FULLBRIGHT = 16, // always draw fullbright with shade -127
|
||||
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.
|
||||
|
|
|
@ -230,16 +230,3 @@ void updateModelInterpolation()
|
|||
}
|
||||
#endif
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int tilehasmodelorvoxel(int const tilenume, int pal)
|
||||
{
|
||||
return
|
||||
(hw_models && modelManager.CheckModel(tilenume, pal)) ||
|
||||
(r_voxels && tiletovox[tilenume] != -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,5 +81,4 @@ struct ModelManager
|
|||
};
|
||||
|
||||
|
||||
int tilehasmodelorvoxel(int const tilenume, int pal);
|
||||
inline ModelManager modelManager;
|
||||
|
|
|
@ -49,10 +49,6 @@
|
|||
|
||||
#include "buildtiles.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
extern short voxelIndex[MAXTILES];
|
||||
END_BLD_NS
|
||||
|
||||
static void PrecacheTex(FGameTexture* tex, int palid)
|
||||
{
|
||||
if (!tex || !tex->isValid()) return;
|
||||
|
@ -71,17 +67,13 @@ static void doprecache(int picnum, int palette)
|
|||
auto tex = tileGetTexture(picnum);
|
||||
PrecacheTex(tex, palid);
|
||||
|
||||
if (!hw_models) return;
|
||||
|
||||
int const mid = modelManager.CheckModel(picnum, palette);
|
||||
int const mid = -1;// hw_models ? modelManager.CheckModel(picnum, palette) : -1;
|
||||
|
||||
if (mid < 0)
|
||||
{
|
||||
if (r_voxels)
|
||||
{
|
||||
int vox = tiletovox[picnum];
|
||||
if (vox == -1) vox = gi->Voxelize(picnum);
|
||||
if (vox == -1 && isBlood()) vox = Blood::voxelIndex[picnum];
|
||||
int vox = GetExtInfo(tileGetTextureID(picnum)).tiletovox;
|
||||
if (vox >= 0 && vox < MAXVOXELS && voxmodels[vox] && voxmodels[vox]->model)
|
||||
{
|
||||
FHWModelRenderer mr(*screen->RenderState(), 0);
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "tiletexture.h"
|
||||
#include "gamecontrol.h"
|
||||
|
||||
int16_t tiletovox[MAXTILES];
|
||||
static int voxlumps[MAXVOXELS];
|
||||
float voxscale[MAXVOXELS];
|
||||
voxmodel_t* voxmodels[MAXVOXELS];
|
||||
|
@ -41,7 +40,6 @@ FixedBitArray<MAXVOXELS> voxrotate;
|
|||
|
||||
void voxInit()
|
||||
{
|
||||
for (auto& v : tiletovox) v = -1;
|
||||
for (auto& v : voxscale) v = 1.f;
|
||||
voxrotate.Zero();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ struct voxmodel_t // : public mdmodel_t
|
|||
|
||||
|
||||
|
||||
extern int16_t tiletovox[];
|
||||
extern float voxscale[];
|
||||
extern voxmodel_t* voxmodels[MAXVOXELS];
|
||||
extern FixedBitArray<MAXVOXELS> voxrotate;
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "gamecontrol.h"
|
||||
#include "hw_sections.h"
|
||||
#include "coreactor.h"
|
||||
#include "texinfo.h"
|
||||
|
||||
//#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_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]]) ||
|
||||
(r_voxels && gi->Voxelize(actor->spr.picnum) > -1) ||
|
||||
tilehasvoxel(actor->spr.spritetexture()) ||
|
||||
(actor->spr.Angles.Yaw.Cos() * viewvec.X) + (actor->spr.Angles.Yaw.Sin() * viewvec.Y) < 0)
|
||||
if (!renderAddTsprite(di->tsprites, actor))
|
||||
break;
|
||||
|
|
|
@ -284,9 +284,11 @@ void HWDrawInfo::DispatchSprites()
|
|||
if (actor == nullptr || tspr->scale.X == 0 || tspr->scale.Y == 0)
|
||||
continue;
|
||||
|
||||
if (!texid.isValid()) return;
|
||||
|
||||
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));
|
||||
}
|
||||
|
@ -295,7 +297,7 @@ void HWDrawInfo::DispatchSprites()
|
|||
tspr->picnum = legacyTileNum(texid);
|
||||
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);
|
||||
if (hw_models && pt && pt->modelid >= 0 && pt->framenum >= 0)
|
||||
|
@ -305,23 +307,15 @@ void HWDrawInfo::DispatchSprites()
|
|||
}
|
||||
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;
|
||||
int num = tiletovox[tilenum];
|
||||
if (hwsprite.ProcessVoxel(this, voxmodels[num], tspr, tspr->sectp, voxrotate[num]))
|
||||
if (hwsprite.ProcessVoxel(this, voxmodels[vox], tspr, tspr->sectp, voxrotate[vox]))
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ struct TexExtInfo
|
|||
// 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 shadeinfo; // Blood's shade.dat
|
||||
uint16_t voxindex;
|
||||
picanm_t picanm;
|
||||
int16_t tiletovox; // engine-side voxel index
|
||||
picanm_t picanm; // tile-based animation data.
|
||||
uint32_t flags; // contents are game dependent.
|
||||
TileOffs hiofs;
|
||||
};
|
||||
|
@ -89,7 +89,7 @@ bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wanti
|
|||
|
||||
void tileUpdatePicnum(FTextureID& tileptr, int randomize = -1);
|
||||
void tileUpdateAnimations();
|
||||
|
||||
int tilehasmodelorvoxel(FTextureID tilenume, int pal);
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if ((unsigned)tilenum >= MAXTILES) return FNullTextureID();
|
||||
|
|
|
@ -237,7 +237,11 @@ void ConstructTileset()
|
|||
}
|
||||
images.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
|
||||
LoadDefinitions(info);
|
||||
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.
|
||||
texExtInfo.Resize(TexMan.NumTextures());
|
||||
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.
|
||||
for (int i = 0; i <= maxarttile; i++)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "hw_voxels.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "texturemanager.h"
|
||||
#include "texinfo.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
@ -475,14 +476,12 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
|
|||
pNSprite->picnum = nTile;
|
||||
pNSprite->shade = pTSprite->shade;
|
||||
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)
|
||||
{
|
||||
auto gView = &gPlayer[gViewIndex];
|
||||
pNSprite->Angles.Yaw = gView->actor->spr.Angles.Yaw += DAngle90; // always face viewer
|
||||
pNSprite->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
|
||||
pNSprite->cstat &= ~CSTAT_SPRITE_YFLIP;
|
||||
pNSprite->picnum = nVoxel;
|
||||
if (pPlayer->curWeapon == kWeapLifeLeech) // position lifeleech behind player
|
||||
{
|
||||
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
|
||||
pNSprite->Angles.Yaw += DAngle90;
|
||||
}
|
||||
else
|
||||
{
|
||||
pNSprite->cstat2 |= CSTAT2_SPRITE_NOMODEL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -582,7 +585,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
|
|||
break;
|
||||
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;
|
||||
break;
|
||||
|
@ -601,7 +604,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
|
|||
}
|
||||
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;
|
||||
break;
|
||||
|
@ -632,15 +635,13 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
|
|||
break;
|
||||
|
||||
// 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)
|
||||
{
|
||||
pTSprite->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
|
||||
pTSprite->cstat &= ~(CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP);
|
||||
auto tex = TexMan.GetGameTexture(pTSprite->spritetexture());
|
||||
pTSprite->yoffset += (uint8_t)tex->GetDisplayTopOffset();
|
||||
pTSprite->picnum = tprops[pTSprite->spritetexture()].voxelIndex;
|
||||
if ((picanm[nTile].extra & 7) == 7)
|
||||
{
|
||||
pTSprite->Angles.Yaw = myclock.Normalized360();
|
||||
|
|
|
@ -132,7 +132,7 @@ struct GameInterface : public ::GameInterface
|
|||
void NextLevel(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;
|
||||
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 playerPitchMax() override { return DAngle::fromDeg(-43.15); }
|
||||
void WarpToCoords(double x, double y, double z, DAngle a) override;
|
||||
|
|
|
@ -93,8 +93,6 @@ enum SurfaceType {
|
|||
kSurfMax
|
||||
};
|
||||
|
||||
extern short voxelIndex[MAXTILES];
|
||||
|
||||
extern int nPrecacheCount;
|
||||
inline FTextureID mirrortile;
|
||||
|
||||
|
@ -106,7 +104,6 @@ struct TextureAttr
|
|||
{
|
||||
uint8_t surfType = kSurfNone;
|
||||
int8_t tileShade = 0;
|
||||
int16_t voxelIndex = -1;
|
||||
};
|
||||
|
||||
class FTextureAttrArray
|
||||
|
|
|
@ -39,7 +39,6 @@ int nTileFiles = 0;
|
|||
// these arrays get partially filled by .def, so they need to remain global.
|
||||
static uint8_t surfType[kMaxTiles];
|
||||
static int8_t tileShade[kMaxTiles];
|
||||
short voxelIndex[kMaxTiles];
|
||||
|
||||
#define x(a, b) registerName(#a, b);
|
||||
static void SetTileNames(TilesetBuildInfo& info)
|
||||
|
@ -76,22 +75,25 @@ void GameInterface::LoadTextureInfo(TilesetBuildInfo& info)
|
|||
hFile = fileSystem.OpenFileReader("VOXEL.DAT");
|
||||
if (hFile.isOpen())
|
||||
{
|
||||
hFile.Read(voxelIndex, sizeof(voxelIndex));
|
||||
#if WORDS_BIGENDIAN
|
||||
for (int i = 0; i < kMaxTiles; i++)
|
||||
voxelIndex[i] = LittleShort(voxelIndex[i]);
|
||||
#endif
|
||||
int count = (int)hFile.GetLength() / 2;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
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");
|
||||
if (hFile.isOpen())
|
||||
{
|
||||
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)
|
||||
|
@ -110,7 +112,7 @@ void tileInitProps()
|
|||
auto tex = tileGetTexture(i);
|
||||
if (tex)
|
||||
{
|
||||
TextureAttr a = { surfType[i], tileShade[i], voxelIndex[i] };
|
||||
TextureAttr a = { surfType[i], tileShade[i] };
|
||||
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 (vox != INT_MAX) voxelIndex[tile] = vox;
|
||||
if (shade != INT_MAX) tileShade[tile] = shade;
|
||||
|
||||
mirrortile = tileGetTextureID(504);
|
||||
|
|
|
@ -83,7 +83,7 @@ void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h)
|
|||
|
||||
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;
|
||||
int t4 = h->temp_data[4];
|
||||
|
@ -92,7 +92,7 @@ void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAn
|
|||
{
|
||||
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;
|
||||
t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
|
|
|
@ -302,7 +302,7 @@ inline int angletorotation2(DAngle sprang, DAngle viewang)
|
|||
// 4 (8) frame rotation.
|
||||
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;
|
||||
return;
|
||||
|
@ -321,7 +321,7 @@ inline void applyRotation1(DDukeActor* h, tspritetype* t, DAngle viewang)
|
|||
// 6 (12) frame rotation.
|
||||
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;
|
||||
return;
|
||||
|
|
|
@ -70,8 +70,6 @@ extern bool QuitFlag, SpriteInfo;
|
|||
extern bool Voxel;
|
||||
extern int f_c;
|
||||
|
||||
extern TILE_INFO_TYPE aVoxelArray[MAXTILES];
|
||||
|
||||
void PreDrawStackedWater(void);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -354,7 +352,7 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, double viewz)
|
|||
scale.Y = clamp(scale.Y + scaleofs, 0.0625, 4.);
|
||||
tSpr->scale = scale;
|
||||
|
||||
if (tilehasmodelorvoxel(tsp->picnum,tsp->pal))
|
||||
if (tilehasmodelorvoxel(tsp->spritetexture(), tsp->pal))
|
||||
{
|
||||
tSpr->scale.Y = (0);
|
||||
// cstat: trans reverse
|
||||
|
|
|
@ -222,7 +222,7 @@ static void SetTileNames(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
|
||||
|
@ -853,9 +853,4 @@ void GameInterface::FreeLevelData()
|
|||
::GameInterface::FreeLevelData();
|
||||
}
|
||||
|
||||
int GameInterface::Voxelize(int sprnum)
|
||||
{
|
||||
return (aVoxelArray[sprnum].Voxel);
|
||||
}
|
||||
|
||||
END_SW_NS
|
||||
|
|
|
@ -1584,7 +1584,7 @@ double GetZadjustment(sectortype* sect,short hitag); // rooms.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
|
||||
|
||||
int PlayerInitChemBomb(PLAYER* pp); // jweapon.c
|
||||
|
@ -1689,7 +1689,6 @@ struct GameInterface : public ::GameInterface
|
|||
void UpdateCameras(double smoothratio) override;
|
||||
void EnterPortal(DCoreActor* viewer, int type) override;
|
||||
void LeavePortal(DCoreActor* viewer, int type) override;
|
||||
int Voxelize(int sprnum);
|
||||
void ExitFromMenu() override;
|
||||
int GetCurrentSkill() override;
|
||||
void StartSoundEngine() override;
|
||||
|
|
|
@ -69,8 +69,6 @@ bool bAutoSize = true; // Autosizing on/off
|
|||
extern AMB_INFO ambarray[];
|
||||
extern short NormalVisibility;
|
||||
|
||||
extern TILE_INFO_TYPE aVoxelArray[MAXTILES];
|
||||
|
||||
// F U N C T I O N S //////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -781,39 +779,9 @@ void JAnalyzeSprites(tspritetype* tspr)
|
|||
// Take care of autosizing
|
||||
DoAutoSize(tspr);
|
||||
|
||||
if (hw_models && modelManager.CheckModel(tspr->picnum, 0)) return;
|
||||
|
||||
// Check for voxels
|
||||
//if (bVoxelsOn)
|
||||
if (r_voxels)
|
||||
if (tspr->picnum == 764 && !tilehasmodelorvoxel(tspr->spritetexture(), 0))
|
||||
{
|
||||
if (aVoxelArray[tspr->picnum].Voxel >= 0 && !(tspr->ownerActor->sprext.renderflags & SPREXT_NOTMD))
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_WALL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
|
||||
BEGIN_SW_NS
|
||||
|
||||
TILE_INFO_TYPE aVoxelArray[MAXTILES];
|
||||
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
|
@ -190,14 +187,11 @@ return;
|
|||
// 1804 1 shotgun.kvx
|
||||
// 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
|
||||
// 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
|
||||
auto buffer = LoadScriptFile(filename);
|
||||
if (!buffer.Size())
|
||||
|
@ -224,8 +218,7 @@ void LoadKVXFromScript(const char* filename)
|
|||
// Load the voxel file into memory
|
||||
if (!voxDefine(lNumber,token))
|
||||
{
|
||||
// Store the sprite and voxel numbers for later use
|
||||
aVoxelArray[lTile].Voxel = lNumber; // Voxel num
|
||||
info.tile[lTile].extinfo.tiletovox = lNumber;
|
||||
}
|
||||
|
||||
if (lNumber >= nextvoxid) // JBF: so voxels in the def file append to the list
|
||||
|
|
Loading…
Reference in a new issue