コード例 #1
0
ファイル: r_plane.c プロジェクト: Nekrofage/DoomRPi
//
// R_MapPlane
//
// Uses global vars:
//  planeheight
//  ds_source
//  basexscale
//  baseyscale
//  viewx
//  viewy
//
// BASIC PRIMITIVE
//
void
R_MapPlane
( int		y,
  int		x1,
  int		x2 )
{
    angle_t	angle;
    fixed_t	distance;
    fixed_t	length;
    unsigned	index;
	
#ifdef RANGECHECK
    if (x2 < x1
     || x1 < 0
     || x2 >= viewwidth
     || y > viewheight)
    {
	I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y);
    }
#endif

    if (planeheight != cachedheight[y])
    {
	cachedheight[y] = planeheight;
	distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]);
	ds_xstep = cachedxstep[y] = FixedMul (distance,basexscale);
	ds_ystep = cachedystep[y] = FixedMul (distance,baseyscale);
    }
    else
    {
	distance = cacheddistance[y];
	ds_xstep = cachedxstep[y];
	ds_ystep = cachedystep[y];
    }
	
    length = FixedMul (distance,distscale[x1]);
    angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
    ds_xfrac = viewx + FixedMul(finecosine[angle], length);
    ds_yfrac = -viewy - FixedMul(finesine[angle], length);

    if (fixedcolormap)
	ds_colormap = fixedcolormap;
    else
    {
	index = distance >> LIGHTZSHIFT;
	
	if (index >= MAXLIGHTZ )
	    index = MAXLIGHTZ-1;

	ds_colormap = planezlight[index];
    }
	
    ds_y = y;
    ds_x1 = x1;
    ds_x2 = x2;

    // high or low detail
    spanfunc ();	
}
コード例 #2
0
ファイル: r_plane.cpp プロジェクト: dwing4g/gzdoom
void R_MapPlane (int y, int x1)
{
	int x2 = spanend[y];
	double 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 = planeheight * yslope[y];

	if (ds_xbits != 0)
	{
		ds_xstep = xs_ToFixed(32 - ds_xbits, distance * xstepscale);
		ds_xfrac = xs_ToFixed(32 - ds_xbits, distance * basexfrac) + pviewx;
	}
	else
	{
		ds_xstep = 0;
		ds_xfrac = 0;
	}
	if (ds_ybits != 0)
	{
		ds_ystep = xs_ToFixed(32 - ds_ybits, distance * ystepscale);
		ds_yfrac = xs_ToFixed(32 - ds_ybits, distance * baseyfrac) + pviewy;
	}
	else
	{
		ds_ystep = 0;
		ds_yfrac = 0;
	}

	if (plane_shade)
	{
		// Determine lighting based on the span's distance from the viewer.
		R_SetDSColorMapLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade);
	}

	ds_y = y;
	ds_x1 = x1;
	ds_x2 = x2;

	spanfunc ();
}
コード例 #3
0
ファイル: r_plane.c プロジェクト: jeffdoggett/Doom
//-----------------------------------------------------------------------------
//
// R_MapPlane
//
// Uses global vars:
//  planeheight
//  ds_source
//  basexscale
//  baseyscale
//  viewx
//  viewy
//
// BASIC PRIMITIVE
//
static void R_MapPlane (int y, int x1, int x2)
{
    fixed_t     distance;
    int         dx, dy;
    unsigned	index;

    if (y == centery)
        return;

#ifdef RANGECHECK
    if (x2 < x1
            || x1<0
            || x2>=viewwidth
            || (unsigned)y>viewheight)
    {
        //I_Error ("R_MapPlane: %i, %i at %i\n",x1,x2,y);
        printf ("R_MapPlane: %i, %i at %i\n",x1,x2,y);
        return;
    }
#endif

    distance = FixedMul(planeheight, yslope[y]);

    dx = x1 - centerx;
    dy = ABS(centery - y);
    ds_xstep = FixedMul(viewsin, planeheight) / dy;
    ds_ystep = FixedMul(viewcos, planeheight) / dy;

    ds_xfrac = viewx + xoffs + FixedMul(viewcos, distance) + dx * ds_xstep;
    ds_yfrac = -viewy + yoffs - FixedMul(viewsin, distance) + dx * ds_ystep;

    if (fixedcolormap)
        ds_colormap = fixedcolormap;
    else
    {
        index = distance >> LIGHTZSHIFT;

        if (index >= MAXLIGHTZ )
            index = MAXLIGHTZ-1;

        ds_colormap = planezlight[index];
    }

    ds_y = y;
    ds_x1 = x1;
    ds_x2 = x2;

    spanfunc();
}
コード例 #4
0
ファイル: r_plane.cpp プロジェクト: JohnnyonFlame/odamex
//
// R_MapLevelPlane
//
// [SL] 2012-11-09 - Based loosely on R_MapPlane() from PrBoom+ to increase
// the accuracy of texture-mapping visplanes with the same textures.
//
// e6y
//
// [RH]Instead of using the xtoviewangle array, I calculated the fractional values
// at the middle of the screen, then used the calculated ds_xstep and ds_ystep
// to step from those to the proper texture coordinate to start drawing at.
// That way, the texture coordinate is always calculated by its position
// on the screen and not by its position relative to the edge of the visplane.
//
// Visplanes with the same texture now match up far better than before.
//
void R_MapLevelPlane(int y, int x1, int x2)
{
	double fdistance = fplaneheight * yslope[y] / 65536.0;
	double slope = fplaneheight / abs(centery - y);

	ds_xstep = (fixed_t)(pl_xstepscale * slope * focratio);
	ds_ystep = (fixed_t)(pl_ystepscale * slope * focratio);

	ds_xfrac = pl_viewxtrans +
				FixedMul((int)(pl_viewcos * fdistance), pl_xscale) + 
				(x1 - centerx) * ds_xstep;
	ds_yfrac = pl_viewytrans -
				FixedMul((int)(pl_viewsin * fdistance), pl_yscale) +
				(x1 - centerx) * ds_ystep;

	ds_xstep <<= 10;	
	ds_ystep <<= 10;	
	ds_xfrac <<= 10;
	ds_yfrac <<= 10;

	if (fixedlightlev)
		ds_colormap = basecolormap + fixedlightlev;
	else if (fixedcolormap)
		ds_colormap = fixedcolormap;
	else
	{
		// Determine lighting based on the span's distance from the viewer.
		unsigned int index = (int)fdistance >> (LIGHTZSHIFT - FRACBITS);

		if (index >= MAXLIGHTZ)
			index = MAXLIGHTZ-1;

		ds_colormap = planezlight[index] + basecolormap;
	}

	ds_y = y;
	ds_x1 = x1;
	ds_x2 = x2;

	spanfunc ();
}
コード例 #5
0
ファイル: r_plane.cpp プロジェクト: JohnnyonFlame/odamex
//
// R_MapLevelPlane
//
// [SL] 2012-11-09 - Based loosely on R_MapPlane() from PrBoom+ to increase
// the accuracy of texture-mapping visplanes with the same textures.
//
// e6y
//
// [RH]Instead of using the xtoviewangle array, I calculated the fractional values
// at the middle of the screen, then used the calculated ds_xstep and ds_ystep
// to step from those to the proper texture coordinate to start drawing at.
// That way, the texture coordinate is always calculated by its position
// on the screen and not by its position relative to the edge of the visplane.
//
// Visplanes with the same texture now match up far better than before.
//
void R_MapLevelPlane(int y, int x1, int x2)
{
	fixed_t distance = FixedMul(planeheight, yslope[y]);
	fixed_t slope = (fixed_t)(focratio * FixedDiv(planeheight, abs(centery - y) << FRACBITS));

	ds_xstep = FixedMul(pl_xstepscale, slope);
	ds_ystep = FixedMul(pl_ystepscale, slope);

	ds_xfrac = pl_viewxtrans +
				FixedMul(FixedMul(pl_viewcos, distance), pl_xscale) + 
				(x1 - centerx) * ds_xstep;
	ds_yfrac = pl_viewytrans -
				FixedMul(FixedMul(pl_viewsin, distance), pl_yscale) +
				(x1 - centerx) * ds_ystep;

	if (fixedlightlev)
		ds_colormap = basecolormap + fixedlightlev;
	else if (fixedcolormap)
		ds_colormap = fixedcolormap;
	else
	{
		// Determine lighting based on the span's distance from the viewer.
		unsigned int index = distance >> LIGHTZSHIFT;

		if (index >= MAXLIGHTZ)
			index = MAXLIGHTZ-1;

		ds_colormap = planezlight[index] + basecolormap;
	}

	ds_y = y;
	ds_x1 = x1;
	ds_x2 = x2;

	spanfunc ();
}