📄 r_segs.c
字号:
// Emacs style mode select -*- C++ -*-//-----------------------------------------------------------------------------//// $Id: r_segs.c,v 1.25 2001/04/30 17:19:24 stroggonmeth Exp $//// Copyright (C) 1993-1996 by id Software, Inc.// Portions Copyright (C) 1998-2000 by DooM Legacy Team.//// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License// as published by the Free Software Foundation; either version 2// of the License, or (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.////// $Log: r_segs.c,v $// Revision 1.25 2001/04/30 17:19:24 stroggonmeth// HW fix and misc. changes//// Revision 1.24 2001/03/21 18:24:39 stroggonmeth// Misc changes and fixes. Code cleanup//// Revision 1.23 2001/03/13 22:14:20 stroggonmeth// Long time no commit. 3D floors, FraggleScript, portals, ect.//// Revision 1.22 2001/02/24 13:35:21 bpereira// no message//// Revision 1.21 2000/11/26 01:02:27 hurdler// small bug fixes//// Revision 1.20 2000/11/25 18:41:21 stroggonmeth// Crash fix//// Revision 1.19 2000/11/21 21:13:18 stroggonmeth// Optimised 3D floors and fixed crashing bug in high resolutions.//// Revision 1.18 2000/11/14 16:23:16 hurdler// Please fix this bug//// Revision 1.17 2000/11/09 17:56:20 stroggonmeth// Hopefully fixed a few bugs and did a few optimizations.//// Revision 1.16 2000/11/03 03:27:17 stroggonmeth// Again with the bug fixing...//// Revision 1.15 2000/11/02 19:49:36 bpereira// no message//// Revision 1.14 2000/11/02 17:50:09 stroggonmeth// Big 3Dfloors & FraggleScript commit!!//// Revision 1.13 2000/09/28 20:57:17 bpereira// no message//// Revision 1.12 2000/04/30 10:30:10 bpereira// no message//// Revision 1.11 2000/04/18 17:39:40 stroggonmeth// Bug fixes and performance tuning.//// Revision 1.10 2000/04/16 18:38:07 bpereira// no message//// Revision 1.9 2000/04/15 22:12:58 stroggonmeth// Minor bug fixes//// Revision 1.8 2000/04/13 23:47:47 stroggonmeth// See logs//// Revision 1.7 2000/04/08 17:29:25 stroggonmeth// no message//// Revision 1.6 2000/04/06 21:06:19 stroggonmeth// Optimized extra_colormap code...// Added #ifdefs for older water code.//// Revision 1.5 2000/04/05 15:47:47 stroggonmeth// Added hack for Dehacked lumps. Transparent sprites are now affected by colormaps.//// Revision 1.4 2000/04/04 19:28:43 stroggonmeth// Global colormaps working. Added a new linedef type 272.//// Revision 1.3 2000/04/04 00:32:48 stroggonmeth// Initial Boom compatability plus few misc changes all around.//// Revision 1.2 2000/02/27 00:42:10 hurdler// fix CR+LF problem//// Revision 1.1.1.1 2000/02/22 20:32:32 hurdler// Initial import into CVS (v1.29 pr3)////// DESCRIPTION:// All the clipping: columns, horizontal spans, sky columns.////-----------------------------------------------------------------------------#include "doomdef.h"#include "r_local.h"#include "r_sky.h"#include "r_splats.h" //faB: testing#include "w_wad.h"#include "z_zone.h"#include "d_netcmd.h"#include "p_local.h" //Camera...#include "console.h" //Con_clipviewtop#ifdef OLDWATERextern fixed_t waterheight;static boolean markwater;static fixed_t waterz;static fixed_t waterfrac;static fixed_t waterstep;#endif// OPTIMIZE: closed two sided lines as single sided// True if any of the segs textures might be visible.static boolean segtextured;static boolean markfloor; // False if the back side is the same plane.static boolean markceiling;static boolean maskedtexture;static int toptexture;static int bottomtexture;static int midtexture;static int numthicksides;//static short* thicksidecol;angle_t rw_normalangle;// angle to line originint rw_angle1;fixed_t rw_distance;//// regular wall//static int rw_x;static int rw_stopx;static angle_t rw_centerangle;static fixed_t rw_offset;static fixed_t rw_offset2; // for splatsstatic fixed_t rw_scale;static fixed_t rw_scalestep;static fixed_t rw_midtexturemid;static fixed_t rw_toptexturemid;static fixed_t rw_bottomtexturemid;static int worldtop;static int worldbottom;static int worldhigh;static int worldlow;static fixed_t pixhigh;static fixed_t pixlow;static fixed_t pixhighstep;static fixed_t pixlowstep;static fixed_t topfrac;static fixed_t topstep;static fixed_t bottomfrac;static fixed_t bottomstep;lighttable_t** walllights;short* maskedtexturecol;// ==========================================================================// R_Splats Wall Splats Drawer// ==========================================================================#ifdef WALLSPLATS#define BORIS_FIX#ifdef BORIS_FIXstatic short last_ceilingclip[MAXVIDWIDTH];static short last_floorclip[MAXVIDWIDTH];#endifstatic void R_DrawSplatColumn (column_t* column){ int topscreen; int bottomscreen; fixed_t basetexturemid; basetexturemid = dc_texturemid; for ( ; column->topdelta != 0xff ; ) { // calculate unclipped screen coordinates // for post topscreen = sprtopscreen + spryscale*column->topdelta; bottomscreen = topscreen + spryscale*column->length; dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; dc_yh = (bottomscreen-1)>>FRACBITS;#ifndef BORIS_FIX if (dc_yh >= mfloorclip[dc_x]) dc_yh = mfloorclip[dc_x] - 1; if (dc_yl < mceilingclip[dc_x]) dc_yl = mceilingclip[dc_x] + 1;#else if (dc_yh >= last_floorclip[dc_x]) dc_yh = last_floorclip[dc_x]-1; if (dc_yl <= last_ceilingclip[dc_x]) dc_yl = last_ceilingclip[dc_x]+1;#endif if (dc_yl <= dc_yh) { dc_source = (byte *)column + 3; dc_texturemid = basetexturemid - (column->topdelta<<FRACBITS); //CONS_Printf("l %d h %d %d\n",dc_yl,dc_yh, column->length); // Drawn by either R_DrawColumn // or (SHADOW) R_DrawFuzzColumn. colfunc (); } column = (column_t *)( (byte *)column + column->length + 4); } dc_texturemid = basetexturemid;}static void R_DrawWallSplats (){ wallsplat_t* splat; seg_t* seg; angle_t angle, angle1, angle2; int x1, x2; unsigned index; column_t* col; patch_t* patch; fixed_t texturecolumn; splat = (wallsplat_t*) linedef->splats;#ifdef PARANOIA if (!splat) I_Error ("R_DrawWallSplats: splat is NULL");#endif seg = ds_p->curline; // draw all splats from the line that touches the range of the seg for ( ; splat ; splat=splat->next) { angle1 = R_PointToAngle (splat->v1.x, splat->v1.y); angle2 = R_PointToAngle (splat->v2.x, splat->v2.y); angle1 = (angle1-viewangle+ANG90)>>ANGLETOFINESHIFT; angle2 = (angle2-viewangle+ANG90)>>ANGLETOFINESHIFT;#if 0 if (angle1>clipangle) angle1=clipangle; if (angle2>clipangle) angle2=clipangle; if ((int)angle1<-(int)clipangle) angle1=-clipangle; if ((int)angle2<-(int)clipangle) angle2=-clipangle;#else // BP: out of the viewangletox lut, TODO clip it to the screen if( angle1 > FINEANGLES/2 || angle2 > FINEANGLES/2) continue;#endif x1 = viewangletox[angle1]; x2 = viewangletox[angle2]; if (x1 >= x2) continue; // does not cross a pixel // splat is not in this seg range if (x2 < ds_p->x1 || x1 > ds_p->x2) continue; if (x1 < ds_p->x1) x1 = ds_p->x1; if (x2 > ds_p->x2) x2 = ds_p->x2; if( x2<=x1 ) continue; // calculate incremental stepping values for texture edges rw_scalestep = ds_p->scalestep; spryscale = ds_p->scale1 + (x1 - ds_p->x1)*rw_scalestep; mfloorclip = floorclip; mceilingclip = ceilingclip; patch = W_CachePatchNum (splat->patch, PU_CACHE); // clip splat range to seg range left /*if (x1 < ds_p->x1) { spryscale += (rw_scalestep * (ds_p->x1 - x1)); x1 = ds_p->x1; }*/ // clip splat range to seg range right // SoM: This is set allready. THIS IS WHAT WAS CAUSING PROBLEMS WITH // BOOM WATER! // frontsector = ds_p->curline->frontsector; dc_texturemid = splat->top + (patch->height<<(FRACBITS-1)) - viewz; if( splat->yoffset ) dc_texturemid += *splat->yoffset; sprtopscreen = centeryfrac - FixedMul(dc_texturemid,spryscale); // set drawing mode switch (splat->flags & SPLATDRAWMODE_MASK) { case SPLATDRAWMODE_OPAQUE: colfunc = basecolfunc; break; case SPLATDRAWMODE_TRANS: colfunc = fuzzcolfunc; dc_transmap = ((tr_transmed-1)<<FF_TRANSSHIFT) + transtables; break; case SPLATDRAWMODE_SHADE: colfunc = shadecolfunc; break; } if (fixedcolormap) dc_colormap = fixedcolormap; dc_texheight = 0; // draw the columns for (dc_x = x1 ; dc_x <= x2 ; dc_x++,spryscale += rw_scalestep) { if (!fixedcolormap) { index = spryscale>>LIGHTSCALESHIFT; if (index >= MAXLIGHTSCALE ) index = MAXLIGHTSCALE-1; dc_colormap = walllights[index]; } if(frontsector->extra_colormap && !fixedcolormap) dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); dc_iscale = 0xffffffffu / (unsigned)spryscale; // find column of patch, from perspective angle = (rw_centerangle + xtoviewangle[dc_x])>>ANGLETOFINESHIFT; texturecolumn = rw_offset2 - splat->offset - FixedMul(finetangent[angle],rw_distance); //texturecolumn &= 7; //DEBUG // FIXME !// CONS_Printf ("%.2f width %d, %d[x], %.1f[off]-%.1f[soff]-tg(%d)=%.1f*%.1f[d] = %.1f\n", // FIXED_TO_FLOAT(texturecolumn), patch->width,// dc_x,FIXED_TO_FLOAT(rw_offset2),FIXED_TO_FLOAT(splat->offset),angle,FIXED_TO_FLOAT(finetangent[angle]),FIXED_TO_FLOAT(rw_distance),FIXED_TO_FLOAT(FixedMul(finetangent[angle],rw_distance))); texturecolumn >>= FRACBITS; if (texturecolumn < 0 || texturecolumn>=patch->width) continue; // draw the texture col = (column_t *) ((byte *)patch + LONG(patch->columnofs[texturecolumn])); R_DrawSplatColumn (col); } }// next splat colfunc = basecolfunc;}#endif //WALLSPLATS// ==========================================================================// R_RenderMaskedSegRange// ==========================================================================// If we have a multi-patch texture on a 2sided wall (rare) then we draw// it using R_DrawColumn, else we draw it using R_DrawMaskedColumn, this// way we don't have to store extra post_t info with each column for// multi-patch textures. They are not normally needed as multi-patch// textures don't have holes in it. At least not for now.static int column2s_length; // column->length : for multi-patch on 2sided wall = texture->heightvoid R_Render2sidedMultiPatchColumn (column_t* column)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -