mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-19 07:51:03 +00:00
cleanup code in sw_surf
This commit is contained in:
parent
26e9c6e5c4
commit
316918c29b
2 changed files with 75 additions and 80 deletions
|
@ -330,6 +330,7 @@ R_AliasSetUpTransform(const entity_t *currententity)
|
|||
// TODO: should use a look-up table
|
||||
// TODO: could cache lazily, stored in the entity
|
||||
//
|
||||
// AngleVectors never change angles, we can convert from const
|
||||
AngleVectors((float *)currententity->angles, s_alias_forward, s_alias_right, s_alias_up );
|
||||
|
||||
// TODO: can do this with simple matrix rearrangement
|
||||
|
|
|
@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "header/local.h"
|
||||
|
||||
static int lightleft, blocksize, sourcetstep;
|
||||
static int lightleft, sourcetstep;
|
||||
static int lightright, lightleftstep, lightrightstep, blockdivshift;
|
||||
static void *prowdestbase;
|
||||
static unsigned char *pbasesource;
|
||||
|
@ -31,8 +31,6 @@ static int r_numhblocks, r_numvblocks;
|
|||
static unsigned char *r_source, *r_sourcemax;
|
||||
static unsigned *r_lightptr;
|
||||
|
||||
static void R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes);
|
||||
|
||||
void R_BuildLightMap (drawsurf_t *drawsurf);
|
||||
extern unsigned blocklights[1024]; // allow some very large lightmaps
|
||||
|
||||
|
@ -68,82 +66,6 @@ R_TextureAnimation (const entity_t *currententity, mtexinfo_t *tex)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
R_DrawSurface
|
||||
===============
|
||||
*/
|
||||
static void
|
||||
R_DrawSurface (drawsurf_t *drawsurf)
|
||||
{
|
||||
unsigned char *basetptr;
|
||||
int smax, tmax, twidth;
|
||||
int u;
|
||||
int soffset, basetoffset, texwidth;
|
||||
unsigned char *pcolumndest;
|
||||
image_t *mt;
|
||||
|
||||
mt = drawsurf->image;
|
||||
|
||||
r_source = mt->pixels[drawsurf->surfmip];
|
||||
|
||||
// the fractional light values should range from 0 to (VID_GRADES - 1) << 16
|
||||
// from a source range of 0 - 255
|
||||
|
||||
texwidth = mt->width >> drawsurf->surfmip;
|
||||
|
||||
blocksize = 16 >> drawsurf->surfmip;
|
||||
blockdivshift = NUM_MIPS - drawsurf->surfmip;
|
||||
|
||||
r_lightwidth = (drawsurf->surf->extents[0]>>4)+1;
|
||||
|
||||
r_numhblocks = drawsurf->surfwidth >> blockdivshift;
|
||||
r_numvblocks = drawsurf->surfheight >> blockdivshift;
|
||||
|
||||
//==============================
|
||||
|
||||
// TODO: only needs to be set when there is a display settings change
|
||||
// blocksize = blocksize;
|
||||
|
||||
smax = mt->width >> drawsurf->surfmip;
|
||||
twidth = texwidth;
|
||||
tmax = mt->height >> drawsurf->surfmip;
|
||||
sourcetstep = texwidth;
|
||||
r_stepback = tmax * twidth;
|
||||
|
||||
r_sourcemax = r_source + (tmax * smax);
|
||||
|
||||
soffset = drawsurf->surf->texturemins[0];
|
||||
basetoffset = drawsurf->surf->texturemins[1];
|
||||
|
||||
// << 16 components are to guarantee positive values for %
|
||||
soffset = ((soffset >> drawsurf->surfmip) + (smax << SHIFT16XYZ)) % smax;
|
||||
basetptr = &r_source[((((basetoffset >> drawsurf->surfmip)
|
||||
+ (tmax << SHIFT16XYZ)) % tmax) * twidth)];
|
||||
|
||||
pcolumndest = drawsurf->surfdat;
|
||||
|
||||
for (u=0 ; u<r_numhblocks; u++)
|
||||
{
|
||||
r_lightptr = blocklights + u;
|
||||
|
||||
prowdestbase = pcolumndest;
|
||||
|
||||
pbasesource = basetptr + soffset;
|
||||
|
||||
R_DrawSurfaceBlock8_anymip(NUM_MIPS - drawsurf->surfmip, drawsurf->rowbytes);
|
||||
|
||||
soffset = soffset + blocksize;
|
||||
if (soffset >= smax)
|
||||
soffset = 0;
|
||||
|
||||
pcolumndest += blocksize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
================
|
||||
R_DrawSurfaceBlock8_anymip
|
||||
|
@ -195,8 +117,80 @@ R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes)
|
|||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
/*
|
||||
===============
|
||||
R_DrawSurface
|
||||
===============
|
||||
*/
|
||||
static void
|
||||
R_DrawSurface (drawsurf_t *drawsurf)
|
||||
{
|
||||
unsigned char *basetptr;
|
||||
int smax, tmax, twidth;
|
||||
int u;
|
||||
int soffset, basetoffset, texwidth;
|
||||
int blocksize;
|
||||
unsigned char *pcolumndest;
|
||||
image_t *mt;
|
||||
|
||||
mt = drawsurf->image;
|
||||
|
||||
r_source = mt->pixels[drawsurf->surfmip];
|
||||
|
||||
// the fractional light values should range from 0 to (VID_GRADES - 1) << 16
|
||||
// from a source range of 0 - 255
|
||||
|
||||
texwidth = mt->width >> drawsurf->surfmip;
|
||||
|
||||
blocksize = 16 >> drawsurf->surfmip;
|
||||
blockdivshift = NUM_MIPS - drawsurf->surfmip;
|
||||
|
||||
r_lightwidth = (drawsurf->surf->extents[0]>>4)+1;
|
||||
|
||||
r_numhblocks = drawsurf->surfwidth >> blockdivshift;
|
||||
r_numvblocks = drawsurf->surfheight >> blockdivshift;
|
||||
|
||||
//==============================
|
||||
|
||||
smax = mt->width >> drawsurf->surfmip;
|
||||
twidth = texwidth;
|
||||
tmax = mt->height >> drawsurf->surfmip;
|
||||
sourcetstep = texwidth;
|
||||
r_stepback = tmax * twidth;
|
||||
|
||||
r_sourcemax = r_source + (tmax * smax);
|
||||
|
||||
soffset = drawsurf->surf->texturemins[0];
|
||||
basetoffset = drawsurf->surf->texturemins[1];
|
||||
|
||||
// << 16 components are to guarantee positive values for %
|
||||
soffset = ((soffset >> drawsurf->surfmip) + (smax << SHIFT16XYZ)) % smax;
|
||||
basetptr = &r_source[((((basetoffset >> drawsurf->surfmip)
|
||||
+ (tmax << SHIFT16XYZ)) % tmax) * twidth)];
|
||||
|
||||
pcolumndest = drawsurf->surfdat;
|
||||
|
||||
for (u=0 ; u<r_numhblocks; u++)
|
||||
{
|
||||
r_lightptr = blocklights + u;
|
||||
|
||||
prowdestbase = pcolumndest;
|
||||
|
||||
pbasesource = basetptr + soffset;
|
||||
|
||||
R_DrawSurfaceBlock8_anymip(NUM_MIPS - drawsurf->surfmip, drawsurf->rowbytes);
|
||||
|
||||
soffset = soffset + blocksize;
|
||||
if (soffset >= smax)
|
||||
soffset = 0;
|
||||
|
||||
pcolumndest += blocksize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
================
|
||||
|
|
Loading…
Reference in a new issue