⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r_segs.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 5 页
字号:
{    int         topscreen;    int         bottomscreen;    topscreen = sprtopscreen; // + spryscale*column->topdelta;  topdelta is 0 for the wall    bottomscreen = topscreen + spryscale * column2s_length;    dc_yl = (sprtopscreen+FRACUNIT-1)>>FRACBITS;    dc_yh = (bottomscreen-1)>>FRACBITS;    if(windowtop != MAXINT && windowbottom != MAXINT)    {      dc_yl = ((windowtop + FRACUNIT) >> FRACBITS);      dc_yh = (windowbottom - 1) >> FRACBITS;    }    {      if (dc_yh >= mfloorclip[dc_x])          dc_yh =  mfloorclip[dc_x]-1;      if (dc_yl <= mceilingclip[dc_x])          dc_yl =  mceilingclip[dc_x]+1;    }    if (dc_yl >= vid.height || dc_yh < 0)      return;    if (dc_yl <= dc_yh)    {        dc_source = (byte *)column + 3;        colfunc ();    }}void R_RenderMaskedSegRange (drawseg_t* ds,                             int        x1,                             int        x2 ){    unsigned        index;    column_t*       col;    int             lightnum;    int             texnum;    int             i;    fixed_t         height;    fixed_t         realbot;    void (*colfunc_2s) (column_t*);        line_t* ldef;   //faB    // Calculate light table.    // Use different light tables    //   for horizontal / vertical / diagonal. Diagonal?    // OPTIMIZE: get rid of LIGHTSEGSHIFT globally    curline = ds->curline;    frontsector = curline->frontsector;    backsector = curline->backsector;    texnum = texturetranslation[curline->sidedef->midtexture];    windowbottom = windowtop = sprbotscreen = MAXINT;    //faB: hack translucent linedef types (201-205 for transtables 1-5)    //SoM: 201-205 are taken... So I'm switching to 284 - 288    ldef = curline->linedef;    if (ldef->special>=284 && ldef->special<=288)    {        dc_transmap = ((ldef->special-284)<<FF_TRANSSHIFT) + transtables;        colfunc = fuzzcolfunc;    }    else    if (ldef->special==260)    {        dc_transmap = transtables; // get first transtable 50/50        colfunc = fuzzcolfunc;    }    else    if (ldef->special==283)    {        colfunc = R_DrawFogColumn_8;        windowtop = frontsector->ceilingheight;        windowbottom = frontsector->floorheight;    }    else        colfunc = basecolfunc;    //SoM: Moved these up here so they are available for my lightlist calculations    rw_scalestep = ds->scalestep;    spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep;    //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;    }    dc_numlights = 0;    if(frontsector->numlights)    {      dc_numlights = frontsector->numlights;      if(dc_numlights >= dc_maxlights)      {        dc_maxlights = dc_numlights;        dc_lightlist = realloc(dc_lightlist, sizeof(r_lightlist_t) * dc_maxlights);      }      for(i = 0; i < dc_numlights; i++)      {        dc_lightlist[i].height = (centeryfrac) - FixedMul((frontsector->lightlist[i].height - viewz), spryscale);        dc_lightlist[i].heightstep = -FixedMul (rw_scalestep, (frontsector->lightlist[i].height - viewz));        dc_lightlist[i].lightlevel = frontsector->lightlist[i].lightlevel;        dc_lightlist[i].extra_colormap = frontsector->lightlist[i].extra_colormap;        dc_lightlist[i].flags = frontsector->lightlist[i].caster ? frontsector->lightlist[i].caster->flags : 0;      }    }    else    {      if(colfunc == fuzzcolfunc)      {        if(frontsector->extra_colormap && frontsector->extra_colormap->fog)          lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);        else          lightnum = LIGHTLEVELS-1;      }      else if(colfunc == R_DrawFogColumn_8)        lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);      else        lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight;      if (colfunc == R_DrawFogColumn_8 || (frontsector->extra_colormap && frontsector->extra_colormap->fog));      else if (curline->v1->y == curline->v2->y)          lightnum--;      else if (curline->v1->x == curline->v2->x)          lightnum++;      if (lightnum < 0)          walllights = scalelight[0];      else if (lightnum >= LIGHTLEVELS)          walllights = scalelight[LIGHTLEVELS-1];      else          walllights = scalelight[lightnum];    }    maskedtexturecol = ds->maskedtexturecol;    mfloorclip = ds->sprbottomclip;    mceilingclip = ds->sprtopclip;    if (curline->linedef->flags & ML_DONTPEGBOTTOM)    {        dc_texturemid = frontsector->floorheight > backsector->floorheight            ? frontsector->floorheight : backsector->floorheight;        dc_texturemid = dc_texturemid + textureheight[texnum] - viewz;    }    else    {        dc_texturemid =frontsector->ceilingheight<backsector->ceilingheight            ? frontsector->ceilingheight : backsector->ceilingheight;        dc_texturemid = dc_texturemid - viewz;    }    dc_texturemid += curline->sidedef->rowoffset;    dc_texheight = textureheight[texnum] >> FRACBITS;    if (fixedcolormap)        dc_colormap = fixedcolormap;    // draw the columns    for (dc_x = x1 ; dc_x <= x2 ; dc_x++)    {        // calculate lighting        if (maskedtexturecol[dc_x] != MAXSHORT)        {          if(dc_numlights)          {            lighttable_t** xwalllights;            sprbotscreen = MAXINT;            sprtopscreen = windowtop = (centeryfrac - FixedMul(dc_texturemid, spryscale));            realbot = windowbottom = FixedMul(textureheight[texnum], spryscale) + sprtopscreen;            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;              if(dc_lightlist[i].flags & FF_FOG || (dc_lightlist[i].extra_colormap && dc_lightlist[i].extra_colormap->fog))                lightnum = (dc_lightlist[i].lightlevel >> LIGHTSEGSHIFT);              else if(colfunc == fuzzcolfunc)                lightnum = LIGHTLEVELS-1;              else                lightnum = (dc_lightlist[i].lightlevel >> LIGHTSEGSHIFT)+extralight;              if((dc_lightlist[i].flags & FF_NOSHADE))                continue;              if (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(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];              else                dc_lightlist[i].rcolormap = fixedcolormap;              dc_lightlist[i].height += dc_lightlist[i].heightstep;              height = dc_lightlist[i].height;              if(height <= windowtop)              {                dc_colormap = dc_lightlist[i].rcolormap;                continue;              }              windowbottom = height;              if(windowbottom >= realbot)              {                windowbottom = realbot;                colfunc_2s (col);                for(i++ ; i < dc_numlights; i++)                  dc_lightlist[i].height += dc_lightlist[i].heightstep;                continue;              }              colfunc_2s (col);              windowtop = windowbottom + 1;              dc_colormap = dc_lightlist[i].rcolormap;            }            windowbottom = realbot;            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 && !fixedcolormap)              dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);            sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale);            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_RenderThickSideRange// Renders all the thick sides in the given range.void R_RenderThickSideRange (drawseg_t* ds,                             int        x1,                             int        x2,                             ffloor_t*  ffloor){    unsigned        index;    column_t*       col;    int             lightnum;    int             texnum;    sector_t        tempsec;    int             templight;    int             i;    fixed_t         bottombounds = viewheight << FRACBITS;    fixed_t         topbounds = (con_clipviewtop - 1) << FRACBITS;    fixed_t         offsetvalue = 0;    void (*colfunc_2s) (column_t*);    // Calculate light table.    // Use different light tables    //   for horizontal / vertical / diagonal. Diagonal?    // OPTIMIZE: get rid of LIGHTSEGSHIFT globally    curline = ds->curline;    backsector = ffloor->target;    frontsector = curline->frontsector == ffloor->target ? curline->backsector : curline->frontsector;    texnum = texturetranslation[sides[ffloor->master->sidenum[0]].midtexture];    colfunc = basecolfunc;    if(ffloor->flags & FF_TRANSLUCENT)    {      dc_transmap = transtables;   // get first transtable 50/50      colfunc = fuzzcolfunc;    }    else if(ffloor->flags & FF_FOG)      colfunc = R_DrawFogColumn_8;    //SoM: Moved these up here so they are available for my lightlist calculations    rw_scalestep = ds->scalestep;    spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep;    dc_numlights = 0;    if(frontsector->numlights && frontsector == curline->backsector)    {      dc_numlights = frontsector->numlights;      if(dc_numlights > dc_maxlights)      {        dc_maxlights = dc_numlights;        dc_lightlist = realloc(dc_lightlist, sizeof(r_lightlist_t) * dc_maxlights);      }      for(i = 0; i < dc_numlights; i++)      {        dc_lightlist[i].heightstep = -FixedMul (rw_scalestep, (frontsector->lightlist[i].height - viewz));        dc_lightlist[i].height = (centeryfrac) - FixedMul((frontsector->lightlist[i].height - viewz), spryscale) - dc_lightlist[i].heightstep;        if(frontsector->lightlist[i].caster)        {          if(frontsector->lightlist[i].caster->flags & FF_CUTLEVEL)          {            dc_lightlist[i].botheightstep = -FixedMul (rw_scalestep, (*frontsector->lightlist[i].caster->bottomheight - viewz));            dc_lightlist[i].botheight = (centeryfrac) - FixedMul((*frontsector->lightlist[i].caster->bottomheight - viewz), spryscale) - dc_lightlist[i].botheightstep;          }          dc_lightlist[i].flags = frontsector->lightlist[i].caster->flags;        }        else          dc_lightlist[i].flags = 0;        dc_lightlist[i].lightlevel = frontsector->lightlist[i].lightlevel;        dc_lightlist[i].extra_colormap = frontsector->lightlist[i].extra_colormap;      }    }    else if(frontsector == curline->frontsector && curline->numlights)    {      dc_numlights = curline->numlights;      if(dc_numlights > dc_maxlights)      {        dc_maxlights = dc_numlights;        dc_lightlist = realloc(dc_lightlist, sizeof(r_lightlist_t) * dc_maxlights);      }      memcpy(dc_lightlist, curline->rlights, sizeof(r_lightlist_t) * dc_numlights);    }    else    {      //SoM: Get correct light level!      if((frontsector->extra_colormap && frontsector->extra_colormap->fog))        lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);      else if(ffloor->flags & FF_FOG)        lightnum = (ffloor->master->frontsector->lightlevel >> LIGHTSEGSHIFT);      else if(colfunc == fuzzcolfunc)        lightnum = LIGHTLEVELS-1;      else        lightnum = (R_FakeFlat(frontsector, &tempsec, &templight, &templight, false)                    ->lightlevel >> LIGHTSEGSHIFT)+extralight;      if (ffloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog));      else if (curline->v1->y == curline->v2->y)          lightnum--;      else if (curline->v1->x == curline->v2->x)          lightnum++;      if (lightnum < 0)          walllights = scalelight[0];      else if (lightnum >= LIGHTLEVELS)          walllights = scalelight[LIGHTLEVELS-1];      else          walllights = scalelight[lightnum];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -