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:
|
|
|
|
// BSP traversal, handling of LineSegs for rendering.
|
|
|
|
//
|
|
|
|
// This file contains some code from the Build Engine.
|
|
|
|
//
|
|
|
|
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
|
|
|
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
|
|
|
// See the included license file "BUILDLIC.TXT" for license info.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
|
|
|
|
#include "m_bbox.h"
|
|
|
|
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "p_lnspec.h"
|
2010-08-27 15:20:05 +00:00
|
|
|
#include "p_setup.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#include "r_main.h"
|
|
|
|
#include "r_plane.h"
|
|
|
|
#include "r_draw.h"
|
|
|
|
#include "r_things.h"
|
|
|
|
#include "a_sharedglobal.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "g_level.h"
|
2010-08-01 02:41:56 +00:00
|
|
|
#include "nodebuild.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// State.
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "r_state.h"
|
|
|
|
#include "r_bsp.h"
|
|
|
|
#include "v_palette.h"
|
2008-06-15 18:36:26 +00:00
|
|
|
#include "r_sky.h"
|
2010-07-23 05:56:25 +00:00
|
|
|
#include "po_man.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int WallMost (short *mostbuf, const secplane_t &plane);
|
|
|
|
|
|
|
|
seg_t* curline;
|
|
|
|
side_t* sidedef;
|
|
|
|
line_t* linedef;
|
|
|
|
sector_t* frontsector;
|
|
|
|
sector_t* backsector;
|
|
|
|
|
|
|
|
// killough 4/7/98: indicates doors closed wrt automap bugfix:
|
|
|
|
int doorclosed;
|
|
|
|
|
|
|
|
bool r_fakingunderwater;
|
|
|
|
|
|
|
|
extern bool rw_prepped;
|
|
|
|
extern bool rw_havehigh, rw_havelow;
|
|
|
|
extern int rw_floorstat, rw_ceilstat;
|
|
|
|
extern bool rw_mustmarkfloor, rw_mustmarkceiling;
|
|
|
|
extern short walltop[MAXWIDTH]; // [RH] record max extents of wall
|
|
|
|
extern short wallbottom[MAXWIDTH];
|
|
|
|
extern short wallupper[MAXWIDTH];
|
|
|
|
extern short walllower[MAXWIDTH];
|
|
|
|
|
|
|
|
fixed_t rw_backcz1, rw_backcz2;
|
|
|
|
fixed_t rw_backfz1, rw_backfz2;
|
|
|
|
fixed_t rw_frontcz1, rw_frontcz2;
|
|
|
|
fixed_t rw_frontfz1, rw_frontfz2;
|
|
|
|
|
|
|
|
|
2006-05-06 03:25:12 +00:00
|
|
|
size_t MaxDrawSegs;
|
2006-02-24 04:48:15 +00:00
|
|
|
drawseg_t *drawsegs;
|
|
|
|
drawseg_t* firstdrawseg;
|
|
|
|
drawseg_t* ds_p;
|
|
|
|
|
2006-05-04 06:14:52 +00:00
|
|
|
size_t FirstInterestingDrawseg;
|
2006-02-24 04:48:15 +00:00
|
|
|
TArray<size_t> InterestingDrawsegs;
|
|
|
|
|
|
|
|
fixed_t WallTX1, WallTX2; // x coords at left, right of wall in view space
|
|
|
|
fixed_t WallTY1, WallTY2; // y coords at left, right of wall in view space
|
|
|
|
|
|
|
|
fixed_t WallCX1, WallCX2; // x coords at left, right of wall in camera space
|
|
|
|
fixed_t WallCY1, WallCY2; // y coords at left, right of wall in camera space
|
|
|
|
|
|
|
|
int WallSX1, WallSX2; // x coords at left, right of wall in screen space
|
|
|
|
fixed_t WallSZ1, WallSZ2; // depth at left, right of wall in screen space
|
|
|
|
|
|
|
|
float WallDepthOrg, WallDepthScale;
|
|
|
|
float WallUoverZorg, WallUoverZstep;
|
|
|
|
float WallInvZorg, WallInvZstep;
|
|
|
|
|
|
|
|
static BYTE FakeSide;
|
|
|
|
|
|
|
|
int WindowLeft, WindowRight;
|
|
|
|
WORD MirrorFlags;
|
|
|
|
seg_t *ActiveWallMirror;
|
|
|
|
TArray<size_t> WallMirrors;
|
|
|
|
|
2010-08-01 02:41:56 +00:00
|
|
|
static FNodeBuilder::FLevel PolyNodeLevel;
|
|
|
|
static FNodeBuilder PolyNodeBuilder(PolyNodeLevel);
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
static subsector_t *InSubsector;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
CVAR (Bool, r_drawflat, false, 0) // [RH] Don't texture segs?
|
|
|
|
|
|
|
|
|
|
|
|
void R_StoreWallRange (int start, int stop);
|
|
|
|
|
|
|
|
//
|
|
|
|
// R_ClearDrawSegs
|
|
|
|
//
|
|
|
|
void R_ClearDrawSegs (void)
|
|
|
|
{
|
|
|
|
if (drawsegs == NULL)
|
|
|
|
{
|
|
|
|
MaxDrawSegs = 256; // [RH] Default. Increased as needed.
|
2006-05-04 03:49:46 +00:00
|
|
|
firstdrawseg = drawsegs = (drawseg_t *)M_Malloc (MaxDrawSegs * sizeof(drawseg_t));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
FirstInterestingDrawseg = 0;
|
|
|
|
InterestingDrawsegs.Clear ();
|
|
|
|
ds_p = drawsegs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// ClipWallSegment
|
|
|
|
// Clips the given range of columns
|
|
|
|
// and includes it in the new clip list.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// 1/11/98 killough: Since a type "short" is sufficient, we
|
|
|
|
// should use it, since smaller arrays fit better in cache.
|
|
|
|
//
|
|
|
|
|
2009-03-28 11:49:44 +00:00
|
|
|
struct cliprange_t
|
|
|
|
{
|
2006-02-24 04:48:15 +00:00
|
|
|
short first, last; // killough
|
2009-03-28 11:49:44 +00:00
|
|
|
};
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// newend is one past the last valid seg
|
|
|
|
static cliprange_t *newend;
|
|
|
|
static cliprange_t solidsegs[MAXWIDTH/2+2];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_ClipWallSegment
|
|
|
|
//
|
|
|
|
// Clips the given range of columns, possibly including it in the clip list.
|
|
|
|
// Handles both windows (e.g. LineDefs with upper and lower textures) and
|
|
|
|
// solid walls (e.g. single sided LineDefs [middle texture]) that entirely
|
|
|
|
// block the view.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
bool R_ClipWallSegment (int first, int last, bool solid)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
cliprange_t *next, *start;
|
|
|
|
int i, j;
|
2010-08-27 15:20:05 +00:00
|
|
|
bool res = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Find the first range that touches the range
|
|
|
|
// (adjacent pixels are touching).
|
|
|
|
start = solidsegs;
|
|
|
|
while (start->last < first)
|
|
|
|
start++;
|
|
|
|
|
|
|
|
if (first < start->first)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
res = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (last <= start->first)
|
|
|
|
{
|
|
|
|
// Post is entirely visible (above start).
|
|
|
|
R_StoreWallRange (first, last);
|
|
|
|
|
|
|
|
// Insert a new clippost for solid walls.
|
|
|
|
if (solid)
|
|
|
|
{
|
|
|
|
if (last == start->first)
|
|
|
|
{
|
|
|
|
start->first = first;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
next = newend;
|
|
|
|
newend++;
|
|
|
|
while (next != start)
|
|
|
|
{
|
|
|
|
*next = *(next-1);
|
|
|
|
next--;
|
|
|
|
}
|
|
|
|
next->first = first;
|
|
|
|
next->last = last;
|
|
|
|
}
|
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
return true;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// There is a fragment above *start.
|
|
|
|
R_StoreWallRange (first, start->first);
|
|
|
|
|
|
|
|
// Adjust the clip size for solid walls
|
|
|
|
if (solid)
|
|
|
|
{
|
|
|
|
start->first = first;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bottom contained in start?
|
|
|
|
if (last <= start->last)
|
2010-08-27 15:20:05 +00:00
|
|
|
return res;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
next = start;
|
|
|
|
while (last >= (next+1)->first)
|
|
|
|
{
|
|
|
|
// There is a fragment between two posts.
|
|
|
|
R_StoreWallRange (next->last, (next+1)->first);
|
|
|
|
next++;
|
|
|
|
|
|
|
|
if (last <= next->last)
|
|
|
|
{
|
|
|
|
// Bottom is contained in next.
|
|
|
|
last = next->last;
|
|
|
|
goto crunch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// There is a fragment after *next.
|
|
|
|
R_StoreWallRange (next->last, last);
|
|
|
|
|
|
|
|
crunch:
|
|
|
|
if (solid)
|
|
|
|
{
|
|
|
|
// Adjust the clip size.
|
|
|
|
start->last = last;
|
|
|
|
|
|
|
|
if (next != start)
|
|
|
|
{
|
|
|
|
// Remove start+1 to next from the clip list,
|
|
|
|
// because start now covers their area.
|
|
|
|
for (i = 1, j = (int)(newend - next); j > 0; i++, j--)
|
|
|
|
{
|
|
|
|
start[i] = next[i];
|
|
|
|
}
|
|
|
|
newend = start+i;
|
|
|
|
}
|
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool R_CheckClipWallSegment (int first, int last)
|
|
|
|
{
|
|
|
|
cliprange_t *start;
|
|
|
|
|
|
|
|
// Find the first range that touches the range
|
|
|
|
// (adjacent pixels are touching).
|
|
|
|
start = solidsegs;
|
|
|
|
while (start->last < first)
|
|
|
|
start++;
|
|
|
|
|
|
|
|
if (first < start->first)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bottom contained in start?
|
|
|
|
if (last > start->last)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// R_ClearClipSegs
|
|
|
|
//
|
|
|
|
void R_ClearClipSegs (short left, short right)
|
|
|
|
{
|
|
|
|
solidsegs[0].first = -0x7fff; // new short limit -- killough
|
|
|
|
solidsegs[0].last = left;
|
|
|
|
solidsegs[1].first = right;
|
|
|
|
solidsegs[1].last = 0x7fff; // new short limit -- killough
|
|
|
|
newend = solidsegs+2;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetFloorLight (const sector_t *sec)
|
|
|
|
{
|
2009-09-17 10:40:38 +00:00
|
|
|
if (sec->GetFlags(sector_t::floor) & PLANEF_ABSLIGHTING)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return sec->GetPlaneLight(sector_t::floor);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return clamp (sec->lightlevel + sec->GetPlaneLight(sector_t::floor), 0, 255);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetCeilingLight (const sector_t *sec)
|
|
|
|
{
|
2009-09-17 10:40:38 +00:00
|
|
|
if (sec->GetFlags(sector_t::ceiling) & PLANEF_ABSLIGHTING)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return sec->GetPlaneLight(sector_t::ceiling);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return clamp (sec->lightlevel + sec->GetPlaneLight(sector_t::ceiling), 0, 255);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CopyPlaneIfValid (secplane_t *dest, const secplane_t *source, const secplane_t *opp)
|
|
|
|
{
|
|
|
|
bool copy = false;
|
|
|
|
|
|
|
|
// If the planes do not have matching slopes, then always copy them
|
|
|
|
// because clipping would require creating new sectors.
|
|
|
|
if (source->a != dest->a || source->b != dest->b || source->c != dest->c)
|
|
|
|
{
|
|
|
|
copy = true;
|
|
|
|
}
|
|
|
|
else if (opp->a != -dest->a || opp->b != -dest->b || opp->c != -dest->c)
|
|
|
|
{
|
|
|
|
if (source->d < dest->d)
|
|
|
|
{
|
|
|
|
copy = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (source->d < dest->d && source->d > -opp->d)
|
|
|
|
{
|
|
|
|
copy = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy)
|
|
|
|
{
|
|
|
|
*dest = *source;
|
|
|
|
}
|
|
|
|
|
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// killough 3/7/98: Hack floor/ceiling heights for deep water etc.
|
|
|
|
//
|
|
|
|
// If player's view height is underneath fake floor, lower the
|
|
|
|
// drawn ceiling to be just under the floor height, and replace
|
|
|
|
// the drawn floor and ceiling textures, and light level, with
|
|
|
|
// the control sector's.
|
|
|
|
//
|
|
|
|
// Similar for ceiling, only reflected.
|
|
|
|
//
|
|
|
|
// killough 4/11/98, 4/13/98: fix bugs, add 'back' parameter
|
|
|
|
//
|
|
|
|
|
|
|
|
sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
|
|
|
|
int *floorlightlevel, int *ceilinglightlevel,
|
2006-09-14 00:02:31 +00:00
|
|
|
bool back)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// [RH] allow per-plane lighting
|
|
|
|
if (floorlightlevel != NULL)
|
|
|
|
{
|
|
|
|
*floorlightlevel = GetFloorLight (sec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ceilinglightlevel != NULL)
|
|
|
|
{
|
|
|
|
*ceilinglightlevel = GetCeilingLight (sec);
|
|
|
|
}
|
|
|
|
|
|
|
|
FakeSide = FAKED_Center;
|
|
|
|
|
2009-05-23 10:21:33 +00:00
|
|
|
const sector_t *s = sec->GetHeightSec();
|
|
|
|
if (s != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
sector_t *heightsec = viewsector->heightsec;
|
|
|
|
bool underwater = r_fakingunderwater ||
|
|
|
|
(heightsec && viewz <= heightsec->floorplane.ZatPoint (viewx, viewy));
|
|
|
|
bool doorunderwater = false;
|
|
|
|
int diffTex = (s->MoreFlags & SECF_CLIPFAKEPLANES);
|
|
|
|
|
|
|
|
// Replace sector being drawn with a copy to be hacked
|
|
|
|
*tempsec = *sec;
|
|
|
|
|
|
|
|
// Replace floor and ceiling height with control sector's heights.
|
|
|
|
if (diffTex)
|
|
|
|
{
|
|
|
|
if (CopyPlaneIfValid (&tempsec->floorplane, &s->floorplane, &sec->ceilingplane))
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
tempsec->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (s->MoreFlags & SECF_FAKEFLOORONLY)
|
|
|
|
{
|
|
|
|
if (underwater)
|
|
|
|
{
|
|
|
|
tempsec->ColorMap = s->ColorMap;
|
|
|
|
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
|
|
|
|
{
|
|
|
|
tempsec->lightlevel = s->lightlevel;
|
|
|
|
|
|
|
|
if (floorlightlevel != NULL)
|
|
|
|
{
|
|
|
|
*floorlightlevel = GetFloorLight (s);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ceilinglightlevel != NULL)
|
|
|
|
{
|
2006-04-16 13:29:50 +00:00
|
|
|
*ceilinglightlevel = GetCeilingLight (s);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
FakeSide = FAKED_BelowFloor;
|
|
|
|
return tempsec;
|
|
|
|
}
|
|
|
|
return sec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tempsec->floorplane = s->floorplane;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(s->MoreFlags & SECF_FAKEFLOORONLY))
|
|
|
|
{
|
|
|
|
if (diffTex)
|
|
|
|
{
|
|
|
|
if (CopyPlaneIfValid (&tempsec->ceilingplane, &s->ceilingplane, &sec->floorplane))
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
tempsec->SetTexture(sector_t::ceiling, s->GetTexture(sector_t::ceiling), false);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tempsec->ceilingplane = s->ceilingplane;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// fixed_t refflorz = s->floorplane.ZatPoint (viewx, viewy);
|
|
|
|
fixed_t refceilz = s->ceilingplane.ZatPoint (viewx, viewy);
|
|
|
|
// fixed_t orgflorz = sec->floorplane.ZatPoint (viewx, viewy);
|
|
|
|
fixed_t orgceilz = sec->ceilingplane.ZatPoint (viewx, viewy);
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
// [RH] Allow viewing underwater areas through doors/windows that
|
|
|
|
// are underwater but not in a water sector themselves.
|
|
|
|
// Only works if you cannot see the top surface of any deep water
|
|
|
|
// sectors at the same time.
|
|
|
|
if (back && !r_fakingunderwater && curline->frontsector->heightsec == NULL)
|
|
|
|
{
|
|
|
|
if (rw_frontcz1 <= s->floorplane.ZatPoint (curline->v1->x, curline->v1->y) &&
|
|
|
|
rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->x, curline->v2->y))
|
|
|
|
{
|
|
|
|
// Check that the window is actually visible
|
|
|
|
for (int z = WallSX1; z < WallSX2; ++z)
|
|
|
|
{
|
|
|
|
if (floorclip[z] > ceilingclip[z])
|
|
|
|
{
|
|
|
|
doorunderwater = true;
|
|
|
|
r_fakingunderwater = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (underwater || doorunderwater)
|
|
|
|
{
|
|
|
|
tempsec->floorplane = sec->floorplane;
|
|
|
|
tempsec->ceilingplane = s->floorplane;
|
|
|
|
tempsec->ceilingplane.FlipVert ();
|
|
|
|
tempsec->ceilingplane.ChangeHeight (-1);
|
|
|
|
tempsec->ColorMap = s->ColorMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
// killough 11/98: prevent sudden light changes from non-water sectors:
|
|
|
|
if ((underwater && !back) || doorunderwater)
|
|
|
|
{ // head-below-floor hack
|
2008-08-16 20:19:35 +00:00
|
|
|
tempsec->SetTexture(sector_t::floor, diffTex ? sec->GetTexture(sector_t::floor) : s->GetTexture(sector_t::floor), false);
|
2008-06-14 15:26:16 +00:00
|
|
|
tempsec->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
tempsec->ceilingplane = s->floorplane;
|
|
|
|
tempsec->ceilingplane.FlipVert ();
|
|
|
|
tempsec->ceilingplane.ChangeHeight (-1);
|
2008-08-16 20:19:35 +00:00
|
|
|
if (s->GetTexture(sector_t::ceiling) == skyflatnum)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
tempsec->floorplane = tempsec->ceilingplane;
|
|
|
|
tempsec->floorplane.FlipVert ();
|
|
|
|
tempsec->floorplane.ChangeHeight (+1);
|
2008-08-16 20:19:35 +00:00
|
|
|
tempsec->SetTexture(sector_t::ceiling, tempsec->GetTexture(sector_t::floor), false);
|
2008-06-14 15:26:16 +00:00
|
|
|
tempsec->planes[sector_t::ceiling].xform = tempsec->planes[sector_t::floor].xform;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
tempsec->SetTexture(sector_t::ceiling, diffTex ? s->GetTexture(sector_t::floor) : s->GetTexture(sector_t::ceiling), false);
|
2008-06-14 15:26:16 +00:00
|
|
|
tempsec->planes[sector_t::ceiling].xform = s->planes[sector_t::ceiling].xform;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
|
|
|
|
{
|
|
|
|
tempsec->lightlevel = s->lightlevel;
|
|
|
|
|
|
|
|
if (floorlightlevel != NULL)
|
|
|
|
{
|
|
|
|
*floorlightlevel = GetFloorLight (s);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ceilinglightlevel != NULL)
|
|
|
|
{
|
2006-04-16 13:29:50 +00:00
|
|
|
*ceilinglightlevel = GetCeilingLight (s);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
FakeSide = FAKED_BelowFloor;
|
|
|
|
}
|
|
|
|
else if (heightsec && viewz >= heightsec->ceilingplane.ZatPoint (viewx, viewy) &&
|
|
|
|
orgceilz > refceilz && !(s->MoreFlags & SECF_FAKEFLOORONLY))
|
|
|
|
{ // Above-ceiling hack
|
|
|
|
tempsec->ceilingplane = s->ceilingplane;
|
|
|
|
tempsec->floorplane = s->ceilingplane;
|
|
|
|
tempsec->floorplane.FlipVert ();
|
|
|
|
tempsec->floorplane.ChangeHeight (+1);
|
|
|
|
tempsec->ColorMap = s->ColorMap;
|
|
|
|
tempsec->ColorMap = s->ColorMap;
|
|
|
|
|
2008-08-16 20:19:35 +00:00
|
|
|
tempsec->SetTexture(sector_t::ceiling, diffTex ? sec->GetTexture(sector_t::ceiling) : s->GetTexture(sector_t::ceiling), false);
|
|
|
|
tempsec->SetTexture(sector_t::floor, s->GetTexture(sector_t::ceiling), false);
|
2008-06-14 15:26:16 +00:00
|
|
|
tempsec->planes[sector_t::ceiling].xform = tempsec->planes[sector_t::floor].xform = s->planes[sector_t::ceiling].xform;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-16 20:19:35 +00:00
|
|
|
if (s->GetTexture(sector_t::floor) != skyflatnum)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
tempsec->ceilingplane = sec->ceilingplane;
|
2008-08-16 20:19:35 +00:00
|
|
|
tempsec->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
|
2008-06-14 15:26:16 +00:00
|
|
|
tempsec->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
|
|
|
|
{
|
|
|
|
tempsec->lightlevel = s->lightlevel;
|
|
|
|
|
|
|
|
if (floorlightlevel != NULL)
|
|
|
|
{
|
|
|
|
*floorlightlevel = GetFloorLight (s);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ceilinglightlevel != NULL)
|
|
|
|
{
|
|
|
|
*ceilinglightlevel = GetCeilingLight (s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FakeSide = FAKED_AboveCeiling;
|
|
|
|
}
|
|
|
|
sec = tempsec; // Use other sector
|
|
|
|
}
|
|
|
|
return sec;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// R_AddLine
|
|
|
|
// Clips the given segment
|
|
|
|
// and adds any visible pieces to the line list.
|
|
|
|
//
|
|
|
|
|
|
|
|
void R_AddLine (seg_t *line)
|
|
|
|
{
|
|
|
|
static sector_t tempsec; // killough 3/8/98: ceiling/water hack
|
|
|
|
bool solid;
|
|
|
|
fixed_t tx1, tx2, ty1, ty2;
|
|
|
|
|
|
|
|
curline = line;
|
|
|
|
|
|
|
|
// [RH] Color if not texturing line
|
|
|
|
dc_color = (((int)(line - segs) * 8) + 4) & 255;
|
|
|
|
|
|
|
|
tx1 = line->v1->x - viewx;
|
|
|
|
tx2 = line->v2->x - viewx;
|
|
|
|
ty1 = line->v1->y - viewy;
|
|
|
|
ty2 = line->v2->y - viewy;
|
|
|
|
|
|
|
|
// Reject lines not facing viewer
|
|
|
|
if (DMulScale32 (ty1, tx1-tx2, tx1, ty2-ty1) >= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
WallTX1 = DMulScale20 (tx1, viewsin, -ty1, viewcos);
|
|
|
|
WallTX2 = DMulScale20 (tx2, viewsin, -ty2, viewcos);
|
|
|
|
|
|
|
|
WallTY1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin);
|
|
|
|
WallTY2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin);
|
|
|
|
|
|
|
|
if (MirrorFlags & RF_XFLIP)
|
|
|
|
{
|
|
|
|
int t = 256-WallTX1;
|
|
|
|
WallTX1 = 256-WallTX2;
|
|
|
|
WallTX2 = t;
|
2010-07-23 21:19:59 +00:00
|
|
|
swapvalues (WallTY1, WallTY2);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (WallTX1 >= -WallTY1)
|
|
|
|
{
|
|
|
|
if (WallTX1 > WallTY1) return; // left edge is off the right side
|
|
|
|
if (WallTY1 == 0) return;
|
|
|
|
WallSX1 = (centerxfrac + Scale (WallTX1, centerxfrac, WallTY1)) >> FRACBITS;
|
|
|
|
if (WallTX1 >= 0) WallSX1 = MIN (viewwidth, WallSX1+1); // fix for signed divide
|
|
|
|
WallSZ1 = WallTY1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (WallTX2 < -WallTY2) return; // wall is off the left side
|
|
|
|
fixed_t den = WallTX1 - WallTX2 - WallTY2 + WallTY1;
|
|
|
|
if (den == 0) return;
|
|
|
|
WallSX1 = 0;
|
|
|
|
WallSZ1 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 + WallTY1, den);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WallSZ1 < 32)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (WallTX2 <= WallTY2)
|
|
|
|
{
|
|
|
|
if (WallTX2 < -WallTY2) return; // right edge is off the left side
|
|
|
|
if (WallTY2 == 0) return;
|
|
|
|
WallSX2 = (centerxfrac + Scale (WallTX2, centerxfrac, WallTY2)) >> FRACBITS;
|
|
|
|
if (WallTX2 >= 0) WallSX2 = MIN (viewwidth, WallSX2+1); // fix for signed divide
|
|
|
|
WallSZ2 = WallTY2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (WallTX1 > WallTY1) return; // wall is off the right side
|
|
|
|
fixed_t den = WallTY2 - WallTY1 - WallTX2 + WallTX1;
|
|
|
|
if (den == 0) return;
|
|
|
|
WallSX2 = viewwidth;
|
|
|
|
WallSZ2 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 - WallTY1, den);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WallSZ2 < 32 || WallSX2 <= WallSX1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (WallSX1 > WindowRight || WallSX2 < WindowLeft)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (line->linedef == NULL)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (R_CheckClipWallSegment (WallSX1, WallSX2))
|
|
|
|
{
|
|
|
|
InSubsector->flags |= SSECF_DRAWN;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
vertex_t *v1, *v2;
|
|
|
|
|
|
|
|
v1 = line->linedef->v1;
|
|
|
|
v2 = line->linedef->v2;
|
|
|
|
|
|
|
|
if ((v1 == line->v1 && v2 == line->v2) || (v2 == line->v1 && v1 == line->v2))
|
|
|
|
{ // The seg is the entire wall.
|
|
|
|
if (MirrorFlags & RF_XFLIP)
|
|
|
|
{
|
|
|
|
WallUoverZorg = (float)WallTX2 * WallTMapScale;
|
|
|
|
WallUoverZstep = (float)(-WallTY2) * 32.f;
|
|
|
|
WallInvZorg = (float)(WallTX2 - WallTX1) * WallTMapScale;
|
|
|
|
WallInvZstep = (float)(WallTY1 - WallTY2) * 32.f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WallUoverZorg = (float)WallTX1 * WallTMapScale;
|
|
|
|
WallUoverZstep = (float)(-WallTY1) * 32.f;
|
|
|
|
WallInvZorg = (float)(WallTX1 - WallTX2) * WallTMapScale;
|
|
|
|
WallInvZstep = (float)(WallTY2 - WallTY1) * 32.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // The seg is only part of the wall.
|
2009-09-06 20:45:56 +00:00
|
|
|
if (line->linedef->sidedef[0] != line->sidedef)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-07-23 21:19:59 +00:00
|
|
|
swapvalues (v1, v2);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
tx1 = v1->x - viewx;
|
|
|
|
tx2 = v2->x - viewx;
|
|
|
|
ty1 = v1->y - viewy;
|
|
|
|
ty2 = v2->y - viewy;
|
|
|
|
|
|
|
|
fixed_t fullx1 = DMulScale20 (tx1, viewsin, -ty1, viewcos);
|
|
|
|
fixed_t fullx2 = DMulScale20 (tx2, viewsin, -ty2, viewcos);
|
|
|
|
fixed_t fully1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin);
|
|
|
|
fixed_t fully2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin);
|
|
|
|
|
|
|
|
if (MirrorFlags & RF_XFLIP)
|
|
|
|
{
|
|
|
|
fullx1 = -fullx1;
|
|
|
|
fullx2 = -fullx2;
|
|
|
|
}
|
|
|
|
|
|
|
|
WallUoverZorg = (float)fullx1 * WallTMapScale;
|
|
|
|
WallUoverZstep = (float)(-fully1) * 32.f;
|
|
|
|
WallInvZorg = (float)(fullx1 - fullx2) * WallTMapScale;
|
|
|
|
WallInvZstep = (float)(fully2 - fully1) * 32.f;
|
|
|
|
}
|
|
|
|
WallDepthScale = WallInvZstep * WallTMapScale2;
|
|
|
|
WallDepthOrg = -WallUoverZstep * WallTMapScale2;
|
|
|
|
|
|
|
|
backsector = line->backsector;
|
|
|
|
|
|
|
|
rw_frontcz1 = frontsector->ceilingplane.ZatPoint (line->v1->x, line->v1->y);
|
|
|
|
rw_frontfz1 = frontsector->floorplane.ZatPoint (line->v1->x, line->v1->y);
|
|
|
|
rw_frontcz2 = frontsector->ceilingplane.ZatPoint (line->v2->x, line->v2->y);
|
|
|
|
rw_frontfz2 = frontsector->floorplane.ZatPoint (line->v2->x, line->v2->y);
|
|
|
|
|
|
|
|
rw_mustmarkfloor = rw_mustmarkceiling = false;
|
|
|
|
rw_havehigh = rw_havelow = false;
|
|
|
|
|
|
|
|
// Single sided line?
|
|
|
|
if (backsector == NULL)
|
|
|
|
{
|
|
|
|
solid = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// killough 3/8/98, 4/4/98: hack for invisible ceilings / deep water
|
|
|
|
backsector = R_FakeFlat (backsector, &tempsec, NULL, NULL, true);
|
|
|
|
|
|
|
|
doorclosed = 0; // killough 4/16/98
|
|
|
|
|
|
|
|
rw_backcz1 = backsector->ceilingplane.ZatPoint (line->v1->x, line->v1->y);
|
|
|
|
rw_backfz1 = backsector->floorplane.ZatPoint (line->v1->x, line->v1->y);
|
|
|
|
rw_backcz2 = backsector->ceilingplane.ZatPoint (line->v2->x, line->v2->y);
|
|
|
|
rw_backfz2 = backsector->floorplane.ZatPoint (line->v2->x, line->v2->y);
|
|
|
|
|
|
|
|
// Cannot make these walls solid, because it can result in
|
|
|
|
// sprite clipping problems for sprites near the wall
|
|
|
|
if (rw_frontcz1 > rw_backcz1 || rw_frontcz2 > rw_backcz2)
|
|
|
|
{
|
|
|
|
rw_havehigh = true;
|
|
|
|
WallMost (wallupper, backsector->ceilingplane);
|
|
|
|
}
|
|
|
|
if (rw_frontfz1 < rw_backfz1 || rw_frontfz2 < rw_backfz2)
|
|
|
|
{
|
|
|
|
rw_havelow = true;
|
|
|
|
WallMost (walllower, backsector->floorplane);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Closed door.
|
|
|
|
if ((rw_backcz1 <= rw_frontfz1 && rw_backcz2 <= rw_frontfz2) ||
|
|
|
|
(rw_backfz1 >= rw_frontcz1 && rw_backfz2 >= rw_frontcz2))
|
|
|
|
{
|
|
|
|
solid = true;
|
|
|
|
}
|
|
|
|
else if (
|
2006-07-11 04:48:10 +00:00
|
|
|
// properly render skies (consider door "open" if both ceilings are sky):
|
2008-08-16 20:19:35 +00:00
|
|
|
(backsector->GetTexture(sector_t::ceiling) != skyflatnum || frontsector->GetTexture(sector_t::ceiling) != skyflatnum)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// if door is closed because back is shut:
|
|
|
|
&& rw_backcz1 <= rw_backfz1 && rw_backcz2 <= rw_backfz2
|
|
|
|
|
|
|
|
// preserve a kind of transparent door/lift special effect:
|
2008-06-15 18:36:26 +00:00
|
|
|
&& ((rw_backcz1 >= rw_frontcz1 && rw_backcz2 >= rw_frontcz2) || line->sidedef->GetTexture(side_t::top).isValid())
|
|
|
|
&& ((rw_backfz1 <= rw_frontfz1 && rw_backfz2 <= rw_frontfz2) || line->sidedef->GetTexture(side_t::bottom).isValid()))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// killough 1/18/98 -- This function is used to fix the automap bug which
|
|
|
|
// showed lines behind closed doors simply because the door had a dropoff.
|
|
|
|
//
|
|
|
|
// It assumes that Doom has already ruled out a door being closed because
|
|
|
|
// of front-back closure (e.g. front floor is taller than back ceiling).
|
|
|
|
|
|
|
|
// This fixes the automap floor height bug -- killough 1/18/98:
|
|
|
|
// killough 4/7/98: optimize: save result in doorclosed for use in r_segs.c
|
|
|
|
doorclosed = true;
|
|
|
|
solid = true;
|
|
|
|
}
|
|
|
|
else if (frontsector->ceilingplane != backsector->ceilingplane ||
|
|
|
|
frontsector->floorplane != backsector->floorplane)
|
|
|
|
{
|
|
|
|
// Window.
|
|
|
|
solid = false;
|
|
|
|
}
|
|
|
|
else if (backsector->lightlevel != frontsector->lightlevel
|
2008-08-16 20:19:35 +00:00
|
|
|
|| backsector->GetTexture(sector_t::floor) != frontsector->GetTexture(sector_t::floor)
|
|
|
|
|| backsector->GetTexture(sector_t::ceiling) != frontsector->GetTexture(sector_t::ceiling)
|
2008-06-15 18:36:26 +00:00
|
|
|
|| curline->sidedef->GetTexture(side_t::mid).isValid()
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// killough 3/7/98: Take flats offsets into account:
|
2008-06-14 15:26:16 +00:00
|
|
|
|| backsector->GetXOffset(sector_t::floor) != frontsector->GetXOffset(sector_t::floor)
|
|
|
|
|| backsector->GetYOffset(sector_t::floor) != frontsector->GetYOffset(sector_t::floor)
|
|
|
|
|| backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling)
|
|
|
|
|| backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-16 20:19:35 +00:00
|
|
|
|| backsector->GetPlaneLight(sector_t::floor) != frontsector->GetPlaneLight(sector_t::floor)
|
|
|
|
|| backsector->GetPlaneLight(sector_t::ceiling) != frontsector->GetPlaneLight(sector_t::ceiling)
|
|
|
|
|| backsector->GetFlags(sector_t::floor) != frontsector->GetFlags(sector_t::floor)
|
|
|
|
|| backsector->GetFlags(sector_t::ceiling) != frontsector->GetFlags(sector_t::ceiling)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Also consider colormaps
|
|
|
|
|| backsector->ColorMap != frontsector->ColorMap
|
|
|
|
|
|
|
|
// [RH] and scaling
|
2008-06-14 15:26:16 +00:00
|
|
|
|| backsector->GetXScale(sector_t::floor) != frontsector->GetXScale(sector_t::floor)
|
|
|
|
|| backsector->GetYScale(sector_t::floor) != frontsector->GetYScale(sector_t::floor)
|
|
|
|
|| backsector->GetXScale(sector_t::ceiling) != frontsector->GetXScale(sector_t::ceiling)
|
|
|
|
|| backsector->GetYScale(sector_t::ceiling) != frontsector->GetYScale(sector_t::ceiling)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] and rotation
|
2008-06-14 15:26:16 +00:00
|
|
|
|| backsector->GetAngle(sector_t::floor) != frontsector->GetAngle(sector_t::floor)
|
|
|
|
|| backsector->GetAngle(sector_t::ceiling) != frontsector->GetAngle(sector_t::ceiling)
|
2006-02-24 04:48:15 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
solid = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Reject empty lines used for triggers and special events.
|
|
|
|
// Identical floor and ceiling on both sides, identical light levels
|
|
|
|
// on both sides, and no middle texture.
|
2010-08-27 15:20:05 +00:00
|
|
|
|
|
|
|
// When using GL nodes, do a clipping test for these lines so we can
|
|
|
|
// mark their subsectors as visible for automap texturing.
|
|
|
|
if (hasglnodes && !(InSubsector->flags & SSECF_DRAWN))
|
|
|
|
{
|
|
|
|
if (R_CheckClipWallSegment(WallSX1, WallSX2))
|
|
|
|
{
|
|
|
|
InSubsector->flags |= SSECF_DRAWN;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rw_prepped = false;
|
|
|
|
|
|
|
|
if (line->linedef->special == Line_Horizon)
|
|
|
|
{
|
|
|
|
// Be aware: Line_Horizon does not work properly with sloped planes
|
|
|
|
clearbufshort (walltop+WallSX1, WallSX2 - WallSX1, centery);
|
|
|
|
clearbufshort (wallbottom+WallSX1, WallSX2 - WallSX1, centery);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rw_ceilstat = WallMost (walltop, frontsector->ceilingplane);
|
|
|
|
rw_floorstat = WallMost (wallbottom, frontsector->floorplane);
|
|
|
|
|
|
|
|
// [RH] treat off-screen walls as solid
|
|
|
|
#if 0 // Maybe later...
|
|
|
|
if (!solid)
|
|
|
|
{
|
2008-03-21 17:35:49 +00:00
|
|
|
if (rw_ceilstat == 12 && line->sidedef->GetTexture(side_t::top) != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
rw_mustmarkceiling = true;
|
|
|
|
solid = true;
|
|
|
|
}
|
2008-03-21 17:35:49 +00:00
|
|
|
if (rw_floorstat == 3 && line->sidedef->GetTexture(side_t::bottom) != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
rw_mustmarkfloor = true;
|
|
|
|
solid = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
if (R_ClipWallSegment (WallSX1, WallSX2, solid))
|
|
|
|
{
|
|
|
|
InSubsector->flags |= SSECF_DRAWN;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// R_CheckBBox
|
|
|
|
// Checks BSP node/subtree bounding box.
|
|
|
|
// Returns true if some part of the bbox might be visible.
|
|
|
|
//
|
|
|
|
extern "C" const int checkcoord[12][4] =
|
|
|
|
{
|
|
|
|
{3,0,2,1},
|
|
|
|
{3,0,2,0},
|
|
|
|
{3,1,2,0},
|
|
|
|
{0},
|
|
|
|
{2,0,2,1},
|
|
|
|
{0,0,0,0},
|
|
|
|
{3,1,3,0},
|
|
|
|
{0},
|
|
|
|
{2,0,3,1},
|
|
|
|
{2,1,3,1},
|
|
|
|
{2,1,3,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int boxx;
|
|
|
|
int boxy;
|
|
|
|
int boxpos;
|
|
|
|
|
|
|
|
fixed_t x1, y1, x2, y2;
|
|
|
|
fixed_t rx1, ry1, rx2, ry2;
|
|
|
|
int sx1, sx2;
|
|
|
|
|
|
|
|
cliprange_t* start;
|
|
|
|
|
|
|
|
// Find the corners of the box
|
|
|
|
// that define the edges from current viewpoint.
|
|
|
|
if (viewx <= bspcoord[BOXLEFT])
|
|
|
|
boxx = 0;
|
|
|
|
else if (viewx < bspcoord[BOXRIGHT])
|
|
|
|
boxx = 1;
|
|
|
|
else
|
|
|
|
boxx = 2;
|
|
|
|
|
|
|
|
if (viewy >= bspcoord[BOXTOP])
|
|
|
|
boxy = 0;
|
|
|
|
else if (viewy > bspcoord[BOXBOTTOM])
|
|
|
|
boxy = 1;
|
|
|
|
else
|
|
|
|
boxy = 2;
|
|
|
|
|
|
|
|
boxpos = (boxy<<2)+boxx;
|
|
|
|
if (boxpos == 5)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
x1 = bspcoord[checkcoord[boxpos][0]] - viewx;
|
|
|
|
y1 = bspcoord[checkcoord[boxpos][1]] - viewy;
|
|
|
|
x2 = bspcoord[checkcoord[boxpos][2]] - viewx;
|
|
|
|
y2 = bspcoord[checkcoord[boxpos][3]] - viewy;
|
|
|
|
|
|
|
|
// check clip list for an open space
|
|
|
|
|
|
|
|
// Sitting on a line?
|
|
|
|
if (DMulScale32 (y1, x1-x2, x1, y2-y1) >= 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
rx1 = DMulScale20 (x1, viewsin, -y1, viewcos);
|
|
|
|
rx2 = DMulScale20 (x2, viewsin, -y2, viewcos);
|
|
|
|
ry1 = DMulScale20 (x1, viewtancos, y1, viewtansin);
|
|
|
|
ry2 = DMulScale20 (x2, viewtancos, y2, viewtansin);
|
|
|
|
|
|
|
|
if (MirrorFlags & RF_XFLIP)
|
|
|
|
{
|
|
|
|
int t = 256-rx1;
|
|
|
|
rx1 = 256-rx2;
|
|
|
|
rx2 = t;
|
2010-07-23 21:19:59 +00:00
|
|
|
swapvalues (ry1, ry2);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rx1 >= -ry1)
|
|
|
|
{
|
|
|
|
if (rx1 > ry1) return false; // left edge is off the right side
|
|
|
|
if (ry1 == 0) return false;
|
|
|
|
sx1 = (centerxfrac + Scale (rx1, centerxfrac, ry1)) >> FRACBITS;
|
|
|
|
if (rx1 >= 0) sx1 = MIN<int> (viewwidth, sx1+1); // fix for signed divide
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (rx2 < -ry2) return false; // wall is off the left side
|
|
|
|
if (rx1 - rx2 - ry2 + ry1 == 0) return false; // wall does not intersect view volume
|
|
|
|
sx1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rx2 <= ry2)
|
|
|
|
{
|
|
|
|
if (rx2 < -ry2) return false; // right edge is off the left side
|
|
|
|
if (ry2 == 0) return false;
|
|
|
|
sx2 = (centerxfrac + Scale (rx2, centerxfrac, ry2)) >> FRACBITS;
|
|
|
|
if (rx2 >= 0) sx2 = MIN<int> (viewwidth, sx2+1); // fix for signed divide
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (rx1 > ry1) return false; // wall is off the right side
|
|
|
|
if (ry2 - ry1 - rx2 + rx1 == 0) return false; // wall does not intersect view volume
|
|
|
|
sx2 = viewwidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the first clippost that touches the source post
|
|
|
|
// (adjacent pixels are touching).
|
|
|
|
|
|
|
|
// Does not cross a pixel.
|
|
|
|
if (sx2 <= sx1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
start = solidsegs;
|
|
|
|
while (start->last < sx2)
|
|
|
|
start++;
|
|
|
|
|
|
|
|
if (sx1 >= start->first && sx2 <= start->last)
|
|
|
|
{
|
|
|
|
// The clippost contains the new span.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_GetExtraLight (int *light, const secplane_t &plane, FExtraLight *el)
|
|
|
|
{
|
- 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
|
|
|
FDynamicColormap *floodcolormap;
|
2006-02-24 04:48:15 +00:00
|
|
|
int floodlight;
|
|
|
|
bool flooding;
|
|
|
|
vertex_t **triangle;
|
|
|
|
int i, j;
|
|
|
|
fixed_t diff;
|
|
|
|
|
|
|
|
if (el == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
triangle = frontsector->Triangle;
|
|
|
|
flooding = false;
|
|
|
|
floodcolormap = basecolormap;
|
|
|
|
floodlight = *light;
|
|
|
|
|
|
|
|
for (i = 0; i < el->NumUsedLights; ++i)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 3; ++j)
|
|
|
|
{
|
|
|
|
diff = plane.ZatPoint (triangle[j]) - el->Lights[i].Plane.ZatPoint (triangle[j]);
|
|
|
|
if (diff != 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (diff >= 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flooding || el->Lights[i].bFlooder)
|
|
|
|
{
|
|
|
|
if (el->Lights[i].Master == NULL)
|
|
|
|
{
|
|
|
|
basecolormap = floodcolormap;
|
|
|
|
*light = floodlight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
- 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
|
|
|
basecolormap = el->Lights[i].Master->ColorMap;
|
2006-02-24 04:48:15 +00:00
|
|
|
*light = el->Lights[i].Master->lightlevel;
|
|
|
|
if (el->Lights[i].bFlooder)
|
|
|
|
{
|
|
|
|
flooding = true;
|
|
|
|
floodcolormap = basecolormap;
|
|
|
|
floodlight = *light;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-23 05:56:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-01 02:41:56 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FMiniBSP Constructor
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2010-07-23 05:56:25 +00:00
|
|
|
|
2010-08-01 02:41:56 +00:00
|
|
|
FMiniBSP::FMiniBSP()
|
2010-07-23 05:56:25 +00:00
|
|
|
{
|
2010-08-01 02:41:56 +00:00
|
|
|
bDirty = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// P_BuildPolyBSP
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2010-07-23 05:56:25 +00:00
|
|
|
|
2010-08-10 08:13:23 +00:00
|
|
|
void R_BuildPolyBSP(subsector_t *sub)
|
2010-08-01 02:41:56 +00:00
|
|
|
{
|
|
|
|
assert((sub->BSP == NULL || sub->BSP->bDirty) && "BSP computed more than once");
|
|
|
|
|
|
|
|
// Set up level information for the node builder.
|
|
|
|
PolyNodeLevel.Sides = sides;
|
|
|
|
PolyNodeLevel.NumSides = numsides;
|
|
|
|
PolyNodeLevel.Lines = lines;
|
|
|
|
PolyNodeLevel.NumLines = numlines;
|
|
|
|
|
|
|
|
// Feed segs to the nodebuilder and build the nodes.
|
|
|
|
PolyNodeBuilder.Clear();
|
|
|
|
PolyNodeBuilder.AddSegs(sub->firstline, sub->numlines);
|
|
|
|
for (FPolyNode *pn = sub->polys; pn != NULL; pn = pn->pnext)
|
2010-07-23 05:56:25 +00:00
|
|
|
{
|
2010-08-01 02:41:56 +00:00
|
|
|
PolyNodeBuilder.AddPolySegs(&pn->segs[0], (int)pn->segs.Size());
|
2010-07-23 05:56:25 +00:00
|
|
|
}
|
2010-08-01 02:41:56 +00:00
|
|
|
PolyNodeBuilder.BuildMini(false);
|
|
|
|
if (sub->BSP == NULL)
|
2010-07-23 05:56:25 +00:00
|
|
|
{
|
2010-08-01 02:41:56 +00:00
|
|
|
sub->BSP = new FMiniBSP;
|
2010-07-23 05:56:25 +00:00
|
|
|
}
|
2010-08-01 02:41:56 +00:00
|
|
|
else
|
2010-07-23 05:56:25 +00:00
|
|
|
{
|
2010-08-01 02:41:56 +00:00
|
|
|
sub->BSP->bDirty = false;
|
|
|
|
}
|
|
|
|
PolyNodeBuilder.ExtractMini(sub->BSP);
|
|
|
|
for (unsigned int i = 0; i < sub->BSP->Subsectors.Size(); ++i)
|
|
|
|
{
|
|
|
|
sub->BSP->Subsectors[i].sector = sub->sector;
|
2010-07-23 05:56:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-01 02:41:56 +00:00
|
|
|
void R_Subsector (subsector_t *sub);
|
|
|
|
static void R_AddPolyobjs(subsector_t *sub)
|
|
|
|
{
|
|
|
|
if (sub->BSP == NULL || sub->BSP->bDirty)
|
|
|
|
{
|
|
|
|
R_BuildPolyBSP(sub);
|
|
|
|
}
|
|
|
|
if (sub->BSP->Nodes.Size() == 0)
|
|
|
|
{
|
|
|
|
R_Subsector(&sub->BSP->Subsectors[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
R_RenderBSPNode(&sub->BSP->Nodes.Last());
|
|
|
|
}
|
|
|
|
}
|
2010-07-23 05:56:25 +00:00
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// R_Subsector
|
|
|
|
// Determine floor/ceiling planes.
|
|
|
|
// Add sprites of things in sector.
|
|
|
|
// Draw one or more line segments.
|
|
|
|
//
|
|
|
|
void R_Subsector (subsector_t *sub)
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
seg_t* line;
|
|
|
|
sector_t tempsec; // killough 3/7/98: deep water hack
|
|
|
|
int floorlightlevel; // killough 3/16/98: set floor lightlevel
|
|
|
|
int ceilinglightlevel; // killough 4/11/98
|
2010-08-27 15:20:05 +00:00
|
|
|
bool outersubsector;
|
|
|
|
|
|
|
|
if (InSubsector != NULL)
|
|
|
|
{ // InSubsector is not NULL. This means we are rendering from a mini-BSP.
|
|
|
|
outersubsector = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
outersubsector = true;
|
|
|
|
InSubsector = sub;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#ifdef RANGECHECK
|
2010-08-27 15:20:05 +00:00
|
|
|
if (outersubsector && sub - subsectors >= (ptrdiff_t)numsubsectors)
|
2008-05-14 03:39:30 +00:00
|
|
|
I_Error ("R_Subsector: ss %ti with numss = %i", sub - subsectors, numsubsectors);
|
2010-08-01 02:41:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
assert(sub->sector != NULL);
|
|
|
|
|
|
|
|
if (sub->polys)
|
|
|
|
{ // Render the polyobjs in the subsector first
|
|
|
|
R_AddPolyobjs(sub);
|
2010-08-27 15:20:05 +00:00
|
|
|
if (outersubsector)
|
|
|
|
{
|
|
|
|
InSubsector = NULL;
|
|
|
|
}
|
2010-08-01 02:41:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
frontsector = sub->sector;
|
2006-10-20 04:04:04 +00:00
|
|
|
frontsector->MoreFlags |= SECF_DRAWN;
|
2006-02-24 04:48:15 +00:00
|
|
|
count = sub->numlines;
|
2010-08-01 02:41:56 +00:00
|
|
|
line = sub->firstline;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// killough 3/8/98, 4/4/98: Deep water / fake ceiling effect
|
|
|
|
frontsector = R_FakeFlat(frontsector, &tempsec, &floorlightlevel,
|
|
|
|
&ceilinglightlevel, false); // killough 4/11/98
|
|
|
|
|
- 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
|
|
|
basecolormap = frontsector->ColorMap;
|
2006-02-24 04:48:15 +00:00
|
|
|
R_GetExtraLight (&ceilinglightlevel, frontsector->ceilingplane, frontsector->ExtraLights);
|
|
|
|
|
|
|
|
// [RH] set foggy flag
|
|
|
|
foggy = level.fadeto || frontsector->ColorMap->Fade || (level.flags & LEVEL_HASFADETABLE);
|
|
|
|
r_actualextralight = foggy ? 0 : extralight << 4;
|
- 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
|
|
|
basecolormap = frontsector->ColorMap;
|
2006-02-24 04:48:15 +00:00
|
|
|
ceilingplane = frontsector->ceilingplane.ZatPoint (viewx, viewy) > viewz ||
|
2008-08-16 20:19:35 +00:00
|
|
|
frontsector->GetTexture(sector_t::ceiling) == skyflatnum ||
|
2006-02-24 04:48:15 +00:00
|
|
|
(frontsector->CeilingSkyBox != NULL && frontsector->CeilingSkyBox->bAlways) ||
|
|
|
|
(frontsector->heightsec &&
|
|
|
|
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
|
2008-08-16 20:19:35 +00:00
|
|
|
frontsector->heightsec->GetTexture(sector_t::floor) == skyflatnum) ?
|
2006-02-24 04:48:15 +00:00
|
|
|
R_FindPlane(frontsector->ceilingplane, // killough 3/8/98
|
2008-08-16 20:19:35 +00:00
|
|
|
frontsector->GetTexture(sector_t::ceiling),
|
2006-02-24 04:48:15 +00:00
|
|
|
ceilinglightlevel + r_actualextralight, // killough 4/11/98
|
2008-06-14 15:26:16 +00:00
|
|
|
frontsector->GetXOffset(sector_t::ceiling), // killough 3/7/98
|
|
|
|
frontsector->GetYOffset(sector_t::ceiling), // killough 3/7/98
|
|
|
|
frontsector->GetXScale(sector_t::ceiling),
|
|
|
|
frontsector->GetYScale(sector_t::ceiling),
|
|
|
|
frontsector->GetAngle(sector_t::ceiling),
|
2008-06-15 18:36:26 +00:00
|
|
|
frontsector->sky,
|
2006-02-24 04:48:15 +00:00
|
|
|
frontsector->CeilingSkyBox
|
|
|
|
) : NULL;
|
|
|
|
|
- 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
|
|
|
basecolormap = frontsector->ColorMap;
|
2006-02-24 04:48:15 +00:00
|
|
|
R_GetExtraLight (&floorlightlevel, frontsector->floorplane, frontsector->ExtraLights);
|
|
|
|
|
|
|
|
// killough 3/7/98: Add (x,y) offsets to flats, add deep water check
|
|
|
|
// killough 3/16/98: add floorlightlevel
|
|
|
|
// killough 10/98: add support for skies transferred from sidedefs
|
|
|
|
floorplane = frontsector->floorplane.ZatPoint (viewx, viewy) < viewz || // killough 3/7/98
|
2008-08-16 20:19:35 +00:00
|
|
|
frontsector->GetTexture(sector_t::floor) == skyflatnum ||
|
2006-02-24 04:48:15 +00:00
|
|
|
(frontsector->FloorSkyBox != NULL && frontsector->FloorSkyBox->bAlways) ||
|
|
|
|
(frontsector->heightsec &&
|
|
|
|
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
|
2008-08-16 20:19:35 +00:00
|
|
|
frontsector->heightsec->GetTexture(sector_t::ceiling) == skyflatnum) ?
|
2006-02-24 04:48:15 +00:00
|
|
|
R_FindPlane(frontsector->floorplane,
|
2008-08-16 20:19:35 +00:00
|
|
|
frontsector->GetTexture(sector_t::floor),
|
2006-02-24 04:48:15 +00:00
|
|
|
floorlightlevel + r_actualextralight, // killough 3/16/98
|
2008-06-14 15:26:16 +00:00
|
|
|
frontsector->GetXOffset(sector_t::floor), // killough 3/7/98
|
|
|
|
frontsector->GetYOffset(sector_t::floor), // killough 3/7/98
|
|
|
|
frontsector->GetXScale(sector_t::floor),
|
|
|
|
frontsector->GetYScale(sector_t::floor),
|
|
|
|
frontsector->GetAngle(sector_t::floor),
|
2008-06-15 18:36:26 +00:00
|
|
|
frontsector->sky,
|
2006-02-24 04:48:15 +00:00
|
|
|
frontsector->FloorSkyBox
|
|
|
|
) : NULL;
|
|
|
|
|
|
|
|
// killough 9/18/98: Fix underwater slowdown, by passing real sector
|
|
|
|
// instead of fake one. Improve sprite lighting by basing sprite
|
|
|
|
// lightlevels on floor & ceiling lightlevels in the surrounding area.
|
|
|
|
// [RH] Handle sprite lighting like Duke 3D: If the ceiling is a sky, sprites are lit by
|
|
|
|
// it, otherwise they are lit by the floor.
|
2008-08-16 20:19:35 +00:00
|
|
|
R_AddSprites (sub->sector, frontsector->GetTexture(sector_t::ceiling) == skyflatnum ?
|
2006-02-24 04:48:15 +00:00
|
|
|
ceilinglightlevel : floorlightlevel, FakeSide);
|
|
|
|
|
|
|
|
// [RH] Add particles
|
2010-08-01 02:41:56 +00:00
|
|
|
if ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors)
|
|
|
|
{ // Only do it for the main BSP.
|
|
|
|
int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel)/2 + r_actualextralight);
|
|
|
|
for (WORD i = ParticlesInSubsec[(unsigned int)(sub-subsectors)]; i != NO_PARTICLE; i = Particles[i].snext)
|
|
|
|
{
|
|
|
|
R_ProjectParticle (Particles + i, subsectors[sub-subsectors].sector, shade, FakeSide);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (count--)
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
if (!outersubsector || line->sidedef == NULL || !(line->sidedef->Flags & WALLF_POLYOBJ))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
R_AddLine (line);
|
|
|
|
}
|
|
|
|
line++;
|
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
if (outersubsector)
|
|
|
|
{
|
|
|
|
InSubsector = NULL;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// RenderBSPNode
|
|
|
|
// Renders all subsectors below a given node, traversing subtree recursively.
|
|
|
|
// Just call with BSP root and -1.
|
|
|
|
// killough 5/2/98: reformatted, removed tail recursion
|
|
|
|
|
|
|
|
void R_RenderBSPNode (void *node)
|
|
|
|
{
|
|
|
|
if (numnodes == 0)
|
|
|
|
{
|
|
|
|
R_Subsector (subsectors);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (!((size_t)node & 1)) // Keep going until found a subsector
|
|
|
|
{
|
|
|
|
node_t *bsp = (node_t *)node;
|
|
|
|
|
|
|
|
// Decide which side the view point is on.
|
|
|
|
int side = R_PointOnSide (viewx, viewy, bsp);
|
|
|
|
|
|
|
|
// Recursively divide front space (toward the viewer).
|
|
|
|
R_RenderBSPNode (bsp->children[side]);
|
|
|
|
|
|
|
|
// Possibly divide back space (away from the viewer).
|
|
|
|
side ^= 1;
|
|
|
|
if (!R_CheckBBox (bsp->bbox[side]))
|
|
|
|
return;
|
|
|
|
|
|
|
|
node = bsp->children[side];
|
|
|
|
}
|
|
|
|
R_Subsector ((subsector_t *)((BYTE *)node - 1));
|
|
|
|
}
|