This commit is contained in:
Christoph Oelckers 2016-04-28 17:35:52 +02:00
commit 60a78a0d9b
40 changed files with 188 additions and 483 deletions

View File

@ -1216,7 +1216,6 @@ set (PCH_SOURCES
statistics.cpp
stats.cpp
stringtable.cpp
tables.cpp
teaminfo.cpp
tempfiles.cpp
v_blend.cpp

View File

@ -24,7 +24,6 @@
#define __P_MOBJ_H__
// Basics.
#include "tables.h"
#include "templates.h"
// We need the thinker_t stuff.

View File

@ -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"

View File

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

View File

@ -438,7 +438,7 @@ void PType::SkipValue(FArchive &ar, int tag)
ar.Read(buff, 2);
break;
case VAL_Int32: case VAL_UInt32: case VAL_Float32: case VAL_Fixed: case VAL_BAM:
case VAL_Int32: case VAL_UInt32: case VAL_Float32:
ar.Read(buff, 4);
break;
@ -936,10 +936,8 @@ bool PInt::ReadValue(FArchive &ar, void *addr) const
BYTE val8;
WORD val16;
DWORD val32;
fixed_t fix;
float single;
double dbl;
angle_t ang;
};
ar << tag;
@ -955,8 +953,6 @@ bool PInt::ReadValue(FArchive &ar, void *addr) const
case VAL_UInt32: ar << val32; uval = val32; break;
case VAL_Int64: ar << sval; break;
case VAL_UInt64: ar << uval; break;
case VAL_Fixed: ar << fix; sval = fix >> FRACBITS; break; // fixed -> int
case VAL_BAM: ar << ang; uval = ang / ANGLE_1; break; // BAM -> degrees
case VAL_Float32: ar << single; sval = (SQWORD)single; break;
case VAL_Float64: ar << dbl; sval = (SQWORD)dbl; break;
default: SkipValue(ar, tag); return false; // Incompatible type
@ -1317,8 +1313,6 @@ static bool ReadValueDbl(FArchive &ar, double *addr, unsigned tag)
case VAL_UInt32: ar << val32; val = val32; break;
case VAL_Int64: ar << val64; val = (double)(SQWORD)val64; break;
case VAL_UInt64: ar << val64; val = (double)val64; break;
case VAL_Fixed: ar << fix; val = FIXED2DBL(fix); break;
case VAL_BAM: ar << ang; val = ang * (90.0 / ANGLE_90); break; // BAM -> degrees
case VAL_Float32: ar << single; val = single; break;
case VAL_Float64: ar << val; break;
default: PType::SkipValue(ar, tag); return false; // Incompatible type

View File

@ -904,8 +904,6 @@ enum ETypeVal : BYTE
VAL_One,
VAL_Float32,
VAL_Float64,
VAL_Fixed,
VAL_BAM,
VAL_String,
VAL_Name,
VAL_Struct,

View File

@ -121,7 +121,6 @@ extern int viewwindowx;
extern int viewwindowy;
extern "C" int viewheight;
extern "C" int viewwidth;
extern "C" int halfviewwidth; // [RH] Half view width, for plane drawing

View File

@ -37,8 +37,8 @@ DEarthquake::DEarthquake()
DEarthquake::DEarthquake(AActor *center, int intensityX, int intensityY, int intensityZ, int duration,
int damrad, int tremrad, FSoundID quakesound, int flags,
double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, int rollIntensity,
double rollWave)
double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint,
double rollIntensity, double rollWave)
: DThinker(STAT_EARTHQUAKE)
{
m_QuakeSFX = quakesound;
@ -283,7 +283,8 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
double dist = quake->m_Spot->Distance2D (victim, true);
if (dist < quake->m_TremorRadius)
{
double falloff = quake->GetFalloff(dist);
const double falloff = quake->GetFalloff(dist);
const double rfalloff = (quake->m_RollIntensity != 0) ? falloff : 0.;
++count;
double x = quake->GetModIntensity(quake->m_Intensity.X);
double y = quake->GetModIntensity(quake->m_Intensity.Y);
@ -293,6 +294,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
if (!(quake->m_Flags & QF_WAVE))
{
jiggers.Falloff = MAX(falloff, jiggers.Falloff);
jiggers.RFalloff = MAX(rfalloff, jiggers.RFalloff);
jiggers.RollIntensity = MAX(r, jiggers.RollIntensity);
if (quake->m_Flags & QF_RELATIVE)
{
@ -310,11 +312,11 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
else
{
jiggers.WFalloff = MAX(falloff, jiggers.WFalloff);
double mr = r * quake->GetModWave(quake->m_RollWave);
jiggers.RWFalloff = MAX(rfalloff, jiggers.RWFalloff);
jiggers.RollWave = r * quake->GetModWave(quake->m_RollWave);
double mx = x * quake->GetModWave(quake->m_WaveSpeed.X);
double my = y * quake->GetModWave(quake->m_WaveSpeed.Y);
double mz = z * quake->GetModWave(quake->m_WaveSpeed.Z);
jiggers.RollWave = r * quake->GetModWave(quake->m_RollWave);
// [RH] This only gives effect to the last sine quake. I would
// prefer if some way was found to make multiples coexist
@ -349,7 +351,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration,
int damrad, int tremrad, FSoundID quakesfx, int flags,
double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint,
int rollIntensity, double rollWave)
double rollIntensity, double rollWave)
{
AActor *center;
bool res = false;

View File

@ -153,7 +153,7 @@ struct FQuakeJiggers
DVector3 RelIntensity;
DVector3 Offset;
DVector3 RelOffset;
double Falloff, WFalloff;
double Falloff, WFalloff, RFalloff, RWFalloff;
double RollIntensity, RollWave;
};
@ -164,7 +164,7 @@ class DEarthquake : public DThinker
public:
DEarthquake(AActor *center, int intensityX, int intensityY, int intensityZ, int duration,
int damrad, int tremrad, FSoundID quakesfx, int flags,
double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, int rollIntensity, double rollWave);
double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave);
void Serialize (FArchive &arc);
void Tick ();

View File

@ -8750,23 +8750,24 @@ scriptwait:
{
int tag = STACK(3);
int secnum;
DVector2 pos(ACSToDouble(STACK(2)), ACSToDouble(STACK(1)));
double x = double(STACK(2));
double y = double(STACK(1));
double z = 0;
if (tag != 0)
secnum = P_FindFirstSectorFromTag (tag);
else
secnum = int(P_PointInSector (pos) - sectors);
secnum = int(P_PointInSector (x, y) - sectors);
if (secnum >= 0)
{
if (pcd == PCD_GETSECTORFLOORZ)
{
z = sectors[secnum].floorplane.ZatPoint (pos);
z = sectors[secnum].floorplane.ZatPoint (x, y);
}
else
{
z = sectors[secnum].ceilingplane.ZatPoint (pos);
z = sectors[secnum].ceilingplane.ZatPoint (x, y);
}
}
sp -= 2;

View File

@ -32,7 +32,6 @@
*/
#include "vectors.h"
#include "tables.h"
#define FX_ROCKET 0x00000001
#define FX_GRENADE 0x00000002

View File

@ -2,7 +2,6 @@
#define __P_ENEMY_H__
#include "thingdef/thingdef.h"
#include "tables.h"
struct sector_t;
class AActor;

View File

@ -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"

View File

@ -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"

View File

@ -25,7 +25,6 @@
#include <float.h>
#include "doomtype.h"
#include "tables.h"
#include "vectors.h"
const double NO_VALUE = FLT_MAX;

View File

@ -25,7 +25,6 @@
// Basic data types.
// Needs fixed point, and BAM angles.
#include "tables.h"
#include "thingdef/thingdef.h"
#define WEAPONBOTTOM 128.

View File

@ -698,7 +698,7 @@ void P_DoDeferedScripts (void);
//
// [RH] p_quake.c
//
bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, int rollIntensity, double rollWave);
bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave);
bool P_StartQuake(AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx);
#endif

View File

@ -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"

View File

@ -3,7 +3,6 @@
#include "sc_man.h"
#include "m_fixed.h"
#include "tables.h"
class UDMFParserBase
{

View File

@ -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"

View File

@ -60,7 +60,6 @@ extern int ST_Y;
BYTE* viewimage;
extern "C" {
int halfviewwidth;
int ylookup[MAXHEIGHT];
BYTE *dc_destorg;
}

View File

@ -24,7 +24,6 @@
#define __R_LOCAL_H__
// Binary Angles, sine/cosine/atan lookups.
#include "tables.h"
// Screen size related parameters.
#include "doomdef.h"

View File

@ -165,31 +165,6 @@ static int lastcenteryfrac;
// CODE --------------------------------------------------------------------
//==========================================================================
//
// viewangletox
//
// Used solely for construction the xtoviewangle table.
//
//==========================================================================
static inline int viewangletox(int i)
{
if (finetangent[i] > FRACUNIT*2)
{
return -1;
}
else if (finetangent[i] < -FRACUNIT*2)
{
return viewwidth+1;
}
else
{
double t = FIXED2DBL(finetangent[i]) * FocalLengthX;
return clamp(xs_CeilToInt(CenterX - t), -1, viewwidth+1);
}
}
//==========================================================================
//
// R_InitTextureMapping
@ -198,46 +173,29 @@ static inline int viewangletox(int i)
void R_InitTextureMapping ()
{
int i, x;
int i;
// Calc focallength so FieldOfView fineangles covers viewwidth.
// Calc focallength so FieldOfView angles cover viewwidth.
FocalLengthX = CenterX / FocalTangent;
FocalLengthY = FocalLengthX * YaspectMul;
// This is 1/FocalTangent before the widescreen extension of FOV.
viewingrangerecip = DivScale32(1, finetangent[FINEANGLES/4+(FieldOfView/2)]);
viewingrangerecip = FLOAT2FIXED(1. / tan(FieldOfView.Radians() / 2));
// [RH] Do not generate viewangletox, because texture mapping is no
// longer done with trig, so it's not needed.
// Now generate xtoviewangle for sky texture mapping.
// We do this with a hybrid approach: The center 90 degree span is
// constructed as per the original code:
// Scan xtoviewangle to find the smallest view angle that maps to x.
// (viewangletox is sorted in non-increasing order.)
// This reduces the chances of "doubling-up" of texture columns in
// the drawn sky texture.
// The remaining arcs are done with tantoangle instead.
// [RH] Do not generate viewangletox, because texture mapping is no
// longer done with trig, so it's not needed.
const double slopestep = FocalTangent / centerx;
double slope;
const int t1 = MAX(int(CenterX - FocalLengthX), 0);
const int t2 = MIN(int(CenterX + FocalLengthX), viewwidth);
const fixed_t dfocus = FLOAT2FIXED(FocalLengthX) >> DBITS;
for (i = 0, x = t2; x >= t1; --x)
for (i = centerx, slope = 0; i <= viewwidth; i++, slope += slopestep)
{
while (viewangletox(i) > x)
{
++i;
}
xtoviewangle[x] = (i << ANGLETOFINESHIFT) - ANGLE_90;
xtoviewangle[i] = angle_t((2 * M_PI - atan(slope)) * (ANGLE_180 / M_PI));
}
for (x = t2 + 1; x <= viewwidth; ++x)
for (i = 0; i < centerx; i++)
{
xtoviewangle[x] = ANGLE_270 + tantoangle[dfocus / (x - centerx)];
}
for (x = 0; x < t1; ++x)
{
xtoviewangle[x] = (angle_t)(-(signed)xtoviewangle[viewwidth - x]);
xtoviewangle[i] = 0 - xtoviewangle[viewwidth - i - 1];
}
}
@ -351,7 +309,6 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight,
}
fuzzviewheight = viewheight - 2; // Maximum row the fuzzer can draw to
halfviewwidth = (viewwidth >> 1) - 1;
lastcenteryfrac = 1<<30;
CenterX = centerx;

View File

@ -582,29 +582,25 @@ static visplane_t *new_visplane (unsigned hash)
//==========================================================================
visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive,
const FTransform &xform,
const FTransform &xxform,
int sky, FSectorPortal *portal)
{
secplane_t plane;
visplane_t *check;
unsigned hash; // killough
bool isskybox;
fixed_t xoffs = FLOAT2FIXED(xform.xOffs);
fixed_t yoffs = FLOAT2FIXED(xform.yOffs + xform.baseyOffs);
fixed_t xscale = FLOAT2FIXED(xform.xScale);
fixed_t yscale = FLOAT2FIXED(xform.yScale);
const FTransform *xform = &xxform;
fixed_t alpha = FLOAT2FIXED(Alpha);
angle_t angle = (xform.Angle + xform.baseAngle).BAMs();
//angle_t angle = (xform.Angle + xform.baseAngle).BAMs();
if (picnum == skyflatnum) // killough 10/98
{ // most skies map together
FTransform nulltransform;
lightlevel = 0;
xoffs = 0;
yoffs = 0;
xscale = 0;
yscale = 0;
angle = 0;
alpha = 0;
xform = &nulltransform;
nulltransform.xOffs = nulltransform.yOffs = nulltransform.baseyOffs = 0;
nulltransform.xScale = nulltransform.yScale = 1;
nulltransform.Angle = nulltransform.baseAngle = 0.0;
additive = false;
// [RH] Map floor skies and ceiling skies to separate visplanes. This isn't
// always necessary, but it is needed if a floor and ceiling sky are in the
@ -656,13 +652,8 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
(plane == check->height &&
picnum == check->picnum &&
lightlevel == check->lightlevel &&
xoffs == check->xoffs && // killough 2/28/98: Add offset checks
yoffs == check->yoffs &&
basecolormap == check->colormap && // [RH] Add more checks
xscale == check->xscale &&
yscale == check->yscale &&
angle == check->angle
*xform == check->xform
)
) &&
check->viewangle == stacked_angle
@ -683,12 +674,8 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
if (plane == check->height &&
picnum == check->picnum &&
lightlevel == check->lightlevel &&
xoffs == check->xoffs && // killough 2/28/98: Add offset checks
yoffs == check->yoffs &&
basecolormap == check->colormap && // [RH] Add more checks
xscale == check->xscale &&
yscale == check->yscale &&
angle == check->angle &&
*xform == check->xform &&
sky == check->sky &&
CurrentPortalUniq == check->CurrentPortalUniq &&
MirrorFlags == check->MirrorFlags &&
@ -705,11 +692,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
check->height = plane;
check->picnum = picnum;
check->lightlevel = lightlevel;
check->xoffs = xoffs; // killough 2/28/98: Save offsets
check->yoffs = yoffs;
check->xscale = xscale;
check->yscale = yscale;
check->angle = angle;
check->xform = *xform;
check->colormap = basecolormap; // [RH] Save colormap
check->sky = sky;
check->portal = portal;
@ -794,11 +777,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop)
new_pl->height = pl->height;
new_pl->picnum = pl->picnum;
new_pl->lightlevel = pl->lightlevel;
new_pl->xoffs = pl->xoffs; // killough 2/28/98
new_pl->yoffs = pl->yoffs;
new_pl->xscale = pl->xscale; // [RH] copy these, too
new_pl->yscale = pl->yscale;
new_pl->angle = pl->angle;
new_pl->xform = pl->xform;
new_pl->colormap = pl->colormap;
new_pl->portal = pl->portal;
new_pl->extralight = pl->extralight;
@ -1117,8 +1096,8 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
masked = false;
}
R_SetupSpanBits(tex);
pl->xscale = fixed_t(pl->xscale * tex->Scale.X);
pl->yscale = fixed_t(pl->yscale * tex->Scale.Y);
double xscale = pl->xform.xScale * tex->Scale.X;
double yscale = pl->xform.yScale * tex->Scale.Y;
ds_source = tex->GetPixels ();
basecolormap = pl->colormap;
@ -1126,11 +1105,11 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
if (r_drawflat || (!pl->height.isSlope() && !tilt))
{
R_DrawNormalPlane (pl, alpha, additive, masked);
R_DrawNormalPlane(pl, xscale, yscale, alpha, additive, masked);
}
else
{
R_DrawTiltedPlane (pl, alpha, additive, masked);
R_DrawTiltedPlane(pl, xscale, yscale, alpha, additive, masked);
}
}
NetUpdate ();
@ -1502,7 +1481,7 @@ void R_DrawSkyPlane (visplane_t *pl)
//
//==========================================================================
void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked)
void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked)
{
#ifdef X86_ASM
if (ds_source != ds_cursource)
@ -1516,31 +1495,30 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
return;
}
angle_t planeang = pl->angle;
xscale = pl->xscale << (16 - ds_xbits);
yscale = pl->yscale << (16 - ds_ybits);
DAngle planeang = pl->xform.Angle + pl->xform.baseAngle;
xscale = xs_ToFixed(32 - ds_xbits, _xscale);
yscale = xs_ToFixed(32 - ds_ybits, _yscale);
if (planeang != 0)
{
double rad = planeang * (M_PI / ANGLE_180);
double cosine = cos(rad), sine = sin(rad);
pviewx = xs_RoundToInt(pl->xoffs + FLOAT2FIXED(ViewPos.X * cosine - ViewPos.Y * sine));
pviewy = xs_RoundToInt(pl->yoffs - FLOAT2FIXED(ViewPos.X * sine - ViewPos.Y * cosine));
double cosine = cos(planeang.Radians()), sine = sin(planeang.Radians());
pviewx = FLOAT2FIXED(pl->xform.xOffs + ViewPos.X * cosine - ViewPos.Y * sine);
pviewy = FLOAT2FIXED(pl->xform.yOffs - ViewPos.X * sine - ViewPos.Y * cosine);
}
else
{
pviewx = pl->xoffs + FLOAT2FIXED(ViewPos.X);
pviewy = pl->yoffs - FLOAT2FIXED(ViewPos.Y);
pviewx = FLOAT2FIXED(pl->xform.xOffs + ViewPos.X);
pviewy = FLOAT2FIXED(pl->xform.yOffs - ViewPos.Y);
}
pviewx = FixedMul (xscale, pviewx);
pviewy = FixedMul (yscale, pviewy);
// left to right mapping
planeang = (ViewAngle.BAMs() - ANG90 + planeang) >> ANGLETOFINESHIFT;
planeang = ViewAngle - 90 + planeang;
// Scale will be unit scale at FocalLengthX (normally SCREENWIDTH/2) distance
xstepscale = fixed_t(FixedMul(xscale, finecosine[planeang]) / FocalLengthX);
ystepscale = fixed_t(FixedMul(yscale, -finesine[planeang]) / FocalLengthX);
xstepscale = xs_RoundToInt(xscale * cos(planeang.Radians()) / FocalLengthX);
ystepscale = xs_RoundToInt(yscale * -sin(planeang.Radians()) / FocalLengthX);
// [RH] flip for mirrors
if (MirrorFlags & RF_XFLIP)
@ -1549,10 +1527,10 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
ystepscale = (DWORD)(-(SDWORD)ystepscale);
}
int x = pl->right - halfviewwidth - 1;
planeang = (planeang + (ANG90 >> ANGLETOFINESHIFT)) & FINEMASK;
basexfrac = FixedMul (xscale, finecosine[planeang]) + x*xstepscale;
baseyfrac = FixedMul (yscale, -finesine[planeang]) + x*ystepscale;
int x = pl->right - centerx;
planeang += 90;
basexfrac = xs_RoundToInt(xscale * cos(planeang.Radians())) + x*xstepscale;
baseyfrac = xs_RoundToInt(yscale * -sin(planeang.Radians())) + x*ystepscale;
planeheight = fabs(pl->height.Zat0() - ViewPos.Z);
@ -1620,7 +1598,7 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
//
//==========================================================================
void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked)
void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked)
{
static const float ifloatpow2[16] =
{
@ -1634,7 +1612,7 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
double lxscale, lyscale;
double xscale, yscale;
FVector3 p, m, n;
double ang;
DAngle ang;
double zeroheight;
if (alpha <= 0)
@ -1642,44 +1620,45 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
return;
}
lxscale = FIXED2DBL(pl->xscale) * ifloatpow2[ds_xbits];
lyscale = FIXED2DBL(pl->yscale) * ifloatpow2[ds_ybits];
lxscale = _xscale * ifloatpow2[ds_xbits];
lyscale = _yscale * ifloatpow2[ds_ybits];
xscale = 64.f / lxscale;
yscale = 64.f / lyscale;
zeroheight = pl->height.ZatPoint(ViewPos);
pviewx = MulScale (pl->xoffs, pl->xscale, ds_xbits);
pviewy = MulScale (pl->yoffs, pl->yscale, ds_ybits);
pviewx = xs_ToFixed(32 - ds_xbits, pl->xform.xOffs * pl->xform.xScale);
pviewy = xs_ToFixed(32 - ds_ybits, pl->xform.yOffs * pl->xform.yScale);
// p is the texture origin in view space
// Don't add in the offsets at this stage, because doing so can result in
// errors if the flat is rotated.
ang = (DAngle(270.) - ViewAngle).Radians();
p[0] = ViewPos.X * cos(ang) - ViewPos.Y * sin(ang);
p[2] = ViewPos.X * sin(ang) + ViewPos.Y * cos(ang);
ang = DAngle(270.) - ViewAngle;
p[0] = ViewPos.X * ang.Cos() - ViewPos.Y * ang.Sin();
p[2] = ViewPos.X * ang.Sin() + ViewPos.Y * ang.Cos();
p[1] = pl->height.ZatPoint(0.0, 0.0) - ViewPos.Z;
// m is the v direction vector in view space
ang = (DAngle(180.) - ViewAngle).Radians();
m[0] = yscale * cos(ang);
m[2] = yscale * sin(ang);
ang = DAngle(180.) - ViewAngle;
m[0] = yscale * cos(ang.Radians());
m[2] = yscale * sin(ang.Radians());
// m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0));
// VectorScale2 (m, 64.f/VectorLength(m));
// n is the u direction vector in view space
ang += PI/2;
n[0] = -xscale * cos(ang);
n[2] = -xscale * sin(ang);
ang += 90;
n[0] = -xscale * cos(ang.Radians());
n[2] = -xscale * sin(ang.Radians());
// n[1] = pl->height.ZatPointF (ixscale, 0) - pl->height.ZatPointF (0,0));
// VectorScale2 (n, 64.f/VectorLength(n));
// This code keeps the texture coordinates constant across the x,y plane no matter
// how much you slope the surface. Use the commented-out code above instead to keep
// the textures a constant size across the surface's plane instead.
ang = pl->angle * (M_PI / ANGLE_180);
m[1] = pl->height.ZatPoint(ViewPos.X + yscale * sin(ang), ViewPos.Y + yscale * cos(ang)) - zeroheight;
ang += PI/2;
n[1] = pl->height.ZatPoint(ViewPos.X + xscale * sin(ang), ViewPos.Y + xscale * cos(ang)) - zeroheight;
ang = pl->xform.Angle + pl->xform.baseAngle;
double cosine = cos(ang.Radians()), sine = sin(ang.Radians());
m[1] = pl->height.ZatPoint(ViewPos.X + yscale * sine, ViewPos.Y + yscale * cosine) - zeroheight;
ang += 90;
n[1] = pl->height.ZatPoint(ViewPos.X + xscale * sine, ViewPos.Y + xscale * cosine) - zeroheight;
plane_su = p ^ m;
plane_sv = p ^ n;

View File

@ -34,16 +34,15 @@ struct visplane_s
{
struct visplane_s *next; // Next visplane in hash chain -- killough
FDynamicColormap *colormap; // [RH] Support multiple colormaps
FSectorPortal *portal; // [RH] Support sky boxes
FTransform xform;
secplane_t height;
FTextureID picnum;
int lightlevel;
fixed_t xoffs, yoffs; // killough 2/28/98: Support scrolling flats
int left, right;
FDynamicColormap *colormap; // [RH] Support multiple colormaps
fixed_t xscale, yscale; // [RH] Support flat scaling
angle_t angle; // [RH] Support flat rotation
int sky;
FSectorPortal *portal; // [RH] Support sky boxes
// [RH] This set of variables copies information from the time when the
// visplane is created. They are only used by stacks so that you can
@ -90,8 +89,8 @@ void R_ClearPlanes (bool fullclear);
int R_DrawPlanes ();
void R_DrawPortals ();
void R_DrawSkyPlane (visplane_t *pl);
void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked);
void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked);
void R_DrawNormalPlane (visplane_t *pl, double xscale, double yscale, fixed_t alpha, bool additive, bool masked);
void R_DrawTiltedPlane (visplane_t *pl, double xscale, double yscale, fixed_t alpha, bool additive, bool masked);
void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1));
visplane_t *R_FindPlane

View File

@ -2670,53 +2670,51 @@ int OWallMost (short *mostbuf, double z, const FWallCoords *wallc)
s3 = globaldclip * wallc->sz1; s4 = globaldclip * wallc->sz2;
bad = (z<s1)+((z<s2)<<1)+((z>s3)<<2)+((z>s4)<<3);
#if 1
if ((bad&3) == 3)
{
{ // entire line is above the screen
memset (&mostbuf[wallc->sx1], 0, (wallc->sx2 - wallc->sx1)*sizeof(mostbuf[0]));
return bad;
}
if ((bad&12) == 12)
{
{ // entire line is below the screen
clearbufshort (&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight);
return bad;
}
#endif
ix1 = wallc->sx1; iy1 = wallc->sz1;
ix2 = wallc->sx2; iy2 = wallc->sz2;
#if 1
if (bad & 3)
{
{ // the line intersects the top of the screen
double t = (z-s1) / (s2-s1);
double inty = wallc->sz1 + t * (wallc->sz2 - wallc->sz1);
int xcross = xs_RoundToInt(wallc->sx1 + (t * wallc->sz2 * (wallc->sx2 - wallc->sx1)) / inty);
if ((bad & 3) == 2)
{
{ // the right side is above the screen
if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; }
if (wallc->sx2 > xcross) memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0]));
}
else
{
{ // the left side is above the screen
if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; }
if (xcross > wallc->sx1) memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0]));
}
}
if (bad & 12)
{
{ // the line intersects the bottom of the screen
double t = (z-s3) / (s4-s3);
double inty = wallc->sz1 + t * (wallc->sz2 - wallc->sz1);
int xcross = xs_RoundToInt(wallc->sx1 + (t * wallc->sz2 * (wallc->sx2 - wallc->sx1)) / inty);
if ((bad & 12) == 8)
{
{ // the right side is below the screen
if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; }
if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2 - xcross, viewheight);
}
else
{
{ // the left side is below the screen
if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; }
if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross - wallc->sx1, viewheight);
}
@ -2779,6 +2777,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
int bad, ix1, ix2;
double iy1, iy2;
// Get Z coordinates at both ends of the line
if (MirrorFlags & RF_XFLIP)
{
x = curline->v2->fX();
@ -2847,20 +2846,20 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
oz1 = z1; oz2 = z2;
if ((bad&3) == 3)
{
memset (&mostbuf[ix1], -1, (ix2-ix1)*sizeof(mostbuf[0]));
{ // The entire line is above the screen
memset (&mostbuf[ix1], 0, (ix2-ix1)*sizeof(mostbuf[0]));
return bad;
}
if ((bad&12) == 12)
{
{ // The entire line is below the screen
clearbufshort (&mostbuf[ix1], ix2-ix1, viewheight);
return bad;
}
if (bad&3)
{
{ // The line intersects the top of the screen
//inty = intz / (globaluclip>>16)
double t = (oz1-s1) / (s2-s1+oz1-oz2);
double inty = wallc->sz1 + t * (wallc->sz2-wallc->sz1);
@ -2872,19 +2871,19 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
//intz = z1 + mulscale30(z2-z1,t);
if ((bad&3) == 2)
{
{ // The right side of the line is above the screen
if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0]));
}
else
{
{ // The left side of the line is above the screen
if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; }
memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0]));
}
}
if (bad&12)
{
{ // The line intersects the bottom of the screen
//inty = intz / (globaldclip>>16)
double t = (oz1-s3) / (s4-s3+oz1-oz2);
double inty = wallc->sz1 + t * (wallc->sz2-wallc->sz1);
@ -2896,12 +2895,12 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
//intz = z1 + mulscale30(z2-z1,t);
if ((bad&12) == 8)
{
{ // The right side of the line is below the screen
if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2-xcross, viewheight);
}
else
{
{ // The left side of the line is below the screen
if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; }
if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross-wallc->sx1, viewheight);
}

View File

@ -115,8 +115,8 @@ void R_InitSkyMap ()
skyiscale = float(r_Yaspect / freelookviewheight);
skyscale = freelookviewheight / r_Yaspect;
skyiscale *= FieldOfView / 2048.f;
skyscale *= 2048.0 / FieldOfView;
skyiscale *= float(FieldOfView.Degrees / 90.);
skyscale *= float(90. / FieldOfView.Degrees);
}
if (skystretch)

View File

@ -82,7 +82,7 @@ extern AActor* camera; // [RH] camera instead of viewplayer
extern sector_t* viewsector; // [RH] keep track of sector viewing from
extern angle_t xtoviewangle[MAXWIDTH+1];
extern int FieldOfView;
extern DAngle FieldOfView;
int R_FindSkin (const char *name, int pclass); // [RH] Find a skin

View File

@ -50,8 +50,6 @@ void R_SetupColormap(player_t *);
void R_SetupFreelook();
void R_InitRenderer();
extern float LastFOV;
//==========================================================================
//
// DCanvas :: Init
@ -272,8 +270,8 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
unsigned char *savecolormap = fixedcolormap;
FSpecialColormap *savecm = realfixedcolormap;
float savedfov = LastFOV;
R_SetFOV ((float)fov);
DAngle savedfov = FieldOfView;
R_SetFOV ((double)fov);
R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
R_SetFOV (savedfov);
if (Pixels == Canvas->GetBuffer())

View File

@ -678,7 +678,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop
}
// Render the voxel, either directly to the screen or offscreen.
R_DrawVoxel(spr->pa.vpos, spr->pa.vang, spr->gpos, spr->angle,
R_DrawVoxel(spr->pa.vpos, spr->pa.vang, spr->gpos, spr->Angle,
spr->xscale, FLOAT2FIXED(spr->yscale), spr->voxel, spr->Style.colormap, cliptop, clipbot,
minslabz, maxslabz, flags);
@ -994,7 +994,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
vis->texturemid = tex->TopOffset - (ViewPos.Z - pos.Z + thing->Floorclip) / yscale;
vis->x1 = x1 < WindowLeft ? WindowLeft : x1;
vis->x2 = x2 > WindowRight ? WindowRight : x2;
vis->angle = thing->Angles.Yaw.BAMs();
vis->Angle = thing->Angles.Yaw;
if (renderflags & RF_XFLIP)
{
@ -1024,13 +1024,13 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
pos.Z -= thing->Floorclip;
vis->angle = thing->Angles.Yaw.BAMs() + voxel->AngleOffset.BAMs();
vis->Angle = thing->Angles.Yaw + voxel->AngleOffset;
int voxelspin = (thing->flags & MF_DROPPED) ? voxel->DroppedSpin : voxel->PlacedSpin;
if (voxelspin != 0)
{
DAngle ang = double(I_FPSTime()) * voxelspin / 1000;
vis->angle -= ang.BAMs();
vis->Angle -= ang;
}
vis->pa.vpos = { (float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z };
@ -2664,7 +2664,7 @@ void R_DrawParticle (vissprite_t *vis)
extern double BaseYaspectMul;;
void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle,
const FVector3 &dasprpos, angle_t dasprang,
const FVector3 &dasprpos, DAngle dasprang,
fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj,
lighttable_t *colormap, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags)
{
@ -2698,10 +2698,10 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle,
dayscale = dayscale / (0xC000 >> 6);
angle_t viewang = viewangle.BAMs();
cosang = finecosine[viewang >> ANGLETOFINESHIFT] >> 2;
sinang = -finesine[viewang >> ANGLETOFINESHIFT] >> 2;
sprcosang = finecosine[dasprang >> ANGLETOFINESHIFT] >> 2;
sprsinang = -finesine[dasprang >> ANGLETOFINESHIFT] >> 2;
cosang = FLOAT2FIXED(viewangle.Cos()) >> 2;
sinang = FLOAT2FIXED(-viewangle.Sin()) >> 2;
sprcosang = FLOAT2FIXED(dasprang.Cos()) >> 2;
sprsinang = FLOAT2FIXED(-dasprang.Sin()) >> 2;
R_SetupDrawSlab(colormap);

View File

@ -41,10 +41,16 @@ struct vissprite_t
FVector3 gpos; // origin in world coordinates
union
{
float gzb, gzt; // global bottom / top for silhouette clipping
int y1, y2; // top / bottom of particle on screen
struct
{
float gzb, gzt; // global bottom / top for silhouette clipping
};
struct
{
int y1, y2; // top / bottom of particle on screen
};
};
angle_t angle;
DAngle Angle;
fixed_t xscale;
float yscale;
float depth;
@ -135,7 +141,7 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly);
enum { DVF_OFFSCREEN = 1, DVF_SPANSONLY = 2, DVF_MIRRORED = 4 };
void R_DrawVoxel(const FVector3 &viewpos, FAngle viewangle,
const FVector3 &sprpos, angle_t dasprang,
const FVector3 &sprpos, DAngle dasprang,
fixed_t daxscale, fixed_t dayscale, struct FVoxel *voxobj,
lighttable_t *colormap, short *daumost, short *dadmost, int minslabz, int maxslabz, int flags);

View File

@ -138,7 +138,6 @@ angle_t LocalViewAngle;
int LocalViewPitch;
bool LocalKeyboardTurner;
float LastFOV;
int WidescreenRatio;
int setblocks;
int extralight;
@ -147,7 +146,7 @@ double FocalTangent;
unsigned int R_OldBlend = ~0;
int validcount = 1; // increment every time a check is made
int FieldOfView = 2048; // Fineangles in the SCREENWIDTH wide window
DAngle FieldOfView = 90.; // Angles in the SCREENWIDTH wide window
FCanvasTextureInfo *FCanvasTextureInfo::List;
@ -158,63 +157,6 @@ DAngle viewpitch;
// CODE --------------------------------------------------------------------
static void R_Shutdown ();
//==========================================================================
//
// R_InitPointToAngle
//
//==========================================================================
void R_InitPointToAngle (void)
{
double f;
int i;
//
// slope (tangent) to angle lookup
//
for (i = 0; i <= SLOPERANGE; i++)
{
f = g_atan2 ((double)i, (double)SLOPERANGE) / (6.28318530718 /* 2*pi */);
tantoangle[i] = (angle_t)(0xffffffff*f);
}
}
//==========================================================================
//
// R_InitTables
//
//==========================================================================
void R_InitTables (void)
{
int i;
const double pimul = PI*2/FINEANGLES;
// viewangle tangent table
finetangent[0] = (fixed_t)(FRACUNIT*g_tan ((0.5-FINEANGLES/4)*pimul)+0.5);
for (i = 1; i < FINEANGLES/2; i++)
{
finetangent[i] = (fixed_t)(FRACUNIT*g_tan ((i-FINEANGLES/4)*pimul)+0.5);
}
// 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
@ -223,33 +165,18 @@ void R_InitTables (void)
//
//==========================================================================
void R_SetFOV (float fov)
void R_SetFOV (DAngle fov)
{
if (fov < 5.f)
fov = 5.f;
else if (fov > 170.f)
fov = 170.f;
if (fov != LastFOV)
if (fov < 5.) fov = 5.;
else if (fov > 170.) fov = 170.;
if (fov != FieldOfView)
{
LastFOV = fov;
FieldOfView = (int)(fov * (float)FINEANGLES / 360.f);
FieldOfView = fov;
setsizeneeded = true;
}
}
//==========================================================================
//
// R_GetFOV
//
// Returns the current field of view in degrees
//
//==========================================================================
float R_GetFOV ()
{
return LastFOV;
}
//==========================================================================
//
// R_SetViewSize
@ -313,18 +240,16 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
}
int fov = FieldOfView;
DAngle fov = FieldOfView;
// For widescreen displays, increase the FOV so that the middle part of the
// screen that would be visible on a 4:3 display has the requested FOV.
if (centerxwide != centerx)
{ // centerxwide is what centerx would be if the display was not widescreen
fov = int(atan(double(centerx)*tan(double(fov)*M_PI/(FINEANGLES))/double(centerxwide))*(FINEANGLES)/M_PI);
if (fov > 170*FINEANGLES/360)
fov = 170*FINEANGLES/360;
fov = DAngle::ToDegrees(2 * atan(centerx * tan(fov.Radians()/2) / double(centerxwide)));
if (fov > 170.) fov = 170.;
}
FocalTangent = FIXED2FLOAT(finetangent[FINEANGLES/4+fov/2]);
FocalTangent = tan(fov.Radians() / 2);
Renderer->SetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio);
}
@ -410,8 +335,6 @@ void R_Init ()
//R_InitColormaps ();
//StartScreen->Progress();
R_InitPointToAngle ();
R_InitTables ();
R_InitTranslationTables ();
R_SetViewSize (screenblocks);
Renderer->Init();
@ -874,7 +797,7 @@ void R_SetupFrame (AActor *actor)
if (jiggers.RollIntensity != 0 || jiggers.RollWave != 0)
{
ViewRoll += QuakePower(quakefactor, jiggers.RollIntensity, jiggers.RollWave, jiggers.Falloff, jiggers.WFalloff);
ViewRoll += QuakePower(quakefactor, jiggers.RollIntensity, jiggers.RollWave, jiggers.RFalloff, jiggers.RWFalloff);
}
if (jiggers.RelIntensity.X != 0 || jiggers.RelOffset.X != 0)
{

View File

@ -85,8 +85,7 @@ bool R_GetViewInterpolationStatus();
void R_ClearInterpolationPath();
void R_AddInterpolationPoint(const DVector3a &vec);
void R_SetViewSize (int blocks);
void R_SetFOV (float fov);
float R_GetFOV ();
void R_SetFOV (DAngle fov);
void R_SetupFrame (AActor * camera);
void R_SetViewAngle ();

View File

@ -1,42 +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 finetangent[4096] - Tangens LUT.
// Should work with BAM fairly well (12 of 16bit,
// effectively, by shifting).
//
// int finesine[10240] - Sine lookup.
// Guess what, serves as cosine, too.
// Remarkable thing is, how to use BAMs with this?
//
// int tantoangle[2049] - ArcTan LUT,
// maps tan(angle) to angle fast. Gotta search.
//
//
//-----------------------------------------------------------------------------
#include "tables.h"
fixed_t finetangent[4096];
fixed_t finesine[10240];
angle_t tantoangle[2049];
cosine_inline finecosine; // in case this is actually needed

View File

@ -1,111 +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 finetangent[4096] - Tangens LUT.
// Should work with BAM fairly well (12 of 16bit,
// effectively, by shifting).
//
// int finesine[10240] - Sine lookup.
// Guess what, serves as cosine, too.
// Remarkable thing is, how to use BAMs with this?
//
// int tantoangle[2049] - ArcTan LUT,
// maps tan(angle) to angle fast. Gotta search.
//
//-----------------------------------------------------------------------------
#ifndef __TABLES_H__
#define __TABLES_H__
#include <stdlib.h>
#include <math.h>
#include "basictypes.h"
#ifndef PI
#define PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif
#define FINEANGLEBITS 13
#define FINEANGLES 8192
#define FINEMASK (FINEANGLES-1)
// 0x100000000 to 0x2000
#define ANGLETOFINESHIFT 19
#define BOBTOFINESHIFT (FINEANGLEBITS - 6)
// Effective size is 10240.
extern fixed_t finesine[5*FINEANGLES/4];
// Re-use data, is just PI/2 phase shift.
// [RH] Instead of using a pointer, use some inline code
// (encapsulated in a struct so that we can still use array accesses).
struct cosine_inline
{
fixed_t operator[] (unsigned int x) const
{
return finesine[x+FINEANGLES/4];
}
};
extern cosine_inline finecosine;
// Effective size is 4096.
extern fixed_t finetangent[FINEANGLES/2];
// Binary Angle Measument, BAM.
#define ANG45 (0x20000000)
#define ANG90 (0x40000000)
#define ANG180 (0x80000000)
#define ANG270 (0xc0000000)
#define ANGLE_45 (0x20000000)
#define ANGLE_90 (0x40000000)
#define ANGLE_180 (0x80000000)
#define ANGLE_270 (0xc0000000)
#define ANGLE_MAX (0xffffffff)
#define ANGLE_1 (ANGLE_45/45)
#define ANGLE_60 (ANGLE_180/3)
#define SLOPERANGE 2048
#define SLOPEBITS 11
#define DBITS (FRACBITS-SLOPEBITS)
typedef uint32 angle_t;
// Previously seen all over the place, code like this: abs(ang1 - ang2)
// Clang warns (and is absolutely correct) that technically, this
// could be optimized away and do nothing:
// warning: taking the absolute value of unsigned type 'unsigned int' has no effect
// note: remove the call to 'abs' since unsigned values cannot be negative
inline angle_t absangle(angle_t a)
{
return (angle_t)abs((int32_t)a);
}
// Effective size is 2049;
// The +1 size is to handle the case when x==y
// without additional checking.
extern angle_t tantoangle[SLOPERANGE+1];
#endif // __TABLES_H__

View File

@ -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);
}
}
//==========================================================================

View File

@ -517,6 +517,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
@ -554,7 +560,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]

View File

@ -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];
}

View File

@ -4985,7 +4985,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_QuakeEx)
PARAM_FLOAT_OPT(mulWaveZ) { mulWaveZ = 1.; }
PARAM_INT_OPT(falloff) { falloff = 0; }
PARAM_INT_OPT(highpoint) { highpoint = 0; }
PARAM_INT_OPT(rollIntensity) { rollIntensity = 0; }
PARAM_FLOAT_OPT(rollIntensity) { rollIntensity = 0.; }
PARAM_FLOAT_OPT(rollWave) { rollWave = 0.; }
P_StartQuakeXYZ(self, 0, intensityX, intensityY, intensityZ, duration, damrad, tremrad, sound, flags, mulWaveX, mulWaveY, mulWaveZ, falloff, highpoint,
rollIntensity, rollWave);

View File

@ -281,7 +281,7 @@ ACTOR Actor native //: Thinker
native void A_SetUserArrayFloat(name varname, int index, float value);
native void A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0);
native void A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake");
native void A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, float mulWaveX = 1, float mulWaveY = 1, float mulWaveZ = 1, int falloff = 0, int highpoint = 0, int rollIntensity = 0, float rollWave = 0);
native void A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, float mulWaveX = 1, float mulWaveY = 1, float mulWaveZ = 1, int falloff = 0, int highpoint = 0, float rollIntensity = 0, float rollWave = 0);
action native A_SetTics(int tics);
native void A_SetDamageType(name damagetype);
native void A_DropItem(class<Actor> item, int dropamount = -1, int chance = 256);