mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- replaced finesine for texture warping with a smaller custom table, based on the old 2005 FP code, but fixes the generation of the sine table.
- removed all remnants of finesine and deleted tables.c and tables.h.
This commit is contained in:
parent
9f0c5d5909
commit
ef98757c7c
21 changed files with 47 additions and 158 deletions
|
@ -1091,7 +1091,6 @@ set (PCH_SOURCES
|
|||
statistics.cpp
|
||||
stats.cpp
|
||||
stringtable.cpp
|
||||
tables.cpp
|
||||
teaminfo.cpp
|
||||
tempfiles.cpp
|
||||
v_blend.cpp
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define __P_MOBJ_H__
|
||||
|
||||
// Basics.
|
||||
#include "tables.h"
|
||||
#include "templates.h"
|
||||
|
||||
// We need the thinker_t stuff.
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define __B_BOT_H__
|
||||
|
||||
#include "c_cvars.h"
|
||||
#include "tables.h"
|
||||
#include "info.h"
|
||||
#include "doomdef.h"
|
||||
#include "d_ticcmd.h"
|
||||
|
|
|
@ -72,6 +72,14 @@ typedef DWORD dsfixed_t; // fixedpt used by span drawer
|
|||
#define DWORD_MIN ((uint32)0)
|
||||
#define DWORD_MAX ((uint32)0xffffffff)
|
||||
|
||||
// the last remnants of tables.h
|
||||
#define ANGLE_90 (0x40000000)
|
||||
#define ANGLE_180 (0x80000000)
|
||||
#define ANGLE_270 (0xc0000000)
|
||||
#define ANGLE_MAX (0xffffffff)
|
||||
|
||||
typedef uint32 angle_t;
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define GCCPRINTF(stri,firstargi) __attribute__((format(printf,stri,firstargi)))
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
*/
|
||||
|
||||
#include "vectors.h"
|
||||
#include "tables.h"
|
||||
|
||||
#define FX_ROCKET 0x00000001
|
||||
#define FX_GRENADE 0x00000002
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define __P_ENEMY_H__
|
||||
|
||||
#include "thingdef/thingdef.h"
|
||||
#include "tables.h"
|
||||
|
||||
struct sector_t;
|
||||
class AActor;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "s_sndseq.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_state.h"
|
||||
#include "tables.h"
|
||||
#include "farchive.h"
|
||||
#include "p_3dmidtex.h"
|
||||
#include "p_spec.h"
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "p_enemy.h"
|
||||
#include "g_level.h"
|
||||
#include "v_palette.h"
|
||||
#include "tables.h"
|
||||
#include "i_system.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "a_lightning.h"
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <float.h>
|
||||
#include "doomtype.h"
|
||||
#include "tables.h"
|
||||
#include "vectors.h"
|
||||
|
||||
const double NO_VALUE = FLT_MAX;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
// Basic data types.
|
||||
// Needs fixed point, and BAM angles.
|
||||
#include "tables.h"
|
||||
#include "thingdef/thingdef.h"
|
||||
|
||||
#define WEAPONBOTTOM 128.
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "p_local.h"
|
||||
#include "info.h"
|
||||
#include "s_sound.h"
|
||||
#include "tables.h"
|
||||
#include "doomstat.h"
|
||||
#include "m_random.h"
|
||||
#include "c_console.h"
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "sc_man.h"
|
||||
#include "m_fixed.h"
|
||||
#include "tables.h"
|
||||
|
||||
class UDMFParserBase
|
||||
{
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "w_wad.h"
|
||||
#include "m_swap.h"
|
||||
#include "m_bbox.h"
|
||||
#include "tables.h"
|
||||
#include "s_sndseq.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "p_3dmidtex.h"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define __R_LOCAL_H__
|
||||
|
||||
// Binary Angles, sine/cosine/atan lookups.
|
||||
#include "tables.h"
|
||||
|
||||
// Screen size related parameters.
|
||||
#include "doomdef.h"
|
||||
|
|
|
@ -175,7 +175,7 @@ static int lastcenteryfrac;
|
|||
|
||||
static inline int viewangletox(int i)
|
||||
{
|
||||
const double pimul = M_PI * 2 / FINEANGLES;
|
||||
const double pimul = M_PI / 4096;
|
||||
|
||||
// Don't waste time calculating the tangent of values outside the valid range.
|
||||
// Checking the index where tan(i) becomes too large is a lot faster
|
||||
|
@ -188,7 +188,7 @@ static inline int viewangletox(int i)
|
|||
return -1;
|
||||
}
|
||||
|
||||
double t = tan((i - FINEANGLES / 4)*pimul) * FocalLengthX;
|
||||
double t = tan((i - 2048)*pimul) * FocalLengthX;
|
||||
return clamp(xs_CeilToInt(CenterX - t), -1, viewwidth+1);
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ void R_InitTextureMapping ()
|
|||
{
|
||||
++i;
|
||||
}
|
||||
xtoviewangle[x] = (i << ANGLETOFINESHIFT) - ANGLE_90;
|
||||
xtoviewangle[x] = (i << 19) - ANGLE_90;
|
||||
}
|
||||
for (x = t2 + 1; x <= viewwidth; ++x)
|
||||
{
|
||||
|
|
|
@ -157,35 +157,6 @@ DAngle viewpitch;
|
|||
// CODE --------------------------------------------------------------------
|
||||
static void R_Shutdown ();
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_InitTables
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void R_InitTables (void)
|
||||
{
|
||||
int i;
|
||||
const double pimul = M_PI*2/FINEANGLES;
|
||||
|
||||
// finesine table
|
||||
for (i = 0; i < FINEANGLES/4; i++)
|
||||
{
|
||||
finesine[i] = (fixed_t)(FRACUNIT * g_sin (i*pimul));
|
||||
}
|
||||
for (i = 0; i < FINEANGLES/4; i++)
|
||||
{
|
||||
finesine[i+FINEANGLES/4] = finesine[FINEANGLES/4-1-i];
|
||||
}
|
||||
for (i = 0; i < FINEANGLES/2; i++)
|
||||
{
|
||||
finesine[i+FINEANGLES/2] = -finesine[i];
|
||||
}
|
||||
finesine[FINEANGLES/4] = FRACUNIT;
|
||||
finesine[FINEANGLES*3/4] = -FRACUNIT;
|
||||
memcpy (&finesine[FINEANGLES], &finesine[0], sizeof(angle_t)*FINEANGLES/4);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_SetFOV
|
||||
|
@ -364,7 +335,6 @@ void R_Init ()
|
|||
//R_InitColormaps ();
|
||||
//StartScreen->Progress();
|
||||
|
||||
R_InitTables ();
|
||||
R_InitTranslationTables ();
|
||||
R_SetViewSize (screenblocks);
|
||||
Renderer->Init();
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Id:$
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
//
|
||||
// This source is available for distribution and/or modification
|
||||
// only under the terms of the DOOM Source Code License as
|
||||
// published by id Software. All rights reserved.
|
||||
//
|
||||
// The source is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||
// for more details.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Lookup tables.
|
||||
// Do not try to look them up :-).
|
||||
// In the order of appearance:
|
||||
//
|
||||
// int finesine[10240] - Sine lookup.
|
||||
// Guess what, serves as cosine, too.
|
||||
// Remarkable thing is, how to use BAMs with this?
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "tables.h"
|
||||
|
||||
fixed_t finesine[10240];
|
||||
|
54
src/tables.h
54
src/tables.h
|
@ -1,54 +0,0 @@
|
|||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Id:$
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
//
|
||||
// This source is available for distribution and/or modification
|
||||
// only under the terms of the DOOM Source Code License as
|
||||
// published by id Software. All rights reserved.
|
||||
//
|
||||
// The source is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||
// for more details.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Lookup tables.
|
||||
// Do not try to look them up :-).
|
||||
// In the order of appearance:
|
||||
//
|
||||
// int finesine[10240] - Sine lookup.
|
||||
// Remarkable thing is, how to use BAMs with this?
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __TABLES_H__
|
||||
#define __TABLES_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "basictypes.h"
|
||||
|
||||
#define FINEANGLES 8192
|
||||
#define FINEMASK (FINEANGLES-1)
|
||||
|
||||
// 0x100000000 to 0x2000
|
||||
#define ANGLETOFINESHIFT 19
|
||||
|
||||
// Effective size is 10240.
|
||||
extern fixed_t finesine[5*FINEANGLES/4];
|
||||
|
||||
// Binary Angle Measument, BAM.
|
||||
#define ANGLE_90 (0x40000000)
|
||||
#define ANGLE_180 (0x80000000)
|
||||
#define ANGLE_270 (0xc0000000)
|
||||
#define ANGLE_MAX (0xffffffff)
|
||||
|
||||
|
||||
typedef uint32 angle_t;
|
||||
|
||||
#endif // __TABLES_H__
|
|
@ -72,6 +72,10 @@ FTextureManager::FTextureManager ()
|
|||
{
|
||||
memset (HashFirst, -1, sizeof(HashFirst));
|
||||
|
||||
for (int i = 0; i < 2048; ++i)
|
||||
{
|
||||
sintable[i] = short(sin(i*(M_PI / 1024)) * 16384);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -446,6 +446,12 @@ private:
|
|||
TArray<FSwitchDef *> mSwitchDefs;
|
||||
TArray<FDoorAnimation> mAnimatedDoors;
|
||||
TArray<BYTE *> BuildTileFiles;
|
||||
public:
|
||||
short sintable[2048]; // for texture warping
|
||||
enum
|
||||
{
|
||||
SINMASK = 2047
|
||||
};
|
||||
};
|
||||
|
||||
// A texture that doesn't really exist
|
||||
|
@ -483,7 +489,7 @@ protected:
|
|||
BYTE *Pixels;
|
||||
Span **Spans;
|
||||
float Speed;
|
||||
int WidthOffsetMultipiler, HeightOffsetMultipiler; // [mxd]
|
||||
int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd]
|
||||
|
||||
virtual void MakeTexture (DWORD time);
|
||||
int NextPo2 (int v); // [mxd]
|
||||
|
|
|
@ -120,9 +120,9 @@ const BYTE *FWarpTexture::GetColumn (unsigned int column, const Span **spans_out
|
|||
return Pixels + column*Height;
|
||||
}
|
||||
|
||||
void FWarpTexture::MakeTexture (DWORD time)
|
||||
void FWarpTexture::MakeTexture(DWORD time)
|
||||
{
|
||||
const BYTE *otherpix = SourcePic->GetPixels ();
|
||||
const BYTE *otherpix = SourcePic->GetPixels();
|
||||
|
||||
if (Pixels == NULL)
|
||||
{
|
||||
|
@ -130,17 +130,17 @@ void FWarpTexture::MakeTexture (DWORD time)
|
|||
}
|
||||
if (Spans != NULL)
|
||||
{
|
||||
FreeSpans (Spans);
|
||||
FreeSpans(Spans);
|
||||
Spans = NULL;
|
||||
}
|
||||
|
||||
GenTime = time;
|
||||
|
||||
BYTE *buffer = (BYTE *)alloca (MAX (Width, Height));
|
||||
BYTE *buffer = (BYTE *)alloca(MAX(Width, Height));
|
||||
int xsize = Width;
|
||||
int ysize = Height;
|
||||
int xmul = WidthOffsetMultipiler; // [mxd]
|
||||
int ymul = HeightOffsetMultipiler; // [mxd]
|
||||
int xmul = WidthOffsetMultiplier; // [mxd]
|
||||
int ymul = HeightOffsetMultiplier; // [mxd]
|
||||
int xmask = WidthMask;
|
||||
int ymask = Height - 1;
|
||||
int ybits = HeightBits;
|
||||
|
@ -153,39 +153,39 @@ void FWarpTexture::MakeTexture (DWORD time)
|
|||
|
||||
DWORD timebase = DWORD(time * Speed * 32 / 28);
|
||||
// [mxd] Rewrote to fix animation for NPo2 textures
|
||||
for (y = ysize-1; y >= 0; y--)
|
||||
for (y = ysize - 1; y >= 0; y--)
|
||||
{
|
||||
int xf = (finesine[(timebase+y*ymul)&FINEMASK]>>13) % xsize;
|
||||
if(xf < 0) xf += xsize;
|
||||
int xf = (TexMan.sintable[((timebase + y*ymul) >> 2)&TexMan.SINMASK] >> 11) % xsize;
|
||||
if (xf < 0) xf += xsize;
|
||||
int xt = xf;
|
||||
const BYTE *source = otherpix + y;
|
||||
BYTE *dest = Pixels + y;
|
||||
for (xt = xsize; xt; xt--, xf = (xf+1)%xsize, dest += ysize)
|
||||
for (xt = xsize; xt; xt--, xf = (xf + 1) % xsize, dest += ysize)
|
||||
*dest = source[xf + ymask * xf];
|
||||
}
|
||||
timebase = DWORD(time * Speed * 23 / 28);
|
||||
for (x = xsize-1; x >= 0; x--)
|
||||
for (x = xsize - 1; x >= 0; x--)
|
||||
{
|
||||
int yf = (finesine[(time+(x+17)*xmul)&FINEMASK]>>13) % ysize;
|
||||
if(yf < 0) yf += ysize;
|
||||
int yf = (TexMan.sintable[((time + (x + 17)*xmul) >> 2)&TexMan.SINMASK] >> 11) % ysize;
|
||||
if (yf < 0) yf += ysize;
|
||||
int yt = yf;
|
||||
const BYTE *source = Pixels + (x + ymask * x);
|
||||
BYTE *dest = buffer;
|
||||
for (yt = ysize; yt; yt--, yf = (yf+1)%ysize)
|
||||
for (yt = ysize; yt; yt--, yf = (yf + 1) % ysize)
|
||||
*dest++ = source[yf];
|
||||
memcpy (Pixels+(x+ymask*x), buffer, ysize);
|
||||
memcpy(Pixels + (x + ymask*x), buffer, ysize);
|
||||
}
|
||||
}
|
||||
|
||||
// [mxd] Non power of 2 textures need different offset multipliers, otherwise warp animation won't sync across texture
|
||||
void FWarpTexture::SetupMultipliers (int width, int height)
|
||||
{
|
||||
WidthOffsetMultipiler = width;
|
||||
HeightOffsetMultipiler = height;
|
||||
WidthOffsetMultiplier = width;
|
||||
HeightOffsetMultiplier = height;
|
||||
int widthpo2 = NextPo2(Width);
|
||||
int heightpo2 = NextPo2(Height);
|
||||
if(widthpo2 != Width) WidthOffsetMultipiler = (int)(WidthOffsetMultipiler * ((float)widthpo2 / Width));
|
||||
if(heightpo2 != Height) HeightOffsetMultipiler = (int)(HeightOffsetMultipiler * ((float)heightpo2 / Height));
|
||||
if(widthpo2 != Width) WidthOffsetMultiplier = (int)(WidthOffsetMultiplier * ((float)widthpo2 / Width));
|
||||
if(heightpo2 != Height) HeightOffsetMultiplier = (int)(HeightOffsetMultiplier * ((float)heightpo2 / Height));
|
||||
}
|
||||
|
||||
int FWarpTexture::NextPo2 (int v)
|
||||
|
@ -225,8 +225,8 @@ void FWarp2Texture::MakeTexture (DWORD time)
|
|||
|
||||
int xsize = Width;
|
||||
int ysize = Height;
|
||||
int xmul = WidthOffsetMultipiler; // [mxd]
|
||||
int ymul = HeightOffsetMultipiler; // [mxd]
|
||||
int xmul = WidthOffsetMultiplier; // [mxd]
|
||||
int ymul = HeightOffsetMultiplier; // [mxd]
|
||||
int xmask = WidthMask;
|
||||
int ymask = Height - 1;
|
||||
int ybits = HeightBits;
|
||||
|
@ -245,12 +245,12 @@ void FWarp2Texture::MakeTexture (DWORD time)
|
|||
for (y = 0; y < ysize; y++)
|
||||
{
|
||||
int xt = (x + 128
|
||||
+ ((finesine[(y*ymul + timebase*5 + 900) & FINEMASK]*2)>>FRACBITS)
|
||||
+ ((finesine[(x*xmul + timebase*4 + 300) & FINEMASK]*2)>>FRACBITS)) % xsize;
|
||||
+ ((TexMan.sintable[((y*ymul + timebase*5 + 900) >> 2) & TexMan.SINMASK])>>13)
|
||||
+ ((TexMan.sintable[((x*xmul + timebase*4 + 300) >> 2) & TexMan.SINMASK])>>13)) % xsize;
|
||||
|
||||
int yt = (y + 128
|
||||
+ ((finesine[(y*ymul + timebase*3 + 700) & FINEMASK]*2)>>FRACBITS)
|
||||
+ ((finesine[(x*xmul + timebase*4 + 1200) & FINEMASK]*2)>>FRACBITS)) % ysize;
|
||||
+ ((TexMan.sintable[((y*ymul + timebase*3 + 700) >> 2) & TexMan.SINMASK])>>13)
|
||||
+ ((TexMan.sintable[((x*xmul + timebase*4 + 1200) >> 2) & TexMan.SINMASK])>>13)) % ysize;
|
||||
|
||||
*dest++ = otherpix[(xt + ymask * xt) + yt];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue