2006-02-24 04:48:15 +00:00
|
|
|
// 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:
|
|
|
|
// Refresh/rendering module, shared data struct definitions.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __R_DEFS_H__
|
|
|
|
#define __R_DEFS_H__
|
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
|
|
|
|
// Some more or less basic data types
|
|
|
|
// we depend on.
|
|
|
|
#include "m_fixed.h"
|
|
|
|
|
|
|
|
// We rely on the thinker data struct
|
|
|
|
// to handle sound origins in sectors.
|
|
|
|
// SECTORS do store MObjs anyway.
|
|
|
|
#include "actor.h"
|
|
|
|
|
|
|
|
#include "dthinker.h"
|
2008-03-21 17:35:49 +00:00
|
|
|
#include "r_interpolate.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-08 01:08:27 +00:00
|
|
|
#define MAXWIDTH 2560
|
|
|
|
#define MAXHEIGHT 1600
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
const WORD NO_INDEX = 0xffffu;
|
|
|
|
const DWORD NO_SIDE = 0xffffffffu;
|
|
|
|
|
|
|
|
// Silhouette, needed for clipping Segs (mainly)
|
|
|
|
// and sprites representing things.
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SIL_NONE,
|
|
|
|
SIL_BOTTOM,
|
|
|
|
SIL_TOP,
|
|
|
|
SIL_BOTH
|
|
|
|
};
|
|
|
|
|
|
|
|
extern size_t MaxDrawSegs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// INTERNAL MAP TYPES
|
|
|
|
// used by play and refresh
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Your plain vanilla vertex.
|
|
|
|
// Note: transformed values not buffered locally,
|
|
|
|
// like some DOOM-alikes ("wt", "WebView") did.
|
|
|
|
//
|
2008-04-12 15:31:18 +00:00
|
|
|
struct vertex_t
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
fixed_t x, y;
|
|
|
|
|
2008-04-12 15:31:18 +00:00
|
|
|
bool operator== (const vertex_t &other)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return x == other.x && y == other.y;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Forward of LineDefs, for Sectors.
|
2008-03-21 17:35:49 +00:00
|
|
|
struct line_t;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-06-01 07:52:33 +00:00
|
|
|
class player_t;
|
2008-04-12 15:31:18 +00:00
|
|
|
class FScanner;
|
2008-04-15 18:05:39 +00:00
|
|
|
class FBitmap;
|
2008-04-16 18:17:20 +00:00
|
|
|
struct FCopyInfo;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// The SECTORS record, at runtime.
|
|
|
|
// Stores things/mobjs.
|
|
|
|
//
|
|
|
|
class DSectorEffect;
|
|
|
|
struct sector_t;
|
2007-12-29 10:25:07 +00:00
|
|
|
struct FRemapTable;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SECSPAC_Enter = 1, // Trigger when player enters
|
|
|
|
SECSPAC_Exit = 2, // Trigger when player exits
|
|
|
|
SECSPAC_HitFloor = 4, // Trigger when player hits floor
|
|
|
|
SECSPAC_HitCeiling = 8, // Trigger when player hits ceiling
|
|
|
|
SECSPAC_Use = 16, // Trigger when player uses
|
|
|
|
SECSPAC_UseWall = 32, // Trigger when player uses a wall
|
|
|
|
SECSPAC_EyesDive = 64, // Trigger when player eyes go below fake floor
|
|
|
|
SECSPAC_EyesSurface = 128, // Trigger when player eyes go above fake floor
|
|
|
|
SECSPAC_EyesBelowC = 256, // Trigger when player eyes go below fake ceiling
|
|
|
|
SECSPAC_EyesAboveC = 512, // Trigger when player eyes go above fake ceiling
|
|
|
|
SECSPAC_HitFakeFloor= 1024, // Trigger when player hits fake floor
|
|
|
|
};
|
|
|
|
|
|
|
|
class ASectorAction : public AActor
|
|
|
|
{
|
|
|
|
DECLARE_ACTOR (ASectorAction, AActor)
|
|
|
|
public:
|
|
|
|
void Destroy ();
|
|
|
|
void BeginPlay ();
|
|
|
|
void Activate (AActor *source);
|
|
|
|
void Deactivate (AActor *source);
|
|
|
|
virtual bool TriggerAction (AActor *triggerer, int activationType);
|
|
|
|
protected:
|
|
|
|
bool CheckTrigger (AActor *triggerer) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ASkyViewpoint;
|
|
|
|
|
|
|
|
struct secplane_t
|
|
|
|
{
|
|
|
|
// the plane is defined as a*x + b*y + c*z + d = 0
|
|
|
|
// ic is 1/c, for faster Z calculations
|
|
|
|
|
|
|
|
fixed_t a, b, c, d, ic;
|
|
|
|
|
|
|
|
// Returns the value of z at (x,y)
|
|
|
|
fixed_t ZatPoint (fixed_t x, fixed_t y) const
|
|
|
|
{
|
|
|
|
return FixedMul (ic, -d - DMulScale16 (a, x, b, y));
|
|
|
|
}
|
|
|
|
|
2008-05-22 05:17:21 +00:00
|
|
|
// Returns the value of z at (x,y) as a double
|
|
|
|
double ZatPoint (double x, double y) const
|
|
|
|
{
|
|
|
|
return (d + a*x + b*y) * ic / (-65536.0 * 65536.0);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Returns the value of z at vertex v
|
|
|
|
fixed_t ZatPoint (const vertex_t *v) const
|
|
|
|
{
|
|
|
|
return FixedMul (ic, -d - DMulScale16 (a, v->x, b, v->y));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the value of z at (x,y) if d is equal to dist
|
|
|
|
fixed_t ZatPointDist (fixed_t x, fixed_t y, fixed_t dist) const
|
|
|
|
{
|
|
|
|
return FixedMul (ic, -dist - DMulScale16 (a, x, b, y));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the value of z at vertex v if d is equal to dist
|
|
|
|
fixed_t ZatPointDist (const vertex_t *v, fixed_t dist)
|
|
|
|
{
|
|
|
|
return FixedMul (ic, -dist - DMulScale16 (a, v->x, b, v->y));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Flips the plane's vertical orientiation, so that if it pointed up,
|
|
|
|
// it will point down, and vice versa.
|
|
|
|
void FlipVert ()
|
|
|
|
{
|
|
|
|
a = -a;
|
|
|
|
b = -b;
|
|
|
|
c = -c;
|
|
|
|
d = -d;
|
|
|
|
ic = -ic;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if 2 planes are the same
|
|
|
|
bool operator== (const secplane_t &other) const
|
|
|
|
{
|
|
|
|
return a == other.a && b == other.b && c == other.c && d == other.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if 2 planes are different
|
|
|
|
bool operator!= (const secplane_t &other) const
|
|
|
|
{
|
|
|
|
return a != other.a || b != other.b || c != other.c || d != other.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Moves a plane up/down by hdiff units
|
|
|
|
void ChangeHeight (fixed_t hdiff)
|
|
|
|
{
|
|
|
|
d = d - FixedMul (hdiff, c);
|
|
|
|
}
|
|
|
|
|
2008-03-18 18:18:18 +00:00
|
|
|
// Moves a plane up/down by hdiff units
|
|
|
|
fixed_t GetChangedHeight (fixed_t hdiff)
|
|
|
|
{
|
|
|
|
return d - FixedMul (hdiff, c);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Returns how much this plane's height would change if d were set to oldd
|
|
|
|
fixed_t HeightDiff (fixed_t oldd) const
|
|
|
|
{
|
|
|
|
return FixedMul (oldd - d, ic);
|
|
|
|
}
|
|
|
|
|
2008-03-18 18:18:18 +00:00
|
|
|
// Returns how much this plane's height would change if d were set to oldd
|
|
|
|
fixed_t HeightDiff (fixed_t oldd, fixed_t newd) const
|
|
|
|
{
|
|
|
|
return FixedMul (oldd - newd, ic);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t PointToDist (fixed_t x, fixed_t y, fixed_t z) const
|
|
|
|
{
|
|
|
|
return -TMulScale16 (a, x, y, b, z, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
fixed_t PointToDist (const vertex_t *v, fixed_t z) const
|
|
|
|
{
|
|
|
|
return -TMulScale16 (a, v->x, b, v->y, z, c);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inline FArchive &operator<< (FArchive &arc, secplane_t &plane)
|
|
|
|
{
|
|
|
|
arc << plane.a << plane.b << plane.c << plane.d;
|
|
|
|
//if (plane.c != 0)
|
|
|
|
{ // plane.c should always be non-0. Otherwise, the plane
|
|
|
|
// would be perfectly vertical.
|
|
|
|
plane.ic = DivScale32 (1, plane.c);
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ceiling/floor flags
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SECF_ABSLIGHTING = 1 // floor/ceiling light is absolute, not relative
|
|
|
|
};
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
// Internal sector flags
|
2006-02-24 04:48:15 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SECF_FAKEFLOORONLY = 2, // when used as heightsec in R_FakeFlat, only copies floor
|
|
|
|
SECF_CLIPFAKEPLANES = 4, // as a heightsec, clip planes to target sector's planes
|
|
|
|
SECF_NOFAKELIGHT = 8, // heightsec does not change lighting
|
|
|
|
SECF_IGNOREHEIGHTSEC= 16, // heightsec is only for triggering sector actions
|
|
|
|
SECF_UNDERWATER = 32, // sector is underwater
|
|
|
|
SECF_FORCEDUNDERWATER= 64, // sector is forced to be underwater
|
2006-10-20 04:04:04 +00:00
|
|
|
SECF_UNDERWATERMASK = 32+64,
|
|
|
|
SECF_DRAWN = 128, // sector has been drawn at least once
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SECF_SILENT = 1, // actors in sector make no noise
|
|
|
|
SECF_NOFALLINGDAMAGE= 2, // No falling damage in this sector
|
2008-05-22 19:35:38 +00:00
|
|
|
SECF_FLOORDROP = 4, // all actors standing on this floor will remain on it when it lowers very fast.
|
2008-05-11 21:16:32 +00:00
|
|
|
};
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
struct FDynamicColormap;
|
|
|
|
|
|
|
|
struct FLightStack
|
|
|
|
{
|
|
|
|
secplane_t Plane; // Plane above this light (points up)
|
|
|
|
sector_t *Master; // Sector to get light from (NULL for owner)
|
|
|
|
BITFIELD bBottom:1; // Light is from the bottom of a block?
|
|
|
|
BITFIELD bFlooder:1; // Light floods lower lights until another flooder is reached?
|
|
|
|
BITFIELD bOverlaps:1; // Plane overlaps the next one
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FExtraLight
|
|
|
|
{
|
|
|
|
short Tag;
|
|
|
|
WORD NumLights;
|
|
|
|
WORD NumUsedLights;
|
|
|
|
FLightStack *Lights; // Lights arranged from top to bottom
|
|
|
|
|
2008-03-21 17:35:49 +00:00
|
|
|
void InsertLight (const secplane_t &plane, line_t *line, int type);
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-03-18 18:18:18 +00:00
|
|
|
// this substructure contains a few sector properties that are stored in dynamic arrays
|
|
|
|
// These must not be copied by R_FakeFlat etc. or bad things will happen.
|
|
|
|
struct sector_t;
|
|
|
|
|
2008-03-20 21:12:03 +00:00
|
|
|
struct FLinkedSector
|
|
|
|
{
|
|
|
|
sector_t *Sector;
|
|
|
|
int Type;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-18 18:18:18 +00:00
|
|
|
struct extsector_t
|
|
|
|
{
|
2008-03-22 12:17:52 +00:00
|
|
|
// Boom sector transfer information
|
|
|
|
struct fakefloor
|
|
|
|
{
|
|
|
|
TArray<sector_t *> Sectors;
|
|
|
|
} FakeFloor;
|
|
|
|
|
2008-03-19 09:53:23 +00:00
|
|
|
// 3DMIDTEX information
|
2008-03-18 18:18:18 +00:00
|
|
|
struct midtex
|
|
|
|
{
|
|
|
|
struct plane
|
|
|
|
{
|
|
|
|
TArray<sector_t *> AttachedSectors; // all sectors containing 3dMidtex lines attached to this sector
|
2008-03-21 17:35:49 +00:00
|
|
|
TArray<line_t *> AttachedLines; // all 3dMidtex lines attached to this sector
|
2008-03-18 18:18:18 +00:00
|
|
|
} Floor, Ceiling;
|
|
|
|
} Midtex;
|
2008-03-19 09:53:23 +00:00
|
|
|
|
2008-03-20 21:12:03 +00:00
|
|
|
// Linked sector information
|
2008-03-19 09:53:23 +00:00
|
|
|
struct linked
|
|
|
|
{
|
2008-03-20 21:12:03 +00:00
|
|
|
struct plane
|
|
|
|
{
|
|
|
|
TArray<FLinkedSector> Sectors;
|
|
|
|
} Floor, Ceiling;
|
2008-03-19 09:53:23 +00:00
|
|
|
} Linked;
|
2008-03-18 18:18:18 +00:00
|
|
|
|
|
|
|
void Serialize(FArchive &arc);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
struct sector_t
|
|
|
|
{
|
|
|
|
// Member functions
|
2008-03-20 21:12:03 +00:00
|
|
|
bool IsLinked(sector_t *other, bool ceiling) const;
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t FindLowestFloorSurrounding (vertex_t **v) const;
|
|
|
|
fixed_t FindHighestFloorSurrounding (vertex_t **v) const;
|
|
|
|
fixed_t FindNextHighestFloor (vertex_t **v) const;
|
|
|
|
fixed_t FindNextLowestFloor (vertex_t **v) const;
|
|
|
|
fixed_t FindLowestCeilingSurrounding (vertex_t **v) const; // jff 2/04/98
|
|
|
|
fixed_t FindHighestCeilingSurrounding (vertex_t **v) const; // jff 2/04/98
|
|
|
|
fixed_t FindNextLowestCeiling (vertex_t **v) const; // jff 2/04/98
|
|
|
|
fixed_t FindNextHighestCeiling (vertex_t **v) const; // jff 2/04/98
|
|
|
|
fixed_t FindShortestTextureAround () const; // jff 2/04/98
|
|
|
|
fixed_t FindShortestUpperAround () const; // jff 2/04/98
|
|
|
|
sector_t *FindModelFloorSector (fixed_t floordestheight) const; // jff 2/04/98
|
|
|
|
sector_t *FindModelCeilingSector (fixed_t floordestheight) const; // jff 2/04/98
|
|
|
|
int FindMinSurroundingLight (int max) const;
|
|
|
|
sector_t *NextSpecialSector (int type, sector_t *prev) const; // [RH]
|
|
|
|
fixed_t FindLowestCeilingPoint (vertex_t **v) const;
|
|
|
|
fixed_t FindHighestFloorPoint (vertex_t **v) const;
|
|
|
|
void AdjustFloorClip () const;
|
2007-10-29 22:15:46 +00:00
|
|
|
void SetColor(int r, int g, int b, int desat);
|
|
|
|
void SetFade(int r, int g, int b);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Member variables
|
|
|
|
fixed_t CenterFloor () const { return floorplane.ZatPoint (soundorg[0], soundorg[1]); }
|
|
|
|
fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (soundorg[0], soundorg[1]); }
|
|
|
|
|
|
|
|
// [RH] store floor and ceiling planes instead of heights
|
|
|
|
secplane_t floorplane, ceilingplane;
|
|
|
|
fixed_t floortexz, ceilingtexz; // [RH] used for wall texture mapping
|
|
|
|
|
|
|
|
// [RH] give floor and ceiling even more properties
|
|
|
|
FDynamicColormap *ColorMap; // [RH] Per-sector colormap
|
|
|
|
|
|
|
|
// killough 3/7/98: floor and ceiling texture offsets
|
|
|
|
fixed_t floor_xoffs, floor_yoffs;
|
|
|
|
fixed_t ceiling_xoffs, ceiling_yoffs;
|
|
|
|
|
|
|
|
// [RH] floor and ceiling texture scales
|
|
|
|
fixed_t floor_xscale, floor_yscale;
|
|
|
|
fixed_t ceiling_xscale, ceiling_yscale;
|
|
|
|
|
|
|
|
// [RH] floor and ceiling texture rotation
|
|
|
|
angle_t floor_angle, ceiling_angle;
|
|
|
|
|
|
|
|
fixed_t base_ceiling_angle, base_ceiling_yoffs;
|
|
|
|
fixed_t base_floor_angle, base_floor_yoffs;
|
|
|
|
|
|
|
|
BYTE FloorLight, CeilingLight;
|
|
|
|
BYTE FloorFlags, CeilingFlags;
|
2007-11-04 08:39:05 +00:00
|
|
|
int floorpic, ceilingpic;
|
2006-02-24 04:48:15 +00:00
|
|
|
BYTE lightlevel;
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
TObjPtr<AActor> SoundTarget;
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE soundtraversed; // 0 = untraversed, 1,2 = sndlines -1
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
short special;
|
|
|
|
short tag;
|
|
|
|
int nexttag,firsttag; // killough 1/30/98: improves searches for tags.
|
|
|
|
|
2006-04-11 08:36:23 +00:00
|
|
|
int sky;
|
2006-02-24 04:48:15 +00:00
|
|
|
short seqType; // this sector's sound sequence
|
|
|
|
|
|
|
|
fixed_t soundorg[3]; // origin for any sounds played by the sector
|
|
|
|
int validcount; // if == validcount, already checked
|
|
|
|
AActor* thinglist; // list of mobjs in sector
|
|
|
|
|
|
|
|
// killough 8/28/98: friction is a sector property, not an mobj property.
|
|
|
|
// these fields used to be in AActor, but presented performance problems
|
|
|
|
// when processed as mobj properties. Fix is to make them sector properties.
|
|
|
|
fixed_t friction, movefactor;
|
|
|
|
|
|
|
|
// thinker_t for reversable actions
|
2008-03-12 02:56:11 +00:00
|
|
|
TObjPtr<DSectorEffect> floordata; // jff 2/22/98 make thinkers on
|
|
|
|
TObjPtr<DSectorEffect> ceilingdata; // floors, ceilings, lighting,
|
|
|
|
TObjPtr<DSectorEffect> lightingdata; // independent of one another
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// jff 2/26/98 lockout machinery for stairbuilding
|
|
|
|
SBYTE stairlock; // -2 on first locked -1 after thinker done 0 normally
|
|
|
|
SWORD prevsec; // -1 or number of sector for previous step
|
|
|
|
SWORD nextsec; // -1 or number of next step sector
|
|
|
|
|
|
|
|
short linecount;
|
2008-03-21 17:35:49 +00:00
|
|
|
struct line_t **lines; // [linecount] size
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// killough 3/7/98: support flat heights drawn at another sector's heights
|
|
|
|
sector_t *heightsec; // other sector, or NULL if no other sector
|
|
|
|
|
|
|
|
DWORD bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps
|
|
|
|
// [RH] these can also be blend values if
|
|
|
|
// the alpha mask is non-zero
|
|
|
|
|
|
|
|
// list of mobjs that are at least partially in the sector
|
|
|
|
// thinglist is a subset of touching_thinglist
|
|
|
|
struct msecnode_s *touching_thinglist; // phares 3/14/98
|
|
|
|
|
|
|
|
float gravity; // [RH] Sector gravity (1.0 is normal)
|
|
|
|
short damage; // [RH] Damage to do while standing on floor
|
|
|
|
short mod; // [RH] Means-of-death for applied damage
|
|
|
|
|
|
|
|
WORD ZoneNumber; // [RH] Zone this sector belongs to
|
2008-05-11 21:16:32 +00:00
|
|
|
WORD MoreFlags; // [RH] Internal sector flags
|
|
|
|
DWORD Flags; // Sector flags
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Action specials for sectors. Like Skull Tag, but more
|
|
|
|
// flexible in a Bloody way. SecActTarget forms a list of actors
|
|
|
|
// joined by their tracer fields. When a potential sector action
|
|
|
|
// occurs, SecActTarget's TriggerAction method is called.
|
2008-03-12 02:56:11 +00:00
|
|
|
TObjPtr<ASectorAction> SecActTarget;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] The sky box to render for this sector. NULL means use a
|
|
|
|
// regular sky.
|
2008-03-12 02:56:11 +00:00
|
|
|
TObjPtr<ASkyViewpoint> FloorSkyBox, CeilingSkyBox;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Planes that partition this sector into different light zones.
|
|
|
|
FExtraLight *ExtraLights;
|
|
|
|
|
|
|
|
vertex_t *Triangle[3]; // Three points that can define a plane
|
2006-04-11 16:27:41 +00:00
|
|
|
short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap)
|
2008-03-18 18:18:18 +00:00
|
|
|
|
|
|
|
extsector_t * e; // This stores data that requires construction/destruction. Such data must not be copied by R_FakeFlat.
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReverbContainer;
|
|
|
|
struct zone_t
|
|
|
|
{
|
|
|
|
ReverbContainer *Environment;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// The SideDef.
|
|
|
|
//
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
class DBaseDecal;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
WALLF_ABSLIGHTING = 1, // Light is absolute instead of relative
|
|
|
|
WALLF_NOAUTODECALS = 2, // Do not attach impact decals to this wall
|
2008-05-30 06:56:50 +00:00
|
|
|
WALLF_AUTOCONTRAST = 4, // Automatically handle fake contrast in side_t::GetLightLevel
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-03-21 17:35:49 +00:00
|
|
|
struct side_t
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-21 17:35:49 +00:00
|
|
|
enum ETexpart
|
|
|
|
{
|
|
|
|
top=0,
|
|
|
|
mid=1,
|
|
|
|
bottom=2
|
|
|
|
};
|
|
|
|
struct part
|
|
|
|
{
|
|
|
|
fixed_t xoffset;
|
|
|
|
fixed_t yoffset;
|
|
|
|
int texture;
|
|
|
|
//int Light;
|
|
|
|
};
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
sector_t* sector; // Sector the SideDef is facing.
|
2006-04-12 01:50:09 +00:00
|
|
|
DBaseDecal* AttachedDecals; // [RH] Decals bound to the wall
|
2008-03-21 17:35:49 +00:00
|
|
|
part textures[3];
|
2008-05-30 06:56:50 +00:00
|
|
|
DWORD linenum;
|
2006-02-24 04:48:15 +00:00
|
|
|
DWORD LeftSide, RightSide; // [RH] Group walls into loops
|
|
|
|
WORD TexelLength;
|
2008-05-23 07:54:09 +00:00
|
|
|
SWORD Light;
|
2006-02-24 04:48:15 +00:00
|
|
|
BYTE Flags;
|
|
|
|
|
|
|
|
int GetLightLevel (bool foggy, int baselight) const;
|
2008-03-21 17:35:49 +00:00
|
|
|
|
|
|
|
int GetTexture(int which) const
|
|
|
|
{
|
|
|
|
return textures[which].texture;
|
|
|
|
}
|
|
|
|
void SetTexture(int which, int tex)
|
|
|
|
{
|
|
|
|
textures[which].texture = tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTextureXOffset(int which, fixed_t offset)
|
|
|
|
{
|
|
|
|
textures[which].xoffset = offset;
|
|
|
|
}
|
|
|
|
void SetTextureXOffset(fixed_t offset)
|
|
|
|
{
|
|
|
|
textures[top].xoffset =
|
|
|
|
textures[mid].xoffset =
|
|
|
|
textures[bottom].xoffset = offset;
|
|
|
|
}
|
|
|
|
fixed_t GetTextureXOffset(int which) const
|
|
|
|
{
|
|
|
|
return textures[which].xoffset;
|
|
|
|
}
|
|
|
|
void AddTextureXOffset(int which, fixed_t delta)
|
|
|
|
{
|
|
|
|
textures[which].xoffset += delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTextureYOffset(int which, fixed_t offset)
|
|
|
|
{
|
|
|
|
textures[which].yoffset = offset;
|
|
|
|
}
|
|
|
|
void SetTextureYOffset(fixed_t offset)
|
|
|
|
{
|
|
|
|
textures[top].yoffset =
|
|
|
|
textures[mid].yoffset =
|
|
|
|
textures[bottom].yoffset = offset;
|
|
|
|
}
|
|
|
|
fixed_t GetTextureYOffset(int which) const
|
|
|
|
{
|
|
|
|
return textures[which].yoffset;
|
|
|
|
}
|
|
|
|
void AddTextureYOffset(int which, fixed_t delta)
|
|
|
|
{
|
|
|
|
textures[which].yoffset += delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetInterpolation(int position)
|
|
|
|
{
|
|
|
|
setinterpolation(EInterpType(INTERP_WallPanning_Top+position), this);
|
|
|
|
}
|
|
|
|
void StopInterpolation(int position)
|
|
|
|
{
|
2008-03-22 09:26:59 +00:00
|
|
|
stopinterpolation(EInterpType(INTERP_WallPanning_Top+position), this);
|
2008-03-21 17:35:49 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-03-21 17:35:49 +00:00
|
|
|
FArchive &operator<< (FArchive &arc, side_t::part &p);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Move clipping aid for LineDefs.
|
|
|
|
//
|
|
|
|
enum slopetype_t
|
|
|
|
{
|
|
|
|
ST_HORIZONTAL,
|
|
|
|
ST_VERTICAL,
|
|
|
|
ST_POSITIVE,
|
|
|
|
ST_NEGATIVE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-21 17:35:49 +00:00
|
|
|
struct line_t
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
vertex_t *v1, *v2; // vertices, from v1 to v2
|
|
|
|
fixed_t dx, dy; // precalculated v2 - v1 for side checking
|
|
|
|
DWORD flags;
|
2008-05-02 10:55:48 +00:00
|
|
|
DWORD activation; // activation type
|
|
|
|
int special;
|
|
|
|
fixed_t Alpha; // <--- translucency (0-255/255=opaque)
|
|
|
|
int id; // <--- same as tag or set with Line_SetIdentification
|
2006-04-16 13:29:50 +00:00
|
|
|
int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width)
|
2006-04-11 08:36:23 +00:00
|
|
|
int firstid, nextid;
|
2008-03-21 17:35:49 +00:00
|
|
|
DWORD sidenum[2]; // sidenum[1] will be NO_SIDE if one sided
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t bbox[4]; // bounding box, for the extent of the LineDef.
|
|
|
|
slopetype_t slopetype; // To aid move clipping.
|
|
|
|
sector_t *frontsector, *backsector;
|
|
|
|
int validcount; // if == validcount, already checked
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// phares 3/14/98
|
|
|
|
//
|
|
|
|
// Sector list node showing all sectors an object appears in.
|
|
|
|
//
|
|
|
|
// There are two threads that flow through these nodes. The first thread
|
|
|
|
// starts at touching_thinglist in a sector_t and flows through the m_snext
|
|
|
|
// links to find all mobjs that are entirely or partially in the sector.
|
|
|
|
// The second thread starts at touching_sectorlist in a AActor and flows
|
|
|
|
// through the m_tnext links to find all sectors a thing touches. This is
|
|
|
|
// useful when applying friction or push effects to sectors. These effects
|
|
|
|
// can be done as thinkers that act upon all objects touching their sectors.
|
|
|
|
// As an mobj moves through the world, these nodes are created and
|
|
|
|
// destroyed, with the links changed appropriately.
|
|
|
|
//
|
|
|
|
// For the links, NULL means top or end of list.
|
|
|
|
|
|
|
|
typedef struct msecnode_s
|
|
|
|
{
|
|
|
|
sector_t *m_sector; // a sector containing this object
|
|
|
|
AActor *m_thing; // this object
|
|
|
|
struct msecnode_s *m_tprev; // prev msecnode_t for this thing
|
|
|
|
struct msecnode_s *m_tnext; // next msecnode_t for this thing
|
|
|
|
struct msecnode_s *m_sprev; // prev msecnode_t for this sector
|
|
|
|
struct msecnode_s *m_snext; // next msecnode_t for this sector
|
2006-09-14 00:02:31 +00:00
|
|
|
bool visited; // killough 4/4/98, 4/7/98: used in search algorithms
|
2006-02-24 04:48:15 +00:00
|
|
|
} msecnode_t;
|
|
|
|
|
|
|
|
//
|
|
|
|
// A SubSector.
|
|
|
|
// References a Sector.
|
|
|
|
// Basically, this is a list of LineSegs indicating the visible walls that
|
|
|
|
// define (all or some) sides of a convex BSP leaf.
|
|
|
|
//
|
|
|
|
struct FPolyObj;
|
|
|
|
typedef struct subsector_s
|
|
|
|
{
|
|
|
|
sector_t *sector;
|
|
|
|
DWORD numlines;
|
|
|
|
DWORD firstline;
|
|
|
|
FPolyObj *poly;
|
|
|
|
int validcount;
|
|
|
|
fixed_t CenterX, CenterY;
|
|
|
|
} subsector_t;
|
|
|
|
|
|
|
|
//
|
|
|
|
// The LineSeg.
|
|
|
|
//
|
|
|
|
struct seg_s
|
|
|
|
{
|
|
|
|
vertex_t* v1;
|
|
|
|
vertex_t* v2;
|
|
|
|
|
|
|
|
side_t* sidedef;
|
|
|
|
line_t* linedef;
|
|
|
|
|
|
|
|
// Sector references. Could be retrieved from linedef, too.
|
|
|
|
sector_t* frontsector;
|
|
|
|
sector_t* backsector; // NULL for one-sided lines
|
|
|
|
|
|
|
|
subsector_t* Subsector;
|
|
|
|
seg_s* PartnerSeg;
|
|
|
|
|
|
|
|
BITFIELD bPolySeg:1;
|
|
|
|
};
|
|
|
|
typedef struct seg_s seg_t;
|
|
|
|
|
|
|
|
// ===== Polyobj data =====
|
|
|
|
typedef struct FPolyObj
|
|
|
|
{
|
|
|
|
int numsegs;
|
|
|
|
seg_t **segs;
|
|
|
|
fixed_t startSpot[3];
|
|
|
|
vertex_t *originalPts; // used as the base for the rotations
|
|
|
|
vertex_t *prevPts; // use to restore the old point values
|
|
|
|
angle_t angle;
|
|
|
|
int tag; // reference tag assigned in HereticEd
|
|
|
|
int bbox[4];
|
|
|
|
int validcount;
|
|
|
|
int crush; // should the polyobj attempt to crush mobjs?
|
|
|
|
bool bHurtOnTouch; // should the polyobj hurt anything it touches?
|
|
|
|
int seqType;
|
|
|
|
fixed_t size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT)
|
|
|
|
DThinker *specialdata; // pointer to a thinker, if the poly is moving
|
|
|
|
} polyobj_t;
|
|
|
|
|
|
|
|
//
|
|
|
|
// BSP node.
|
|
|
|
//
|
|
|
|
struct node_s
|
|
|
|
{
|
|
|
|
// Partition line.
|
|
|
|
fixed_t x;
|
|
|
|
fixed_t y;
|
|
|
|
fixed_t dx;
|
|
|
|
fixed_t dy;
|
|
|
|
fixed_t bbox[2][4]; // Bounding box for each child.
|
|
|
|
union
|
|
|
|
{
|
|
|
|
void *children[2]; // If bit 0 is set, it's a subsector.
|
|
|
|
int intchildren[2]; // Used by nodebuilder.
|
|
|
|
};
|
|
|
|
};
|
|
|
|
typedef struct node_s node_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct polyblock_s
|
|
|
|
{
|
|
|
|
polyobj_t *polyobj;
|
|
|
|
struct polyblock_s *prev;
|
|
|
|
struct polyblock_s *next;
|
|
|
|
} polyblock_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// posts are runs of non masked source pixels
|
|
|
|
struct post_s
|
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE topdelta; // -1 is the last post in a column
|
|
|
|
BYTE length; // length data bytes follows
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
typedef struct post_s post_t;
|
|
|
|
|
|
|
|
// column_t is a list of 0 or more post_t, (byte)-1 terminated
|
|
|
|
typedef post_t column_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// OTHER TYPES
|
|
|
|
//
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
typedef BYTE lighttable_t; // This could be wider for >8 bit display.
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Patches.
|
|
|
|
// A patch holds one or more columns.
|
|
|
|
// Patches are used for sprites and all masked pictures, and we compose
|
|
|
|
// textures from the TEXTURE1/2 lists of patches.
|
|
|
|
struct patch_t
|
|
|
|
{
|
|
|
|
SWORD width; // bounding box size
|
|
|
|
SWORD height;
|
|
|
|
SWORD leftoffset; // pixels to the left of origin
|
|
|
|
SWORD topoffset; // pixels below the origin
|
|
|
|
DWORD columnofs[8]; // only [width] used
|
|
|
|
// the [0] is &columnofs[width]
|
|
|
|
};
|
|
|
|
|
2006-08-20 12:55:46 +00:00
|
|
|
class FileReader;
|
|
|
|
|
2007-12-20 04:36:43 +00:00
|
|
|
// All FTextures present their data to the world in 8-bit format, but if
|
|
|
|
// the source data is something else, this is it.
|
|
|
|
enum FTextureFormat
|
|
|
|
{
|
|
|
|
TEX_Pal,
|
|
|
|
TEX_Gray,
|
|
|
|
TEX_RGB, // Actually ARGB
|
|
|
|
TEX_DXT1,
|
|
|
|
TEX_DXT2,
|
|
|
|
TEX_DXT3,
|
|
|
|
TEX_DXT4,
|
|
|
|
TEX_DXT5,
|
|
|
|
};
|
|
|
|
|
|
|
|
class FNativeTexture;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Base texture class
|
|
|
|
class FTexture
|
|
|
|
{
|
|
|
|
public:
|
2006-08-20 12:55:46 +00:00
|
|
|
static FTexture *CreateTexture(int lumpnum, int usetype);
|
2006-02-24 04:48:15 +00:00
|
|
|
virtual ~FTexture ();
|
|
|
|
|
|
|
|
SWORD LeftOffset, TopOffset;
|
|
|
|
|
|
|
|
BYTE WidthBits, HeightBits;
|
2007-04-29 12:07:27 +00:00
|
|
|
|
|
|
|
fixed_t xScale;
|
|
|
|
fixed_t yScale;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
char Name[9];
|
|
|
|
BYTE UseType; // This texture's primary purpose
|
|
|
|
|
|
|
|
BYTE bNoDecals:1; // Decals should not stick to texture
|
|
|
|
BYTE bNoRemap0:1; // Do not remap color 0 (used by front layer of parallax skies)
|
|
|
|
BYTE bWorldPanning:1; // Texture is panned in world units rather than texels
|
|
|
|
BYTE bMasked:1; // Texture (might) have holes
|
|
|
|
BYTE bAlphaTexture:1; // Texture is an alpha channel without color information
|
|
|
|
BYTE bHasCanvas:1; // Texture is based off FCanvasTexture
|
2006-04-11 16:27:41 +00:00
|
|
|
BYTE bWarped:2; // This is a warped texture. Used to avoid multiple warps on one texture
|
2006-08-20 12:55:46 +00:00
|
|
|
BYTE bIsPatch:1; // 1 if an FPatchTexture. Required to fix FMultipatchTexture::CheckForHacks
|
2008-04-13 11:40:53 +00:00
|
|
|
BYTE bComplex:1; // Will be used to mark extended MultipatchTextures that have to be
|
|
|
|
// fully composited before subjected to any kinf of postprocessing instead of
|
|
|
|
// doing it per patch.
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
WORD Rotations;
|
|
|
|
|
|
|
|
enum // UseTypes
|
|
|
|
{
|
|
|
|
TEX_Any,
|
|
|
|
TEX_Wall,
|
|
|
|
TEX_Flat,
|
|
|
|
TEX_Sprite,
|
|
|
|
TEX_WallPatch,
|
|
|
|
TEX_Build,
|
|
|
|
TEX_SkinSprite,
|
|
|
|
TEX_Decal,
|
|
|
|
TEX_MiscPatch,
|
|
|
|
TEX_FontChar,
|
|
|
|
TEX_Override, // For patches between TX_START/TX_END
|
2006-08-20 12:55:46 +00:00
|
|
|
TEX_Autopage, // Automap background - used to enable the use of FAutomapTexture
|
2006-02-24 04:48:15 +00:00
|
|
|
TEX_Null,
|
2008-05-23 14:04:16 +00:00
|
|
|
TEX_FirstDefined,
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Span
|
|
|
|
{
|
|
|
|
WORD TopOffset;
|
|
|
|
WORD Length; // A length of 0 terminates this column
|
|
|
|
};
|
|
|
|
|
|
|
|
// Returns a single column of the texture
|
|
|
|
virtual const BYTE *GetColumn (unsigned int column, const Span **spans_out) = 0;
|
|
|
|
|
|
|
|
// Returns the whole texture, stored in column-major order
|
|
|
|
virtual const BYTE *GetPixels () = 0;
|
2007-12-20 18:53:35 +00:00
|
|
|
|
2008-04-16 18:17:20 +00:00
|
|
|
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL);
|
2008-04-22 18:48:30 +00:00
|
|
|
int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL);
|
2007-12-20 18:53:35 +00:00
|
|
|
virtual bool UseBasePalette();
|
2007-12-28 11:17:52 +00:00
|
|
|
virtual int GetSourceLump() { return -1; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
virtual void Unload () = 0;
|
|
|
|
|
2007-12-20 04:36:43 +00:00
|
|
|
// Returns the native pixel format for this image
|
|
|
|
virtual FTextureFormat GetFormat();
|
|
|
|
|
|
|
|
// Returns a native 3D representation of the texture
|
2008-01-10 04:11:38 +00:00
|
|
|
FNativeTexture *GetNative(bool wrapping);
|
2007-12-20 04:36:43 +00:00
|
|
|
|
|
|
|
// Frees the native 3D representation of the texture
|
|
|
|
void KillNative();
|
|
|
|
|
|
|
|
// Fill the native texture buffer with pixel data for this image
|
2007-12-20 18:53:35 +00:00
|
|
|
virtual void FillBuffer(BYTE *buff, int pitch, int height, FTextureFormat fmt);
|
2007-12-20 04:36:43 +00:00
|
|
|
|
2006-08-20 12:55:46 +00:00
|
|
|
int GetWidth () { return Width; }
|
|
|
|
int GetHeight () { return Height; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-01-29 18:47:33 +00:00
|
|
|
int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
|
|
|
int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
2006-08-22 21:45:12 +00:00
|
|
|
|
2008-01-29 18:47:33 +00:00
|
|
|
int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
|
|
|
int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
2006-08-22 21:45:12 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
virtual void SetFrontSkyLayer();
|
|
|
|
|
2008-04-14 18:51:05 +00:00
|
|
|
void CopyToBlock (BYTE *dest, int dwidth, int dheight, int x, int y, const BYTE *translation=NULL)
|
|
|
|
{
|
|
|
|
CopyToBlock(dest, dwidth, dheight, x, y, 0, translation);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CopyToBlock (BYTE *dest, int dwidth, int dheight, int x, int y, int rotate, const BYTE *translation=NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Returns true if the next call to GetPixels() will return an image different from the
|
|
|
|
// last call to GetPixels(). This should be considered valid only if a call to CheckModified()
|
|
|
|
// is immediately followed by a call to GetPixels().
|
|
|
|
virtual bool CheckModified ();
|
2007-12-20 04:36:43 +00:00
|
|
|
|
2006-08-20 12:55:46 +00:00
|
|
|
static void InitGrayMap();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-04-29 12:07:27 +00:00
|
|
|
void CopySize(FTexture *BaseTexture)
|
|
|
|
{
|
|
|
|
Width = BaseTexture->GetWidth();
|
|
|
|
Height = BaseTexture->GetHeight();
|
|
|
|
TopOffset = BaseTexture->TopOffset;
|
|
|
|
LeftOffset = BaseTexture->LeftOffset;
|
|
|
|
WidthBits = BaseTexture->WidthBits;
|
|
|
|
HeightBits = BaseTexture->HeightBits;
|
|
|
|
xScale = BaseTexture->xScale;
|
|
|
|
yScale = BaseTexture->yScale;
|
|
|
|
WidthMask = (1 << WidthBits) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetScaledSize(int fitwidth, int fitheight)
|
|
|
|
{
|
|
|
|
xScale = DivScale16(Width, fitwidth);
|
|
|
|
yScale = DivScale16(Height,fitheight);
|
|
|
|
// compensate for roundoff errors
|
|
|
|
if (MulScale16(xScale, fitwidth) != Width) xScale++;
|
|
|
|
if (MulScale16(yScale, fitheight) != Height) yScale++;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
protected:
|
|
|
|
WORD Width, Height, WidthMask;
|
2006-08-20 12:55:46 +00:00
|
|
|
static BYTE GrayMap[256];
|
2007-12-20 04:36:43 +00:00
|
|
|
FNativeTexture *Native;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-08-20 12:55:46 +00:00
|
|
|
FTexture ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
Span **CreateSpans (const BYTE *pixels) const;
|
|
|
|
void FreeSpans (Span **spans) const;
|
|
|
|
void CalcBitSize ();
|
|
|
|
|
|
|
|
static void FlipSquareBlock (BYTE *block, int x, int y);
|
|
|
|
static void FlipSquareBlockRemap (BYTE *block, int x, int y, const BYTE *remap);
|
2006-05-19 05:14:37 +00:00
|
|
|
static void FlipNonSquareBlock (BYTE *blockto, const BYTE *blockfrom, int x, int y, int srcpitch);
|
2008-02-09 03:09:56 +00:00
|
|
|
static void FlipNonSquareBlockRemap (BYTE *blockto, const BYTE *blockfrom, int x, int y, int srcpitch, const BYTE *remap);
|
2007-12-27 04:30:12 +00:00
|
|
|
|
|
|
|
friend class D3DTex;
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Texture manager
|
|
|
|
class FTextureManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FTextureManager ();
|
|
|
|
~FTextureManager ();
|
|
|
|
|
|
|
|
// Get texture without translation
|
|
|
|
FTexture *operator[] (int texnum)
|
|
|
|
{
|
|
|
|
if ((size_t)texnum >= Textures.Size()) return NULL;
|
|
|
|
return Textures[texnum].Texture;
|
|
|
|
}
|
|
|
|
FTexture *operator[] (const char *texname)
|
|
|
|
{
|
|
|
|
int texnum = GetTexture (texname, FTexture::TEX_MiscPatch);
|
2008-04-12 15:31:18 +00:00
|
|
|
if (texnum==-1) return NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
return Textures[texnum].Texture;
|
|
|
|
}
|
2008-01-27 09:38:37 +00:00
|
|
|
FTexture *FindTexture(const char *texname, int usetype = FTexture::TEX_MiscPatch, BITFIELD flags = TEXMAN_TryAny);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Get texture with translation
|
|
|
|
FTexture *operator() (int texnum)
|
|
|
|
{
|
|
|
|
if ((size_t)texnum >= Textures.Size()) return NULL;
|
|
|
|
return Textures[Translation[texnum]].Texture;
|
|
|
|
}
|
|
|
|
FTexture *operator() (const char *texname)
|
|
|
|
{
|
|
|
|
int texnum = GetTexture (texname, FTexture::TEX_MiscPatch);
|
2008-04-12 15:31:18 +00:00
|
|
|
if (texnum==-1) return NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
return Textures[Translation[texnum]].Texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTranslation (int fromtexnum, int totexnum)
|
|
|
|
{
|
|
|
|
if ((size_t)fromtexnum < Translation.Size())
|
|
|
|
{
|
|
|
|
if ((size_t)totexnum >= Textures.Size())
|
|
|
|
{
|
|
|
|
totexnum = fromtexnum;
|
|
|
|
}
|
2008-05-30 06:56:50 +00:00
|
|
|
Translation[fromtexnum] = totexnum;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TEXMAN_TryAny = 1,
|
|
|
|
TEXMAN_Overridable = 2,
|
2008-05-23 14:04:16 +00:00
|
|
|
TEXMAN_ReturnFirst = 4,
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int CheckForTexture (const char *name, int usetype, BITFIELD flags=TEXMAN_TryAny);
|
|
|
|
int GetTexture (const char *name, int usetype, BITFIELD flags=0);
|
2007-12-28 11:17:52 +00:00
|
|
|
int ListTextures (const char *name, TArray<int> &list);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void WriteTexture (FArchive &arc, int picnum);
|
|
|
|
int ReadTexture (FArchive &arc);
|
|
|
|
|
2008-03-25 09:43:50 +00:00
|
|
|
void AddTexturesLump (const void *lumpdata, int lumpsize, int deflumpnum, int patcheslump, int firstdup=0, bool texture1=false);
|
2006-02-24 04:48:15 +00:00
|
|
|
void AddTexturesLumps (int lump1, int lump2, int patcheslump);
|
2008-01-26 23:20:34 +00:00
|
|
|
void AddGroup(int wadnum, const char * startlump, const char * endlump, int ns, int usetype);
|
2006-02-24 04:48:15 +00:00
|
|
|
void AddPatches (int lumpnum);
|
|
|
|
void AddTiles (void *tileFile);
|
2008-01-26 23:20:34 +00:00
|
|
|
void AddHiresTextures (int wadnum);
|
2008-05-30 06:56:50 +00:00
|
|
|
void LoadTextureDefs(int wadnum, const char *lumpname);
|
2008-04-12 15:31:18 +00:00
|
|
|
void ParseXTexture(FScanner &sc, int usetype);
|
2008-05-30 06:56:50 +00:00
|
|
|
void SortTexturesByType(int start, int end);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int CreateTexture (int lumpnum, int usetype=FTexture::TEX_Any); // Also calls AddTexture
|
|
|
|
int AddTexture (FTexture *texture);
|
2007-12-28 22:00:41 +00:00
|
|
|
int AddPatch (const char *patchname, int namespc=0, bool tryany = false);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-01-26 23:20:34 +00:00
|
|
|
void LoadTextureX(int wadnum);
|
|
|
|
void AddTexturesForWad(int wadnum);
|
|
|
|
void Init();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Replaces one texture with another. The new texture will be assigned
|
|
|
|
// the same name, slot, and use type as the texture it is replacing.
|
|
|
|
// The old texture will no longer be managed. Set free true if you want
|
|
|
|
// the old texture to be deleted or set it false if you want it to
|
|
|
|
// be left alone in memory. You will still need to delete it at some
|
|
|
|
// point, because the texture manager no longer knows about it.
|
|
|
|
// This function can be used for such things as warping textures.
|
|
|
|
void ReplaceTexture (int picnum, FTexture *newtexture, bool free);
|
|
|
|
|
|
|
|
void UnloadAll ();
|
|
|
|
|
|
|
|
int NumTextures () const { return (int)Textures.Size(); }
|
|
|
|
|
2006-08-20 12:55:46 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
private:
|
|
|
|
struct TextureHash
|
|
|
|
{
|
|
|
|
FTexture *Texture;
|
2008-05-30 06:56:50 +00:00
|
|
|
int HashNext;
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
2008-05-30 06:56:50 +00:00
|
|
|
enum { HASH_END = -1, HASH_SIZE = 1027 };
|
2006-02-24 04:48:15 +00:00
|
|
|
TArray<TextureHash> Textures;
|
2008-05-30 06:56:50 +00:00
|
|
|
TArray<int> Translation;
|
|
|
|
int HashFirst[HASH_SIZE];
|
2006-02-24 04:48:15 +00:00
|
|
|
int DefaultTexture;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern FTextureManager TexMan;
|
|
|
|
|
|
|
|
|
|
|
|
// A vissprite_t is a thing
|
|
|
|
// that will be drawn during a refresh.
|
|
|
|
// I.e. a sprite object that is partly visible.
|
|
|
|
struct vissprite_t
|
|
|
|
{
|
|
|
|
short x1, x2;
|
|
|
|
fixed_t cx; // for line side calculation
|
|
|
|
fixed_t gx, gy; // for fake floor clipping
|
|
|
|
fixed_t gz, gzt; // global bottom / top for silhouette clipping
|
|
|
|
fixed_t startfrac; // horizontal position of x1
|
|
|
|
fixed_t xscale, yscale;
|
|
|
|
fixed_t xiscale; // negative if flipped
|
|
|
|
fixed_t idepth; // 1/z
|
|
|
|
fixed_t texturemid;
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
DWORD FillColor;
|
2006-02-24 04:48:15 +00:00
|
|
|
lighttable_t *colormap;
|
|
|
|
sector_t *heightsec; // killough 3/27/98: height sector for underwater/fake ceiling
|
|
|
|
sector_t *sector; // [RH] sector this sprite is in
|
|
|
|
fixed_t alpha;
|
|
|
|
fixed_t floorclip;
|
|
|
|
FTexture *pic;
|
|
|
|
short renderflags;
|
2007-12-26 16:06:03 +00:00
|
|
|
DWORD Translation; // [RH] for color translation
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
FRenderStyle RenderStyle;
|
2006-02-24 04:48:15 +00:00
|
|
|
BYTE FakeFlatStat; // [RH] which side of fake/floor ceiling sprite is on
|
|
|
|
BYTE bSplitSprite; // [RH] Sprite was split by a drawseg
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
FAKED_Center,
|
|
|
|
FAKED_BelowFloor,
|
|
|
|
FAKED_AboveCeiling
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Sprites are patches with a special naming convention so they can be
|
|
|
|
// recognized by R_InitSprites. The base name is NNNNFx or NNNNFxFx, with
|
|
|
|
// x indicating the rotation, x = 0, 1-7. The sprite and frame specified
|
|
|
|
// by a thing_t is range checked at run time.
|
|
|
|
// A sprite is a patch_t that is assumed to represent a three dimensional
|
|
|
|
// object and may have multiple rotations pre drawn. Horizontal flipping
|
|
|
|
// is used to save space, thus NNNNF2F5 defines a mirrored patch.
|
|
|
|
// Some sprites will only have one picture used for all views: NNNNF0
|
|
|
|
//
|
|
|
|
struct spriteframe_t
|
|
|
|
{
|
|
|
|
WORD Texture[16]; // texture to use for view angles 0-15
|
|
|
|
WORD Flip; // flip (1 = flip) to use for view angles 0-15.
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// A sprite definition:
|
|
|
|
// a number of animation frames.
|
|
|
|
//
|
|
|
|
struct spritedef_t
|
|
|
|
{
|
|
|
|
char name[5];
|
|
|
|
BYTE numframes;
|
|
|
|
WORD spriteframes;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern TArray<spriteframe_t> SpriteFrames;
|
|
|
|
|
|
|
|
//
|
|
|
|
// [RH] Internal "skin" definition.
|
|
|
|
//
|
|
|
|
class FPlayerSkin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
char name[17]; // 16 chars + NULL
|
2008-04-05 12:14:33 +00:00
|
|
|
char face[4]; // 3 chars ([MH] + NULL so can use as a C string)
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE gender; // This skin's gender (not really used)
|
|
|
|
BYTE range0start;
|
|
|
|
BYTE range0end;
|
2006-07-13 10:17:56 +00:00
|
|
|
bool othergame; // [GRB]
|
2008-04-27 22:33:19 +00:00
|
|
|
fixed_t ScaleX;
|
|
|
|
fixed_t ScaleY;
|
2006-02-24 04:48:15 +00:00
|
|
|
int sprite;
|
2006-06-11 11:28:48 +00:00
|
|
|
int crouchsprite;
|
2006-02-24 04:48:15 +00:00
|
|
|
int namespc; // namespace for this skin
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|