mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +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
|
// SMMU-style swirly hack? Don't apply on already-warping texture
|
||||||
if (animspeed > 65535 && tex1 != NULL && !tex1->bWarped)
|
if (animspeed > 65535 && tex1 != NULL && !tex1->bWarped)
|
||||||
{
|
{
|
||||||
FTexture *warper = new FWarp2Texture (tex1);
|
FTexture *warper = new FWarpTexture (tex1, 2);
|
||||||
ReplaceTexture (pic1, warper, false);
|
ReplaceTexture (pic1, warper, false);
|
||||||
}
|
}
|
||||||
// These tests were not really relevant for swirling textures, or even potentially
|
// 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
|
// don't warp a texture more than once
|
||||||
if (!warper->bWarped)
|
if (!warper->bWarped)
|
||||||
{
|
{
|
||||||
if (type2) warper = new FWarp2Texture (warper);
|
warper = new FWarpTexture (warper, type2? 2:1);
|
||||||
else warper = new FWarpTexture (warper);
|
|
||||||
|
|
||||||
ReplaceTexture (picnum, warper, false);
|
ReplaceTexture (picnum, warper, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,7 @@ public:
|
||||||
class FWarpTexture : public FTexture
|
class FWarpTexture : public FTexture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FWarpTexture (FTexture *source);
|
FWarpTexture (FTexture *source, int warptype);
|
||||||
~FWarpTexture ();
|
~FWarpTexture ();
|
||||||
|
|
||||||
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL);
|
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]
|
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.
|
// A texture that can be drawn to.
|
||||||
class DSimpleCanvas;
|
class DSimpleCanvas;
|
||||||
class AActor;
|
class AActor;
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
|
|
||||||
template<class TYPE>
|
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 ymask = height - 1;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
|
if (warptype == 1)
|
||||||
|
{
|
||||||
|
TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * MAX(width, height));
|
||||||
// [mxd] Rewrote to fix animation for NPo2 textures
|
// [mxd] Rewrote to fix animation for NPo2 textures
|
||||||
unsigned timebase = unsigned(time * Speed * 32 / 28);
|
unsigned timebase = unsigned(time * Speed * 32 / 28);
|
||||||
for (y = height - 1; y >= 0; y--)
|
for (y = height - 1; y >= 0; y--)
|
||||||
|
@ -31,14 +33,8 @@ void WarpBufferType1(TYPE *Pixels, const TYPE *source, int width, int height, in
|
||||||
memcpy(Pixels + (x + ymask*x), buffer, height * sizeof(TYPE));
|
memcpy(Pixels + (x + ymask*x), buffer, height * sizeof(TYPE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (warptype == 2)
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
unsigned timebase = unsigned(time * Speed * 40 / 28);
|
unsigned timebase = unsigned(time * Speed * 40 / 28);
|
||||||
// [mxd] Rewrote to fix animation for NPo2 textures
|
// [mxd] Rewrote to fix animation for NPo2 textures
|
||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
|
@ -58,4 +54,10 @@ void WarpBufferType2(TYPE *Pixels, const TYPE *source, int width, int height, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// should never happen, just in case...
|
||||||
|
memcpy(Pixels, source, width*height * sizeof(TYPE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,12 @@
|
||||||
#include "warpbuffer.h"
|
#include "warpbuffer.h"
|
||||||
|
|
||||||
|
|
||||||
FWarpTexture::FWarpTexture (FTexture *source)
|
FWarpTexture::FWarpTexture (FTexture *source, int warptype)
|
||||||
: GenTime (0), SourcePic (source), Pixels (0), Spans (0), Speed (1.f)
|
: GenTime (0), SourcePic (source), Pixels (0), Spans (0), Speed (1.f)
|
||||||
{
|
{
|
||||||
CopyInfo(source);
|
CopyInfo(source);
|
||||||
SetupMultipliers(128, 128); // [mxd]
|
SetupMultipliers(128, 128); // [mxd]
|
||||||
bWarped = 1;
|
bWarped = warptype;
|
||||||
}
|
}
|
||||||
|
|
||||||
FWarpTexture::~FWarpTexture ()
|
FWarpTexture::~FWarpTexture ()
|
||||||
|
@ -137,7 +137,7 @@ void FWarpTexture::MakeTexture(DWORD time)
|
||||||
}
|
}
|
||||||
|
|
||||||
GenTime = 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
|
// [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;
|
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
|
// FMultiPatchTexture :: TexPart :: TexPart
|
||||||
|
|
Loading…
Reference in a new issue