* Updated to ZDoom r3249:

- Moved R_AlignFlat out of renderer into main game code (r_ to p_.)
- Moved the code from r_data.cpp to some better fitting places and deleted this file and r_data.h because the remaining parts of it were just a random collection of unrelated functions.
- Updated CMakeLists.txt for last commit.
- Separated all voxel related resource maintenance code from r_things.cpp and r_data.cpp into its own file.
* Adapted GL files to #include changes.
* Added back GL-needed fields to FVoxel, FVoxeldef and FCanvasTexture.

git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1221 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
gez 2011-07-06 12:47:47 +00:00
parent cebc85342e
commit 05888b9577
79 changed files with 731 additions and 724 deletions

View file

@ -2324,10 +2324,6 @@
RelativePath=".\src\r_bsp.cpp"
>
</File>
<File
RelativePath=".\src\r_data.cpp"
>
</File>
<File
RelativePath=".\src\r_draw.cpp"
>
@ -2384,10 +2380,6 @@
RelativePath=".\src\r_bsp.h"
>
</File>
<File
RelativePath=".\src\r_data.h"
>
</File>
<File
RelativePath=".\src\r_defs.h"
>
@ -7141,6 +7133,10 @@
RelativePath=".\src\resources\colormaps.h"
>
</File>
<File
RelativePath=".\src\resources\voxels.h"
>
</File>
</Filter>
<Filter
Name="Resource Sources"
@ -7149,6 +7145,10 @@
RelativePath=".\src\resources\colormaps.cpp"
>
</File>
<File
RelativePath=".\src\resources\voxels.cpp"
>
</File>
</Filter>
<Filter
Name="Textures"

View file

@ -742,7 +742,6 @@ add_executable( zdoom WIN32
po_man.cpp
r_3dfloors.cpp
r_bsp.cpp
r_data.cpp
r_draw.cpp
r_drawt.cpp
r_interpolate.cpp
@ -975,6 +974,7 @@ add_executable( zdoom WIN32
fragglescript/t_variable.cpp
fragglescript/t_cmd.cpp
resources/colormaps.cpp
resources/voxels.cpp
autozend.cpp
)

View file

@ -70,6 +70,7 @@
#include "d_net.h"
#include "v_text.h"
#include "p_lnspec.h"
#include "v_video.h"
extern FILE *Logfile;
extern bool insave;

View file

@ -58,6 +58,7 @@
#include "d_event.h"
#include "m_argv.h"
#include "p_lnspec.h"
#include "v_video.h"
int P_StartScript (AActor *who, line_t *where, int script, char *map, bool backSide,
int arg0, int arg1, int arg2, int always, bool wantResultCode, bool net);

View file

@ -48,6 +48,7 @@
#include "gi.h"
#include "g_level.h"
#include "colormatcher.h"
#include "b_bot.h"
FDecalLib DecalLibrary;

View file

@ -61,7 +61,6 @@
#include "b_bot.h"
#include "p_local.h"
#include "g_game.h"
#include "r_data.h"
#include "a_sharedglobal.h"
#include "sbar.h"
#include "stats.h"
@ -72,6 +71,7 @@
#include "doomstat.h"
#include "m_argv.h"
#include "po_man.h"
#include "v_video.h"
#include "menu/menu.h"
#include "intermission/intermission.h"

View file

@ -37,6 +37,7 @@
#include "p_local.h"
#include "farchive.h"
#include "sbar.h"
#include "v_video.h"

View file

@ -38,7 +38,6 @@
#include "g_level.h"
#include "sc_man.h"
#include "s_sound.h"
#include "r_data.h"
#include "r_sky.h"
#include "t_script.h"
#include "cmdlib.h"

View file

@ -61,7 +61,6 @@
#include "p_local.h"
#include "s_sound.h"
#include "gstrings.h"
#include "r_data.h"
#include "r_sky.h"
#include "r_draw.h"
#include "g_game.h"

View file

@ -42,7 +42,6 @@
#include "m_random.h"
#include "doomstat.h"
#include "wi_stuff.h"
#include "r_data.h"
#include "w_wad.h"
#include "am_map.h"
#include "c_dispatch.h"

View file

@ -2,10 +2,10 @@
#include "info.h"
#include "gi.h"
#include "r_data.h"
#include "a_pickups.h"
#include "templates.h"
#include "g_level.h"
#include "d_player.h"
IMPLEMENT_CLASS (AArmor)

View file

@ -1,13 +1,13 @@
#include "a_lightning.h"
#include "p_lnspec.h"
#include "statnums.h"
#include "r_data.h"
#include "m_random.h"
#include "templates.h"
#include "s_sound.h"
#include "p_acs.h"
#include "r_sky.h"
#include "g_level.h"
#include "r_state.h"
static FRandom pr_lightning ("Lightning");

View file

@ -40,7 +40,6 @@
#include "d_player.h"
#include "doomstat.h"
#include "v_font.h"
#include "r_data.h"
#include "p_spec.h"
EXTERN_CVAR(String, secretmessage)

View file

@ -51,6 +51,7 @@
#include "d_net.h"
#include "colormatcher.h"
#include "v_palette.h"
#include "d_player.h"
#include "../version.h"

View file

@ -46,6 +46,8 @@
#include "g_game.h"
#include "doomstat.h"
#include "g_level.h"
#include "r_state.h"
//#include "resources/voxels.h"
//#include "gl/gl_intern.h"
#include "gl/renderer/gl_renderer.h"

View file

@ -1,8 +1,9 @@
#ifndef __GL_MODELS_H_
#define __GL_MODELS_H_
#include "r_data.h"
#include "gl/utility/gl_geometric.h"
#include "p_pspr.h"
#include "resources/voxels.h"
#define MAX_LODS 4

View file

@ -40,6 +40,7 @@
#include "g_level.h"
#include "sc_man.h"
#include "w_wad.h"
#include "r_state.h"
//#include "gl/gl_intern.h"
#include "gl/data/gl_data.h"

View file

@ -46,6 +46,8 @@
#include "i_system.h"
#include "doomerrors.h"
#include "v_palette.h"
#include "sc_man.h"
#include "cmdlib.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_renderstate.h"

View file

@ -2,9 +2,10 @@
#ifndef __GL_TEXTURE_H
#define __GL_TEXTURE_H
#include "m_fixed.h"
#include "textures/textures.h"
#include "gl/textures/gl_hwtexture.h"
#include "gl/renderer/gl_colormap.h"
#include "r_data.h"
#include "i_system.h"
EXTERN_CVAR(Bool, gl_precache)

View file

@ -38,7 +38,6 @@
#include "gl/system/gl_system.h"
#include "c_cvars.h"
#include "w_wad.h"
#include "r_data.h"
#include "templates.h"
#include "colormatcher.h"
#include "r_translate.h"
@ -47,6 +46,7 @@
#include "win32gliface.h"
#endif
#include "v_palette.h"
#include "sc_man.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/textures/gl_texture.h"

View file

@ -11,6 +11,7 @@
#include "c_console.h"
#include "c_dispatch.h"
#include "r_main.h"
#include "v_video.h"
#include "gl/utility/gl_clock.h"
#include "gl/utility/gl_convert.h"

View file

@ -61,7 +61,7 @@ extern void ClearStrifeTypes();
//
//==========================================================================
int GetSpriteIndex(const char * spritename)
int GetSpriteIndex(const char * spritename, bool add)
{
static char lastsprite[5];
static int lastindex;
@ -87,6 +87,10 @@ int GetSpriteIndex(const char * spritename)
return (lastindex = (int)i);
}
}
if (!add)
{
return (lastindex = -1);
}
spritedef_t temp;
strcpy (temp.name, upper);
temp.numframes = 0;

View file

@ -240,7 +240,7 @@ private:
extern FDoomEdMap DoomEdMap;
int GetSpriteIndex(const char * spritename);
int GetSpriteIndex(const char * spritename, bool add = true);
TArray<FName> &MakeStateNameList(const char * fname);
void AddStateLight(FState *state, const char *lname);

View file

@ -38,6 +38,7 @@
#include "dobject.h"
#include "dthinker.h"
#include "doomtype.h"
#include "farchive.h"
#define LOCAL_SIZE 20
#define NUM_MAPVARS 128

View file

@ -655,11 +655,11 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
int sidenum = int(intptr_t(lines[linenum].sidedef[1]));
if (bsec->floorstat & 64)
{ // floor is aligned to first wall
R_AlignFlat (linenum, sidenum == bsec->wallptr, 0);
P_AlignFlat (linenum, sidenum == bsec->wallptr, 0);
}
if (bsec->ceilingstat & 64)
{ // ceiling is aligned to first wall
R_AlignFlat (linenum, sidenum == bsec->wallptr, 0);
P_AlignFlat (linenum, sidenum == bsec->wallptr, 0);
}
}
for (i = 0; i < numlines; i++)

View file

@ -35,7 +35,6 @@
#include <assert.h>
#include "actor.h"
#include "r_data.h"
#include "r_main.h"
#include "p_conversation.h"
#include "w_wad.h"

View file

@ -3,9 +3,13 @@
#include <tarray.h>
#include "s_sound.h"
#include "textures/textures.h"
struct FStrifeDialogueReply;
class FTexture;
struct FBrokenLines;
struct PClass;
struct FStrifeDialogueItemCheck
{

View file

@ -2357,7 +2357,7 @@ FUNC(LS_Line_AlignCeiling)
I_Error ("Sector_AlignCeiling: Lineid %d is undefined", arg0);
do
{
ret |= R_AlignFlat (line, !!arg1, 1);
ret |= P_AlignFlat (line, !!arg1, 1);
} while ( (line = P_FindLineFromID (arg0, line)) >= 0);
return ret;
}
@ -2372,7 +2372,7 @@ FUNC(LS_Line_AlignFloor)
I_Error ("Sector_AlignFloor: Lineid %d is undefined", arg0);
do
{
ret |= R_AlignFlat (line, !!arg1, 0);
ret |= P_AlignFlat (line, !!arg1, 0);
} while ( (line = P_FindLineFromID (arg0, line)) >= 0);
return ret;
}

View file

@ -547,5 +547,6 @@ FPolyObj *PO_GetPolyobj(int polyNum);
//
#include "p_spec.h"
bool P_AlignFlat (int linenum, int side, int fc);
#endif // __P_LOCAL__

View file

@ -21,10 +21,10 @@
//
//-----------------------------------------------------------------------------
#include "r_data.h"
#include "p_spec.h"
#include "c_cvars.h"
#include "doomstat.h"
#include "r_main.h"
#include "resources/colormaps.h"
@ -772,3 +772,36 @@ bool sector_t::PlaneMoving(int pos)
else
return (ceilingdata != NULL || (planes[ceiling].Flags & PLANEF_BLOCKED));
}
//==========================================================================
//
// P_AlignFlat
//
//==========================================================================
bool P_AlignFlat (int linenum, int side, int fc)
{
line_t *line = lines + linenum;
sector_t *sec = side ? line->backsector : line->frontsector;
if (!sec)
return false;
fixed_t x = line->v1->x;
fixed_t y = line->v1->y;
angle_t angle = R_PointToAngle2 (x, y, line->v2->x, line->v2->y);
angle_t norm = (angle-ANGLE_90) >> ANGLETOFINESHIFT;
fixed_t dist = -DMulScale16 (finecosine[norm], x, finesine[norm], y);
if (side)
{
angle = angle + ANGLE_180;
dist = -dist;
}
sec->SetBase(fc, dist & ((1<<(FRACBITS+8))-1), 0-angle);
return true;
}

View file

@ -3964,7 +3964,7 @@ void P_SetupLevel (char *lumpname, int position)
// preload graphics and sounds
if (precache)
{
R_PrecacheLevel ();
TexMan.PrecacheLevel ();
S_PrecacheLevel ();
}
times[17].Unclock();

View file

@ -34,7 +34,6 @@
#include "doomtype.h"
#include "p_local.h"
#include "r_data.h"
#include "cmdlib.h"
#include "p_lnspec.h"

View file

@ -27,6 +27,7 @@
#include "dsectoreffect.h"
#include "doomdata.h"
#include "r_state.h"
class FScanner;
struct level_info_t;

View file

@ -33,7 +33,6 @@
**
*/
#include "r_data.h"
#include "p_setup.h"
#include "p_lnspec.h"
#include "templates.h"
@ -43,6 +42,7 @@
#include "g_level.h"
#include "v_palette.h"
#include "p_udmf.h"
#include "r_state.h"
#include "resources/colormaps.h"
//===========================================================================

View file

@ -32,7 +32,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "r_data.h"
#include "p_setup.h"
#include "p_lnspec.h"
#include "templates.h"
@ -40,6 +39,8 @@
#include "p_conversation.h"
#include "p_udmf.h"
#include "doomerrors.h"
#include "cmdlib.h"
#include "actor.h"
#define Zd 1
#define St 2

View file

@ -36,7 +36,6 @@
#include "g_level.h"
#include "p_lnspec.h"
#include "doomdata.h"
#include "r_data.h"
#include "m_swap.h"
#include "p_spec.h"
#include "p_local.h"

View file

@ -1,144 +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:
// Refresh module, data I/O, caching, retrieval of graphics
// by name.
//
//-----------------------------------------------------------------------------
#ifndef __R_DATA__
#define __R_DATA__
#include "r_defs.h"
#include "r_state.h"
#include "v_video.h"
class FWadLump;
// A texture that doesn't really exist
class FDummyTexture : public FTexture
{
public:
FDummyTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload ();
void SetSize (int width, int height);
};
// A texture that returns a wiggly version of another texture.
class FWarpTexture : public FTexture
{
public:
FWarpTexture (FTexture *source);
~FWarpTexture ();
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL);
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload ();
bool CheckModified ();
float GetSpeed() const { return Speed; }
int GetSourceLump() { return SourcePic->GetSourceLump(); }
void SetSpeed(float fac) { Speed = fac; }
FTexture *GetRedirect(bool wantwarped);
DWORD GenTime;
protected:
FTexture *SourcePic;
BYTE *Pixels;
Span **Spans;
float Speed;
virtual void MakeTexture (DWORD time);
};
// [GRB] Eternity-like warping
class FWarp2Texture : public FWarpTexture
{
public:
FWarp2Texture (FTexture *source);
protected:
void MakeTexture (DWORD time);
};
// A texture that can be drawn to.
class DSimpleCanvas;
class FCanvasTexture : public FTexture
{
public:
FCanvasTexture (const char *name, int width, int height);
~FCanvasTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload ();
bool CheckModified ();
void RenderView (AActor *viewpoint, int fov);
void RenderGLView(AActor *viewpoint, int fov);
void NeedUpdate() { bNeedsUpdate=true; }
protected:
DSimpleCanvas *Canvas;
BYTE *Pixels;
Span DummySpans[2];
BYTE bNeedsUpdate:1;
BYTE bDidUpdate:1;
BYTE bFirstUpdate:1;
void MakeTexture ();
friend struct FCanvasTextureInfo;
};
// This list keeps track of the cameras that draw into canvas textures.
struct FCanvasTextureInfo
{
FCanvasTextureInfo *Next;
TObjPtr<AActor> Viewpoint;
FCanvasTexture *Texture;
FTextureID PicNum;
int FOV;
static void Add (AActor *viewpoint, FTextureID picnum, int fov);
static void UpdateAll ();
static void EmptyList ();
static void Serialize (FArchive &arc);
static void Mark();
private:
static FCanvasTextureInfo *List;
};
// I/O, setting up the stuff.
void R_InitData (void);
void R_DeinitData ();
void R_PrecacheLevel (void);
// Retrieval.
int R_FindSkin (const char *name, int pclass); // [RH] Find a skin
FVoxel *R_LoadKVX(int lumpnum);
#endif

View file

@ -1137,15 +1137,6 @@ struct FMiniBSP
// posts are runs of non masked source pixels
struct column_t
{
BYTE topdelta; // -1 is the last post in a column
BYTE length; // length data bytes follows
};
//
// OTHER TYPES
//
@ -1251,57 +1242,6 @@ public:
};
// [RH] Voxels from Build
#define MAXVOXMIPS 5
struct kvxslab_t
{
BYTE ztop; // starting z coordinate of top of slab
BYTE zleng; // # of bytes in the color array - slab height
BYTE backfacecull; // low 6 bits tell which of 6 faces are exposed
BYTE col[1/*zleng*/];// color data from top to bottom
};
struct FVoxelMipLevel
{
FVoxelMipLevel();
~FVoxelMipLevel();
int SizeX;
int SizeY;
int SizeZ;
fixed_t PivotX; // 24.8 fixed point
fixed_t PivotY; // ""
fixed_t PivotZ; // ""
int *OffsetX;
short *OffsetXY;
BYTE *SlabData;
};
struct FVoxel
{
int LumpNum;
int NumMips;
int VoxelIndex;
BYTE *Palette;
FVoxelMipLevel Mips[MAXVOXMIPS];
FVoxel();
~FVoxel();
void Remap();
};
struct FVoxelDef
{
FVoxel *Voxel;
int PlacedSpin; // degrees/sec to spin actors without MF_DROPPED set
int DroppedSpin; // degrees/sec to spin actors with MF_DROPPED set
int VoxeldefIndex;
fixed_t Scale;
angle_t AngleOffset; // added to actor's angle to compensate for wrong-facing voxels
};
// [RH] A c-buffer. Used for keeping track of offscreen voxel spans.
struct FCoverageBuffer

View file

@ -2043,6 +2043,18 @@ void R_DrawBorder (int x1, int y1, int x2, int y2)
}
}
//==========================================================================
//
// R_GetColumn
//
//==========================================================================
const BYTE *R_GetColumn (FTexture *tex, int col)
{
return tex->GetColumn (col, NULL);
}
/*
==================
=

View file

@ -23,7 +23,7 @@
#ifndef __R_DRAW__
#define __R_DRAW__
#include "r_data.h"
#include "r_defs.h"
extern "C" int ylookup[MAXHEIGHT];

View file

@ -33,7 +33,6 @@
**
*/
#include "r_data.h"
#include "p_3dmidtex.h"
#include "stats.h"
#include "r_interpolate.h"

View file

@ -1,6 +1,7 @@
#ifndef R_INTERPOLATE_H
#define R_INTERPOLATE_H
#include "dobject.h"
//==========================================================================
//
//

View file

@ -30,7 +30,6 @@
#include "doomdef.h"
// Include the refresh/render data structs.
#include "r_data.h"
//
// Separate header file for each module.
@ -39,6 +38,4 @@
#include "r_things.h"
#include "r_draw.h"
bool R_AlignFlat (int linenum, int side, int fc);
#endif // __R_LOCAL_H__

View file

@ -52,6 +52,8 @@
#include "r_3dfloors.h"
#include "v_palette.h"
#include "po_man.h"
#include "st_start.h"
#include "v_font.h"
#include "resources/colormaps.h"
//#include "gl/data/gl_data.h"
#include "gl/gl_functions.h"
@ -814,7 +816,12 @@ void R_Init ()
{
atterm (R_Shutdown);
R_InitData ();
StartScreen->Progress();
V_InitFonts();
StartScreen->Progress();
R_InitColormaps ();
StartScreen->Progress();
gl_ParseDefs();
R_InitPointToAngle ();
R_InitTables ();
@ -850,7 +857,22 @@ static void R_Shutdown ()
R_DeinitParticles();
R_DeinitTranslationTables();
R_DeinitPlanes();
R_DeinitData();
R_DeinitColormaps ();
FCanvasTextureInfo::EmptyList();
// Free openings
if (openings != NULL)
{
M_Free (openings);
openings = NULL;
}
// Free drawsegs
if (drawsegs != NULL)
{
M_Free (drawsegs);
drawsegs = NULL;
}
}
//==========================================================================

View file

@ -28,9 +28,9 @@
#define NUMCOLORMAPS 32
#include "d_player.h"
#include "r_data.h"
#include "r_state.h"
#include "v_palette.h"
#include "resources/colormaps.h"
//
@ -214,4 +214,24 @@ extern angle_t stacked_angle;
extern void R_CopyStackedViewParameters();
// This list keeps track of the cameras that draw into canvas textures.
struct FCanvasTextureInfo
{
FCanvasTextureInfo *Next;
TObjPtr<AActor> Viewpoint;
FCanvasTexture *Texture;
FTextureID PicNum;
int FOV;
static void Add (AActor *viewpoint, FTextureID picnum, int fov);
static void UpdateAll ();
static void EmptyList ();
static void Serialize (FArchive &arc);
static void Mark();
private:
static FCanvasTextureInfo *List;
};
#endif // __R_MAIN_H__

View file

@ -1787,35 +1787,3 @@ bool R_PlaneInitData ()
return true;
}
//==========================================================================
//
// R_AlignFlat
//
//==========================================================================
bool R_AlignFlat (int linenum, int side, int fc)
{
line_t *line = lines + linenum;
sector_t *sec = side ? line->backsector : line->frontsector;
if (!sec)
return false;
fixed_t x = line->v1->x;
fixed_t y = line->v1->y;
angle_t angle = R_PointToAngle2 (x, y, line->v2->x, line->v2->y);
angle_t norm = (angle-ANGLE_90) >> ANGLETOFINESHIFT;
fixed_t dist = -DMulScale16 (finecosine[norm], x, finesine[norm], y);
if (side)
{
angle = angle + ANGLE_180;
dist = -dist;
}
sec->SetBase(fc, dist & ((1<<(FRACBITS+8))-1), 0-angle);
return true;
}

View file

@ -24,7 +24,6 @@
#define __R_PLANE_H__
#include <stddef.h>
#include "r_data.h"
class ASkyViewpoint;

View file

@ -81,6 +81,7 @@ Low priority:
#include "r_bsp.h"
#include "v_palette.h"
#include "v_font.h"
#include "v_video.h"
#include "resources/colormaps.h"
EXTERN_CVAR (Int, r_polymost)

View file

@ -28,7 +28,6 @@
// Needed for FRACUNIT.
#include "m_fixed.h"
#include "r_data.h"
#include "c_cvars.h"
#include "g_level.h"
#include "r_sky.h"

View file

@ -25,7 +25,6 @@
// Need data structure definitions.
#include "d_player.h"
#include "r_data.h"
//
// Refresh internal data structures,
@ -130,4 +129,6 @@ extern sector_t* viewsector; // [RH] keep track of sector viewing from
extern angle_t xtoviewangle[MAXWIDTH+1];
extern int FieldOfView;
int R_FindSkin (const char *name, int pclass); // [RH] Find a skin
#endif // __R_STATE_H__

View file

@ -60,6 +60,7 @@
#include "v_palette.h"
#include "r_translate.h"
#include "resources/colormaps.h"
#include "resources/voxels.h"
extern fixed_t globaluclip, globaldclip;
@ -96,9 +97,6 @@ TArray<WORD> ParticlesInSubsec;
short zeroarray[MAXWIDTH];
short screenheightarray[MAXWIDTH];
#define MAX_SPRITE_FRAMES 29 // [RH] Macro-ized as in BOOM.
CVAR (Bool, r_drawplayersprites, true, 0) // [RH] Draw player sprites?
CVAR (Bool, r_drawvoxels, true, 0)
@ -113,9 +111,6 @@ TArray<spritedef_t> sprites;
TArray<spriteframe_t> SpriteFrames;
DWORD NumStdSprites; // The first x sprites that don't belong to skins.
TDeletingArray<FVoxel *> Voxels; // used only to auto-delete voxels on exit.
TDeletingArray<FVoxelDef *> VoxelDefs;
int OffscreenBufferWidth, OffscreenBufferHeight;
BYTE *OffscreenColorBuffer;
FCoverageBuffer *OffscreenCoverageBuffer;
@ -128,18 +123,6 @@ sprtemp[MAX_SPRITE_FRAMES];
int maxframe;
char* spritename;
struct VoxelOptions
{
VoxelOptions()
: DroppedSpin(0), PlacedSpin(0), Scale(FRACUNIT), AngleOffset(0)
{}
int DroppedSpin;
int PlacedSpin;
fixed_t Scale;
angle_t AngleOffset;
};
// [RH] skin globals
FPlayerSkin *skins;
size_t numskins;
@ -487,23 +470,9 @@ void R_InitSpriteDefs ()
VHasher *vh = &vhashes[hash];
if (vh->Name == (int)intname)
{
FVoxel *vox = R_LoadKVX(hash);
if (vox == NULL)
FVoxelDef *voxdef = R_LoadVoxelDef(hash, vh->Spin);
if (voxdef != NULL)
{
Printf("%s is not a valid voxel file\n", Wads.GetLumpFullName(hash));
}
else
{
FVoxelDef *voxdef = new FVoxelDef;
voxdef->Voxel = vox;
voxdef->Scale = FRACUNIT;
voxdef->DroppedSpin = voxdef->PlacedSpin = vh->Spin;
voxdef->AngleOffset = 0;
Voxels.Push(vox);
VoxelDefs.Push(voxdef);
if (vh->Frame == ' ' || vh->Frame == '\0')
{ // voxel applies to every sprite frame
for (j = 0; j < MAX_SPRITE_FRAMES; ++j)
@ -573,163 +542,6 @@ static void R_ExtendSpriteFrames(spritedef_t &spr, int frame)
spr.numframes = frame;
}
//==========================================================================
//
// VOX_ReadSpriteNames
//
// Reads a list of sprite names from a VOXELDEF lump.
//
//==========================================================================
static bool VOX_ReadSpriteNames(FScanner &sc, TArray<DWORD> &vsprites)
{
unsigned int i;
vsprites.Clear();
while (sc.GetString())
{
// A sprite name list is terminated by an '=' character.
if (sc.String[0] == '=')
{
if (vsprites.Size() == 0)
{
sc.ScriptMessage("No sprites specified for voxel.\n");
}
return true;
}
if (sc.StringLen != 4 && sc.StringLen != 5)
{
sc.ScriptMessage("Sprite name \"%s\" is wrong size.\n", sc.String);
}
else if (sc.StringLen == 5 && (sc.String[4] = toupper(sc.String[4]), sc.String[4] < 'A' || sc.String[4] >= 'A' + MAX_SPRITE_FRAMES))
{
sc.ScriptMessage("Sprite frame %s is invalid.\n", sc.String[4]);
}
else
{
int frame = (sc.StringLen == 4) ? 255 : sc.String[4] - 'A';
int spritename;
for (i = 0; i < 4; ++i)
{
sc.String[i] = toupper(sc.String[i]);
}
spritename = *(int *)sc.String;
for (i = 0; i < sprites.Size(); ++i)
{
if ((int)sprites[i].dwName == spritename)
{
break;
}
}
if (i != sprites.Size())
{
vsprites.Push((frame << 24) | i);
}
}
}
if (vsprites.Size() != 0)
{
sc.ScriptMessage("Unexpected end of file\n");
}
return false;
}
//==========================================================================
//
// VOX_ReadOptions
//
// Reads a list of options from a VOXELDEF lump, terminated with a '}'
// character. The leading '{' must already be consumed
//
//==========================================================================
static void VOX_ReadOptions(FScanner &sc, VoxelOptions &opts)
{
while (sc.GetToken())
{
if (sc.TokenType == '}')
{
return;
}
sc.TokenMustBe(TK_Identifier);
if (sc.Compare("scale"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_FloatConst);
opts.Scale = FLOAT2FIXED(sc.Float);
}
else if (sc.Compare("spin"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_IntConst);
opts.DroppedSpin = opts.PlacedSpin = sc.Number;
}
else if (sc.Compare("placedspin"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_IntConst);
opts.PlacedSpin = sc.Number;
}
else if (sc.Compare("droppedspin"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_IntConst);
opts.DroppedSpin = sc.Number;
}
else if (sc.Compare("angleoffset"))
{
sc.MustGetToken('=');
sc.MustGetAnyToken();
if (sc.TokenType == TK_IntConst)
{
sc.Float = sc.Number;
}
else
{
sc.TokenMustBe(TK_FloatConst);
}
opts.AngleOffset = angle_t(sc.Float * ANGLE_180 / 180.0);
}
else
{
sc.ScriptMessage("Unknown voxel option '%s'\n", sc.String);
if (sc.CheckToken('='))
{
sc.MustGetAnyToken();
}
}
}
sc.ScriptMessage("Unterminated voxel option block\n");
}
//==========================================================================
//
// VOX_GetVoxel
//
// Returns a voxel object for the given lump or NULL if it is not a valid
// voxel. If the voxel has already been loaded, it will be reused.
//
//==========================================================================
static FVoxel *VOX_GetVoxel(int lumpnum)
{
// Is this voxel already loaded? If so, return it.
for (unsigned i = 0; i < Voxels.Size(); ++i)
{
if (Voxels[i]->LumpNum == lumpnum)
{
return Voxels[i];
}
}
FVoxel *vox = R_LoadKVX(lumpnum);
if (vox != NULL)
{
Voxels.Push(vox);
}
return vox;
}
//==========================================================================
//
// VOX_AddVoxel
@ -738,88 +550,12 @@ static FVoxel *VOX_GetVoxel(int lumpnum)
//
//==========================================================================
static void VOX_AddVoxel(int sprnum, int frame, FVoxelDef *def)
void VOX_AddVoxel(int sprnum, int frame, FVoxelDef *def)
{
R_ExtendSpriteFrames(sprites[sprnum], frame);
SpriteFrames[sprites[sprnum].spriteframes + frame].Voxel = def;
}
//==========================================================================
//
// R_InitVoxels
//
// Process VOXELDEF lumps for defining voxel options that cannot be
// condensed neatly into a sprite name format.
//
//==========================================================================
void R_InitVoxels()
{
int lump, lastlump = 0;
while ((lump = Wads.FindLump("VOXELDEF", &lastlump)) != -1)
{
FScanner sc(lump);
TArray<DWORD> vsprites;
while (VOX_ReadSpriteNames(sc, vsprites))
{
FVoxel *voxeldata = NULL;
int voxelfile;
VoxelOptions opts;
sc.SetCMode(true);
sc.MustGetToken(TK_StringConst);
voxelfile = Wads.CheckNumForFullName(sc.String, true, ns_voxels);
if (voxelfile < 0)
{
sc.ScriptMessage("Voxel \"%s\" not found.\n", sc.String);
}
else
{
voxeldata = VOX_GetVoxel(voxelfile);
if (voxeldata == NULL)
{
sc.ScriptMessage("\"%s\" is not a valid voxel file.\n", sc.String);
}
}
if (sc.CheckToken('{'))
{
VOX_ReadOptions(sc, opts);
}
sc.SetCMode(false);
if (voxeldata != NULL && vsprites.Size() != 0)
{
FVoxelDef *def = new FVoxelDef;
def->Voxel = voxeldata;
def->Scale = opts.Scale;
def->DroppedSpin = opts.DroppedSpin;
def->PlacedSpin = opts.PlacedSpin;
def->AngleOffset = opts.AngleOffset;
VoxelDefs.Push(def);
for (unsigned i = 0; i < vsprites.Size(); ++i)
{
int sprnum = int(vsprites[i] & 0xFFFFFF);
int frame = int(vsprites[i] >> 24);
if (frame == 255)
{ // Apply voxel to all frames.
for (int j = MAX_SPRITE_FRAMES - 1; j >= 0; --j)
{
VOX_AddVoxel(sprnum, j, def);
}
}
else
{ // Apply voxel to only one frame.
VOX_AddVoxel(sprnum, frame, def);
}
}
}
}
}
}
// [RH]
// R_InitSkins
// Reads in everything applicable to a skin. The skins should have already

View file

@ -23,6 +23,8 @@
#ifndef __R_THINGS__
#define __R_THINGS__
#define MAX_SPRITE_FRAMES 29 // [RH] Macro-ized as in BOOM.
// [RH] Particle details
struct particle_t
{

View file

@ -43,7 +43,6 @@
#include "r_local.h"
#include "r_sky.h"
#include "c_dispatch.h"
#include "r_data.h"
#include "sc_man.h"
#include "v_text.h"
#include "st_start.h"
@ -53,6 +52,7 @@
#include "v_palette.h"
#include "colormatcher.h"
#include "colormaps.h"
#include "v_video.h"
static bool R_CheckForFixedLights(const BYTE *colormaps);

View file

@ -1,8 +1,8 @@
/*
** r_data.cpp
** voxels.cpp
**
**---------------------------------------------------------------------------
** Copyright 1998-2008 Randy Heit
** Copyright 2010-2011 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
@ -32,106 +32,56 @@
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include "templates.h"
#include "doomdef.h"
#include "m_swap.h"
#include "m_argv.h"
#include "i_system.h"
#include "w_wad.h"
#include "doomdef.h"
#include "r_local.h"
#include "r_sky.h"
#include "c_console.h"
#include "c_cvars.h"
#include "c_dispatch.h"
#include "r_data.h"
#include "sc_man.h"
#include "v_text.h"
#include "st_start.h"
#include "doomstat.h"
#include "v_video.h"
#include "sc_man.h"
#include "s_sound.h"
#include "sbar.h"
#include "gi.h"
#include "r_sky.h"
#include "cmdlib.h"
#include "g_level.h"
#include "d_net.h"
#include "colormatcher.h"
#include "d_netinf.h"
#include "r_bsp.h"
#include "r_plane.h"
#include "r_segs.h"
#include "v_palette.h"
#include "r_translate.h"
#include "resources/colormaps.h"
#include "voxels.h"
void VOX_AddVoxel(int sprnum, int frame, FVoxelDef *def);
//==========================================================================
//
// R_InitData
// Locates all the lumps that will be used by all views
// Must be called after W_Init.
//
//==========================================================================
TDeletingArray<FVoxel *> Voxels; // used only to auto-delete voxels on exit.
TDeletingArray<FVoxelDef *> VoxelDefs;
void R_InitData ()
struct VoxelOptions
{
StartScreen->Progress();
VoxelOptions()
: DroppedSpin(0), PlacedSpin(0), Scale(FRACUNIT), AngleOffset(0)
{}
V_InitFonts();
StartScreen->Progress();
R_InitColormaps ();
StartScreen->Progress();
}
//===========================================================================
//
// R_DeinitData
//
//===========================================================================
void R_DeinitData ()
{
R_DeinitColormaps ();
FCanvasTextureInfo::EmptyList();
// Free openings
if (openings != NULL)
{
M_Free (openings);
openings = NULL;
}
// Free drawsegs
if (drawsegs != NULL)
{
M_Free (drawsegs);
drawsegs = NULL;
}
}
//===========================================================================
//
// R_PrecacheLevel
//
// Preloads all relevant graphics for the level.
//
//===========================================================================
void R_PrecacheLevel (void)
{
BYTE *hitlist;
if (demoplayback)
return;
hitlist = new BYTE[TexMan.NumTextures()];
memset (hitlist, 0, TexMan.NumTextures());
screen->GetHitlist(hitlist);
for (int i = TexMan.NumTextures() - 1; i >= 0; i--)
{
screen->PrecacheTexture(TexMan.ByIndex(i), hitlist[i]);
}
delete[] hitlist;
}
//==========================================================================
//
// R_GetColumn
//
//==========================================================================
const BYTE *R_GetColumn (FTexture *tex, int col)
{
return tex->GetColumn (col, NULL);
}
int DroppedSpin;
int PlacedSpin;
fixed_t Scale;
angle_t AngleOffset;
};
//==========================================================================
//
@ -276,62 +226,60 @@ FVoxel *R_LoadKVX(int lumpnum)
{ // Clearly, not enough.
break;
}
if (voxdatasize == 0)
{ // This mip level is empty.
goto nextmip;
}
if (voxdatasize != 0)
{ // This mip level is not empty.
// Allocate slab data space.
mipl->OffsetX = new int[(numbytes - 24 + 3) / 4];
mipl->OffsetXY = (short *)(mipl->OffsetX + mipl->SizeX + 1);
mipl->SlabData = (BYTE *)(mipl->OffsetXY + mipl->SizeX * (mipl->SizeY + 1));
// Allocate slab data space.
mipl->OffsetX = new int[(numbytes - 24 + 3) / 4];
mipl->OffsetXY = (short *)(mipl->OffsetX + mipl->SizeX + 1);
mipl->SlabData = (BYTE *)(mipl->OffsetXY + mipl->SizeX * (mipl->SizeY + 1));
// Load x offsets.
for (i = 0, n = mipl->SizeX; i <= n; ++i)
{
// The X offsets stored in the KVX file are relative to the start of the
// X offsets array. Make them relative to voxdata instead.
mipl->OffsetX[i] = GetInt(rawmip + 24 + i * 4) - offsetsize;
}
// The first X offset must be 0 (since we subtracted offsetsize), according to the spec:
// NOTE: xoffset[0] = (xsiz+1)*4 + xsiz*(ysiz+1)*2 (ALWAYS)
if (mipl->OffsetX[0] != 0)
{
break;
}
// And the final X offset must point just past the end of the voxdata.
if (mipl->OffsetX[mipl->SizeX] != voxdatasize)
{
break;
}
// Load xy offsets.
i = 24 + i * 4;
for (j = 0, n *= mipl->SizeY + 1; j < n; ++j)
{
mipl->OffsetXY[j] = GetShort(rawmip + i + j * 2);
}
// Ensure all offsets are within bounds.
for (i = 0; i < mipl->SizeX; ++i)
{
int xoff = mipl->OffsetX[i];
for (j = 0; j < mipl->SizeY; ++j)
// Load x offsets.
for (i = 0, n = mipl->SizeX; i <= n; ++i)
{
int yoff = mipl->OffsetXY[(mipl->SizeY + 1) * i + j];
if (unsigned(xoff + yoff) > unsigned(voxdatasize))
// The X offsets stored in the KVX file are relative to the start of the
// X offsets array. Make them relative to voxdata instead.
mipl->OffsetX[i] = GetInt(rawmip + 24 + i * 4) - offsetsize;
}
// The first X offset must be 0 (since we subtracted offsetsize), according to the spec:
// NOTE: xoffset[0] = (xsiz+1)*4 + xsiz*(ysiz+1)*2 (ALWAYS)
if (mipl->OffsetX[0] != 0)
{
break;
}
// And the final X offset must point just past the end of the voxdata.
if (mipl->OffsetX[mipl->SizeX] != voxdatasize)
{
break;
}
// Load xy offsets.
i = 24 + i * 4;
for (j = 0, n *= mipl->SizeY + 1; j < n; ++j)
{
mipl->OffsetXY[j] = GetShort(rawmip + i + j * 2);
}
// Ensure all offsets are within bounds.
for (i = 0; i < mipl->SizeX; ++i)
{
int xoff = mipl->OffsetX[i];
for (j = 0; j < mipl->SizeY; ++j)
{
goto bad;
int yoff = mipl->OffsetXY[(mipl->SizeY + 1) * i + j];
if (unsigned(xoff + yoff) > unsigned(voxdatasize))
{
delete voxel;
return NULL;
}
}
}
// Record slab location for the end.
slabs[mip] = (kvxslab_t *)(rawmip + 24 + offsetsize);
}
// Record slab location for the end.
slabs[mip] = (kvxslab_t *)(rawmip + 24 + offsetsize);
// Time for the next mip Level.
nextmip:
rawmip += numbytes;
maxmipsize -= numbytes + 4;
}
@ -339,7 +287,7 @@ nextmip:
// enough room for the palette after it?
if (mip == 0 || rawmip != rawvoxel + voxelsize - 768)
{
bad: delete voxel;
delete voxel;
return NULL;
}
@ -367,6 +315,34 @@ bad: delete voxel;
return voxel;
}
//==========================================================================
//
//
//
//==========================================================================
FVoxelDef *R_LoadVoxelDef(int lumpnum, int spin)
{
FVoxel *vox = R_LoadKVX(lumpnum);
if (vox == NULL)
{
Printf("%s is not a valid voxel file\n", Wads.GetLumpFullName(lumpnum));
return NULL;
}
else
{
FVoxelDef *voxdef = new FVoxelDef;
voxdef->Voxel = vox;
voxdef->Scale = FRACUNIT;
voxdef->DroppedSpin = voxdef->PlacedSpin = spin;
voxdef->AngleOffset = 0;
Voxels.Push(vox);
VoxelDefs.Push(voxdef);
return voxdef;
}
}
//==========================================================================
//
// FVoxelMipLevel Constructor
@ -432,37 +408,226 @@ void FVoxel::Remap()
}
}
//==========================================================================
//
// Debug stuff
// VOX_ReadSpriteNames
//
// Reads a list of sprite names from a VOXELDEF lump.
//
//==========================================================================
#ifdef _DEBUG
// Prints the spans generated for a texture. Only needed for debugging.
CCMD (printspans)
static bool VOX_ReadSpriteNames(FScanner &sc, TArray<DWORD> &vsprites)
{
if (argv.argc() != 2)
return;
unsigned int i;
FTextureID picnum = TexMan.CheckForTexture (argv[1], FTexture::TEX_Any);
if (!picnum.Exists())
vsprites.Clear();
while (sc.GetString())
{
Printf ("Unknown texture %s\n", argv[1]);
return;
}
FTexture *tex = TexMan[picnum];
for (int x = 0; x < tex->GetWidth(); ++x)
{
const FTexture::Span *spans;
Printf ("%4d:", x);
tex->GetColumn (x, &spans);
while (spans->Length != 0)
// A sprite name list is terminated by an '=' character.
if (sc.String[0] == '=')
{
Printf (" (%4d,%4d)", spans->TopOffset, spans->TopOffset+spans->Length-1);
spans++;
if (vsprites.Size() == 0)
{
sc.ScriptMessage("No sprites specified for voxel.\n");
}
return true;
}
if (sc.StringLen != 4 && sc.StringLen != 5)
{
sc.ScriptMessage("Sprite name \"%s\" is wrong size.\n", sc.String);
}
else if (sc.StringLen == 5 && (sc.String[4] = toupper(sc.String[4]), sc.String[4] < 'A' || sc.String[4] >= 'A' + MAX_SPRITE_FRAMES))
{
sc.ScriptMessage("Sprite frame %s is invalid.\n", sc.String[4]);
}
else
{
int frame = (sc.StringLen == 4) ? 255 : sc.String[4] - 'A';
i = GetSpriteIndex(sc.String, false);
if (i != -1)
{
vsprites.Push((frame << 24) | i);
}
}
}
if (vsprites.Size() != 0)
{
sc.ScriptMessage("Unexpected end of file\n");
}
return false;
}
//==========================================================================
//
// VOX_ReadOptions
//
// Reads a list of options from a VOXELDEF lump, terminated with a '}'
// character. The leading '{' must already be consumed
//
//==========================================================================
static void VOX_ReadOptions(FScanner &sc, VoxelOptions &opts)
{
while (sc.GetToken())
{
if (sc.TokenType == '}')
{
return;
}
sc.TokenMustBe(TK_Identifier);
if (sc.Compare("scale"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_FloatConst);
opts.Scale = FLOAT2FIXED(sc.Float);
}
else if (sc.Compare("spin"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_IntConst);
opts.DroppedSpin = opts.PlacedSpin = sc.Number;
}
else if (sc.Compare("placedspin"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_IntConst);
opts.PlacedSpin = sc.Number;
}
else if (sc.Compare("droppedspin"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_IntConst);
opts.DroppedSpin = sc.Number;
}
else if (sc.Compare("angleoffset"))
{
sc.MustGetToken('=');
sc.MustGetAnyToken();
if (sc.TokenType == TK_IntConst)
{
sc.Float = sc.Number;
}
else
{
sc.TokenMustBe(TK_FloatConst);
}
opts.AngleOffset = angle_t(sc.Float * ANGLE_180 / 180.0);
}
else
{
sc.ScriptMessage("Unknown voxel option '%s'\n", sc.String);
if (sc.CheckToken('='))
{
sc.MustGetAnyToken();
}
}
}
sc.ScriptMessage("Unterminated voxel option block\n");
}
//==========================================================================
//
// VOX_GetVoxel
//
// Returns a voxel object for the given lump or NULL if it is not a valid
// voxel. If the voxel has already been loaded, it will be reused.
//
//==========================================================================
static FVoxel *VOX_GetVoxel(int lumpnum)
{
// Is this voxel already loaded? If so, return it.
for (unsigned i = 0; i < Voxels.Size(); ++i)
{
if (Voxels[i]->LumpNum == lumpnum)
{
return Voxels[i];
}
}
FVoxel *vox = R_LoadKVX(lumpnum);
if (vox != NULL)
{
Voxels.Push(vox);
}
return vox;
}
//==========================================================================
//
// R_InitVoxels
//
// Process VOXELDEF lumps for defining voxel options that cannot be
// condensed neatly into a sprite name format.
//
//==========================================================================
void R_InitVoxels()
{
int lump, lastlump = 0;
while ((lump = Wads.FindLump("VOXELDEF", &lastlump)) != -1)
{
FScanner sc(lump);
TArray<DWORD> vsprites;
while (VOX_ReadSpriteNames(sc, vsprites))
{
FVoxel *voxeldata = NULL;
int voxelfile;
VoxelOptions opts;
sc.SetCMode(true);
sc.MustGetToken(TK_StringConst);
voxelfile = Wads.CheckNumForFullName(sc.String, true, ns_voxels);
if (voxelfile < 0)
{
sc.ScriptMessage("Voxel \"%s\" not found.\n", sc.String);
}
else
{
voxeldata = VOX_GetVoxel(voxelfile);
if (voxeldata == NULL)
{
sc.ScriptMessage("\"%s\" is not a valid voxel file.\n", sc.String);
}
}
if (sc.CheckToken('{'))
{
VOX_ReadOptions(sc, opts);
}
sc.SetCMode(false);
if (voxeldata != NULL && vsprites.Size() != 0)
{
FVoxelDef *def = new FVoxelDef;
def->Voxel = voxeldata;
def->Scale = opts.Scale;
def->DroppedSpin = opts.DroppedSpin;
def->PlacedSpin = opts.PlacedSpin;
def->AngleOffset = opts.AngleOffset;
VoxelDefs.Push(def);
for (unsigned i = 0; i < vsprites.Size(); ++i)
{
int sprnum = int(vsprites[i] & 0xFFFFFF);
int frame = int(vsprites[i] >> 24);
if (frame == 255)
{ // Apply voxel to all frames.
for (int j = MAX_SPRITE_FRAMES - 1; j >= 0; --j)
{
VOX_AddVoxel(sprnum, j, def);
}
}
else
{ // Apply voxel to only one frame.
VOX_AddVoxel(sprnum, frame, def);
}
}
}
}
Printf ("\n");
}
}
#endif

64
src/resources/voxels.h Normal file
View file

@ -0,0 +1,64 @@
#ifndef __RES_VOXEL_H
#define __RES_VOXEL_H
#include "doomdef.h"
// [RH] Voxels from Build
#define MAXVOXMIPS 5
struct kvxslab_t
{
BYTE ztop; // starting z coordinate of top of slab
BYTE zleng; // # of bytes in the color array - slab height
BYTE backfacecull; // low 6 bits tell which of 6 faces are exposed
BYTE col[1/*zleng*/];// color data from top to bottom
};
struct FVoxelMipLevel
{
FVoxelMipLevel();
~FVoxelMipLevel();
int SizeX;
int SizeY;
int SizeZ;
fixed_t PivotX; // 24.8 fixed point
fixed_t PivotY; // ""
fixed_t PivotZ; // ""
int *OffsetX;
short *OffsetXY;
BYTE *SlabData;
};
struct FVoxel
{
int LumpNum;
int NumMips;
int VoxelIndex; // Needed by GZDoom
BYTE *Palette;
FVoxelMipLevel Mips[MAXVOXMIPS];
FVoxel();
~FVoxel();
void Remap();
};
struct FVoxelDef
{
FVoxel *Voxel;
int PlacedSpin; // degrees/sec to spin actors without MF_DROPPED set
int DroppedSpin; // degrees/sec to spin actors with MF_DROPPED set
int VoxeldefIndex; // Needed by GZDoom
fixed_t Scale;
angle_t AngleOffset; // added to actor's angle to compensate for wrong-facing voxels
};
extern TDeletingArray<FVoxel *> Voxels; // used only to auto-delete voxels on exit.
extern TDeletingArray<FVoxelDef *> VoxelDefs;
FVoxel *R_LoadKVX(int lumpnum);
FVoxelDef *R_LoadVoxelDef(int lumpnum, int spin);
void R_InitVoxels();
#endif

View file

@ -46,10 +46,10 @@
#include "gi.h"
#include "doomstat.h"
#include "i_sound.h"
#include "r_data.h"
#include "m_random.h"
#include "d_netinf.h"
#include "i_system.h"
#include "d_player.h"
// MACROS ------------------------------------------------------------------

View file

@ -3,5 +3,5 @@
// This file was automatically generated by the
// updaterevision tool. Do not edit by hand.
#define ZD_SVN_REVISION_STRING "3245"
#define ZD_SVN_REVISION_NUMBER 3245
#define ZD_SVN_REVISION_STRING "3249"
#define ZD_SVN_REVISION_NUMBER 3249

View file

@ -37,8 +37,8 @@
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "w_wad.h"
#include "textures/textures.h"
//==========================================================================
//

View file

@ -40,6 +40,7 @@
#include "templates.h"
#include "cmdlib.h"
#include "st_start.h"
#include "textures/textures.h"
//==========================================================================
//

View file

@ -37,6 +37,8 @@
#include "files.h"
#include "r_local.h"
#include "v_palette.h"
#include "v_video.h"
#include "textures/textures.h"
extern float LastFOV;

View file

@ -54,6 +54,8 @@
#include "w_wad.h"
#include "templates.h"
#include "bitmap.h"
#include "v_video.h"
#include "textures/textures.h"
// Since we want this to compile under Linux too, we need to define this
// stuff ourselves instead of including a DirectX header.

View file

@ -36,8 +36,8 @@
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "w_wad.h"
#include "textures/textures.h"
//==========================================================================
//

View file

@ -35,9 +35,9 @@
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "w_wad.h"
#include "v_palette.h"
#include "textures/textures.h"
//==========================================================================
//

View file

@ -35,8 +35,8 @@
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "w_wad.h"
#include "textures/textures.h"
//==========================================================================

View file

@ -35,11 +35,12 @@
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "r_jpeg.h"
#include "w_wad.h"
#include "v_text.h"
#include "bitmap.h"
#include "v_video.h"
#include "textures/textures.h"
//==========================================================================
//

View file

@ -36,7 +36,6 @@
#include <ctype.h>
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "w_wad.h"
#include "i_system.h"
#include "gi.h"
@ -47,6 +46,9 @@
#include "bitmap.h"
#include "colormatcher.h"
#include "v_palette.h"
#include "v_video.h"
#include "m_fixed.h"
#include "textures/textures.h"
#include "resources/colormaps.h"
// On the Alpha, accessing the shorts directly if they aren't aligned on a

View file

@ -35,10 +35,18 @@
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "w_wad.h"
#include "templates.h"
#include "v_palette.h"
#include "textures/textures.h"
// posts are runs of non masked source pixels
struct column_t
{
BYTE topdelta; // -1 is the last post in a column
BYTE length; // length data bytes follows
};
//==========================================================================

View file

@ -41,6 +41,8 @@
#include "templates.h"
#include "bitmap.h"
#include "colormatcher.h"
#include "v_video.h"
#include "textures/textures.h"
//==========================================================================
//

View file

@ -41,6 +41,7 @@
#include "m_png.h"
#include "bitmap.h"
#include "v_palette.h"
#include "textures/textures.h"
//==========================================================================
//

View file

@ -35,9 +35,9 @@
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "w_wad.h"
#include "v_palette.h"
#include "textures/textures.h"
//==========================================================================

View file

@ -36,12 +36,15 @@
#include "doomtype.h"
#include "files.h"
#include "w_wad.h"
#include "r_data.h"
#include "templates.h"
#include "i_system.h"
#include "r_translate.h"
#include "bitmap.h"
#include "colormatcher.h"
#include "c_dispatch.h"
#include "v_video.h"
#include "m_fixed.h"
#include "textures/textures.h"
typedef bool (*CheckFunc)(FileReader & file);
typedef FTexture * (*CreateFunc)(FileReader & file, int lumpnum);
@ -596,3 +599,37 @@ const BYTE *FDummyTexture::GetPixels ()
return NULL;
}
//==========================================================================
//
// Debug stuff
//
//==========================================================================
#ifdef _DEBUG
// Prints the spans generated for a texture. Only needed for debugging.
CCMD (printspans)
{
if (argv.argc() != 2)
return;
FTextureID picnum = TexMan.CheckForTexture (argv[1], FTexture::TEX_Any);
if (!picnum.Exists())
{
Printf ("Unknown texture %s\n", argv[1]);
return;
}
FTexture *tex = TexMan[picnum];
for (int x = 0; x < tex->GetWidth(); ++x)
{
const FTexture::Span *spans;
Printf ("%4d:", x);
tex->GetColumn (x, &spans);
while (spans->Length != 0)
{
Printf (" (%4d,%4d)", spans->TopOffset, spans->TopOffset+spans->Length-1);
spans++;
}
Printf ("\n");
}
}
#endif

View file

@ -35,8 +35,8 @@
*/
#include "doomtype.h"
#include "doomstat.h"
#include "w_wad.h"
#include "r_data.h"
#include "templates.h"
#include "i_system.h"
#include "r_translate.h"
@ -47,6 +47,10 @@
#include "st_start.h"
#include "cmdlib.h"
#include "g_level.h"
#include "m_fixed.h"
#include "farchive.h"
#include "v_video.h"
#include "textures/textures.h"
FTextureManager TexMan;
@ -1143,6 +1147,36 @@ int FTextureManager::CountLumpTextures (int lumpnum)
return 0;
}
//===========================================================================
//
// R_PrecacheLevel
//
// Preloads all relevant graphics for the level.
//
//===========================================================================
void FTextureManager::PrecacheLevel (void)
{
BYTE *hitlist;
int cnt = NumTextures();
if (demoplayback)
return;
hitlist = new BYTE[cnt];
memset (hitlist, 0, cnt);
screen->GetHitlist(hitlist);
for (int i = cnt - 1; i >= 0; i--)
{
screen->PrecacheTexture(ByIndex(i), hitlist[i]);
}
delete[] hitlist;
}
//==========================================================================
//

View file

@ -461,6 +461,7 @@ public:
void UnloadAll ();
int NumTextures () const { return (int)Textures.Size(); }
void PrecacheLevel (void);
void WriteTexture (FArchive &arc, int picnum);
int ReadTexture (FArchive &arc);
@ -526,6 +527,87 @@ private:
TArray<BYTE *> BuildTileFiles;
};
// A texture that doesn't really exist
class FDummyTexture : public FTexture
{
public:
FDummyTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload ();
void SetSize (int width, int height);
};
// A texture that returns a wiggly version of another texture.
class FWarpTexture : public FTexture
{
public:
FWarpTexture (FTexture *source);
~FWarpTexture ();
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL);
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload ();
bool CheckModified ();
float GetSpeed() const { return Speed; }
int GetSourceLump() { return SourcePic->GetSourceLump(); }
void SetSpeed(float fac) { Speed = fac; }
FTexture *GetRedirect(bool wantwarped);
DWORD GenTime;
protected:
FTexture *SourcePic;
BYTE *Pixels;
Span **Spans;
float Speed;
virtual void MakeTexture (DWORD time);
};
// [GRB] Eternity-like warping
class FWarp2Texture : public FWarpTexture
{
public:
FWarp2Texture (FTexture *source);
protected:
void MakeTexture (DWORD time);
};
// A texture that can be drawn to.
class DSimpleCanvas;
class AActor;
class FArchive;
class FCanvasTexture : public FTexture
{
public:
FCanvasTexture (const char *name, int width, int height);
~FCanvasTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload ();
bool CheckModified ();
void RenderView (AActor *viewpoint, int fov);
void RenderGLView(AActor *viewpoint, int fov); // Needed by GZDoom
void NeedUpdate() { bNeedsUpdate=true; }
protected:
DSimpleCanvas *Canvas;
BYTE *Pixels;
Span DummySpans[2];
BYTE bNeedsUpdate:1;
BYTE bDidUpdate:1;
BYTE bFirstUpdate:1;
void MakeTexture ();
friend struct FCanvasTextureInfo;
};
extern FTextureManager TexMan;
#endif

View file

@ -40,6 +40,8 @@
#include "templates.h"
#include "bitmap.h"
#include "colormatcher.h"
#include "v_video.h"
#include "textures/textures.h"
//==========================================================================

View file

@ -35,9 +35,9 @@
#include "doomtype.h"
#include "files.h"
#include "r_data.h"
#include "r_main.h"
#include "templates.h"
#include "textures/textures.h"
FWarpTexture::FWarpTexture (FTexture *source)

View file

@ -68,6 +68,7 @@
#include "a_morph.h"
#include "colormatcher.h"
#include "teaminfo.h"
#include "v_video.h"
#include "resources/colormaps.h"

View file

@ -85,7 +85,6 @@ The FON2 header is followed by variable length data:
#include "v_font.h"
#include "v_video.h"
#include "w_wad.h"
#include "r_data.h"
#include "i_system.h"
#include "gi.h"
#include "cmdlib.h"

View file

@ -63,6 +63,7 @@
#include "v_palette.h"
#include "r_sky.h"
#include "menu/menu.h"
#include "resources/voxels.h"
IMPLEMENT_ABSTRACT_CLASS (DCanvas)
@ -1318,7 +1319,6 @@ void DFrameBuffer::RenderView(player_t *player)
//
//
//==========================================================================
extern TDeletingArray<FVoxel *> Voxels;
void DFrameBuffer::RemapVoxels()
{

View file

@ -83,8 +83,8 @@
#include "doomstat.h"
#include "v_palette.h"
#include "stats.h"
#include "r_data.h"
#include "textures/bitmap.h"
#include "textures/textures.h"
// MACROS ------------------------------------------------------------------