- fixed order of multipatch texture initialization.

This didn't play well with hires replacements - the texture size needs to be set as early as possible.
This commit is contained in:
Christoph Oelckers 2020-05-04 21:24:36 +02:00
parent 3fd4d08004
commit 192ea40634
3 changed files with 13 additions and 8 deletions

View file

@ -240,6 +240,10 @@ public:
if (int(ScaleY * h) != TexelHeight) ScaleY += (1 / 65536.);
}
void SetBase(FTexture* Tex)
{
Base = Tex;
}
void SetOffsets(int which, int x, int y)
{
LeftOffset[which] = x;

View file

@ -138,19 +138,18 @@ void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType u
{
buildinfo.texture = new FGameTexture(nullptr, buildinfo.Name);
buildinfo.texture->SetUseType(usetype);
buildinfo.texture->SetSize(buildinfo.Width, buildinfo.Height);
buildinfo.texture->SetOffsets(0, buildinfo.LeftOffset[0], buildinfo.TopOffset[0]); // These are needed for construction of other multipatch textures.
buildinfo.texture->SetOffsets(1, buildinfo.LeftOffset[1], buildinfo.TopOffset[1]);
buildinfo.texture->SetScale((float)buildinfo.Scale.X, (float)buildinfo.Scale.X);
buildinfo.texture->SetWorldPanning(buildinfo.bWorldPanning);
buildinfo.texture->SetNoDecals(buildinfo.bNoDecals);
TexMan.AddGameTexture(buildinfo.texture);
}
void FMultipatchTextureBuilder::AddImageToTexture(FImageTexture *tex, BuildInfo& buildinfo)
{
buildinfo.texture->Setup(tex);
buildinfo.texture->SetOffsets(0, buildinfo.LeftOffset[0], buildinfo.TopOffset[0]);
buildinfo.texture->SetOffsets(1, buildinfo.LeftOffset[1], buildinfo.TopOffset[1]);
buildinfo.texture->SetScale((float)buildinfo.Scale.X, (float)buildinfo.Scale.X);
buildinfo.texture->SetWorldPanning(buildinfo.bWorldPanning);
buildinfo.texture->SetNoDecals(buildinfo.bNoDecals);
buildinfo.texture->SetBase(tex);
calcShouldUpscale(buildinfo.texture); // calculate this once at insertion
}
@ -874,6 +873,7 @@ void FMultipatchTextureBuilder::ResolveAllPatches()
for (int i = BuiltTextures.Size()-1; i>= 0; i--)
{
auto &buildinfo = BuiltTextures[i];
bool hasEmpty = false;
for (unsigned j = 0; j < buildinfo.Inits.Size(); j++)

View file

@ -625,8 +625,9 @@ void FTextureManager::AddHiresTextures (int wadnum)
auto gtex = MakeGameTexture(newtex, nullptr, ETextureType::Override);
gtex->SetWorldPanning(true);
gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight());
gtex->SetOffsets(0, oldtex->GetTexelLeftOffset(0), oldtex->GetTexelTopOffset(0));
gtex->SetOffsets(1, oldtex->GetTexelLeftOffset(1), oldtex->GetTexelTopOffset(1));
gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetDisplayLeftOffset(0) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetDisplayTopOffset(0) * gtex->GetScaleY()));
gtex->SetOffsets(1, xs_RoundToInt(oldtex->GetDisplayLeftOffset(1) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetDisplayTopOffset(1) * gtex->GetScaleY()));
ReplaceTexture(tlist[i], gtex, true);
}
}