mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- moved R_AlignFlat out of renderer into main game code (r_ to p_.)
SVN r3249 (trunk)
This commit is contained in:
parent
17ed7aaabd
commit
b57a39dd86
9 changed files with 39 additions and 352 deletions
|
@ -655,11 +655,11 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
|
||||||
int sidenum = int(intptr_t(lines[linenum].sidedef[1]));
|
int sidenum = int(intptr_t(lines[linenum].sidedef[1]));
|
||||||
if (bsec->floorstat & 64)
|
if (bsec->floorstat & 64)
|
||||||
{ // floor is aligned to first wall
|
{ // floor is aligned to first wall
|
||||||
R_AlignFlat (linenum, sidenum == bsec->wallptr, 0);
|
P_AlignFlat (linenum, sidenum == bsec->wallptr, 0);
|
||||||
}
|
}
|
||||||
if (bsec->ceilingstat & 64)
|
if (bsec->ceilingstat & 64)
|
||||||
{ // ceiling is aligned to first wall
|
{ // 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++)
|
for (i = 0; i < numlines; i++)
|
||||||
|
|
|
@ -2357,7 +2357,7 @@ FUNC(LS_Line_AlignCeiling)
|
||||||
I_Error ("Sector_AlignCeiling: Lineid %d is undefined", arg0);
|
I_Error ("Sector_AlignCeiling: Lineid %d is undefined", arg0);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret |= R_AlignFlat (line, !!arg1, 1);
|
ret |= P_AlignFlat (line, !!arg1, 1);
|
||||||
} while ( (line = P_FindLineFromID (arg0, line)) >= 0);
|
} while ( (line = P_FindLineFromID (arg0, line)) >= 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2372,7 +2372,7 @@ FUNC(LS_Line_AlignFloor)
|
||||||
I_Error ("Sector_AlignFloor: Lineid %d is undefined", arg0);
|
I_Error ("Sector_AlignFloor: Lineid %d is undefined", arg0);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret |= R_AlignFlat (line, !!arg1, 0);
|
ret |= P_AlignFlat (line, !!arg1, 0);
|
||||||
} while ( (line = P_FindLineFromID (arg0, line)) >= 0);
|
} while ( (line = P_FindLineFromID (arg0, line)) >= 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -547,5 +547,6 @@ FPolyObj *PO_GetPolyobj(int polyNum);
|
||||||
//
|
//
|
||||||
#include "p_spec.h"
|
#include "p_spec.h"
|
||||||
|
|
||||||
|
bool P_AlignFlat (int linenum, int side, int fc);
|
||||||
|
|
||||||
#endif // __P_LOCAL__
|
#endif // __P_LOCAL__
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "p_spec.h"
|
#include "p_spec.h"
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
|
#include "r_main.h"
|
||||||
#include "resources/colormaps.h"
|
#include "resources/colormaps.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -771,3 +772,36 @@ bool sector_t::PlaneMoving(int pos)
|
||||||
else
|
else
|
||||||
return (ceilingdata != NULL || (planes[ceiling].Flags & PLANEF_BLOCKED));
|
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;
|
||||||
|
}
|
||||||
|
|
169
src/r_data.cpp
169
src/r_data.cpp
|
@ -1,169 +0,0 @@
|
||||||
/*
|
|
||||||
** r_data.cpp
|
|
||||||
**
|
|
||||||
**---------------------------------------------------------------------------
|
|
||||||
** Copyright 1998-2008 Randy Heit
|
|
||||||
** All rights reserved.
|
|
||||||
**
|
|
||||||
** Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions
|
|
||||||
** are met:
|
|
||||||
**
|
|
||||||
** 1. Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in the
|
|
||||||
** documentation and/or other materials provided with the distribution.
|
|
||||||
** 3. The name of the author may not be used to endorse or promote products
|
|
||||||
** derived from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (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 "i_system.h"
|
|
||||||
#include "w_wad.h"
|
|
||||||
#include "doomdef.h"
|
|
||||||
#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"
|
|
||||||
#include "doomstat.h"
|
|
||||||
#include "r_bsp.h"
|
|
||||||
#include "r_segs.h"
|
|
||||||
#include "v_palette.h"
|
|
||||||
#include "resources/colormaps.h"
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// R_InitData
|
|
||||||
// Locates all the lumps that will be used by all views
|
|
||||||
// Must be called after W_Init.
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void R_InitData ()
|
|
||||||
{
|
|
||||||
StartScreen->Progress();
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// 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
|
|
141
src/r_data.h
141
src/r_data.h
|
@ -1,141 +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 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
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -38,6 +38,4 @@
|
||||||
#include "r_things.h"
|
#include "r_things.h"
|
||||||
#include "r_draw.h"
|
#include "r_draw.h"
|
||||||
|
|
||||||
bool R_AlignFlat (int linenum, int side, int fc);
|
|
||||||
|
|
||||||
#endif // __R_LOCAL_H__
|
#endif // __R_LOCAL_H__
|
||||||
|
|
|
@ -1787,35 +1787,3 @@ bool R_PlaneInitData ()
|
||||||
|
|
||||||
return true;
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -2379,10 +2379,6 @@
|
||||||
RelativePath=".\src\r_bsp.h"
|
RelativePath=".\src\r_bsp.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\r_data.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\r_defs.h"
|
RelativePath=".\src\r_defs.h"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue