Thanks, i'm looking into it but i haven't gone very far as expected. I created two functions for Warp1 and Warp2. Uggh, i tried master, i tried.

The original code in WarpBuffer does two passes "for (y = height - 1; y >= 0; y--)" and "for (x = width - 1; x >= 0; x--)" and here the texture is between x0 and x1 it seems.

I don't know how to go from one to the other.

It's very complicated stuff and i'm not that smart.

The original code is:

- Code: Select all • Expand view
`template<class TYPE> `

void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, uint64_t time, float Speed, int warptype)

{

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--)

{

int xf = (TexMan.sintable[((timebase + y*ymul) >> 2)&TexMan.SINMASK] >> 11) % width;

if (xf < 0) xf += width;

int xt = xf;

const TYPE *sourcep = source + y;

TYPE *dest = Pixels + y;

for (xt = width; xt; xt--, xf = (xf + 1) % width, dest += height)

*dest = sourcep[xf + ymask * xf];

}

timebase = unsigned(time * Speed * 23 / 28);

for (x = width - 1; x >= 0; x--)

{

int yf = (TexMan.sintable[((time + (x + 17)*xmul) >> 2)&TexMan.SINMASK] >> 11) % height;

if (yf < 0) yf += height;

int yt = yf;

const TYPE *sourcep = Pixels + (x + ymask * x);

TYPE *dest = buffer;

for (yt = height; yt; yt--, yf = (yf + 1) % height)

*dest++ = sourcep[yf];

memcpy(Pixels + (x + ymask*x), buffer, height * sizeof(TYPE));

}

}

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++)

{

TYPE *dest = Pixels + (x + ymask * x);

for (y = 0; y < height; y++)

{

int xt = (x + 128

+ ((TexMan.sintable[((y*ymul + timebase * 5 + 900) >> 2) & TexMan.SINMASK]) >> 13)

+ ((TexMan.sintable[((x*xmul + timebase * 4 + 300) >> 2) & TexMan.SINMASK]) >> 13)) % width;

int yt = (y + 128

+ ((TexMan.sintable[((y*ymul + timebase * 3 + 700) >> 2) & TexMan.SINMASK]) >> 13)

+ ((TexMan.sintable[((x*xmul + timebase * 4 + 1200) >> 2) & TexMan.SINMASK]) >> 13)) % height;

*dest++ = source[(xt + ymask * xt) + yt];

}

}

}

else

{

// should never happen, just in case...

memcpy(Pixels, source, width*height * sizeof(TYPE));

}

}