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.
|
|
|
|
//
|
|
|
|
// $Log:$
|
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
|
|
|
// Here is a core component: drawing the floors and ceilings,
|
|
|
|
// while maintaining a per column clipping list only.
|
|
|
|
// Moreover, the sky areas have to be determined.
|
|
|
|
//
|
|
|
|
// MAXVISPLANES is no longer a limit on the number of visplanes,
|
|
|
|
// but a limit on the number of hash slots; larger numbers mean
|
|
|
|
// better performance usually but after a point they are wasted,
|
|
|
|
// and memory and time overheads creep in.
|
|
|
|
//
|
|
|
|
// Lee Killough
|
|
|
|
//
|
|
|
|
// [RH] Further modified to significantly increase accuracy and add slopes.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
|
|
|
|
#include "r_local.h"
|
|
|
|
#include "r_sky.h"
|
|
|
|
#include "stats.h"
|
|
|
|
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "a_sharedglobal.h"
|
2007-12-18 01:50:08 +00:00
|
|
|
#include "c_console.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "cmdlib.h"
|
|
|
|
#include "d_net.h"
|
|
|
|
#include "g_level.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
#include "r_bsp.h"
|
|
|
|
#include "r_plane.h"
|
|
|
|
#include "r_segs.h"
|
2011-01-29 11:09:38 +00:00
|
|
|
#include "r_3dfloors.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
#include "v_palette.h"
|
2011-07-06 07:35:36 +00:00
|
|
|
#include "r_data/colormaps.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-05-15 10:39:40 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(disable:4244)
|
|
|
|
#endif
|
|
|
|
|
2007-04-29 12:07:27 +00:00
|
|
|
//EXTERN_CVAR (Int, tx)
|
|
|
|
//EXTERN_CVAR (Int, ty)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static void R_DrawSkyStriped (visplane_t *pl);
|
|
|
|
|
|
|
|
planefunction_t floorfunc;
|
|
|
|
planefunction_t ceilingfunc;
|
|
|
|
|
|
|
|
// Here comes the obnoxious "visplane".
|
|
|
|
#define MAXVISPLANES 128 /* must be a power of 2 */
|
|
|
|
|
|
|
|
// Avoid infinite recursion with stacked sectors by limiting them.
|
2010-12-02 02:08:54 +00:00
|
|
|
#define MAX_SKYBOX_PLANES 1000
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Allocate one extra for sky box planes.
|
|
|
|
static visplane_t *visplanes[MAXVISPLANES+1]; // killough
|
|
|
|
static visplane_t *freetail; // killough
|
|
|
|
static visplane_t **freehead = &freetail; // killough
|
|
|
|
|
|
|
|
visplane_t *floorplane;
|
|
|
|
visplane_t *ceilingplane;
|
|
|
|
|
|
|
|
// killough -- hash function for visplanes
|
|
|
|
// Empirically verified to be fairly uniform:
|
|
|
|
|
|
|
|
#define visplane_hash(picnum,lightlevel,height) \
|
|
|
|
((unsigned)((picnum)*3+(lightlevel)+((height).d)*7) & (MAXVISPLANES-1))
|
|
|
|
|
|
|
|
// These are copies of the main parameters used when drawing stacked sectors.
|
|
|
|
// When you change the main parameters, you should copy them here too *unless*
|
|
|
|
// you are changing them to draw a stacked sector. Otherwise, stacked sectors
|
|
|
|
// won't draw in skyboxes properly.
|
|
|
|
int stacked_extralight;
|
|
|
|
float stacked_visibility;
|
|
|
|
fixed_t stacked_viewx, stacked_viewy, stacked_viewz;
|
|
|
|
angle_t stacked_angle;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// opening
|
|
|
|
//
|
|
|
|
|
|
|
|
size_t maxopenings;
|
|
|
|
short *openings;
|
|
|
|
ptrdiff_t lastopening;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Clip values are the solid pixel bounding the range.
|
|
|
|
// floorclip starts out SCREENHEIGHT and is just outside the range
|
|
|
|
// ceilingclip starts out 0 and is just inside the range
|
|
|
|
//
|
|
|
|
short floorclip[MAXWIDTH];
|
|
|
|
short ceilingclip[MAXWIDTH];
|
|
|
|
|
|
|
|
//
|
|
|
|
// texture mapping
|
|
|
|
//
|
|
|
|
|
|
|
|
static fixed_t planeheight;
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
//
|
|
|
|
// spanend holds the end of a plane span in each screen row
|
|
|
|
//
|
|
|
|
short spanend[MAXHEIGHT];
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE *tiltlighting[MAXWIDTH];
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int planeshade;
|
2007-01-19 02:00:39 +00:00
|
|
|
FVector3 plane_sz, plane_su, plane_sv;
|
2006-02-24 04:48:15 +00:00
|
|
|
float planelightfloat;
|
|
|
|
bool plane_shade;
|
|
|
|
fixed_t pviewx, pviewy;
|
|
|
|
|
|
|
|
void R_DrawTiltedPlane_ASM (int y, int x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
fixed_t yslope[MAXHEIGHT];
|
|
|
|
static fixed_t xscale, yscale;
|
|
|
|
static DWORD xstepscale, ystepscale;
|
|
|
|
static DWORD basexfrac, baseyfrac;
|
|
|
|
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
#ifdef X86_ASM
|
2006-09-14 00:02:31 +00:00
|
|
|
extern "C" void R_SetSpanSource_ASM (const BYTE *flat);
|
2006-02-24 04:48:15 +00:00
|
|
|
extern "C" void STACK_ARGS R_SetSpanSize_ASM (int xbits, int ybits);
|
2006-09-14 00:02:31 +00:00
|
|
|
extern "C" void R_SetSpanColormap_ASM (BYTE *colormap);
|
|
|
|
extern "C" void R_SetTiltedSpanSource_ASM (const BYTE *flat);
|
|
|
|
extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource;
|
2006-02-24 04:48:15 +00:00
|
|
|
#endif
|
2011-02-12 09:53:40 +00:00
|
|
|
void R_DrawSinglePlane (visplane_t *, fixed_t alpha, bool additive, bool masked);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_InitPlanes
|
|
|
|
//
|
|
|
|
// Called at game startup.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_InitPlanes ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DeinitPlanes
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_DeinitPlanes ()
|
|
|
|
{
|
2011-01-29 11:09:38 +00:00
|
|
|
fakeActive = 0;
|
2013-07-14 07:47:39 +00:00
|
|
|
|
|
|
|
// do not use R_ClearPlanes because at this point the screen pointer is no longer valid.
|
|
|
|
for (int i = 0; i <= MAXVISPLANES; i++) // new code -- killough
|
|
|
|
{
|
|
|
|
for (*freehead = visplanes[i], visplanes[i] = NULL; *freehead; )
|
|
|
|
{
|
|
|
|
freehead = &(*freehead)->next;
|
|
|
|
}
|
|
|
|
}
|
2006-05-12 03:14:40 +00:00
|
|
|
for (visplane_t *pl = freetail; pl != NULL; )
|
|
|
|
{
|
|
|
|
visplane_t *next = pl->next;
|
|
|
|
free (pl);
|
|
|
|
pl = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_MapPlane
|
|
|
|
//
|
|
|
|
// Globals used: planeheight, ds_source, basexscale, baseyscale,
|
|
|
|
// pviewx, pviewy, xoffs, yoffs, basecolormap, xscale, yscale.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_MapPlane (int y, int x1)
|
|
|
|
{
|
|
|
|
int x2 = spanend[y];
|
|
|
|
fixed_t distance;
|
|
|
|
|
|
|
|
#ifdef RANGECHECK
|
|
|
|
if (x2 < x1 || x1<0 || x2>=viewwidth || (unsigned)y>=(unsigned)viewheight)
|
|
|
|
{
|
|
|
|
I_FatalError ("R_MapPlane: %i, %i at %i", x1, x2, y);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// [RH] Notice that I dumped the caching scheme used by Doom.
|
|
|
|
// It did not offer any appreciable speedup.
|
|
|
|
|
|
|
|
distance = FixedMul (planeheight, yslope[y]);
|
|
|
|
|
|
|
|
ds_xstep = FixedMul (distance, xstepscale);
|
|
|
|
ds_ystep = FixedMul (distance, ystepscale);
|
|
|
|
ds_xfrac = FixedMul (distance, basexfrac) + pviewx;
|
|
|
|
ds_yfrac = FixedMul (distance, baseyfrac) + pviewy;
|
|
|
|
|
|
|
|
if (plane_shade)
|
|
|
|
{
|
|
|
|
// Determine lighting based on the span's distance from the viewer.
|
- 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
|
|
|
ds_colormap = basecolormap->Maps + (GETPALOOKUP (
|
2006-02-24 04:48:15 +00:00
|
|
|
FixedMul (GlobVis, abs (centeryfrac - (y << FRACBITS))), planeshade) << COLORMAPSHIFT);
|
|
|
|
}
|
|
|
|
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
#ifdef X86_ASM
|
2006-02-24 04:48:15 +00:00
|
|
|
if (ds_colormap != ds_curcolormap)
|
|
|
|
R_SetSpanColormap_ASM (ds_colormap);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ds_y = y;
|
|
|
|
ds_x1 = x1;
|
|
|
|
ds_x2 = x2;
|
|
|
|
|
|
|
|
spanfunc ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_CalcTiltedLighting
|
|
|
|
//
|
|
|
|
// Calculates the lighting for one row of a tilted plane. If the definition
|
|
|
|
// of GETPALOOKUP changes, this needs to change, too.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
void STACK_ARGS R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
|
|
|
|
{
|
|
|
|
fixed_t lstep;
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE *lightfiller;
|
- 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
|
|
|
BYTE *basecolormapdata = basecolormap->Maps;
|
2006-02-24 04:48:15 +00:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if (width == 0 || lval == lend)
|
|
|
|
{ // Constant lighting
|
2011-06-12 03:15:15 +00:00
|
|
|
lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2011-06-12 03:15:15 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
lstep = (lend - lval) / width;
|
|
|
|
if (lval >= MAXLIGHTVIS)
|
|
|
|
{ // lval starts "too bright".
|
|
|
|
lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT);
|
|
|
|
for (; i <= width && lval >= MAXLIGHTVIS; ++i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2011-06-12 03:15:15 +00:00
|
|
|
tiltlighting[i] = lightfiller;
|
2006-02-24 04:48:15 +00:00
|
|
|
lval += lstep;
|
|
|
|
}
|
|
|
|
}
|
2011-06-12 03:15:15 +00:00
|
|
|
if (lend >= MAXLIGHTVIS)
|
|
|
|
{ // lend ends "too bright".
|
|
|
|
lightfiller = basecolormapdata + (GETPALOOKUP(lend, planeshade) << COLORMAPSHIFT);
|
|
|
|
for (; width > i && lend >= MAXLIGHTVIS; --width)
|
|
|
|
{
|
|
|
|
tiltlighting[width] = lightfiller;
|
|
|
|
lend -= lstep;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2011-06-12 03:15:15 +00:00
|
|
|
if (width > 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2011-06-12 03:15:15 +00:00
|
|
|
lval = planeshade - lval;
|
|
|
|
lend = planeshade - lend;
|
|
|
|
lstep = (lend - lval) / width;
|
|
|
|
if (lstep < 0)
|
|
|
|
{ // Going from dark to light
|
|
|
|
if (lval < FRACUNIT)
|
|
|
|
{ // All bright
|
|
|
|
lightfiller = basecolormapdata;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lval >= NUMCOLORMAPS*FRACUNIT)
|
|
|
|
{ // Starts beyond the dark end
|
|
|
|
BYTE *clight = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT);
|
|
|
|
while (lval >= NUMCOLORMAPS*FRACUNIT && i <= width)
|
|
|
|
{
|
|
|
|
tiltlighting[i++] = clight;
|
|
|
|
lval += lstep;
|
|
|
|
}
|
|
|
|
if (i > width)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (i <= width && lval >= 0)
|
|
|
|
{
|
|
|
|
tiltlighting[i++] = basecolormapdata + ((lval >> FRACBITS) << COLORMAPSHIFT);
|
|
|
|
lval += lstep;
|
|
|
|
}
|
|
|
|
lightfiller = basecolormapdata;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2011-06-12 03:15:15 +00:00
|
|
|
else
|
|
|
|
{ // Going from light to dark
|
|
|
|
if (lval >= (NUMCOLORMAPS-1)*FRACUNIT)
|
|
|
|
{ // All dark
|
|
|
|
lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (lval < 0 && i <= width)
|
|
|
|
{
|
|
|
|
tiltlighting[i++] = basecolormapdata;
|
|
|
|
lval += lstep;
|
|
|
|
}
|
|
|
|
if (i > width)
|
|
|
|
return;
|
|
|
|
while (i <= width && lval < (NUMCOLORMAPS-1)*FRACUNIT)
|
|
|
|
{
|
|
|
|
tiltlighting[i++] = basecolormapdata + ((lval >> FRACBITS) << COLORMAPSHIFT);
|
|
|
|
lval += lstep;
|
|
|
|
}
|
|
|
|
lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; i <= width; i++)
|
|
|
|
{
|
|
|
|
tiltlighting[i] = lightfiller;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // extern "C"
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_MapTiltedPlane
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_MapTiltedPlane (int y, int x1)
|
|
|
|
{
|
|
|
|
int x2 = spanend[y];
|
|
|
|
int width = x2 - x1;
|
2008-05-22 05:17:21 +00:00
|
|
|
double iz, uz, vz;
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE *fb;
|
2006-02-24 04:48:15 +00:00
|
|
|
DWORD u, v;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
iz = plane_sz[2] + plane_sz[1]*(centery-y) + plane_sz[0]*(x1-centerx);
|
|
|
|
|
|
|
|
// Lighting is simple. It's just linear interpolation from start to end
|
|
|
|
if (plane_shade)
|
|
|
|
{
|
|
|
|
uz = (iz + plane_sz[0]*width) * planelightfloat;
|
|
|
|
vz = iz * planelightfloat;
|
2009-11-20 05:34:20 +00:00
|
|
|
R_CalcTiltedLighting (xs_RoundToInt(vz), xs_RoundToInt(uz), width);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx);
|
|
|
|
vz = plane_sv[2] + plane_sv[1]*(centery-y) + plane_sv[0]*(x1-centerx);
|
|
|
|
|
|
|
|
fb = ylookup[y] + x1 + dc_destorg;
|
|
|
|
|
|
|
|
BYTE vshift = 32 - ds_ybits;
|
|
|
|
BYTE ushift = vshift - ds_xbits;
|
|
|
|
int umask = ((1 << ds_xbits) - 1) << ds_ybits;
|
|
|
|
|
|
|
|
#if 0 // The "perfect" reference version of this routine. Pretty slow.
|
|
|
|
// Use it only to see how things are supposed to look.
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
2008-05-22 05:17:21 +00:00
|
|
|
double z = 1.f/iz;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-22 05:17:21 +00:00
|
|
|
u = SQWORD(uz*z) + pviewx;
|
|
|
|
v = SQWORD(vz*z) + pviewy;
|
2006-02-24 04:48:15 +00:00
|
|
|
ds_colormap = tiltlighting[i];
|
|
|
|
fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]];
|
|
|
|
iz += plane_sz[0];
|
|
|
|
uz += plane_su[0];
|
|
|
|
vz += plane_sv[0];
|
|
|
|
} while (--width >= 0);
|
|
|
|
#else
|
|
|
|
//#define SPANSIZE 32
|
|
|
|
//#define INVSPAN 0.03125f
|
|
|
|
//#define SPANSIZE 8
|
|
|
|
//#define INVSPAN 0.125f
|
|
|
|
#define SPANSIZE 16
|
|
|
|
#define INVSPAN 0.0625f
|
|
|
|
|
2008-05-22 05:17:21 +00:00
|
|
|
double startz = 1.f/iz;
|
|
|
|
double startu = uz*startz;
|
|
|
|
double startv = vz*startz;
|
|
|
|
double izstep, uzstep, vzstep;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
izstep = plane_sz[0] * SPANSIZE;
|
|
|
|
uzstep = plane_su[0] * SPANSIZE;
|
|
|
|
vzstep = plane_sv[0] * SPANSIZE;
|
|
|
|
x1 = 0;
|
|
|
|
width++;
|
|
|
|
|
|
|
|
while (width >= SPANSIZE)
|
|
|
|
{
|
|
|
|
iz += izstep;
|
|
|
|
uz += uzstep;
|
|
|
|
vz += vzstep;
|
|
|
|
|
2008-05-22 05:17:21 +00:00
|
|
|
double endz = 1.f/iz;
|
|
|
|
double endu = uz*endz;
|
|
|
|
double endv = vz*endz;
|
|
|
|
DWORD stepu = SQWORD((endu - startu) * INVSPAN);
|
|
|
|
DWORD stepv = SQWORD((endv - startv) * INVSPAN);
|
|
|
|
u = SQWORD(startu) + pviewx;
|
|
|
|
v = SQWORD(startv) + pviewy;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (i = SPANSIZE-1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]);
|
|
|
|
x1++;
|
|
|
|
u += stepu;
|
|
|
|
v += stepv;
|
|
|
|
}
|
|
|
|
startu = endu;
|
|
|
|
startv = endv;
|
|
|
|
width -= SPANSIZE;
|
|
|
|
}
|
|
|
|
if (width > 0)
|
|
|
|
{
|
|
|
|
if (width == 1)
|
|
|
|
{
|
2008-05-22 05:17:21 +00:00
|
|
|
u = SQWORD(startu);
|
|
|
|
v = SQWORD(startv);
|
2006-02-24 04:48:15 +00:00
|
|
|
fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-22 05:17:21 +00:00
|
|
|
double left = width;
|
2006-02-24 04:48:15 +00:00
|
|
|
iz += plane_sz[0] * left;
|
|
|
|
uz += plane_su[0] * left;
|
|
|
|
vz += plane_sv[0] * left;
|
|
|
|
|
2008-05-22 05:17:21 +00:00
|
|
|
double endz = 1.f/iz;
|
|
|
|
double endu = uz*endz;
|
|
|
|
double endv = vz*endz;
|
2006-02-24 04:48:15 +00:00
|
|
|
left = 1.f/left;
|
2008-05-22 05:17:21 +00:00
|
|
|
DWORD stepu = SQWORD((endu - startu) * left);
|
|
|
|
DWORD stepv = SQWORD((endv - startv) * left);
|
|
|
|
u = SQWORD(startu) + pviewx;
|
|
|
|
v = SQWORD(startv) + pviewy;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (; width != 0; width--)
|
|
|
|
{
|
|
|
|
fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]);
|
|
|
|
x1++;
|
|
|
|
u += stepu;
|
|
|
|
v += stepv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_MapColoredPlane
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_MapColoredPlane (int y, int x1)
|
|
|
|
{
|
|
|
|
memset (ylookup[y] + x1 + dc_destorg, ds_color, spanend[y] - x1 + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_ClearPlanes
|
|
|
|
//
|
|
|
|
// Called at the beginning of each frame.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_ClearPlanes (bool fullclear)
|
|
|
|
{
|
2013-07-14 07:47:39 +00:00
|
|
|
int i;
|
2006-07-12 03:35:55 +00:00
|
|
|
|
2013-03-02 01:54:40 +00:00
|
|
|
// Don't clear fake planes if not doing a full clear.
|
|
|
|
if (!fullclear)
|
|
|
|
{
|
|
|
|
for (i = 0; i <= MAXVISPLANES-1; i++) // new code -- killough
|
|
|
|
{
|
|
|
|
for (visplane_t **probe = &visplanes[i]; *probe != NULL; )
|
|
|
|
{
|
|
|
|
if ((*probe)->sky < 0)
|
|
|
|
{ // fake: move past it
|
|
|
|
probe = &(*probe)->next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // not fake: move to freelist
|
|
|
|
visplane_t *vis = *probe;
|
|
|
|
*freehead = vis;
|
|
|
|
*probe = vis->next;
|
|
|
|
vis->next = NULL;
|
|
|
|
freehead = &vis->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i <= MAXVISPLANES; i++) // new code -- killough
|
|
|
|
{
|
|
|
|
for (*freehead = visplanes[i], visplanes[i] = NULL; *freehead; )
|
|
|
|
{
|
|
|
|
freehead = &(*freehead)->next;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// opening / clipping determination
|
|
|
|
clearbufshort (floorclip, viewwidth, viewheight);
|
|
|
|
// [RH] clip ceiling to console bottom
|
|
|
|
clearbufshort (ceilingclip, viewwidth,
|
2007-12-27 04:30:12 +00:00
|
|
|
!screen->Accel2D && ConBottom > viewwindowy && !bRenderingToCanvas
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
? (ConBottom - viewwindowy) : 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
lastopening = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// new_visplane
|
|
|
|
//
|
|
|
|
// New function, by Lee Killough
|
|
|
|
// [RH] top and bottom buffers get allocated immediately after the visplane.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
static visplane_t *new_visplane (unsigned hash)
|
|
|
|
{
|
|
|
|
visplane_t *check = freetail;
|
|
|
|
|
|
|
|
if (check == NULL)
|
|
|
|
{
|
2014-04-03 21:28:29 +00:00
|
|
|
check = (visplane_t *)M_Malloc (sizeof(*check) + 3 + sizeof(*check->top)*(MAXWIDTH*2));
|
|
|
|
memset(check, 0, sizeof(*check) + 3 + sizeof(*check->top)*(MAXWIDTH*2));
|
2014-01-06 00:50:09 +00:00
|
|
|
check->bottom = check->top + MAXWIDTH+2;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (NULL == (freetail = freetail->next))
|
|
|
|
{
|
|
|
|
freehead = &freetail;
|
|
|
|
}
|
|
|
|
|
|
|
|
check->next = visplanes[hash];
|
|
|
|
visplanes[hash] = check;
|
|
|
|
return check;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_FindPlane
|
|
|
|
//
|
|
|
|
// killough 2/28/98: Add offsets
|
|
|
|
//==========================================================================
|
|
|
|
|
2011-02-12 09:53:40 +00:00
|
|
|
visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightlevel, fixed_t alpha, bool additive,
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t xoffs, fixed_t yoffs,
|
|
|
|
fixed_t xscale, fixed_t yscale, angle_t angle,
|
2008-06-15 18:36:26 +00:00
|
|
|
int sky, ASkyViewpoint *skybox)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
secplane_t plane;
|
|
|
|
visplane_t *check;
|
|
|
|
unsigned hash; // killough
|
|
|
|
bool isskybox;
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
if (picnum == skyflatnum) // killough 10/98
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // most skies map together
|
|
|
|
lightlevel = 0;
|
|
|
|
xoffs = 0;
|
|
|
|
yoffs = 0;
|
|
|
|
xscale = 0;
|
|
|
|
yscale = 0;
|
|
|
|
angle = 0;
|
2010-11-07 16:11:42 +00:00
|
|
|
alpha = 0;
|
2011-02-12 09:53:40 +00:00
|
|
|
additive = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
plane.a = plane.b = plane.d = 0;
|
|
|
|
// [RH] Map floor skies and ceiling skies to separate visplanes. This isn't
|
|
|
|
// always necessary, but it is needed if a floor and ceiling sky are in the
|
|
|
|
// same column but separated by a wall. If they both try to reside in the
|
|
|
|
// same visplane, then only the floor sky will be drawn.
|
|
|
|
plane.c = height.c;
|
|
|
|
plane.ic = height.ic;
|
2014-01-18 20:40:48 +00:00
|
|
|
isskybox = skybox != NULL && !skybox->bInSkybox;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (skybox != NULL && skybox->bAlways && !skybox->bInSkybox)
|
|
|
|
{
|
|
|
|
plane = height;
|
|
|
|
isskybox = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
plane = height;
|
|
|
|
isskybox = false;
|
2011-01-29 11:09:38 +00:00
|
|
|
// kg3D - hack, store alpha in sky
|
|
|
|
// i know there is ->alpha, but this also allows to identify fake plane
|
|
|
|
// and ->alpha is for stacked sectors
|
|
|
|
if (fake3D & (FAKE3D_FAKEFLOOR|FAKE3D_FAKECEILING)) sky = 0x80000000 | fakeAlpha;
|
|
|
|
else sky = 0; // not skyflatnum so it can't be a sky
|
2010-11-07 17:05:21 +00:00
|
|
|
skybox = NULL;
|
2010-11-07 16:11:42 +00:00
|
|
|
alpha = FRACUNIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2013-03-02 01:54:40 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// New visplane algorithm uses hash table -- killough
|
2008-06-15 18:36:26 +00:00
|
|
|
hash = isskybox ? MAXVISPLANES : visplane_hash (picnum.GetIndex(), lightlevel, height);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (check = visplanes[hash]; check; check = check->next) // killough
|
|
|
|
{
|
|
|
|
if (isskybox)
|
|
|
|
{
|
|
|
|
if (skybox == check->skybox && plane == check->height)
|
|
|
|
{
|
|
|
|
if (skybox->Mate != NULL)
|
|
|
|
{ // This skybox is really a stacked sector, so we need to
|
|
|
|
// check even more.
|
|
|
|
if (check->extralight == stacked_extralight &&
|
|
|
|
check->visibility == stacked_visibility &&
|
|
|
|
check->viewx == stacked_viewx &&
|
|
|
|
check->viewy == stacked_viewy &&
|
|
|
|
check->viewz == stacked_viewz &&
|
2010-12-02 15:08:44 +00:00
|
|
|
(
|
|
|
|
// headache inducing logic... :(
|
2010-12-24 13:43:36 +00:00
|
|
|
(!(skybox->flags & MF_JUSTATTACKED)) ||
|
2010-12-02 15:08:44 +00:00
|
|
|
(
|
2011-02-12 09:53:40 +00:00
|
|
|
check->Alpha == alpha &&
|
|
|
|
check->Additive == additive &&
|
2010-12-02 15:08:44 +00:00
|
|
|
(alpha == 0 || // if alpha is > 0 everything needs to be checked
|
|
|
|
(plane == check->height &&
|
|
|
|
picnum == check->picnum &&
|
|
|
|
lightlevel == check->lightlevel &&
|
|
|
|
xoffs == check->xoffs && // killough 2/28/98: Add offset checks
|
|
|
|
yoffs == check->yoffs &&
|
|
|
|
basecolormap == check->colormap && // [RH] Add more checks
|
|
|
|
xscale == check->xscale &&
|
|
|
|
yscale == check->yscale &&
|
|
|
|
angle == check->angle
|
|
|
|
)
|
|
|
|
) &&
|
|
|
|
check->viewangle == stacked_angle
|
2010-11-07 16:11:42 +00:00
|
|
|
)
|
2010-12-02 15:08:44 +00:00
|
|
|
)
|
|
|
|
)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return check;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return check;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (plane == check->height &&
|
|
|
|
picnum == check->picnum &&
|
|
|
|
lightlevel == check->lightlevel &&
|
|
|
|
xoffs == check->xoffs && // killough 2/28/98: Add offset checks
|
|
|
|
yoffs == check->yoffs &&
|
|
|
|
basecolormap == check->colormap && // [RH] Add more checks
|
|
|
|
xscale == check->xscale &&
|
|
|
|
yscale == check->yscale &&
|
2008-06-15 18:36:26 +00:00
|
|
|
angle == check->angle &&
|
2011-01-29 11:09:38 +00:00
|
|
|
sky == check->sky &&
|
|
|
|
CurrentMirror == check->CurrentMirror &&
|
|
|
|
MirrorFlags == check->MirrorFlags &&
|
|
|
|
CurrentSkybox == check->CurrentSkybox
|
2006-02-24 04:48:15 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
return check;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
check = new_visplane (hash); // killough
|
|
|
|
|
|
|
|
check->height = plane;
|
|
|
|
check->picnum = picnum;
|
|
|
|
check->lightlevel = lightlevel;
|
|
|
|
check->xoffs = xoffs; // killough 2/28/98: Save offsets
|
|
|
|
check->yoffs = yoffs;
|
|
|
|
check->xscale = xscale;
|
|
|
|
check->yscale = yscale;
|
|
|
|
check->angle = angle;
|
|
|
|
check->colormap = basecolormap; // [RH] Save colormap
|
2008-06-15 18:36:26 +00:00
|
|
|
check->sky = sky;
|
2006-02-24 04:48:15 +00:00
|
|
|
check->skybox = skybox;
|
2016-01-31 03:19:23 +00:00
|
|
|
check->left = viewwidth; // Was SCREENWIDTH -- killough 11/98
|
|
|
|
check->right = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
check->extralight = stacked_extralight;
|
|
|
|
check->visibility = stacked_visibility;
|
|
|
|
check->viewx = stacked_viewx;
|
|
|
|
check->viewy = stacked_viewy;
|
|
|
|
check->viewz = stacked_viewz;
|
|
|
|
check->viewangle = stacked_angle;
|
2011-02-12 09:53:40 +00:00
|
|
|
check->Alpha = alpha;
|
|
|
|
check->Additive = additive;
|
2011-01-29 11:09:38 +00:00
|
|
|
check->CurrentMirror = CurrentMirror;
|
|
|
|
check->MirrorFlags = MirrorFlags;
|
|
|
|
check->CurrentSkybox = CurrentSkybox;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
clearbufshort (check->top, viewwidth, 0x7fff);
|
|
|
|
|
|
|
|
return check;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_CheckPlane
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop)
|
|
|
|
{
|
|
|
|
int intrl, intrh;
|
|
|
|
int unionl, unionh;
|
|
|
|
int x;
|
|
|
|
|
2006-07-11 04:48:10 +00:00
|
|
|
assert (start >= 0 && start < viewwidth);
|
2016-01-31 03:19:23 +00:00
|
|
|
assert (stop > start && stop <= viewwidth);
|
2006-07-11 04:48:10 +00:00
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
if (start < pl->left)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2016-01-31 03:19:23 +00:00
|
|
|
intrl = pl->left;
|
2006-02-24 04:48:15 +00:00
|
|
|
unionl = start;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-31 03:19:23 +00:00
|
|
|
unionl = pl->left;
|
2006-02-24 04:48:15 +00:00
|
|
|
intrl = start;
|
|
|
|
}
|
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
if (stop > pl->right)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2016-01-31 03:19:23 +00:00
|
|
|
intrh = pl->right;
|
2006-02-24 04:48:15 +00:00
|
|
|
unionh = stop;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-31 03:19:23 +00:00
|
|
|
unionh = pl->right;
|
2006-02-24 04:48:15 +00:00
|
|
|
intrh = stop;
|
|
|
|
}
|
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
for (x = intrl; x < intrh && pl->top[x] == 0x7fff; x++)
|
2006-02-24 04:48:15 +00:00
|
|
|
;
|
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
if (x >= intrh)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// use the same visplane
|
2016-01-31 03:19:23 +00:00
|
|
|
pl->left = unionl;
|
|
|
|
pl->right = unionh;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// make a new visplane
|
|
|
|
unsigned hash;
|
|
|
|
|
|
|
|
if (pl->skybox != NULL && !pl->skybox->bInSkybox && (pl->picnum == skyflatnum || pl->skybox->bAlways) && viewactive)
|
|
|
|
{
|
|
|
|
hash = MAXVISPLANES;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
hash = visplane_hash (pl->picnum.GetIndex(), pl->lightlevel, pl->height);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
visplane_t *new_pl = new_visplane (hash);
|
|
|
|
|
|
|
|
new_pl->height = pl->height;
|
|
|
|
new_pl->picnum = pl->picnum;
|
|
|
|
new_pl->lightlevel = pl->lightlevel;
|
|
|
|
new_pl->xoffs = pl->xoffs; // killough 2/28/98
|
|
|
|
new_pl->yoffs = pl->yoffs;
|
|
|
|
new_pl->xscale = pl->xscale; // [RH] copy these, too
|
|
|
|
new_pl->yscale = pl->yscale;
|
|
|
|
new_pl->angle = pl->angle;
|
|
|
|
new_pl->colormap = pl->colormap;
|
|
|
|
new_pl->skybox = pl->skybox;
|
|
|
|
new_pl->extralight = pl->extralight;
|
|
|
|
new_pl->visibility = pl->visibility;
|
|
|
|
new_pl->viewx = pl->viewx;
|
|
|
|
new_pl->viewy = pl->viewy;
|
|
|
|
new_pl->viewz = pl->viewz;
|
|
|
|
new_pl->viewangle = pl->viewangle;
|
2008-07-20 17:52:12 +00:00
|
|
|
new_pl->sky = pl->sky;
|
2011-02-12 09:53:40 +00:00
|
|
|
new_pl->Alpha = pl->Alpha;
|
|
|
|
new_pl->Additive = pl->Additive;
|
2011-01-29 11:09:38 +00:00
|
|
|
new_pl->CurrentMirror = pl->CurrentMirror;
|
|
|
|
new_pl->MirrorFlags = pl->MirrorFlags;
|
|
|
|
new_pl->CurrentSkybox = pl->CurrentSkybox;
|
2006-02-24 04:48:15 +00:00
|
|
|
pl = new_pl;
|
2016-01-31 03:19:23 +00:00
|
|
|
pl->left = start;
|
|
|
|
pl->right = stop;
|
2006-02-24 04:48:15 +00:00
|
|
|
clearbufshort (pl->top, viewwidth, 0x7fff);
|
|
|
|
}
|
|
|
|
return pl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_MakeSpans
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
inline void R_MakeSpans (int x, int t1, int b1, int t2, int b2, void (*mapfunc)(int y, int x1))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawSky
|
|
|
|
//
|
|
|
|
// Can handle overlapped skies. Note that the front sky is *not* masked in
|
|
|
|
// in the normal convention for patches, but uses color 0 as a transparent
|
|
|
|
// color instead.
|
|
|
|
//
|
2010-08-01 20:21:04 +00:00
|
|
|
// Note that since ZDoom now uses color 0 as transparent for other purposes,
|
|
|
|
// you can use normal texture transparency, so the distinction isn't so
|
|
|
|
// important anymore, but you should still be aware of it.
|
|
|
|
//
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
static FTexture *frontskytex, *backskytex;
|
|
|
|
static angle_t skyflip;
|
|
|
|
static int frontpos, backpos;
|
2007-04-29 12:07:27 +00:00
|
|
|
static fixed_t frontyScale;
|
2009-10-24 23:42:58 +00:00
|
|
|
static fixed_t frontcyl, backcyl;
|
2009-11-12 01:05:55 +00:00
|
|
|
static fixed_t skymid;
|
|
|
|
static angle_t skyangle;
|
2007-04-29 12:07:27 +00:00
|
|
|
int frontiScale;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
extern fixed_t swall[MAXWIDTH];
|
|
|
|
extern fixed_t lwall[MAXWIDTH];
|
|
|
|
extern fixed_t rw_offset;
|
|
|
|
extern FTexture *rw_pic;
|
|
|
|
|
|
|
|
// Allow for layer skies up to 512 pixels tall. This is overkill,
|
|
|
|
// since the most anyone can ever see of the sky is 500 pixels.
|
|
|
|
// We need 4 skybufs because wallscan can draw up to 4 columns at a time.
|
|
|
|
static BYTE skybuf[4][512];
|
|
|
|
static DWORD lastskycol[4];
|
|
|
|
static int skycolplace;
|
|
|
|
|
|
|
|
// Get a column of sky when there is only one sky texture.
|
|
|
|
static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x)
|
|
|
|
{
|
2009-11-12 01:05:55 +00:00
|
|
|
angle_t column = (skyangle + xtoviewangle[x]) ^ skyflip;
|
2009-11-08 02:51:22 +00:00
|
|
|
return fronttex->GetColumn((UMulScale16(column, frontcyl) + frontpos) >> FRACBITS, NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get a column of sky when there are two overlapping sky textures
|
|
|
|
static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x)
|
|
|
|
{
|
2009-11-12 01:05:55 +00:00
|
|
|
DWORD ang = (skyangle + xtoviewangle[x]) ^ skyflip;
|
2009-11-08 02:51:22 +00:00
|
|
|
DWORD angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS);
|
|
|
|
DWORD angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Check if this column has already been built. If so, there's
|
|
|
|
// no reason to waste time building it again.
|
|
|
|
DWORD skycol = (angle1 << 16) | angle2;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
if (lastskycol[i] == skycol)
|
|
|
|
{
|
|
|
|
return skybuf[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lastskycol[skycolplace] = skycol;
|
|
|
|
BYTE *composite = skybuf[skycolplace];
|
|
|
|
skycolplace = (skycolplace + 1) & 3;
|
|
|
|
|
|
|
|
// The ordering of the following code has been tuned to allow VC++ to optimize
|
|
|
|
// it well. In particular, this arrangement lets it keep count in a register
|
|
|
|
// instead of on the stack.
|
|
|
|
const BYTE *front = fronttex->GetColumn (angle1, NULL);
|
|
|
|
const BYTE *back = backskytex->GetColumn (angle2, NULL);
|
|
|
|
|
|
|
|
int count = MIN<int> (512, MIN (backskytex->GetHeight(), fronttex->GetHeight()));
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (front[i])
|
|
|
|
{
|
|
|
|
composite[i] = front[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
composite[i] = back[i];
|
|
|
|
}
|
|
|
|
} while (++i, --count);
|
|
|
|
return composite;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void R_DrawSky (visplane_t *pl)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
if (pl->left >= pl->right)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-13 04:38:03 +00:00
|
|
|
dc_iscale = skyiscale;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
clearbuf (swall+pl->left, pl->right-pl->left, dc_iscale<<2);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (MirrorFlags & RF_XFLIP)
|
|
|
|
{
|
2016-01-31 03:19:23 +00:00
|
|
|
for (x = pl->left; x < pl->right; ++x)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
lwall[x] = (viewwidth - x) << FRACBITS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-31 03:19:23 +00:00
|
|
|
for (x = pl->left; x < pl->right; ++x)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
lwall[x] = x << FRACBITS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (x = 0; x < 4; ++x)
|
|
|
|
{
|
|
|
|
lastskycol[x] = 0xffffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
rw_pic = frontskytex;
|
|
|
|
rw_offset = 0;
|
|
|
|
|
2007-04-29 12:07:27 +00:00
|
|
|
frontyScale = rw_pic->yScale;
|
2009-11-12 01:05:55 +00:00
|
|
|
dc_texturemid = MulScale16 (skymid, frontyScale);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (1 << frontskytex->HeightBits == frontskytex->GetHeight())
|
|
|
|
{ // The texture tiles nicely
|
|
|
|
for (x = 0; x < 4; ++x)
|
|
|
|
{
|
|
|
|
lastskycol[x] = 0xffffffff;
|
|
|
|
}
|
2016-01-31 03:19:23 +00:00
|
|
|
wallscan (pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, swall, lwall,
|
2009-06-07 01:14:14 +00:00
|
|
|
frontyScale, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // The texture does not tile nicely
|
2009-11-13 04:38:03 +00:00
|
|
|
frontyScale = DivScale16 (skyscale, frontyScale);
|
2007-04-29 12:07:27 +00:00
|
|
|
frontiScale = DivScale32 (1, frontyScale);
|
2009-11-14 03:08:35 +00:00
|
|
|
// Sodding crap. Fixed point sucks when you want precision.
|
|
|
|
// TODO (if I'm feeling adventurous): Rewrite the renderer to use floating point
|
|
|
|
// coordinates to keep as much precision as possible until the final
|
|
|
|
// rasterization stage so fudges like this aren't needed.
|
|
|
|
if (viewheight <= 600)
|
|
|
|
{
|
|
|
|
skymid -= FRACUNIT;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
R_DrawSkyStriped (pl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void R_DrawSkyStriped (visplane_t *pl)
|
|
|
|
{
|
|
|
|
fixed_t centerysave = centeryfrac;
|
2007-04-29 12:07:27 +00:00
|
|
|
short drawheight = (short)MulScale16 (frontskytex->GetHeight(), frontyScale);
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t topfrac;
|
2007-04-29 12:07:27 +00:00
|
|
|
fixed_t iscale = frontiScale;
|
2006-02-24 04:48:15 +00:00
|
|
|
short top[MAXWIDTH], bot[MAXWIDTH];
|
|
|
|
short yl, yh;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
// So that I don't have to worry about fractional precision, chop off the
|
|
|
|
// fractional part of centeryfrac.
|
|
|
|
centeryfrac = centery << FRACBITS;
|
2009-11-12 01:05:55 +00:00
|
|
|
topfrac = (skymid + iscale * (1-centery)) % (frontskytex->GetHeight() << FRACBITS);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (topfrac < 0) topfrac += frontskytex->GetHeight() << FRACBITS;
|
|
|
|
yl = 0;
|
2007-04-29 12:07:27 +00:00
|
|
|
yh = (short)MulScale32 ((frontskytex->GetHeight() << FRACBITS) - topfrac, frontyScale);
|
2006-02-24 04:48:15 +00:00
|
|
|
dc_texturemid = topfrac - iscale * (1-centery);
|
|
|
|
|
|
|
|
while (yl < viewheight)
|
|
|
|
{
|
2016-01-31 03:19:23 +00:00
|
|
|
for (x = pl->left; x < pl->right; ++x)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
top[x] = MAX (yl, (short)pl->top[x]);
|
|
|
|
bot[x] = MIN (yh, (short)pl->bottom[x]);
|
|
|
|
}
|
|
|
|
for (x = 0; x < 4; ++x)
|
|
|
|
{
|
|
|
|
lastskycol[x] = 0xffffffff;
|
|
|
|
}
|
2016-01-31 03:19:23 +00:00
|
|
|
wallscan (pl->left, pl->right, top, bot, swall, lwall, rw_pic->yScale,
|
2006-02-24 04:48:15 +00:00
|
|
|
backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns);
|
|
|
|
yl = yh;
|
|
|
|
yh += drawheight;
|
|
|
|
dc_texturemid = iscale * (centery-yl-1);
|
|
|
|
}
|
|
|
|
centeryfrac = centerysave;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawPlanes
|
|
|
|
//
|
|
|
|
// At the end of each frame.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
CVAR (Bool, tilt, false, 0);
|
|
|
|
//CVAR (Int, pa, 0, 0)
|
|
|
|
|
2013-02-23 05:15:32 +00:00
|
|
|
int R_DrawPlanes ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
visplane_t *pl;
|
|
|
|
int i;
|
2013-02-23 05:15:32 +00:00
|
|
|
int vpcount = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
ds_color = 3;
|
|
|
|
|
2013-02-23 05:15:32 +00:00
|
|
|
for (i = 0; i < MAXVISPLANES; i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
for (pl = visplanes[i]; pl; pl = pl->next)
|
|
|
|
{
|
2011-01-29 11:09:38 +00:00
|
|
|
// kg3D - draw only correct planes
|
|
|
|
if(pl->CurrentMirror != CurrentMirror || pl->CurrentSkybox != CurrentSkybox)
|
|
|
|
continue;
|
|
|
|
// kg3D - draw only real planes now
|
|
|
|
if(pl->sky >= 0) {
|
|
|
|
vpcount++;
|
2011-02-12 09:53:40 +00:00
|
|
|
R_DrawSinglePlane (pl, OPAQUE, false, false);
|
2011-01-29 11:09:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-23 05:15:32 +00:00
|
|
|
return vpcount;
|
2011-01-29 11:09:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// kg3D - draw all visplanes with "height"
|
|
|
|
void R_DrawHeightPlanes(fixed_t height)
|
|
|
|
{
|
|
|
|
visplane_t *pl;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ds_color = 3;
|
|
|
|
|
|
|
|
for (i = 0; i < MAXVISPLANES; i++)
|
|
|
|
{
|
|
|
|
for (pl = visplanes[i]; pl; pl = pl->next)
|
|
|
|
{
|
|
|
|
// kg3D - draw only correct planes
|
|
|
|
if(pl->CurrentSkybox != CurrentSkybox)
|
|
|
|
continue;
|
|
|
|
if(pl->sky < 0 && pl->height.Zat0() == height) {
|
|
|
|
viewx = pl->viewx;
|
|
|
|
viewy = pl->viewy;
|
|
|
|
viewangle = pl->viewangle;
|
|
|
|
MirrorFlags = pl->MirrorFlags;
|
2012-08-09 04:31:31 +00:00
|
|
|
R_DrawSinglePlane (pl, pl->sky & 0x7FFFFFFF, pl->Additive, true);
|
2011-01-29 11:09:38 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 11:09:38 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawSinglePlane
|
|
|
|
//
|
|
|
|
// Draws a single visplane.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2011-02-12 09:53:40 +00:00
|
|
|
void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// pl->angle = pa<<ANGLETOFINESHIFT;
|
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
if (pl->left >= pl->right)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (r_drawflat)
|
|
|
|
{ // [RH] no texture mapping
|
|
|
|
ds_color += 4;
|
|
|
|
R_MapVisPlane (pl, R_MapColoredPlane);
|
|
|
|
}
|
2008-06-15 18:36:26 +00:00
|
|
|
else if (pl->picnum == skyflatnum)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // sky flat
|
|
|
|
R_DrawSkyPlane (pl);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // regular flat
|
2011-11-04 01:12:53 +00:00
|
|
|
FTexture *tex = TexMan(pl->picnum, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (tex->UseType == FTexture::TEX_Null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-12 09:53:40 +00:00
|
|
|
if (!masked && !additive)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // If we're not supposed to see through this plane, draw it opaque.
|
|
|
|
alpha = OPAQUE;
|
|
|
|
}
|
|
|
|
else if (!tex->bMasked)
|
|
|
|
{ // Don't waste time on a masked texture if it isn't really masked.
|
|
|
|
masked = false;
|
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
R_SetupSpanBits(tex);
|
2007-04-29 12:07:27 +00:00
|
|
|
pl->xscale = MulScale16 (pl->xscale, tex->xScale);
|
|
|
|
pl->yscale = MulScale16 (pl->yscale, tex->yScale);
|
2006-02-24 04:48:15 +00:00
|
|
|
ds_source = tex->GetPixels ();
|
|
|
|
|
|
|
|
basecolormap = pl->colormap;
|
|
|
|
planeshade = LIGHT2SHADE(pl->lightlevel);
|
|
|
|
|
2008-06-25 22:16:04 +00:00
|
|
|
if (r_drawflat || ((pl->height.a == 0 && pl->height.b == 0) && !tilt))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2011-02-12 09:53:40 +00:00
|
|
|
R_DrawNormalPlane (pl, alpha, additive, masked);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-12 09:53:40 +00:00
|
|
|
R_DrawTiltedPlane (pl, alpha, additive, masked);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NetUpdate ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawSkyBoxes
|
|
|
|
//
|
|
|
|
// Draws any recorded sky boxes and then frees them.
|
|
|
|
//
|
|
|
|
// The process:
|
|
|
|
// 1. Move the camera to coincide with the SkyViewpoint.
|
|
|
|
// 2. Clear out the old planes. (They have already been drawn.)
|
|
|
|
// 3. Clear a window out of the ClipSegs just large enough for the plane.
|
|
|
|
// 4. Pretend the existing vissprites and drawsegs aren't there.
|
|
|
|
// 5. Create a drawseg at 0 distance to clip sprites to the visplane. It
|
|
|
|
// doesn't need to be associated with a line in the map, since there
|
|
|
|
// will never be any sprites in front of it.
|
|
|
|
// 6. Render the BSP, then planes, then masked stuff.
|
|
|
|
// 7. Restore the previous vissprites and drawsegs.
|
|
|
|
// 8. Repeat for any other sky boxes.
|
|
|
|
// 9. Put the camera back where it was to begin with.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
CVAR (Bool, r_skyboxes, true, 0)
|
|
|
|
static int numskyboxes;
|
|
|
|
|
|
|
|
void R_DrawSkyBoxes ()
|
|
|
|
{
|
|
|
|
static TArray<size_t> interestingStack;
|
|
|
|
static TArray<ptrdiff_t> drawsegStack;
|
|
|
|
static TArray<ptrdiff_t> visspriteStack;
|
|
|
|
static TArray<fixed_t> viewxStack, viewyStack, viewzStack;
|
2010-11-07 15:30:41 +00:00
|
|
|
static TArray<visplane_t *> visplaneStack;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
numskyboxes = 0;
|
|
|
|
|
|
|
|
if (visplanes[MAXVISPLANES] == NULL)
|
|
|
|
return;
|
|
|
|
|
2011-01-29 11:09:38 +00:00
|
|
|
R_3D_EnterSkybox();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
int savedextralight = extralight;
|
|
|
|
fixed_t savedx = viewx;
|
|
|
|
fixed_t savedy = viewy;
|
|
|
|
fixed_t savedz = viewz;
|
|
|
|
angle_t savedangle = viewangle;
|
|
|
|
ptrdiff_t savedvissprite_p = vissprite_p - vissprites;
|
|
|
|
ptrdiff_t savedds_p = ds_p - drawsegs;
|
|
|
|
ptrdiff_t savedlastopening = lastopening;
|
2006-05-04 06:14:52 +00:00
|
|
|
size_t savedinteresting = FirstInterestingDrawseg;
|
2006-02-24 04:48:15 +00:00
|
|
|
float savedvisibility = R_GetVisibility ();
|
|
|
|
AActor *savedcamera = camera;
|
|
|
|
sector_t *savedsector = viewsector;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
visplane_t *pl;
|
|
|
|
|
|
|
|
for (pl = visplanes[MAXVISPLANES]; pl != NULL; pl = visplanes[MAXVISPLANES])
|
|
|
|
{
|
|
|
|
// Pop the visplane off the list now so that if this skybox adds more
|
|
|
|
// skyboxes to the list, they will be drawn instead of skipped (because
|
|
|
|
// new skyboxes go to the beginning of the list instead of the end).
|
|
|
|
visplanes[MAXVISPLANES] = pl->next;
|
|
|
|
pl->next = NULL;
|
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
if (pl->right < pl->left || !r_skyboxes || numskyboxes == MAX_SKYBOX_PLANES)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2011-02-12 09:53:40 +00:00
|
|
|
R_DrawSinglePlane (pl, OPAQUE, false, false);
|
2006-02-24 04:48:15 +00:00
|
|
|
*freehead = pl;
|
|
|
|
freehead = &pl->next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
numskyboxes++;
|
|
|
|
|
|
|
|
ASkyViewpoint *sky = pl->skybox;
|
|
|
|
ASkyViewpoint *mate = sky->Mate;
|
|
|
|
|
|
|
|
if (mate == NULL)
|
|
|
|
{
|
|
|
|
// Don't let gun flashes brighten the sky box
|
|
|
|
extralight = 0;
|
|
|
|
R_SetVisibility (sky->args[0] * 0.25f);
|
2009-12-30 12:20:47 +00:00
|
|
|
|
2016-01-19 10:50:07 +00:00
|
|
|
fixedvec3 viewpos = sky->InterpolatedPosition(r_TicFrac);
|
|
|
|
viewx = viewpos.x;
|
|
|
|
viewy = viewpos.y;
|
|
|
|
viewz = viewpos.z;
|
2009-12-30 12:20:47 +00:00
|
|
|
viewangle = savedangle + sky->PrevAngle + FixedMul(r_TicFrac, sky->angle - sky->PrevAngle);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
R_CopyStackedViewParameters();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
extralight = pl->extralight;
|
|
|
|
R_SetVisibility (pl->visibility);
|
2016-01-19 10:50:07 +00:00
|
|
|
viewx = pl->viewx - sky->Mate->X() + sky->X();
|
|
|
|
viewy = pl->viewy - sky->Mate->Y() + sky->Y();
|
2006-02-24 04:48:15 +00:00
|
|
|
viewz = pl->viewz;
|
|
|
|
viewangle = pl->viewangle;
|
|
|
|
}
|
|
|
|
|
|
|
|
sky->bInSkybox = true;
|
|
|
|
if (mate != NULL) mate->bInSkybox = true;
|
|
|
|
camera = sky;
|
|
|
|
viewsector = sky->Sector;
|
|
|
|
R_SetViewAngle ();
|
|
|
|
validcount++; // Make sure we see all sprites
|
|
|
|
|
|
|
|
R_ClearPlanes (false);
|
2016-01-31 03:19:23 +00:00
|
|
|
R_ClearClipSegs (pl->left, pl->right);
|
|
|
|
WindowLeft = pl->left;
|
|
|
|
WindowRight = pl->right;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
for (i = pl->left; i < pl->right; i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (pl->top[i] == 0x7fff)
|
|
|
|
{
|
|
|
|
ceilingclip[i] = viewheight;
|
|
|
|
floorclip[i] = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ceilingclip[i] = pl->top[i];
|
|
|
|
floorclip[i] = pl->bottom[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a drawseg to clip sprites to the sky plane
|
|
|
|
R_CheckDrawSegs ();
|
|
|
|
ds_p->siz1 = INT_MAX;
|
|
|
|
ds_p->siz2 = INT_MAX;
|
|
|
|
ds_p->sz1 = 0;
|
|
|
|
ds_p->sz2 = 0;
|
2016-01-31 03:19:23 +00:00
|
|
|
ds_p->x1 = pl->left;
|
|
|
|
ds_p->x2 = pl->right;
|
2006-02-24 04:48:15 +00:00
|
|
|
ds_p->silhouette = SIL_BOTH;
|
2016-01-31 03:19:23 +00:00
|
|
|
ds_p->sprbottomclip = R_NewOpening (pl->right - pl->left);
|
|
|
|
ds_p->sprtopclip = R_NewOpening (pl->right - pl->left);
|
2006-02-24 04:48:15 +00:00
|
|
|
ds_p->maskedtexturecol = ds_p->swall = -1;
|
|
|
|
ds_p->bFogBoundary = false;
|
2016-01-14 05:49:57 +00:00
|
|
|
ds_p->fake = 0;
|
2016-01-31 03:19:23 +00:00
|
|
|
memcpy (openings + ds_p->sprbottomclip, floorclip + pl->left, (pl->right - pl->left)*sizeof(short));
|
|
|
|
memcpy (openings + ds_p->sprtopclip, ceilingclip + pl->left, (pl->right - pl->left)*sizeof(short));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
firstvissprite = vissprite_p;
|
|
|
|
firstdrawseg = ds_p++;
|
|
|
|
FirstInterestingDrawseg = InterestingDrawsegs.Size();
|
|
|
|
|
|
|
|
interestingStack.Push (FirstInterestingDrawseg);
|
2006-06-09 00:26:07 +00:00
|
|
|
ptrdiff_t diffnum = firstdrawseg - drawsegs;
|
|
|
|
drawsegStack.Push (diffnum);
|
|
|
|
diffnum = firstvissprite - vissprites;
|
|
|
|
visspriteStack.Push (diffnum);
|
2006-02-24 04:48:15 +00:00
|
|
|
viewxStack.Push (viewx);
|
|
|
|
viewyStack.Push (viewy);
|
|
|
|
viewzStack.Push (viewz);
|
2010-11-07 15:30:41 +00:00
|
|
|
visplaneStack.Push (pl);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
R_RenderBSPNode (nodes + numnodes - 1);
|
2011-01-29 11:09:38 +00:00
|
|
|
R_3D_ResetClip(); // reset clips (floor/ceiling)
|
2006-02-24 04:48:15 +00:00
|
|
|
R_DrawPlanes ();
|
|
|
|
|
|
|
|
sky->bInSkybox = false;
|
|
|
|
if (mate != NULL) mate->bInSkybox = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw all the masked textures in a second pass, in the reverse order they
|
|
|
|
// were added. This must be done separately from the previous step for the
|
|
|
|
// sake of nested skyboxes.
|
|
|
|
while (interestingStack.Pop (FirstInterestingDrawseg))
|
|
|
|
{
|
2006-12-29 03:38:37 +00:00
|
|
|
ptrdiff_t pd = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
drawsegStack.Pop (pd);
|
|
|
|
firstdrawseg = drawsegs + pd;
|
|
|
|
visspriteStack.Pop (pd);
|
|
|
|
firstvissprite = vissprites + pd;
|
|
|
|
viewxStack.Pop (viewx); // Masked textures and planes need the view
|
|
|
|
viewyStack.Pop (viewy); // coordinates restored for proper positioning.
|
|
|
|
viewzStack.Pop (viewz);
|
|
|
|
|
|
|
|
R_DrawMasked ();
|
|
|
|
|
|
|
|
ds_p = firstdrawseg;
|
|
|
|
vissprite_p = firstvissprite;
|
|
|
|
|
2010-11-07 15:30:41 +00:00
|
|
|
visplaneStack.Pop (pl);
|
2011-02-12 09:53:40 +00:00
|
|
|
if (pl->Alpha > 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2011-02-12 09:53:40 +00:00
|
|
|
R_DrawSinglePlane (pl, pl->Alpha, pl->Additive, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-11-07 15:30:41 +00:00
|
|
|
*freehead = pl;
|
|
|
|
freehead = &pl->next;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
firstvissprite = vissprites;
|
|
|
|
vissprite_p = vissprites + savedvissprite_p;
|
|
|
|
firstdrawseg = drawsegs;
|
|
|
|
ds_p = drawsegs + savedds_p;
|
2006-05-04 06:14:52 +00:00
|
|
|
InterestingDrawsegs.Resize ((unsigned int)FirstInterestingDrawseg);
|
2006-02-24 04:48:15 +00:00
|
|
|
FirstInterestingDrawseg = savedinteresting;
|
|
|
|
|
|
|
|
lastopening = savedlastopening;
|
|
|
|
|
|
|
|
camera = savedcamera;
|
|
|
|
viewsector = savedsector;
|
|
|
|
viewx = savedx;
|
|
|
|
viewy = savedy;
|
|
|
|
viewz = savedz;
|
|
|
|
R_SetVisibility (savedvisibility);
|
|
|
|
extralight = savedextralight;
|
|
|
|
viewangle = savedangle;
|
|
|
|
R_SetViewAngle ();
|
|
|
|
|
2011-01-29 11:09:38 +00:00
|
|
|
R_3D_LeaveSkybox();
|
|
|
|
|
|
|
|
if(fakeActive) return;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
for (*freehead = visplanes[MAXVISPLANES], visplanes[MAXVISPLANES] = NULL; *freehead; )
|
|
|
|
freehead = &(*freehead)->next;
|
|
|
|
}
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
ADD_STAT(skyboxes)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
FString out;
|
2013-02-23 04:24:40 +00:00
|
|
|
out.Format ("%d skybox planes", numskyboxes);
|
2006-09-14 00:02:31 +00:00
|
|
|
return out;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawSkyPlane
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_DrawSkyPlane (visplane_t *pl)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID sky1tex, sky2tex;
|
2009-11-08 02:51:22 +00:00
|
|
|
double frontdpos = 0, backdpos = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if ((level.flags & LEVEL_SWAPSKIES) && !(level.flags & LEVEL_DOUBLESKY))
|
|
|
|
{
|
|
|
|
sky1tex = sky2texture;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sky1tex = sky1texture;
|
|
|
|
}
|
|
|
|
sky2tex = sky2texture;
|
2009-11-12 01:05:55 +00:00
|
|
|
skymid = skytexturemid;
|
|
|
|
skyangle = viewangle;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (pl->picnum == skyflatnum)
|
2008-06-15 18:36:26 +00:00
|
|
|
{
|
|
|
|
if (!(pl->sky & PL_SKYFLAT))
|
|
|
|
{ // use sky1
|
|
|
|
sky1:
|
2011-11-04 01:12:53 +00:00
|
|
|
frontskytex = TexMan(sky1tex, true);
|
2008-06-15 18:36:26 +00:00
|
|
|
if (level.flags & LEVEL_DOUBLESKY)
|
2011-11-04 01:12:53 +00:00
|
|
|
backskytex = TexMan(sky2tex, true);
|
2008-06-15 18:36:26 +00:00
|
|
|
else
|
|
|
|
backskytex = NULL;
|
|
|
|
skyflip = 0;
|
2009-10-24 23:42:58 +00:00
|
|
|
frontdpos = sky1pos;
|
|
|
|
backdpos = sky2pos;
|
|
|
|
frontcyl = sky1cyl;
|
|
|
|
backcyl = sky2cyl;
|
2008-06-15 18:36:26 +00:00
|
|
|
}
|
|
|
|
else if (pl->sky == PL_SKYFLAT)
|
|
|
|
{ // use sky2
|
2011-11-04 01:12:53 +00:00
|
|
|
frontskytex = TexMan(sky2tex, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
backskytex = NULL;
|
2009-10-24 23:42:58 +00:00
|
|
|
frontcyl = sky2cyl;
|
2008-06-15 18:36:26 +00:00
|
|
|
skyflip = 0;
|
2009-10-24 23:42:58 +00:00
|
|
|
frontdpos = sky2pos;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
2008-06-15 18:36:26 +00:00
|
|
|
{ // MBF's linedef-controlled skies
|
|
|
|
// Sky Linedef
|
|
|
|
const line_t *l = &lines[(pl->sky & ~PL_SKYFLAT)-1];
|
|
|
|
|
|
|
|
// Sky transferred from first sidedef
|
2009-09-06 20:45:56 +00:00
|
|
|
const side_t *s = l->sidedef[0];
|
2008-06-15 18:36:26 +00:00
|
|
|
int pos;
|
|
|
|
|
|
|
|
// Texture comes from upper texture of reference sidedef
|
|
|
|
// [RH] If swapping skies, then use the lower sidedef
|
|
|
|
if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid())
|
|
|
|
{
|
|
|
|
pos = side_t::bottom;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos = side_t::top;
|
|
|
|
}
|
|
|
|
|
2011-11-04 01:12:53 +00:00
|
|
|
frontskytex = TexMan(s->GetTexture(pos), true);
|
2009-11-15 08:11:14 +00:00
|
|
|
if (frontskytex == NULL || frontskytex->UseType == FTexture::TEX_Null)
|
2008-06-15 18:36:26 +00:00
|
|
|
{ // [RH] The blank texture: Use normal sky instead.
|
|
|
|
goto sky1;
|
|
|
|
}
|
|
|
|
backskytex = NULL;
|
2008-03-21 17:35:49 +00:00
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
// Horizontal offset is turned into an angle offset,
|
|
|
|
// to allow sky rotation as well as careful positioning.
|
|
|
|
// However, the offset is scaled very small, so that it
|
|
|
|
// allows a long-period of sky rotation.
|
2009-11-12 01:05:55 +00:00
|
|
|
skyangle += s->GetTextureXOffset(pos);
|
2008-06-15 18:36:26 +00:00
|
|
|
|
|
|
|
// Vertical offset allows careful sky positioning.
|
2009-11-12 01:05:55 +00:00
|
|
|
skymid = s->GetTextureYOffset(pos) - 28*FRACUNIT;
|
2008-06-15 18:36:26 +00:00
|
|
|
|
|
|
|
// We sometimes flip the picture horizontally.
|
|
|
|
//
|
|
|
|
// Doom always flipped the picture, so we make it optional,
|
|
|
|
// to make it easier to use the new feature, while to still
|
|
|
|
// allow old sky textures to be used.
|
|
|
|
skyflip = l->args[2] ? 0u : ~0u;
|
2009-10-24 23:42:58 +00:00
|
|
|
|
|
|
|
frontcyl = MAX(frontskytex->GetWidth(), frontskytex->xScale >> (16 - 10));
|
2009-11-13 04:38:03 +00:00
|
|
|
if (skystretch)
|
2009-10-24 23:42:58 +00:00
|
|
|
{
|
2009-11-13 04:38:03 +00:00
|
|
|
skymid = Scale(skymid, frontskytex->GetScaledHeight(), SKYSTRETCH_HEIGHT);
|
2009-10-24 23:42:58 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-08 02:51:22 +00:00
|
|
|
frontpos = int(fmod(frontdpos, sky1cyl * 65536.0));
|
2009-10-24 04:39:36 +00:00
|
|
|
if (backskytex != NULL)
|
|
|
|
{
|
2009-11-08 02:51:22 +00:00
|
|
|
backpos = int(fmod(backdpos, sky2cyl * 65536.0));
|
2009-10-24 04:39:36 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
bool fakefixed = false;
|
|
|
|
if (fixedcolormap)
|
|
|
|
{
|
|
|
|
dc_colormap = fixedcolormap;
|
|
|
|
}
|
- 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
|
|
|
else
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
fakefixed = true;
|
|
|
|
fixedcolormap = dc_colormap = NormalLight.Maps;
|
|
|
|
}
|
|
|
|
|
|
|
|
R_DrawSky (pl);
|
|
|
|
|
|
|
|
if (fakefixed)
|
|
|
|
fixedcolormap = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawNormalPlane
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2011-02-12 09:53:40 +00:00
|
|
|
void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
#ifdef X86_ASM
|
2006-02-24 04:48:15 +00:00
|
|
|
if (ds_source != ds_cursource)
|
|
|
|
{
|
|
|
|
R_SetSpanSource_ASM (ds_source);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (alpha <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
angle_t planeang = pl->angle;
|
|
|
|
xscale = pl->xscale << (16 - ds_xbits);
|
|
|
|
yscale = pl->yscale << (16 - ds_ybits);
|
|
|
|
if (planeang != 0)
|
|
|
|
{
|
2015-02-21 04:52:30 +00:00
|
|
|
double rad = bam2rad(planeang);
|
|
|
|
double cosine = cos(rad), sine = sin(rad);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2015-02-21 04:52:30 +00:00
|
|
|
pviewx = xs_RoundToInt(pl->xoffs + viewx * cosine - viewy * sine);
|
|
|
|
pviewy = xs_RoundToInt(pl->yoffs - viewx * sine - viewy * cosine);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pviewx = pl->xoffs + viewx;
|
|
|
|
pviewy = pl->yoffs - viewy;
|
|
|
|
}
|
|
|
|
|
|
|
|
pviewx = FixedMul (xscale, pviewx);
|
|
|
|
pviewy = FixedMul (yscale, pviewy);
|
|
|
|
|
|
|
|
// left to right mapping
|
|
|
|
planeang = (viewangle - ANG90 + planeang) >> ANGLETOFINESHIFT;
|
|
|
|
// Scale will be unit scale at FocalLengthX (normally SCREENWIDTH/2) distance
|
|
|
|
xstepscale = Scale (xscale, finecosine[planeang], FocalLengthX);
|
|
|
|
ystepscale = Scale (yscale, -finesine[planeang], FocalLengthX);
|
|
|
|
|
|
|
|
// [RH] flip for mirrors
|
|
|
|
if (MirrorFlags & RF_XFLIP)
|
|
|
|
{
|
|
|
|
xstepscale = (DWORD)(-(SDWORD)xstepscale);
|
|
|
|
ystepscale = (DWORD)(-(SDWORD)ystepscale);
|
|
|
|
}
|
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
int x = pl->right - halfviewwidth - 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
planeang = (planeang + (ANG90 >> ANGLETOFINESHIFT)) & FINEMASK;
|
|
|
|
basexfrac = FixedMul (xscale, finecosine[planeang]) + x*xstepscale;
|
|
|
|
baseyfrac = FixedMul (yscale, -finesine[planeang]) + x*ystepscale;
|
|
|
|
|
|
|
|
planeheight = abs (FixedMul (pl->height.d, -pl->height.ic) - viewz);
|
|
|
|
|
|
|
|
GlobVis = FixedDiv (r_FloorVisibility, planeheight);
|
2009-09-20 03:50:05 +00:00
|
|
|
if (fixedlightlev >= 0)
|
- 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
|
|
|
ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
else if (fixedcolormap)
|
|
|
|
ds_colormap = fixedcolormap, plane_shade = false;
|
|
|
|
else
|
|
|
|
plane_shade = true;
|
|
|
|
|
|
|
|
if (spanfunc != R_FillSpan)
|
|
|
|
{
|
|
|
|
if (masked)
|
|
|
|
{
|
2012-08-09 04:31:31 +00:00
|
|
|
if (alpha < OPAQUE || additive)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-08-09 04:31:31 +00:00
|
|
|
if (!additive)
|
|
|
|
{
|
|
|
|
spanfunc = R_DrawSpanMaskedTranslucent;
|
|
|
|
dc_srcblend = Col2RGB8[alpha>>10];
|
|
|
|
dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spanfunc = R_DrawSpanMaskedAddClamp;
|
|
|
|
dc_srcblend = Col2RGB8_LessPrecision[alpha>>10];
|
|
|
|
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10];
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spanfunc = R_DrawSpanMasked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-09 04:31:31 +00:00
|
|
|
if (alpha < OPAQUE || additive)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-08-09 04:31:31 +00:00
|
|
|
if (!additive)
|
|
|
|
{
|
|
|
|
spanfunc = R_DrawSpanTranslucent;
|
|
|
|
dc_srcblend = Col2RGB8[alpha>>10];
|
|
|
|
dc_destblend = Col2RGB8[(OPAQUE-alpha)>>10];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spanfunc = R_DrawSpanAddClamp;
|
|
|
|
dc_srcblend = Col2RGB8_LessPrecision[alpha>>10];
|
|
|
|
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT>>10];
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spanfunc = R_DrawSpan;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
R_MapVisPlane (pl, R_MapPlane);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawTiltedPlane
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2011-02-12 09:53:40 +00:00
|
|
|
void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
static const float ifloatpow2[16] =
|
|
|
|
{
|
|
|
|
// ifloatpow2[i] = 1 / (1 << i)
|
|
|
|
64.f, 32.f, 16.f, 8.f, 4.f, 2.f, 1.f, 0.5f,
|
|
|
|
0.25f, 0.125f, 0.0625f, 0.03125f, 0.015625f, 0.0078125f,
|
|
|
|
0.00390625f, 0.001953125f
|
|
|
|
/*, 0.0009765625f, 0.00048828125f, 0.000244140625f,
|
|
|
|
1.220703125e-4f, 6.103515625e-5, 3.0517578125e-5*/
|
|
|
|
};
|
2008-05-22 05:17:21 +00:00
|
|
|
double lxscale, lyscale;
|
|
|
|
double xscale, yscale;
|
2007-01-19 02:00:39 +00:00
|
|
|
FVector3 p, m, n;
|
2008-05-22 05:17:21 +00:00
|
|
|
double ang;
|
|
|
|
double zeroheight;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (alpha <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-22 05:17:21 +00:00
|
|
|
double vx = FIXED2FLOAT(viewx);
|
|
|
|
double vy = FIXED2FLOAT(viewy);
|
|
|
|
double vz = FIXED2FLOAT(viewz);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
lxscale = FIXED2FLOAT(pl->xscale) * ifloatpow2[ds_xbits];
|
|
|
|
lyscale = FIXED2FLOAT(pl->yscale) * ifloatpow2[ds_ybits];
|
|
|
|
xscale = 64.f / lxscale;
|
|
|
|
yscale = 64.f / lyscale;
|
2008-05-22 05:17:21 +00:00
|
|
|
zeroheight = pl->height.ZatPoint(vx, vy);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
pviewx = MulScale (pl->xoffs, pl->xscale, ds_xbits);
|
|
|
|
pviewy = MulScale (pl->yoffs, pl->yscale, ds_ybits);
|
|
|
|
|
2008-05-22 05:17:21 +00:00
|
|
|
// p is the texture origin in view space
|
|
|
|
// Don't add in the offsets at this stage, because doing so can result in
|
|
|
|
// errors if the flat is rotated.
|
|
|
|
ang = bam2rad(ANG270 - viewangle);
|
|
|
|
p[0] = vx * cos(ang) - vy * sin(ang);
|
|
|
|
p[2] = vx * sin(ang) + vy * cos(ang);
|
|
|
|
p[1] = pl->height.ZatPoint(0.0, 0.0) - vz;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// m is the v direction vector in view space
|
2008-05-22 05:17:21 +00:00
|
|
|
ang = bam2rad(ANG180 - viewangle - pl->angle);
|
|
|
|
m[0] = yscale * cos(ang);
|
|
|
|
m[2] = yscale * sin(ang);
|
2006-02-24 04:48:15 +00:00
|
|
|
// m[1] = FIXED2FLOAT(pl->height.ZatPoint (0, iyscale) - pl->height.ZatPoint (0,0));
|
|
|
|
// VectorScale2 (m, 64.f/VectorLength(m));
|
|
|
|
|
|
|
|
// n is the u direction vector in view space
|
2008-05-22 05:17:21 +00:00
|
|
|
ang += PI/2;
|
|
|
|
n[0] = -xscale * cos(ang);
|
|
|
|
n[2] = -xscale * sin(ang);
|
2006-02-24 04:48:15 +00:00
|
|
|
// n[1] = FIXED2FLOAT(pl->height.ZatPoint (ixscale, 0) - pl->height.ZatPoint (0,0));
|
|
|
|
// VectorScale2 (n, 64.f/VectorLength(n));
|
|
|
|
|
2008-05-22 05:17:21 +00:00
|
|
|
// This code keeps the texture coordinates constant across the x,y plane no matter
|
|
|
|
// how much you slope the surface. Use the commented-out code above instead to keep
|
|
|
|
// the textures a constant size across the surface's plane instead.
|
|
|
|
ang = bam2rad(pl->angle);
|
|
|
|
m[1] = pl->height.ZatPoint(vx + yscale * sin(ang), vy + yscale * cos(ang)) - zeroheight;
|
|
|
|
ang += PI/2;
|
|
|
|
n[1] = pl->height.ZatPoint(vx + xscale * sin(ang), vy + xscale * cos(ang)) - zeroheight;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-01-19 02:00:39 +00:00
|
|
|
plane_su = p ^ m;
|
|
|
|
plane_sv = p ^ n;
|
|
|
|
plane_sz = m ^ n;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-01-19 02:00:39 +00:00
|
|
|
plane_su.Z *= FocalLengthXfloat;
|
|
|
|
plane_sv.Z *= FocalLengthXfloat;
|
|
|
|
plane_sz.Z *= FocalLengthXfloat;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-01-19 02:00:39 +00:00
|
|
|
plane_su.Y *= iyaspectmulfloat;
|
|
|
|
plane_sv.Y *= iyaspectmulfloat;
|
|
|
|
plane_sz.Y *= iyaspectmulfloat;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Premultiply the texture vectors with the scale factors
|
2007-01-19 02:00:39 +00:00
|
|
|
plane_su *= 4294967296.f;
|
|
|
|
plane_sv *= 4294967296.f;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (MirrorFlags & RF_XFLIP)
|
|
|
|
{
|
|
|
|
plane_su[0] = -plane_su[0];
|
|
|
|
plane_sv[0] = -plane_sv[0];
|
|
|
|
plane_sz[0] = -plane_sz[0];
|
|
|
|
}
|
|
|
|
|
2013-04-17 01:32:40 +00:00
|
|
|
planelightfloat = (r_TiltVisibility * lxscale * lyscale) / (fabs(pl->height.ZatPoint(FIXED2DBL(viewx), FIXED2DBL(viewy)) - FIXED2DBL(viewz))) / 65536.0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (pl->height.c > 0)
|
|
|
|
planelightfloat = -planelightfloat;
|
|
|
|
|
2009-09-20 03:50:05 +00:00
|
|
|
if (fixedlightlev >= 0)
|
- 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
|
|
|
ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
else if (fixedcolormap)
|
|
|
|
ds_colormap = fixedcolormap, plane_shade = false;
|
|
|
|
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
|
|
|
ds_colormap = basecolormap->Maps, plane_shade = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!plane_shade)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < viewwidth; ++i)
|
|
|
|
{
|
|
|
|
tiltlighting[i] = ds_colormap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
#if defined(X86_ASM)
|
2006-02-24 04:48:15 +00:00
|
|
|
if (ds_source != ds_curtiltedsource)
|
|
|
|
R_SetTiltedSpanSource_ASM (ds_source);
|
|
|
|
R_MapVisPlane (pl, R_DrawTiltedPlane_ASM);
|
|
|
|
#else
|
|
|
|
R_MapVisPlane (pl, R_MapTiltedPlane);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_MapVisPlane
|
|
|
|
//
|
|
|
|
// t1/b1 are at x
|
|
|
|
// t2/b2 are at x+1
|
|
|
|
// spanend[y] is at the right edge
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1))
|
|
|
|
{
|
2016-01-31 03:19:23 +00:00
|
|
|
int x = pl->right - 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
int t2 = pl->top[x];
|
|
|
|
int b2 = pl->bottom[x];
|
|
|
|
|
|
|
|
if (b2 > t2)
|
|
|
|
{
|
|
|
|
clearbufshort (spanend+t2, b2-t2, x);
|
|
|
|
}
|
|
|
|
|
2016-01-31 03:19:23 +00:00
|
|
|
for (--x; x >= pl->left; --x)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int t1 = pl->top[x];
|
|
|
|
int b1 = pl->bottom[x];
|
|
|
|
const int xr = x+1;
|
|
|
|
int stop;
|
|
|
|
|
|
|
|
// Draw any spans that have just closed
|
|
|
|
stop = MIN (t1, b2);
|
|
|
|
while (t2 < stop)
|
|
|
|
{
|
|
|
|
mapfunc (t2++, xr);
|
|
|
|
}
|
|
|
|
stop = MAX (b1, t2);
|
|
|
|
while (b2 > stop)
|
|
|
|
{
|
|
|
|
mapfunc (--b2, xr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mark any spans that have just opened
|
|
|
|
stop = MIN (t2, b1);
|
|
|
|
while (t1 < stop)
|
|
|
|
{
|
|
|
|
spanend[t1++] = x;
|
|
|
|
}
|
|
|
|
stop = MAX (b2, t2);
|
|
|
|
while (b1 > stop)
|
|
|
|
{
|
|
|
|
spanend[--b1] = x;
|
|
|
|
}
|
|
|
|
|
|
|
|
t2 = pl->top[x];
|
|
|
|
b2 = pl->bottom[x];
|
|
|
|
basexfrac -= xstepscale;
|
|
|
|
baseyfrac -= ystepscale;
|
|
|
|
}
|
|
|
|
// Draw any spans that are still open
|
|
|
|
while (t2 < b2)
|
|
|
|
{
|
2016-01-31 03:19:23 +00:00
|
|
|
mapfunc (--b2, pl->left);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_PlaneInitData
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
bool R_PlaneInitData ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
visplane_t *pl;
|
|
|
|
|
|
|
|
// Free all visplanes and let them be re-allocated as needed.
|
|
|
|
pl = freetail;
|
|
|
|
|
|
|
|
while (pl)
|
|
|
|
{
|
|
|
|
visplane_t *next = pl->next;
|
2008-02-17 02:40:03 +00:00
|
|
|
M_Free (pl);
|
2006-02-24 04:48:15 +00:00
|
|
|
pl = next;
|
|
|
|
}
|
|
|
|
freetail = NULL;
|
|
|
|
freehead = &freetail;
|
|
|
|
|
|
|
|
for (i = 0; i < MAXVISPLANES; i++)
|
|
|
|
{
|
|
|
|
pl = visplanes[i];
|
|
|
|
visplanes[i] = NULL;
|
|
|
|
while (pl)
|
|
|
|
{
|
|
|
|
visplane_t *next = pl->next;
|
2008-02-17 02:40:03 +00:00
|
|
|
M_Free (pl);
|
2006-02-24 04:48:15 +00:00
|
|
|
pl = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|