📄 r_segs.c
字号:
} maskedtexturecol = ds->thicksidecol; mfloorclip = ds->sprbottomclip; mceilingclip = ds->sprtopclip; dc_texheight = textureheight[texnum] >> FRACBITS; dc_texturemid = *ffloor->topheight - viewz; offsetvalue = sides[ffloor->master->sidenum[0]].rowoffset; if(curline->linedef->flags & ML_DONTPEGBOTTOM) offsetvalue -= *ffloor->topheight - *ffloor->bottomheight; dc_texturemid += offsetvalue; if (fixedcolormap) dc_colormap = fixedcolormap; //faB: handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures // are not stored per-column with post info anymore in Doom Legacy if (textures[texnum]->patchcount==1) colfunc_2s = R_DrawMaskedColumn; //render the usual 2sided single-patch packed texture else { colfunc_2s = R_Render2sidedMultiPatchColumn; //render multipatch with no holes (no post_t info) column2s_length = textures[texnum]->height; } // draw the columns for (dc_x = x1 ; dc_x <= x2 ; dc_x++) { if(maskedtexturecol[dc_x] != MAXSHORT) { // SoM: New code does not rely on r_drawColumnShadowed_8 which // will (hopefully) put less strain on the stack. if(dc_numlights) { lighttable_t** xwalllights; fixed_t height; fixed_t bheight = 0; int solid = 0; int lighteffect = 0; sprtopscreen = windowtop = (centeryfrac - FixedMul((dc_texturemid - offsetvalue), spryscale)); sprbotscreen = windowbottom = FixedMul(*ffloor->topheight - *ffloor->bottomheight, spryscale) + sprtopscreen; // SoM: If column is out of range, why bother with it?? if(windowbottom < topbounds || windowtop > bottombounds) { for(i = 0; i < dc_numlights; i++) { dc_lightlist[i].height += dc_lightlist[i].heightstep; if(dc_lightlist[i].flags & FF_CUTLEVEL) dc_lightlist[i].botheight += dc_lightlist[i].botheightstep; } spryscale += rw_scalestep; continue; } dc_iscale = 0xffffffffu / (unsigned)spryscale; // draw the texture col = (column_t *)((byte *)R_GetColumn(texnum,maskedtexturecol[dc_x]) - 3); for(i = 0; i < dc_numlights; i++) { int lightnum; // Check if the current light effects the colormap/lightlevel lighteffect = !(dc_lightlist[i].flags & FF_NOSHADE); if(lighteffect) { if(ffloor->flags & FF_FOG || dc_lightlist[i].flags & FF_FOG || (dc_lightlist[i].extra_colormap && dc_lightlist[i].extra_colormap->fog)) lightnum = (ffloor->master->frontsector->lightlevel >> LIGHTSEGSHIFT); else lightnum = (dc_lightlist[i].lightlevel >> LIGHTSEGSHIFT)+extralight; if(ffloor->flags & FF_FOG || dc_lightlist[i].flags & FF_FOG || (dc_lightlist[i].extra_colormap && dc_lightlist[i].extra_colormap->fog)); else if (curline->v1->y == curline->v2->y) lightnum--; else if (curline->v1->x == curline->v2->x) lightnum++; if (lightnum < 0) xwalllights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) xwalllights = scalelight[LIGHTLEVELS-1]; else xwalllights = scalelight[lightnum]; index = spryscale>>LIGHTSCALESHIFT; if (index >= MAXLIGHTSCALE ) index = MAXLIGHTSCALE-1; if(ffloor->flags & FF_FOG) { if(ffloor->master->frontsector->extra_colormap && !fixedcolormap) dc_lightlist[i].rcolormap = ffloor->master->frontsector->extra_colormap->colormap + (xwalllights[index] - colormaps); else if(!fixedcolormap) dc_lightlist[i].rcolormap = xwalllights[index]; } else { if(dc_lightlist[i].extra_colormap && !fixedcolormap) dc_lightlist[i].rcolormap = dc_lightlist[i].extra_colormap->colormap + (xwalllights[index] - colormaps); else if(!fixedcolormap) dc_lightlist[i].rcolormap = xwalllights[index]; } if(fixedcolormap) dc_lightlist[i].rcolormap = fixedcolormap; } // Check if the current light can cut the current 3D floor. if(dc_lightlist[i].flags & FF_CUTSOLIDS && !(ffloor->flags & FF_EXTRA)) solid = 1; else if(dc_lightlist[i].flags & FF_CUTEXTRA && ffloor->flags & FF_EXTRA) { if(dc_lightlist[i].flags & FF_EXTRA) { // The light is from an extra 3D floor... Check the flags so // there are no undesired cuts. if((dc_lightlist[i].flags & (FF_TRANSLUCENT|FF_FOG)) == (ffloor->flags & (FF_TRANSLUCENT|FF_FOG))) solid = 1; } else solid = 1; } else solid = 0; dc_lightlist[i].height += dc_lightlist[i].heightstep; height = dc_lightlist[i].height; if(solid) { dc_lightlist[i].botheight += dc_lightlist[i].botheightstep; bheight = dc_lightlist[i].botheight - (FRACUNIT >> 1); } if(height <= windowtop) { if(lighteffect) dc_colormap = dc_lightlist[i].rcolormap; if(solid && windowtop < bheight) windowtop = bheight; continue; } windowbottom = height; if(windowbottom >= sprbotscreen) { windowbottom = sprbotscreen; colfunc_2s (col); for(i++ ; i < dc_numlights; i++) { dc_lightlist[i].height += dc_lightlist[i].heightstep; if(dc_lightlist[i].flags & FF_CUTLEVEL) dc_lightlist[i].botheight += dc_lightlist[i].botheightstep; } continue; } colfunc_2s (col); if(solid) windowtop = bheight; else windowtop = windowbottom + 1; if(lighteffect) dc_colormap = dc_lightlist[i].rcolormap; } windowbottom = sprbotscreen; if(windowtop < windowbottom) colfunc_2s (col); spryscale += rw_scalestep; continue; } // calculate lighting if (!fixedcolormap) { index = spryscale>>LIGHTSCALESHIFT; if (index >= MAXLIGHTSCALE ) index = MAXLIGHTSCALE-1; dc_colormap = walllights[index]; if(frontsector->extra_colormap) dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); if(ffloor->flags & FF_FOG && ffloor->master->frontsector->extra_colormap) dc_colormap = ffloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps); } sprtopscreen = windowtop = (centeryfrac - FixedMul((dc_texturemid - offsetvalue), spryscale)); sprbotscreen = windowbottom = FixedMul(*ffloor->topheight - *ffloor->bottomheight, spryscale) + sprtopscreen; dc_iscale = 0xffffffffu / (unsigned)spryscale; // draw the texture col = (column_t *)((byte *)R_GetColumn(texnum,maskedtexturecol[dc_x]) - 3); colfunc_2s (col); spryscale += rw_scalestep; } } colfunc = basecolfunc;}//// R_RenderSegLoop// Draws zero, one, or two textures (and possibly a masked// texture) for walls.// Can draw or mark the starting pixel of floor and ceiling// textures.// CALLED: CORE LOOPING ROUTINE.//#define HEIGHTBITS 12#define HEIGHTUNIT (1<<HEIGHTBITS)//profile stuff ---------------------------------------------------------//#define TIMING#ifdef TIMING#include "p5prof.h"long long mycount;long long mytotal = 0;unsigned long nombre = 100000;//static char runtest[10][80];#endif//profile stuff ---------------------------------------------------------void R_RenderSegLoop (void){ angle_t angle; unsigned index; int yl; int yh;#ifdef OLDWATER int yw; //added:18-02-98:WATER!#endif int mid; fixed_t texturecolumn; int top; int bottom; int i; texturecolumn = 0; // shut up compiler warning for ( ; rw_x < rw_stopx ; rw_x++) { // mark floor / ceiling areas yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS; // no space above wall? if (yl < ceilingclip[rw_x]+1) yl = ceilingclip[rw_x]+1; if (markceiling) { top = ceilingclip[rw_x]+1; bottom = yl-1; if (bottom >= floorclip[rw_x]) bottom = floorclip[rw_x]-1; if (top <= bottom) { ceilingplane->top[rw_x] = top; ceilingplane->bottom[rw_x] = bottom; } } yh = bottomfrac>>HEIGHTBITS; if (yh >= floorclip[rw_x]) yh = floorclip[rw_x]-1; if (markfloor) { top = yh+1; bottom = floorclip[rw_x]-1; if (top <= ceilingclip[rw_x]) top = ceilingclip[rw_x]+1; if (top <= bottom && floorplane) { floorplane->top[rw_x] = top; floorplane->bottom[rw_x] = bottom; } } if (frontsector->ceilingportal) { top = ceilingclip[rw_x]+1; bottom = yl-1; if (bottom >= floorclip[rw_x]) bottom = floorclip[rw_x]-1; if (top <= bottom) { dc_x = rw_x; dc_yl = top; dc_yh = bottom; dc_portal = frontsector->ceilingportal; R_StorePortalRange(); } }#ifdef OLDWATER if (markwater) { //added:18-02-98:WATER! yw = waterfrac>>HEIGHTBITS; // the markwater stuff... if (waterplane->height<viewz) { top = yw; bottom = waterclip[rw_x]-1; if (top <= ceilingclip[rw_x]) top = ceilingclip[rw_x]+1; } else //view from under { top = waterclip[rw_x]+1; bottom = yw; if (bottom >= floorclip[rw_x]) bottom = floorclip[rw_x]-1; } if (top <= bottom) { waterplane->top[rw_x] = top; waterplane->bottom[rw_x] = bottom; } // do it only if markwater else not needed! waterfrac += waterstep; //added:18-02-98:WATER! //dc_wcolormap = colormaps+(32<<8); }#endif if (numffloors) { ffloor[0].plane->frontscale[rw_x] = frontscale[rw_x]; for(i = 0; i < numffloors; i++) { if(ffloor[i].height < viewz) { int top_w = (ffloor[i].f_frac >> HEIGHTBITS) + 1; int bottom_w = ffloor[i].f_clip[rw_x]; if(top_w < ceilingclip[rw_x] + 1) top_w = ceilingclip[rw_x] + 1; if (bottom_w > floorclip[rw_x] - 1) bottom_w = floorclip[rw_x] - 1; if (top_w <= bottom_w) { ffloor[i].plane->top[rw_x] = top_w; ffloor[i].plane->bottom[rw_x] = bottom_w; } } else if (ffloor[i].height > viewz) { int top_w = ffloor[i].c_clip[rw_x] + 1; int bottom_w = (ffloor[i].f_frac >> HEIGHTBITS); if (top_w < ceilingclip[rw_x] + 1) top_w = ceilingclip[rw_x] + 1; if (bottom_w > floorclip[rw_x] - 1) bottom_w = floorclip[rw_x] - 1; if (top_w <= bottom_w) { ffloor[i].plane->top[rw_x] = top_w; ffloor[i].plane->bottom[rw_x] = bottom_w; } } } } //SoM: Calculate offsets for Thick fake floors. // calculate texture offset angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; texturecolumn = rw_offset-FixedMul(finetangent[angle],rw_distance); texturecolumn >>= FRACBITS; // texturecolumn and lighting are independent of wall tiers if (segtextured)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -