mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
- merged FWarpTexture and FWarp2Texture, making the choice of effect a parameter of the WarpBuffer function.
Ideally the warping shouldn't be a property of the texture class itself but an effect processor that can get added to a texture. Unfortunately the current setup will not allow this, requiring some significant refactoring of texture access first.
This commit is contained in:
parent
a95c6b9644
commit
c3759646e7
4 changed files with 57 additions and 93 deletions
|
@ -219,7 +219,7 @@ void FTextureManager::InitAnimated (void)
|
|||
// SMMU-style swirly hack? Don't apply on already-warping texture
|
||||
if (animspeed > 65535 && tex1 != NULL && !tex1->bWarped)
|
||||
{
|
||||
FTexture *warper = new FWarp2Texture (tex1);
|
||||
FTexture *warper = new FWarpTexture (tex1, 2);
|
||||
ReplaceTexture (pic1, warper, false);
|
||||
}
|
||||
// These tests were not really relevant for swirling textures, or even potentially
|
||||
|
@ -617,9 +617,7 @@ void FTextureManager::ParseWarp(FScanner &sc)
|
|||
// don't warp a texture more than once
|
||||
if (!warper->bWarped)
|
||||
{
|
||||
if (type2) warper = new FWarp2Texture (warper);
|
||||
else warper = new FWarpTexture (warper);
|
||||
|
||||
warper = new FWarpTexture (warper, type2? 2:1);
|
||||
ReplaceTexture (picnum, warper, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -469,7 +469,7 @@ public:
|
|||
class FWarpTexture : public FTexture
|
||||
{
|
||||
public:
|
||||
FWarpTexture (FTexture *source);
|
||||
FWarpTexture (FTexture *source, int warptype);
|
||||
~FWarpTexture ();
|
||||
|
||||
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL);
|
||||
|
@ -496,16 +496,6 @@ protected:
|
|||
void SetupMultipliers (int width, int height); // [mxd]
|
||||
};
|
||||
|
||||
// [GRB] Eternity-like warping
|
||||
class FWarp2Texture : public FWarpTexture
|
||||
{
|
||||
public:
|
||||
FWarp2Texture (FTexture *source);
|
||||
|
||||
protected:
|
||||
void MakeTexture (DWORD time);
|
||||
};
|
||||
|
||||
// A texture that can be drawn to.
|
||||
class DSimpleCanvas;
|
||||
class AActor;
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
|
||||
template<class TYPE>
|
||||
void WarpBufferType1(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, unsigned time, float Speed)
|
||||
void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, unsigned time, float Speed, int warptype)
|
||||
{
|
||||
TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * MAX(width, height));
|
||||
int ymask = height - 1;
|
||||
int x, y;
|
||||
|
||||
if (warptype == 1)
|
||||
{
|
||||
TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * MAX(width, height));
|
||||
// [mxd] Rewrote to fix animation for NPo2 textures
|
||||
unsigned timebase = unsigned(time * Speed * 32 / 28);
|
||||
for (y = height - 1; y >= 0; y--)
|
||||
|
@ -30,15 +32,9 @@ void WarpBufferType1(TYPE *Pixels, const TYPE *source, int width, int height, in
|
|||
*dest++ = sourcep[yf];
|
||||
memcpy(Pixels + (x + ymask*x), buffer, height * sizeof(TYPE));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class TYPE>
|
||||
void WarpBufferType2(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, unsigned time, float Speed)
|
||||
{
|
||||
int ymask = height - 1;
|
||||
int x, y;
|
||||
|
||||
}
|
||||
else if (warptype == 2)
|
||||
{
|
||||
unsigned timebase = unsigned(time * Speed * 40 / 28);
|
||||
// [mxd] Rewrote to fix animation for NPo2 textures
|
||||
for (x = 0; x < width; x++)
|
||||
|
@ -57,5 +53,11 @@ void WarpBufferType2(TYPE *Pixels, const TYPE *source, int width, int height, in
|
|||
*dest++ = source[(xt + ymask * xt) + yt];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// should never happen, just in case...
|
||||
memcpy(Pixels, source, width*height * sizeof(TYPE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,12 +41,12 @@
|
|||
#include "warpbuffer.h"
|
||||
|
||||
|
||||
FWarpTexture::FWarpTexture (FTexture *source)
|
||||
FWarpTexture::FWarpTexture (FTexture *source, int warptype)
|
||||
: GenTime (0), SourcePic (source), Pixels (0), Spans (0), Speed (1.f)
|
||||
{
|
||||
CopyInfo(source);
|
||||
SetupMultipliers(128, 128); // [mxd]
|
||||
bWarped = 1;
|
||||
bWarped = warptype;
|
||||
}
|
||||
|
||||
FWarpTexture::~FWarpTexture ()
|
||||
|
@ -137,7 +137,7 @@ void FWarpTexture::MakeTexture(DWORD time)
|
|||
}
|
||||
|
||||
GenTime = time;
|
||||
WarpBufferType1(Pixels, otherpix, Width, Height, WidthOffsetMultiplier, HeightOffsetMultiplier, time, Speed);
|
||||
WarpBuffer(Pixels, otherpix, Width, Height, WidthOffsetMultiplier, HeightOffsetMultiplier, time, Speed, bWarped);
|
||||
}
|
||||
|
||||
// [mxd] Non power of 2 textures need different offset multipliers, otherwise warp animation won't sync across texture
|
||||
|
@ -162,32 +162,6 @@ int FWarpTexture::NextPo2 (int v)
|
|||
return ++v;
|
||||
}
|
||||
|
||||
// [GRB] Eternity-like warping
|
||||
FWarp2Texture::FWarp2Texture (FTexture *source)
|
||||
: FWarpTexture (source)
|
||||
{
|
||||
SetupMultipliers(256, 128); // [mxd]
|
||||
bWarped = 2;
|
||||
}
|
||||
|
||||
void FWarp2Texture::MakeTexture (DWORD time)
|
||||
{
|
||||
const BYTE *otherpix = SourcePic->GetPixels ();
|
||||
|
||||
if (Pixels == NULL)
|
||||
{
|
||||
Pixels = new BYTE[Width * Height];
|
||||
}
|
||||
if (Spans != NULL)
|
||||
{
|
||||
FreeSpans (Spans);
|
||||
Spans = NULL;
|
||||
}
|
||||
|
||||
GenTime = time;
|
||||
WarpBufferType2(Pixels, otherpix, Width, Height, WidthOffsetMultiplier, HeightOffsetMultiplier, time, Speed);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FMultiPatchTexture :: TexPart :: TexPart
|
||||
|
|
Loading…
Reference in a new issue