Skip to content

Commit

Permalink
- reimplemented the GetRawTexture redirect.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Dec 15, 2018
1 parent 1aba331 commit dc9c7af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/textures/formats/multipatchtexture.h
@@ -1,4 +1,5 @@
#pragma once
#include "sc_man.h"

//==========================================================================
//
Expand Down Expand Up @@ -28,6 +29,7 @@ struct TexPart

class FMultiPatchTexture : public FImageSource
{
friend class FTexture;
public:
FMultiPatchTexture(int w, int h, const TArray<TexPart> &parts, bool complex, bool textual);

Expand Down
16 changes: 15 additions & 1 deletion src/textures/texture.cpp
Expand Up @@ -50,6 +50,7 @@
#include "swrenderer/textures/r_swtexture.h"
#include "imagehelpers.h"
#include "image.h"
#include "formats/multipatchtexture.h"

FTexture *CreateBrightmapTexture(FImageSource*);

Expand Down Expand Up @@ -221,7 +222,20 @@ FBitmap FTexture::GetBgraBitmap(PalEntry *remap, int *ptrans)

FTexture *FTexture::GetRawTexture()
{
return this;
if (OffsetLess) return OffsetLess;
// Reject anything that cannot have been a single-patch multipatch texture in vanilla.
auto image = static_cast<FMultiPatchTexture *>(GetImage());
if (bMultiPatch != 1 || UseType != ETextureType::Wall || Scale.X != 1 || Scale.Y != 1 || bWorldPanning || image == nullptr || image->NumParts != 1)
{
OffsetLess = this;
return this;
}
// Set up a new texture that directly references the underlying patch.
// From here we cannot retrieve the original texture made for it, so just create a new one.
FImageSource *source = image->Parts[0].Image;
OffsetLess = new FImageTexture(source, "");
TexMan.AddTexture(OffsetLess);
return OffsetLess;
}

void FTexture::SetScaledSize(int fitwidth, int fitheight)
Expand Down
5 changes: 3 additions & 2 deletions src/textures/textures.h
Expand Up @@ -338,7 +338,7 @@ class FTexture
int GetSkyOffset() const { return SkyOffset; }
FTextureID GetID() const { return id; }
PalEntry GetSkyCapColor(bool bottom);
virtual FTexture *GetRawTexture(); // for FMultiPatchTexture to override
FTexture *GetRawTexture();
virtual int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method.
void GetGlowColor(float *data);
bool isGlowing() const { return bGlowing; }
Expand Down Expand Up @@ -371,11 +371,12 @@ class FTexture
public:
FHardwareTextureContainer SystemTextures;
protected:
//IHardwareTexture *SystemTexture[2] = { nullptr, nullptr };
FSoftwareTexture *SoftwareTexture = nullptr;

// None of the following pointers are owned by this texture, they are all controlled by the texture manager.

// Offset-less version for COMPATF_MASKEDMIDTEX
FTexture *OffsetLess = nullptr;
// Paletted variant
FTexture *PalVersion = nullptr;
// External hires texture
Expand Down

0 comments on commit dc9c7af

Please sign in to comment.