- reworking some lower level texture code.
This commit is contained in:
parent
72835c5462
commit
9099bc8420
21 changed files with 76 additions and 61 deletions
|
|
@ -1081,16 +1081,17 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTe
|
|||
}
|
||||
FTextureID chk = value;
|
||||
if (chk.GetIndex() >= TexMan.NumTextures()) chk.SetNull();
|
||||
FTexture *pic = TexMan.GetTexture(chk);
|
||||
auto pic = TexMan.GetGameTexture(chk);
|
||||
const char *name;
|
||||
auto lump = pic->GetSourceLump();
|
||||
|
||||
if (fileSystem.GetLinkedTexture(pic->SourceLump) == pic)
|
||||
if (fileSystem.GetLinkedTexture(lump) == pic)
|
||||
{
|
||||
name = fileSystem.GetFileFullName(pic->SourceLump);
|
||||
name = fileSystem.GetFileFullName(lump);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = pic->Name;
|
||||
name = pic->GetName();
|
||||
}
|
||||
arc.WriteKey(key);
|
||||
arc.w->StartArray();
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ extern FILE* hashfile;
|
|||
struct FileSystem::LumpRecord
|
||||
{
|
||||
FResourceLump *lump;
|
||||
FTexture* linkedTexture;
|
||||
FGameTexture* linkedTexture;
|
||||
LumpShortName shortName;
|
||||
FString longName;
|
||||
int rfnum;
|
||||
|
|
@ -725,7 +725,7 @@ int FileSystem::GetResource (int resid, const char *type, int filenum) const
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FileSystem::SetLinkedTexture(int lump, FTexture *tex)
|
||||
void FileSystem::SetLinkedTexture(int lump, FGameTexture *tex)
|
||||
{
|
||||
if ((size_t)lump < NumEntries)
|
||||
{
|
||||
|
|
@ -739,7 +739,7 @@ void FileSystem::SetLinkedTexture(int lump, FTexture *tex)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *FileSystem::GetLinkedTexture(int lump)
|
||||
FGameTexture *FileSystem::GetLinkedTexture(int lump)
|
||||
{
|
||||
if ((size_t)lump < NumEntries)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
class FResourceFile;
|
||||
struct FResourceLump;
|
||||
class FTexture;
|
||||
class FGameTexture;
|
||||
|
||||
union LumpShortName
|
||||
{
|
||||
|
|
@ -124,8 +124,8 @@ public:
|
|||
inline int CheckNumForFullName (const FString &name, int wadfile) { return CheckNumForFullName(name.GetChars(), wadfile); }
|
||||
inline int GetNumForFullName (const FString &name) { return GetNumForFullName(name.GetChars()); }
|
||||
|
||||
void SetLinkedTexture(int lump, FTexture *tex);
|
||||
FTexture *GetLinkedTexture(int lump);
|
||||
void SetLinkedTexture(int lump, FGameTexture *tex);
|
||||
FGameTexture *GetLinkedTexture(int lump);
|
||||
|
||||
|
||||
void ReadFile (int lump, void *dest);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ struct LumpFilterInfo
|
|||
};
|
||||
|
||||
class FResourceFile;
|
||||
class FTexture;
|
||||
|
||||
// [RH] Namespaces from BOOM.
|
||||
// These are needed here in the low level part so that WAD files can be properly set up.
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include "name.h"
|
||||
|
||||
class DCanvas;
|
||||
class FTexture;
|
||||
class FGameTexture;
|
||||
struct FRemapTable;
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static void CastCo2S(FString *a, int b) { PalEntry c(b); a->Format("%02x %02x %0
|
|||
static int CastS2So(FString *b) { return FSoundID(*b); }
|
||||
static void CastSo2S(FString* a, int b) { *a = soundEngine->GetSoundName(b); }
|
||||
static void CastSID2S(FString* a, unsigned int b) { VM_CastSpriteIDToString(a, b); }
|
||||
static void CastTID2S(FString *a, int b) { auto tex = TexMan.GetTexture(*(FTextureID*)&b); *a = (tex == nullptr) ? "(null)" : tex->GetName().GetChars(); }
|
||||
static void CastTID2S(FString *a, int b) { auto tex = TexMan.GetGameTexture(*(FTextureID*)&b); *a = (tex == nullptr) ? "(null)" : tex->GetName().GetChars(); }
|
||||
|
||||
void JitCompiler::EmitCAST()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1848,7 +1848,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
|||
case CAST_TID2S:
|
||||
{
|
||||
ASSERTS(a); ASSERTD(b);
|
||||
auto tex = TexMan.GetTexture(*(FTextureID*)&(reg.d[b]));
|
||||
auto tex = TexMan.GetGameTexture(*(FTextureID*)&(reg.d[b]));
|
||||
reg.s[a] = tex == nullptr ? "(null)" : tex->GetName().GetChars();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ void FMultipatchTextureBuilder::AddTexturesLump(const void *lumpdata, int lumpsi
|
|||
// It still needs to be created in case someone uses it by name.
|
||||
offset = LittleLong(directory[1]);
|
||||
const maptexture_t *tex = (const maptexture_t *)((const uint8_t *)maptex + offset);
|
||||
FTexture *tex0 = TexMan.ByIndex(0);
|
||||
auto tex0 = TexMan.GameByIndex(0);
|
||||
tex0->SetSize(SAFESHORT(tex->width), SAFESHORT(tex->height));
|
||||
}
|
||||
|
||||
|
|
@ -373,7 +373,7 @@ void FMultipatchTextureBuilder::AddTexturesLump(const void *lumpdata, int lumpsi
|
|||
int j;
|
||||
for (j = (int)TexMan.NumTextures() - 1; j >= firstdup; --j)
|
||||
{
|
||||
if (strnicmp(TexMan.ByIndex(j)->GetName(), (const char *)maptex + offset, 8) == 0)
|
||||
if (strnicmp(TexMan.GameByIndex(j)->GetName(), (const char *)maptex + offset, 8) == 0)
|
||||
break;
|
||||
}
|
||||
if (j + 1 == firstdup)
|
||||
|
|
@ -780,7 +780,7 @@ void FMultipatchTextureBuilder::ResolvePatches(BuildInfo &buildinfo)
|
|||
TexMan.ListTextures(buildinfo.Inits[i].TexName, list, true);
|
||||
for (int i = list.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (list[i] != buildinfo.tex->id && !TexMan.GetTexture(list[i])->bMultiPatch)
|
||||
if (list[i] != buildinfo.tex->id && !TexMan.GetGameTexture(list[i])->isMultiPatch() )
|
||||
{
|
||||
texno = list[i];
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -148,8 +148,8 @@ FTexture::FTexture (const char *name, int lumpnum)
|
|||
|
||||
FTexture::~FTexture ()
|
||||
{
|
||||
FTexture *link = fileSystem.GetLinkedTexture(SourceLump);
|
||||
if (link == this) fileSystem.SetLinkedTexture(SourceLump, nullptr);
|
||||
FGameTexture *link = fileSystem.GetLinkedTexture(SourceLump);
|
||||
if (link->GetTexture() == this) fileSystem.SetLinkedTexture(SourceLump, nullptr);
|
||||
if (areas != nullptr) delete[] areas;
|
||||
areas = nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -220,20 +220,20 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset
|
|||
// Any graphic being placed in the zip's root directory can not be found by this.
|
||||
if (strchr(name, '/'))
|
||||
{
|
||||
FTexture *const NO_TEXTURE = (FTexture*)-1;
|
||||
FGameTexture *const NO_TEXTURE = (FGameTexture*)-1;
|
||||
int lump = fileSystem.CheckNumForFullName(name);
|
||||
if (lump >= 0)
|
||||
{
|
||||
FTexture *tex = fileSystem.GetLinkedTexture(lump);
|
||||
FGameTexture *tex = fileSystem.GetLinkedTexture(lump);
|
||||
if (tex == NO_TEXTURE) return FTextureID(-1);
|
||||
if (tex != NULL) return tex->id;
|
||||
if (tex != NULL) return tex->GetID();
|
||||
if (flags & TEXMAN_DontCreate) return FTextureID(-1); // we only want to check, there's no need to create a texture if we don't have one yet.
|
||||
tex = FTexture::CreateTexture("", lump, ETextureType::Override);
|
||||
tex = reinterpret_cast<FGameTexture*>(FTexture::CreateTexture("", lump, ETextureType::Override));
|
||||
if (tex != NULL)
|
||||
{
|
||||
tex->AddAutoMaterials();
|
||||
fileSystem.SetLinkedTexture(lump, tex);
|
||||
return AddTexture(tex);
|
||||
return AddTexture(tex->GetTexture());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -618,11 +618,13 @@ public:
|
|||
bool isHardwareCanvas() const { return wrapped.isHardwareCanvas(); } // There's two here so that this can deal with software canvases in the hardware renderer later.
|
||||
bool isSoftwareCanvas() const { return wrapped.isCanvas(); }
|
||||
bool isMiscPatch() const { return wrapped.GetUseType() == ETextureType::MiscPatch; } // only used by the intermission screen to decide whether to tile the background image or not.
|
||||
bool isMultiPatch() const { return wrapped.bMultiPatch; }
|
||||
bool isFullbrightDisabled() const { return wrapped.isFullbrightDisabled(); }
|
||||
bool useWorldPanning() const { return wrapped.UseWorldPanning(); }
|
||||
bool allowNoDecals() const { return wrapped.allowNoDecals(); }
|
||||
void SetTranslucent(bool on) { wrapped.bTranslucent = on; }
|
||||
ETextureType GetUseType() const { return wrapped.GetUseType(); }
|
||||
void SetUseType(ETextureType type) { wrapped.SetUseType(type); }
|
||||
float GetShaderSpeed() const { return wrapped.GetShaderSpeed(); }
|
||||
uint16_t GetRotations() const { return wrapped.GetRotations(); }
|
||||
void SetRotations(int index) { wrapped.SetRotations(index); }
|
||||
|
|
@ -651,6 +653,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void CopySize(FGameTexture* BaseTexture)
|
||||
{
|
||||
wrapped.CopySize(&BaseTexture->wrapped);
|
||||
}
|
||||
|
||||
// These substitutions must be done on the material level because their sizes can differ. Substitution must happen before any coordinate calculations take place.
|
||||
FGameTexture* GetPalVersion() { return reinterpret_cast<FGameTexture*>(wrapped.GetPalVersion()); }
|
||||
|
|
@ -669,6 +675,11 @@ public:
|
|||
void SetGlowing(PalEntry color) { auto tex = GetTexture(); tex->bAutoGlowing = false; tex->bGlowing = true; tex->GlowColor = color; }
|
||||
|
||||
bool isUserContent() const;
|
||||
void AddAutoMaterials() { wrapped.AddAutoMaterials(); }
|
||||
int CheckRealHeight() { return wrapped.CheckRealHeight(); }
|
||||
bool isSkybox() const { return wrapped.isSkybox(); }
|
||||
void SetSize(int x, int y) { wrapped.SetSize(x, y); }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue