mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- separated hitlist generation for texture precaching into a virtual function of DFrameBuffer.
SVN r2466 (trunk)
This commit is contained in:
parent
6f4ed40496
commit
e1f06da5e3
3 changed files with 83 additions and 67 deletions
|
@ -421,80 +421,15 @@ void R_DeinitData ()
|
|||
void R_PrecacheLevel (void)
|
||||
{
|
||||
BYTE *hitlist;
|
||||
BYTE *spritelist;
|
||||
int i;
|
||||
|
||||
if (demoplayback)
|
||||
return;
|
||||
|
||||
hitlist = new BYTE[TexMan.NumTextures()];
|
||||
spritelist = new BYTE[sprites.Size()];
|
||||
|
||||
// Precache textures (and sprites).
|
||||
memset (hitlist, 0, TexMan.NumTextures());
|
||||
memset (spritelist, 0, sprites.Size());
|
||||
|
||||
{
|
||||
AActor *actor;
|
||||
TThinkerIterator<AActor> iterator;
|
||||
|
||||
while ( (actor = iterator.Next ()) )
|
||||
spritelist[actor->sprite] = 1;
|
||||
}
|
||||
|
||||
for (i = (int)(sprites.Size () - 1); i >= 0; i--)
|
||||
{
|
||||
if (spritelist[i])
|
||||
{
|
||||
int j, k;
|
||||
for (j = 0; j < sprites[i].numframes; j++)
|
||||
{
|
||||
const spriteframe_t *frame = &SpriteFrames[sprites[i].spriteframes + j];
|
||||
|
||||
for (k = 0; k < 16; k++)
|
||||
{
|
||||
FTextureID pic = frame->Texture[k];
|
||||
if (pic.isValid())
|
||||
{
|
||||
hitlist[pic.GetIndex()] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete[] spritelist;
|
||||
|
||||
for (i = numsectors - 1; i >= 0; i--)
|
||||
{
|
||||
hitlist[sectors[i].GetTexture(sector_t::floor).GetIndex()] =
|
||||
hitlist[sectors[i].GetTexture(sector_t::ceiling).GetIndex()] |= 2;
|
||||
}
|
||||
|
||||
for (i = numsides - 1; i >= 0; i--)
|
||||
{
|
||||
hitlist[sides[i].GetTexture(side_t::top).GetIndex()] =
|
||||
hitlist[sides[i].GetTexture(side_t::mid).GetIndex()] =
|
||||
hitlist[sides[i].GetTexture(side_t::bottom).GetIndex()] |= 1;
|
||||
}
|
||||
|
||||
// Sky texture is always present.
|
||||
// Note that F_SKY1 is the name used to
|
||||
// indicate a sky floor/ceiling as a flat,
|
||||
// while the sky texture is stored like
|
||||
// a wall texture, with an episode dependant
|
||||
// name.
|
||||
|
||||
if (sky1texture.isValid())
|
||||
{
|
||||
hitlist[sky1texture.GetIndex()] |= 1;
|
||||
}
|
||||
if (sky2texture.isValid())
|
||||
{
|
||||
hitlist[sky2texture.GetIndex()] |= 1;
|
||||
}
|
||||
|
||||
for (i = TexMan.NumTextures() - 1; i >= 0; i--)
|
||||
screen->GetHitlist(hitlist);
|
||||
for (int i = TexMan.NumTextures() - 1; i >= 0; i--)
|
||||
{
|
||||
screen->PrecacheTexture(TexMan.ByIndex(i), hitlist[i]);
|
||||
}
|
||||
|
@ -502,6 +437,8 @@ void R_PrecacheLevel (void)
|
|||
delete[] hitlist;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_GetColumn
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "m_png.h"
|
||||
#include "colormatcher.h"
|
||||
#include "v_palette.h"
|
||||
#include "r_sky.h"
|
||||
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS (DCanvas)
|
||||
|
@ -1196,6 +1197,83 @@ void DFrameBuffer::WipeCleanup()
|
|||
wipe_Cleanup();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Create texture hitlist
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void DFrameBuffer::GetHitlist(BYTE *hitlist)
|
||||
{
|
||||
BYTE *spritelist;
|
||||
int i;
|
||||
|
||||
spritelist = new BYTE[sprites.Size()];
|
||||
|
||||
// Precache textures (and sprites).
|
||||
memset (spritelist, 0, sprites.Size());
|
||||
|
||||
{
|
||||
AActor *actor;
|
||||
TThinkerIterator<AActor> iterator;
|
||||
|
||||
while ( (actor = iterator.Next ()) )
|
||||
spritelist[actor->sprite] = 1;
|
||||
}
|
||||
|
||||
for (i = (int)(sprites.Size () - 1); i >= 0; i--)
|
||||
{
|
||||
if (spritelist[i])
|
||||
{
|
||||
int j, k;
|
||||
for (j = 0; j < sprites[i].numframes; j++)
|
||||
{
|
||||
const spriteframe_t *frame = &SpriteFrames[sprites[i].spriteframes + j];
|
||||
|
||||
for (k = 0; k < 16; k++)
|
||||
{
|
||||
FTextureID pic = frame->Texture[k];
|
||||
if (pic.isValid())
|
||||
{
|
||||
hitlist[pic.GetIndex()] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete[] spritelist;
|
||||
|
||||
for (i = numsectors - 1; i >= 0; i--)
|
||||
{
|
||||
hitlist[sectors[i].GetTexture(sector_t::floor).GetIndex()] =
|
||||
hitlist[sectors[i].GetTexture(sector_t::ceiling).GetIndex()] |= 2;
|
||||
}
|
||||
|
||||
for (i = numsides - 1; i >= 0; i--)
|
||||
{
|
||||
hitlist[sides[i].GetTexture(side_t::top).GetIndex()] =
|
||||
hitlist[sides[i].GetTexture(side_t::mid).GetIndex()] =
|
||||
hitlist[sides[i].GetTexture(side_t::bottom).GetIndex()] |= 1;
|
||||
}
|
||||
|
||||
// Sky texture is always present.
|
||||
// Note that F_SKY1 is the name used to
|
||||
// indicate a sky floor/ceiling as a flat,
|
||||
// while the sky texture is stored like
|
||||
// a wall texture, with an episode dependant
|
||||
// name.
|
||||
|
||||
if (sky1texture.isValid())
|
||||
{
|
||||
hitlist[sky1texture.GetIndex()] |= 1;
|
||||
}
|
||||
if (sky2texture.isValid())
|
||||
{
|
||||
hitlist[sky2texture.GetIndex()] |= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Texture precaching
|
||||
|
|
|
@ -398,6 +398,7 @@ public:
|
|||
virtual FNativePalette *CreatePalette(FRemapTable *remap);
|
||||
|
||||
// Precaches or unloads a texture
|
||||
virtual void GetHitlist(BYTE *hitlist);
|
||||
virtual void PrecacheTexture(FTexture *tex, int cache);
|
||||
|
||||
// Screen wiping
|
||||
|
|
Loading…
Reference in a new issue