Merge pull request #293 from 0lvin/warp_review

#292 Warp fixes
This commit is contained in:
Yamagi 2018-06-01 09:43:07 +02:00 committed by GitHub
commit c8fefdc18c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1400 additions and 775 deletions

File diff suppressed because it is too large Load diff

View file

@ -56,6 +56,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#define NUM_MIPS 4
typedef struct image_s
{
char name[MAX_QPATH]; // game path, including extension
@ -63,7 +65,7 @@ typedef struct image_s
int width, height;
qboolean transparent; // true if any 255 pixels in image
int registration_sequence; // 0 = free
byte *pixels[4]; // mip levels
byte *pixels[NUM_MIPS]; // mip levels
} image_t;
@ -73,6 +75,10 @@ typedef unsigned char pixel_t;
typedef int shift20_t;
typedef int zvalue_t;
// xyz-prescale to 16.16 fixed-point
#define SHIFT16XYZ 16
#define SHIFT16XYZ_MULT (1 << SHIFT16XYZ)
typedef enum
{
rserr_ok,
@ -140,9 +146,6 @@ extern oldrefdef_t r_refdef;
#define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
// polygon (while processing)
#define WARP_WIDTH 320
#define WARP_HEIGHT 240
#define PARTICLE_Z_CLIP 8.0
#define TRANSPARENT_COLOR 0xFF
@ -220,17 +223,6 @@ typedef struct finalvert_s {
float xyz[3]; // eye space
} finalvert_t;
#define FINALVERT_V0 0
#define FINALVERT_V1 4
#define FINALVERT_V2 8
#define FINALVERT_V3 12
#define FINALVERT_V4 16
#define FINALVERT_V5 20
#define FINALVERT_FLAGS 24
#define FINALVERT_X 28
#define FINALVERT_Y 32
#define FINALVERT_Z 36
#define FINALVERT_SIZE 40
typedef struct
{
@ -396,7 +388,7 @@ extern zvalue_t *d_pzbuffer;
extern unsigned int d_zwidth;
extern int d_minmip;
extern float d_scalemip[3];
extern float d_scalemip[NUM_MIPS-1];
//===================================================================

View file

@ -271,14 +271,14 @@ R_AliasPreparePoints (void)
continue; // completely clipped
// insert s/t coordinates
pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;
pfv[0]->s = pstverts[ptri->index_st[0]].s << SHIFT16XYZ;
pfv[0]->t = pstverts[ptri->index_st[0]].t << SHIFT16XYZ;
pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;
pfv[1]->s = pstverts[ptri->index_st[1]].s << SHIFT16XYZ;
pfv[1]->t = pstverts[ptri->index_st[1]].t << SHIFT16XYZ;
pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;
pfv[2]->s = pstverts[ptri->index_st[2]].s << SHIFT16XYZ;
pfv[2]->t = pstverts[ptri->index_st[2]].t << SHIFT16XYZ;
if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
{ // totally unclipped
@ -306,14 +306,14 @@ R_AliasPreparePoints (void)
continue; // completely clipped
// insert s/t coordinates
pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;
pfv[0]->s = pstverts[ptri->index_st[0]].s << SHIFT16XYZ;
pfv[0]->t = pstverts[ptri->index_st[0]].t << SHIFT16XYZ;
pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;
pfv[1]->s = pstverts[ptri->index_st[1]].s << SHIFT16XYZ;
pfv[1]->t = pstverts[ptri->index_st[1]].t << SHIFT16XYZ;
pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;
pfv[2]->s = pstverts[ptri->index_st[2]].s << SHIFT16XYZ;
pfv[2]->t = pstverts[ptri->index_st[2]].t << SHIFT16XYZ;
if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
{ // totally unclipped
@ -858,9 +858,9 @@ void R_AliasDrawModel (void)
R_AliasSetUpLerpData( s_pmdl, currententity->backlerp );
if (currententity->flags & RF_DEPTHHACK)
s_ziscale = (float)0x8000 * (float)0x10000 * 3.0;
s_ziscale = (float)0x8000 * (float)SHIFT16XYZ_MULT * 3.0;
else
s_ziscale = (float)0x8000 * (float)0x10000;
s_ziscale = (float)0x8000 * (float)SHIFT16XYZ_MULT;
R_AliasPreparePoints ();

View file

@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// current entity info
//
qboolean insubmodel;
entity_t *currententity;
vec3_t modelorg; // modelorg is the viewpoint reletive to
// the currently rendering entity
@ -643,5 +642,5 @@ void R_RenderWorld (void)
currentmodel = r_worldmodel;
r_pcurrentvertbase = currentmodel->vertexes;
R_RecursiveWorldNode (currentmodel->nodes, 15);
R_RecursiveWorldNode (currentmodel->nodes, ALIAS_XY_CLIP_MASK);
}

View file

@ -93,7 +93,6 @@ void RE_Draw_CharScaled(int x, int y, int num, float scale)
if (y <= -8)
return; // totally off screen
// if ( ( y + 8 ) >= vid.height )
if ( ( y + 8 ) > vid.height ) // PGM - status text was missing in sw...
return;
@ -191,7 +190,7 @@ void RE_Draw_StretchPicImplementation (int x, int y, int w, int h, image_t *pic)
else
{
f = 0;
fstep = pic->width*0x10000/w;
fstep = (pic->width * SHIFT16XYZ_MULT) / w;
for (u=0 ; u<w ; u++)
{
dest[u] = source[f>>16];

View file

@ -136,23 +136,13 @@ R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist)
do
{
next_edge = edgestoadd->next;
edgesearch:
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
goto edgesearch;
while (edgelist->u < edgestoadd->u)
{
edgelist = edgelist->next;
}
// insert edgestoadd before edgelist
addedge:
edgestoadd->next = edgelist;
edgestoadd->prev = edgelist->prev;
edgelist->prev->next = edgestoadd;
@ -265,6 +255,31 @@ R_CleanupSpan (void)
}
/*
==============
D_SurfSearchBackwards
==============
*/
static surf_t*
D_SurfSearchBackwards(surf_t *surf, surf_t *surf2)
{
do
{
do
{
surf2 = surf2->next;
} while (surf->key < surf2->key);
// if it's two surfaces on the same plane, the one that's already
// active is in front, so keep going unless it's a bmodel
// must be two bmodels in the same leaf; don't care which is really
// in front, because they'll never be farthest anyway
} while (surf->key == surf2->key && !surf->insubmodel);
return surf2;
}
/*
==============
R_LeadingEdgeBackwards
@ -273,9 +288,7 @@ R_LeadingEdgeBackwards
static void
R_LeadingEdgeBackwards (edge_t *edge)
{
espan_t *span;
surf_t *surf, *surf2;
shift20_t iu;
// it's adding a new surface in, so find the correct place
surf = &surfaces[edge->surfs[1]];
@ -285,57 +298,38 @@ R_LeadingEdgeBackwards (edge_t *edge)
// end edge)
if (++surf->spanstate == 1)
{
shift20_t iu;
surf2 = surfaces[1].next;
if (surf->key > surf2->key)
goto newtop;
// if it's two surfaces on the same plane, the one that's already
// active is in front, so keep going unless it's a bmodel
if (surf->insubmodel && (surf->key == surf2->key))
{
// must be two bmodels in the same leaf; don't care, because they'll
// never be farthest anyway
goto newtop;
if (surf->key > surf2->key || (surf->insubmodel && (surf->key == surf2->key))) {
// emit a span (obscures current top)
iu = edge->u >> shift_size;
if (iu > surf2->last_u)
{
espan_t *span;
span = span_p++;
span->u = surf2->last_u;
span->count = iu - span->u;
span->v = current_iv;
span->pnext = surf2->spans;
surf2->spans = span;
}
// set last_u on the new span
surf->last_u = iu;
}
else
{
surf2 = D_SurfSearchBackwards(surf, surf2);
}
continue_search:
do
{
surf2 = surf2->next;
} while (surf->key < surf2->key);
if (surf->key == surf2->key)
{
// if it's two surfaces on the same plane, the one that's already
// active is in front, so keep going unless it's a bmodel
if (!surf->insubmodel)
goto continue_search;
// must be two bmodels in the same leaf; don't care which is really
// in front, because they'll never be farthest anyway
}
goto gotposition;
newtop:
// emit a span (obscures current top)
iu = edge->u >> shift_size;
if (iu > surf2->last_u)
{
span = span_p++;
span->u = surf2->last_u;
span->count = iu - span->u;
span->v = current_iv;
span->pnext = surf2->spans;
surf2->spans = span;
}
// set last_u on the new span
surf->last_u = iu;
gotposition:
// insert before surf2
surf->next = surf2;
surf->prev = surf2->prev;
@ -385,6 +379,63 @@ R_TrailingEdge (surf_t *surf, edge_t *edge)
}
}
/*
==============
D_SurfSearchForward
==============
*/
static surf_t*
D_SurfSearchForward(surf_t *surf, surf_t *surf2)
{
do
{
do
{
surf2 = surf2->next;
} while (surf->key > surf2->key);
// if it's two surfaces on the same plane, the one that's already
// active is in front, so keep going unless it's a bmodel
} while (surf->key == surf2->key && !surf->insubmodel);
return surf2;
}
/*
==============
R_LeadingEdgeSearch
==============
*/
static surf_t*
R_LeadingEdgeSearch (edge_t *edge, surf_t *surf, surf_t *surf2)
{
float fu, newzi, testzi, newzitop, newzibottom;
do
{
surf2 = D_SurfSearchForward(surf, surf2);
if (surf->key != surf2->key)
return surf2;
// must be two bmodels in the same leaf; sort on 1/z
fu = (float)(edge->u - (1<<shift_size) + 1) * (1.0 / (1<<shift_size));
newzi = surf->d_ziorigin + fv*surf->d_zistepv +
fu*surf->d_zistepu;
newzibottom = newzi * 0.99;
testzi = surf2->d_ziorigin + fv*surf2->d_zistepv +
fu*surf2->d_zistepu;
if (newzibottom < testzi)
return surf2;
newzitop = newzi * 1.01;
}
while(newzitop < testzi || surf->d_zistepu < surf2->d_zistepu);
return surf2;
}
/*
==============
R_LeadingEdge
@ -395,10 +446,8 @@ R_LeadingEdge (edge_t *edge)
{
if (edge->surfs[1])
{
espan_t *span;
surf_t *surf, *surf2;
shift20_t iu;
float fu, newzi, testzi, newzitop, newzibottom;
// it's adding a new surface in, so find the correct place
surf = &surfaces[edge->surfs[1]];
@ -417,6 +466,8 @@ R_LeadingEdge (edge_t *edge)
// active is in front, so keep going unless it's a bmodel
if (surf->insubmodel && (surf->key == surf2->key))
{
float fu, newzi, testzi, newzitop, newzibottom;
// must be two bmodels in the same leaf; sort on 1/z
fu = (float)(edge->u - (1<<shift_size) + 1) * (1.0 / (1<<shift_size));
newzi = surf->d_ziorigin + fv*surf->d_zistepv +
@ -441,54 +492,16 @@ R_LeadingEdge (edge_t *edge)
}
}
continue_search:
do
{
surf2 = surf2->next;
} while (surf->key > surf2->key);
if (surf->key == surf2->key)
{
// if it's two surfaces on the same plane, the one that's already
// active is in front, so keep going unless it's a bmodel
if (!surf->insubmodel)
goto continue_search;
// must be two bmodels in the same leaf; sort on 1/z
fu = (float)(edge->u - (1<<shift_size) + 1) * (1.0 / (1<<shift_size));
newzi = surf->d_ziorigin + fv*surf->d_zistepv +
fu*surf->d_zistepu;
newzibottom = newzi * 0.99;
testzi = surf2->d_ziorigin + fv*surf2->d_zistepv +
fu*surf2->d_zistepu;
if (newzibottom >= testzi)
{
goto gotposition;
}
newzitop = newzi * 1.01;
if (newzitop >= testzi)
{
if (surf->d_zistepu >= surf2->d_zistepu)
{
goto gotposition;
}
}
goto continue_search;
}
surf2 = R_LeadingEdgeSearch (edge, surf, surf2);
goto gotposition;
newtop:
// emit a span (obscures current top)
iu = edge->u >> shift_size;
if (iu > surf2->last_u)
{
espan_t *span;
span = span_p++;
span->u = surf2->last_u;
span->count = iu - span->u;
@ -645,15 +658,18 @@ void R_ScanEdges (void)
if (newedges[iv])
{
// Update AET with GET event
R_InsertNewEdges (newedges[iv], edge_head.next);
}
// Generate spans
(*pdrawfunc) ();
// flush the span list if we can't be sure we have enough spans left for
// the next scan
if (span_p > max_span_p)
{
// Draw stuff on screen
D_DrawSurfaces ();
// clear the surface span pointers
@ -677,9 +693,12 @@ void R_ScanEdges (void)
// mark that the head (background start) span is pre-included
surfaces[1].spanstate = 1;
// Flush span buffer
if (newedges[iv])
// Update AET with GET event
R_InsertNewEdges (newedges[iv], edge_head.next);
// Update AET with GET event
(*pdrawfunc) ();
// draw whatever's left in the span list
@ -709,16 +728,16 @@ D_MipLevelForScale
static int
D_MipLevelForScale (float scale)
{
int lmiplevel;
int lmiplevel = NUM_MIPS-1, i;
if (scale >= d_scalemip[0] )
lmiplevel = 0;
else if (scale >= d_scalemip[1] )
lmiplevel = 1;
else if (scale >= d_scalemip[2] )
lmiplevel = 2;
else
lmiplevel = 3;
for (i=0; i < NUM_MIPS-1; i ++)
{
if (scale >= d_scalemip[i])
{
lmiplevel = i;
break;
}
}
if (lmiplevel < d_minmip)
lmiplevel = d_minmip;
@ -786,29 +805,29 @@ D_CalcGradients (msurface_t *pface)
VectorScale (transformed_modelorg, mipscale, p_temp1);
t = 0x10000*mipscale;
sadjust = ((int)(DotProduct (p_temp1, p_saxis) * 0x10000 + 0.5)) -
((pface->texturemins[0] << 16) >> miplevel)
t = SHIFT16XYZ_MULT * mipscale;
sadjust = ((int)(DotProduct (p_temp1, p_saxis) * SHIFT16XYZ_MULT + 0.5)) -
((pface->texturemins[0] << SHIFT16XYZ) >> miplevel)
+ pface->texinfo->vecs[0][3]*t;
tadjust = ((int)(DotProduct (p_temp1, p_taxis) * 0x10000 + 0.5)) -
((pface->texturemins[1] << 16) >> miplevel)
tadjust = ((int)(DotProduct (p_temp1, p_taxis) * SHIFT16XYZ_MULT + 0.5)) -
((pface->texturemins[1] << SHIFT16XYZ) >> miplevel)
+ pface->texinfo->vecs[1][3]*t;
// PGM - changing flow speed for non-warping textures.
if (pface->texinfo->flags & SURF_FLOWING)
{
if(pface->texinfo->flags & SURF_WARP)
sadjust += 0x10000 * (-128 * ( (r_newrefdef.time * 0.25) - (int)(r_newrefdef.time * 0.25) ));
sadjust += SHIFT16XYZ_MULT * (-128 * ( (r_newrefdef.time * 0.25) - (int)(r_newrefdef.time * 0.25) ));
else
sadjust += 0x10000 * (-128 * ( (r_newrefdef.time * 0.77) - (int)(r_newrefdef.time * 0.77) ));
sadjust += SHIFT16XYZ_MULT * (-128 * ( (r_newrefdef.time * 0.77) - (int)(r_newrefdef.time * 0.77) ));
}
// PGM
//
// -1 (-epsilon) so we never wander off the edge of the texture
//
bbextents = ((pface->extents[0] << 16) >> miplevel) - 1;
bbextentt = ((pface->extents[1] << 16) >> miplevel) - 1;
bbextents = ((pface->extents[0] << SHIFT16XYZ) >> miplevel) - 1;
bbextentt = ((pface->extents[1] << SHIFT16XYZ) >> miplevel) - 1;
}

View file

@ -104,8 +104,8 @@ R_LoadPic
static image_t*
R_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type)
{
image_t *image;
int i, c;
image_t *image;
size_t i, size;
image = R_FindFreeImage ();
if (strlen(name) >= sizeof(image->name))
@ -117,19 +117,19 @@ R_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type)
image->height = height;
image->type = type;
c = width*height;
image->pixels[0] = malloc (c);
size = width*height;
image->pixels[0] = malloc (size);
image->transparent = false;
for (i=0 ; i<c ; i++)
for (i=0 ; i<size ; i++)
{
int b;
b = pic[i];
if (b == 255)
if (pic[i] == 255)
{
image->transparent = true;
image->pixels[0][i] = b;
break;
}
}
memcpy(image->pixels[0], pic, size);
return image;
}
@ -239,7 +239,7 @@ image_t *R_FindImage (char *name, imagetype_t type)
// fix backslashes
while ((ptr=strchr(name,'\\'))) {
*ptr = '/';
*ptr = '/';
}
#endif
@ -299,7 +299,6 @@ void R_FreeUnusedImages (void)
{
if (image->registration_sequence == registration_sequence)
{
Com_PageInMemory ((byte *)image->pixels[0], image->width*image->height);
continue; // used this sequence
}
if (!image->registration_sequence)

View file

@ -124,6 +124,7 @@ cvar_t *sw_surfcacheoverride;
cvar_t *sw_waterwarp;
static cvar_t *sw_overbrightbits;
cvar_t *sw_custom_particles;
cvar_t *sw_texture_filtering;
cvar_t *r_drawworld;
static cvar_t *r_drawentities;
@ -185,6 +186,8 @@ pixel_t *d_viewbuffer;
zvalue_t *d_pzbuffer;
unsigned int d_zwidth;
qboolean insubmodel;
static struct texture_buffer {
image_t image;
byte buffer[1024];
@ -272,6 +275,7 @@ R_Register (void)
sw_waterwarp = ri.Cvar_Get ("sw_waterwarp", "1", 0);
sw_overbrightbits = ri.Cvar_Get("sw_overbrightbits", "1.0", CVAR_ARCHIVE);
sw_custom_particles = ri.Cvar_Get("sw_custom_particles", "0", CVAR_ARCHIVE);
sw_texture_filtering = ri.Cvar_Get("sw_texture_filtering", "0", CVAR_ARCHIVE);
r_mode = ri.Cvar_Get( "r_mode", "0", CVAR_ARCHIVE );
r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
@ -309,7 +313,7 @@ static void
R_UnRegister (void)
{
ri.Cmd_RemoveCommand( "screenshot" );
ri.Cmd_RemoveCommand ("modellist");
ri.Cmd_RemoveCommand( "modellist" );
ri.Cmd_RemoveCommand( "imagelist" );
}
@ -781,7 +785,7 @@ R_DrawBEntitiesOnList
static void
R_DrawBEntitiesOnList (void)
{
int i, clipflags;
int i, clipflags;
vec3_t oldorigin;
vec3_t mins, maxs;
float minmaxs[6];
@ -864,6 +868,8 @@ static surf_t *lsurfs;
/*
================
R_EdgeDrawing
Render the map
================
*/
static void
@ -890,6 +896,7 @@ R_EdgeDrawing (void)
surfaces--;
}
// Set function pointer pdrawfunc used later in this function
R_BeginEdgeFrame ();
if (r_dspeeds->value)
@ -897,6 +904,8 @@ R_EdgeDrawing (void)
rw_time1 = SDL_GetTicks();
}
// Build the Global Edget Table
// Also populate the surface stack and count # surfaces to render (surf_max is the max)
R_RenderWorld ();
if (r_dspeeds->value)
@ -913,6 +922,8 @@ R_EdgeDrawing (void)
se_time1 = db_time2;
}
// Use the Global Edge Table to maintin the Active Edge Table: Draw the world as scanlines
// Write the Z-Buffer (but no read)
R_ScanEdges ();
}
@ -1016,10 +1027,15 @@ RE_RenderFrame (refdef_t *fd)
R_SetupFrame ();
// Using the current view cluster (r_viewcluster), retrieve and decompress
// the PVS (Potentially Visible Set)
R_MarkLeaves (); // done here so we know if we're in water
// For each dlight_t* passed via r_newrefdef.dlights, mark polygons affected by a light.
R_PushDlights (r_worldmodel);
// Build the Global Edge Table and render it via the Active Edge Table
// Render the map
R_EdgeDrawing ();
if (r_dspeeds->value)
@ -1028,6 +1044,8 @@ RE_RenderFrame (refdef_t *fd)
de_time1 = se_time2;
}
// Draw enemies, barrel etc...
// Use Z-Buffer in read mode only.
R_DrawEntitiesOnList ();
if (r_dspeeds->value)
@ -1036,13 +1054,16 @@ RE_RenderFrame (refdef_t *fd)
dp_time1 = SDL_GetTicks();
}
// Duh !
R_DrawParticles ();
if (r_dspeeds->value)
dp_time2 = SDL_GetTicks();
// Perform pixel palette blending ia the pics/colormap.pcx lower part lookup table.
R_DrawAlphaSurfaces();
// Save off light value for server to look at (BIG HACK!)
R_SetLightLevel ();
if (r_dowarp)
@ -1054,6 +1075,7 @@ RE_RenderFrame (refdef_t *fd)
if (r_dspeeds->value)
da_time2 = SDL_GetTicks();
// Modify the palette (when taking hit or pickup item) so all colors are modified
R_CalcPalette ();
if (sw_aliasstats->value)
@ -1312,11 +1334,11 @@ R_DrawBeam( entity_t *e )
for ( i = 0; i < NUM_BEAM_SEGS; i++ )
{
R_IMFlatShadedQuad( start_points[i],
end_points[i],
end_points[(i+1)%NUM_BEAM_SEGS],
start_points[(i+1)%NUM_BEAM_SEGS],
e->skinnum & 0xFF,
e->alpha );
end_points[i],
end_points[(i+1)%NUM_BEAM_SEGS],
start_points[(i+1)%NUM_BEAM_SEGS],
e->skinnum & 0xFF,
e->alpha );
}
}
@ -1907,7 +1929,7 @@ SWimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
finalverts = malloc((MAXALIASVERTS + 3) * sizeof(finalvert_t));
ledges = malloc((NUMSTACKEDGES + 1) * sizeof(edge_t));
lsurfs = malloc((NUMSTACKSURFACES + 1) * sizeof(surf_t));
r_warpbuffer = malloc(WARP_WIDTH * WARP_HEIGHT * sizeof(pixel_t));
r_warpbuffer = malloc(vid.height * vid.width * sizeof(pixel_t));
if ((vid.width >= 2048) && (sizeof(shift20_t) == 4)) // 2k+ resolution and 32 == shift20_t
{

View file

@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "header/local.h"
#define NUM_MIPS 4
cvar_t *sw_mipcap;
cvar_t *sw_mipscale;
@ -341,6 +339,8 @@ void R_SetupFrame (void)
// current viewleaf
if ( !( r_newrefdef.rdflags & RDF_NOWORLDMODEL ) )
{
// Determine what is the current view cluster (walking the BSP tree)
// and store it in r_viewcluster
r_viewleaf = Mod_PointInLeaf (r_origin, r_worldmodel);
r_viewcluster = r_viewleaf->cluster;
}
@ -355,11 +355,11 @@ void R_SetupFrame (void)
// warp into off screen buffer
vrect.x = 0;
vrect.y = 0;
vrect.width = r_newrefdef.width < WARP_WIDTH ? r_newrefdef.width : WARP_WIDTH;
vrect.height = r_newrefdef.height < WARP_HEIGHT ? r_newrefdef.height : WARP_HEIGHT;
vrect.width = r_newrefdef.width;
vrect.height = r_newrefdef.height;
d_viewbuffer = r_warpbuffer;
r_screenwidth = WARP_WIDTH;
r_screenwidth = vid.width;
}
else
{

View file

@ -192,13 +192,11 @@ mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
ri.Sys_Error (ERR_DROP, "Mod_PointInLeaf: bad model");
node = model->nodes;
while (1)
while (node->contents == -1)
{
float d;
mplane_t *plane;
if (node->contents != -1)
return (mleaf_t *)node;
plane = node->plane;
d = DotProduct (p,plane->normal) - plane->dist;
if (d > 0)
@ -207,7 +205,7 @@ mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
node = node->children[1];
}
return NULL; // never reached
return (mleaf_t *)node;
}
@ -1150,11 +1148,11 @@ Mod_LoadSpriteModel (model_t *mod, void *buffer)
//=============================================================================
/*
@@@@@@@@@@@@@@@@@@@@@
=====================
RE_BeginRegistration
Specifies the model that will be used as the world
@@@@@@@@@@@@@@@@@@@@@
=====================
*/
void RE_BeginRegistration (char *model)
{
@ -1177,10 +1175,10 @@ void RE_BeginRegistration (char *model)
/*
@@@@@@@@@@@@@@@@@@@@@
=====================
RE_RegisterModel
@@@@@@@@@@@@@@@@@@@@@
=====================
*/
struct model_s *RE_RegisterModel (char *name)
{
@ -1223,10 +1221,10 @@ struct model_s *RE_RegisterModel (char *name)
}
/*
@@@@@@@@@@@@@@@@@@@@@
=====================
RE_EndRegistration
@@@@@@@@@@@@@@@@@@@@@
=====================
*/
void RE_EndRegistration (void)
{
@ -1242,10 +1240,6 @@ void RE_EndRegistration (void)
Hunk_Free (mod->extradata);
memset (mod, 0, sizeof(*mod));
}
else
{ // make sure it is paged in
Com_PageInMemory (mod->extradata, mod->extradatasize);
}
}
R_FreeUnusedImages ();

View file

@ -63,15 +63,15 @@ R_DrawSpanletOpaque( void )
unsigned btemp;
unsigned ts, tt;
ts = s_spanletvars.s >> 16;
tt = s_spanletvars.t >> 16;
ts = s_spanletvars.s >> SHIFT16XYZ;
tt = s_spanletvars.t >> SHIFT16XYZ;
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
if (btemp != 255)
if (btemp != TRANSPARENT_COLOR)
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
if (*s_spanletvars.pz <= (s_spanletvars.izi >> SHIFT16XYZ))
{
*s_spanletvars.pz = s_spanletvars.izi >> 16;
*s_spanletvars.pz = s_spanletvars.izi >> SHIFT16XYZ;
*s_spanletvars.pdest = btemp;
}
}
@ -128,7 +128,7 @@ R_DrawSpanletTurbulentStipple33( void )
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *pz <= ( izi >> 16 ) )
if ( *pz <= ( izi >> SHIFT16XYZ ) )
*pdest = btemp;
izi += s_spanletvars.izistep_times_2;
@ -186,7 +186,7 @@ R_DrawSpanletTurbulentStipple66( void )
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *pz <= ( izi >> 16 ) )
if ( *pz <= ( izi >> SHIFT16XYZ ) )
*pdest = btemp;
izi += s_spanletvars.izistep_times_2;
@ -216,7 +216,7 @@ R_DrawSpanletTurbulentStipple66( void )
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *pz <= ( izi >> 16 ) )
if ( *pz <= ( izi >> SHIFT16XYZ ) )
*pdest = btemp;
izi += s_spanletvars.izistep;
@ -247,7 +247,7 @@ R_DrawSpanletTurbulentBlended66( void )
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> 16 ) )
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> SHIFT16XYZ ) )
*s_spanletvars.pdest = vid_alphamap[btemp*256+*s_spanletvars.pdest];
s_spanletvars.izi += s_spanletvars.izistep;
@ -272,7 +272,7 @@ R_DrawSpanletTurbulentBlended33( void )
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> 16 ) )
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> SHIFT16XYZ ) )
*s_spanletvars.pdest = vid_alphamap[btemp+*s_spanletvars.pdest*256];
s_spanletvars.izi += s_spanletvars.izistep;
@ -295,14 +295,14 @@ R_DrawSpanlet33( void )
unsigned btemp;
unsigned ts, tt;
ts = s_spanletvars.s >> 16;
tt = s_spanletvars.t >> 16;
ts = s_spanletvars.s >> SHIFT16XYZ;
tt = s_spanletvars.t >> SHIFT16XYZ;
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
if ( btemp != 255 )
if ( btemp != TRANSPARENT_COLOR )
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
if (*s_spanletvars.pz <= (s_spanletvars.izi >> SHIFT16XYZ))
{
*s_spanletvars.pdest = vid_alphamap[btemp+*s_spanletvars.pdest*256];
}
@ -321,7 +321,7 @@ R_DrawSpanletConstant33( void )
{
do
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
if (*s_spanletvars.pz <= (s_spanletvars.izi >> SHIFT16XYZ))
{
*s_spanletvars.pdest = vid_alphamap[r_polyblendcolor+*s_spanletvars.pdest*256];
}
@ -343,14 +343,14 @@ R_DrawSpanlet66( void )
unsigned btemp;
unsigned ts, tt;
ts = s_spanletvars.s >> 16;
tt = s_spanletvars.t >> 16;
ts = s_spanletvars.s >> SHIFT16XYZ;
tt = s_spanletvars.t >> SHIFT16XYZ;
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
if ( btemp != 255 )
if ( btemp != TRANSPARENT_COLOR )
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
if (*s_spanletvars.pz <= (s_spanletvars.izi >> SHIFT16XYZ))
{
*s_spanletvars.pdest = vid_alphamap[btemp*256+*s_spanletvars.pdest];
}
@ -401,14 +401,14 @@ R_DrawSpanlet33Stipple( void )
while ( s_spanletvars.spancount > 0 )
{
unsigned btemp;
unsigned s = s_spanletvars.s >> 16;
unsigned t = s_spanletvars.t >> 16;
unsigned s = s_spanletvars.s >> SHIFT16XYZ;
unsigned t = s_spanletvars.t >> SHIFT16XYZ;
btemp = *( s_spanletvars.pbase + ( s ) + ( t * cachewidth ) );
if ( btemp != 255 )
if ( btemp != TRANSPARENT_COLOR )
{
if ( *pz <= ( izi >> 16 ) )
if ( *pz <= ( izi >> SHIFT16XYZ ) )
*pdest = btemp;
}
@ -461,14 +461,14 @@ R_DrawSpanlet66Stipple( void )
while ( s_spanletvars.spancount > 0 )
{
unsigned s = s_spanletvars.s >> 16;
unsigned t = s_spanletvars.t >> 16;
unsigned s = s_spanletvars.s >> SHIFT16XYZ;
unsigned t = s_spanletvars.t >> SHIFT16XYZ;
btemp = *( s_spanletvars.pbase + ( s ) + ( t * cachewidth ) );
if ( btemp != 255 )
if ( btemp != TRANSPARENT_COLOR )
{
if ( *pz <= ( izi >> 16 ) )
if ( *pz <= ( izi >> SHIFT16XYZ ) )
*pdest = btemp;
}
@ -486,14 +486,14 @@ R_DrawSpanlet66Stipple( void )
{
while ( s_spanletvars.spancount > 0 )
{
unsigned s = s_spanletvars.s >> 16;
unsigned t = s_spanletvars.t >> 16;
unsigned s = s_spanletvars.s >> SHIFT16XYZ;
unsigned t = s_spanletvars.t >> SHIFT16XYZ;
btemp = *( s_spanletvars.pbase + ( s ) + ( t * cachewidth ) );
if ( btemp != 255 )
if ( btemp != TRANSPARENT_COLOR )
{
if ( *pz <= ( izi >> 16 ) )
if ( *pz <= ( izi >> SHIFT16XYZ ) )
*pdest = btemp;
}
@ -614,7 +614,7 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
zispanletstepu = d_zistepu * AFFINE_SPANLET_SIZE;
// we count on FP exceptions being turned off to avoid range problems
s_spanletvars.izistep = (int)(d_zistepu * 0x8000 * 0x10000);
s_spanletvars.izistep = (int)(d_zistepu * 0x8000 * SHIFT16XYZ_MULT);
s_spanletvars.izistep_times_2 = s_spanletvars.izistep * 2;
s_spanletvars.pz = 0;
@ -637,9 +637,9 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
// we count on FP exceptions being turned off to avoid range problems
s_spanletvars.izi = (int)(zi * 0x8000 * 0x10000);
s_spanletvars.izi = (int)(zi * 0x8000 * SHIFT16XYZ_MULT);
s_spanletvars.s = (int)(sdivz * z) + sadjust;
s_spanletvars.t = (int)(tdivz * z) + tadjust;
@ -674,7 +674,7 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
sdivz += sdivzspanletstepu;
tdivz += tdivzspanletstepu;
zi += zispanletstepu;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
snext = (int)(sdivz * z) + sadjust;
tnext = (int)(tdivz * z) + tadjust;
@ -707,7 +707,7 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
sdivz += d_sdivzstepu * spancountminus1;
tdivz += d_tdivzstepu * spancountminus1;
zi += d_zistepu * spancountminus1;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
snext = (int)(sdivz * z) + sadjust;
tnext = (int)(tdivz * z) + tadjust;
@ -762,11 +762,10 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
static void
R_PolygonScanLeftEdge (espan_t *s_polygon_spans)
{
int i, v, itop, ibottom, lmaxindex;
int i, lmaxindex;
emitpoint_t *pvert, *pnext;
espan_t *pspan;
float du, dv, vtop, slope;
int u, u_step;
float du, dv, vtop, u_step;
pspan = s_polygon_spans;
i = s_minindex;
@ -790,22 +789,24 @@ R_PolygonScanLeftEdge (espan_t *s_polygon_spans)
if (vtop < vbottom)
{
int v, u, istep, itop, ibottom;
du = pnext->u - pvert->u;
dv = pnext->v - pvert->v;
slope = du / dv;
u_step = (int)(slope * 0x10000);
u_step = (du * SHIFT16XYZ_MULT) / dv;
// adjust u to ceil the integer portion
u = (int)((pvert->u + (slope * (vtop - pvert->v))) * 0x10000) +
(0x10000 - 1);
u = (int)((pvert->u * SHIFT16XYZ_MULT) + u_step * (vtop - pvert->v)) +
(SHIFT16XYZ_MULT - 1);
itop = (int)vtop;
ibottom = (int)vbottom;
istep = (int)u_step;
for (v=itop ; v<ibottom ; v++)
{
pspan->u = u >> 16;
pspan->u = u >> SHIFT16XYZ;
pspan->v = v;
u += u_step;
u += istep;
pspan++;
}
}
@ -828,11 +829,10 @@ R_PolygonScanLeftEdge (espan_t *s_polygon_spans)
static void
R_PolygonScanRightEdge(espan_t *s_polygon_spans)
{
int i, v, itop, ibottom;
int i;
emitpoint_t *pvert, *pnext;
espan_t *pspan;
float du, dv, vtop, slope, uvert, unext, vvert;
int u, u_step;
float du, dv, vtop, u_step, uvert, unext, vvert;
pspan = s_polygon_spans;
i = s_minindex;
@ -862,6 +862,8 @@ R_PolygonScanRightEdge(espan_t *s_polygon_spans)
if (vtop < vbottom)
{
int v, u, istep, itop, ibottom;
uvert = pvert->u;
if (uvert < r_refdef.fvrectx_adj)
uvert = r_refdef.fvrectx_adj;
@ -876,18 +878,18 @@ R_PolygonScanRightEdge(espan_t *s_polygon_spans)
du = unext - uvert;
dv = vnext - vvert;
slope = du / dv;
u_step = (int)(slope * 0x10000);
u_step = (du * SHIFT16XYZ_MULT) / dv;
// adjust u to ceil the integer portion
u = (int)((uvert + (slope * (vtop - vvert))) * 0x10000) +
(0x10000 - 1);
u = (int)((uvert * SHIFT16XYZ_MULT) + u_step * (vtop - vvert)) +
(SHIFT16XYZ_MULT - 1);
itop = (int)vtop;
ibottom = (int)vbottom;
istep = (int)u_step;
for (v=itop ; v<ibottom ; v++)
{
pspan->count = (u >> 16) - pspan->u;
u += u_step;
pspan->count = (u >> SHIFT16XYZ) - pspan->u;
u += istep;
pspan++;
}
}
@ -1131,12 +1133,12 @@ R_PolygonCalculateGradients (void)
d_zistepv = -p_normal[1] * yscaleinv * distinv;
d_ziorigin = p_normal[2] * distinv - xcenter * d_zistepu - ycenter * d_zistepv;
sadjust = (int) ( ( DotProduct( r_polydesc.viewer_position, r_polydesc.vright) + r_polydesc.s_offset ) * 0x10000 );
tadjust = (int) ( ( DotProduct( r_polydesc.viewer_position, r_polydesc.vup ) + r_polydesc.t_offset ) * 0x10000 );
sadjust = (int) ( ( DotProduct( r_polydesc.viewer_position, r_polydesc.vright) + r_polydesc.s_offset ) * SHIFT16XYZ_MULT );
tadjust = (int) ( ( DotProduct( r_polydesc.viewer_position, r_polydesc.vup ) + r_polydesc.t_offset ) * SHIFT16XYZ_MULT );
// -1 (-epsilon) so we never wander off the edge of the texture
bbextents = (r_polydesc.pixel_width << 16) - 1;
bbextentt = (r_polydesc.pixel_height << 16) - 1;
bbextents = (r_polydesc.pixel_width << SHIFT16XYZ) - 1;
bbextentt = (r_polydesc.pixel_height << SHIFT16XYZ) - 1;
}
/*

View file

@ -265,7 +265,7 @@ static void R_PolysetScanLeftEdge_C(int height)
d_aspancount += d_countextrastep;
d_ptex += d_ptexextrastep;
d_sfrac += d_sfracextrastep;
d_ptex += d_sfrac >> 16;
d_ptex += d_sfrac >> SHIFT16XYZ;
d_sfrac &= 0xFFFF;
d_tfrac += d_tfracextrastep;
@ -285,7 +285,7 @@ static void R_PolysetScanLeftEdge_C(int height)
d_aspancount += ubasestep;
d_ptex += d_ptexbasestep;
d_sfrac += d_sfracbasestep;
d_ptex += d_sfrac >> 16;
d_ptex += d_sfrac >> SHIFT16XYZ;
d_sfrac &= 0xFFFF;
d_tfrac += d_tfracbasestep;
if (d_tfrac & 0x10000)
@ -440,7 +440,7 @@ static void R_PolysetCalcGradients (int skinwidth)
a_tstepxfrac = r_tstepx & 0xFFFF;
}
a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
a_ststepxwhole = skinwidth * (r_tstepx >> SHIFT16XYZ) + (r_sstepx >> SHIFT16XYZ);
}
@ -487,7 +487,7 @@ void R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
do
{
if ((lzi >> 16) >= *lpz)
if ((lzi >> SHIFT16XYZ) >= *lpz)
{
int temp = vid_colormap[*lptex + ( llight & 0xFF00 )];
@ -499,7 +499,7 @@ void R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
llight += r_lstepx;
lptex += a_ststepxwhole;
lsfrac += a_sstepxfrac;
lptex += lsfrac >> 16;
lptex += lsfrac >> SHIFT16XYZ;
lsfrac &= 0xFFFF;
ltfrac += a_tstepxfrac;
if (ltfrac & 0x10000)
@ -545,7 +545,7 @@ void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage)
do
{
if ((lzi >> 16) >= *lpz)
if ((lzi >> SHIFT16XYZ) >= *lpz)
{
*lpdest = vid_alphamap[r_aliasblendcolor + *lpdest*256];
}
@ -597,12 +597,12 @@ void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
do
{
if ((lzi >> 16) >= *lpz)
if ((lzi >> SHIFT16XYZ) >= *lpz)
{
int temp = vid_colormap[*lptex + ( llight & 0xFF00 )];
*lpdest = vid_alphamap[temp*256 + *lpdest];
*lpz = lzi >> 16;
*lpz = lzi >> SHIFT16XYZ;
}
lpdest++;
lzi += r_zistepx;
@ -610,7 +610,7 @@ void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
llight += r_lstepx;
lptex += a_ststepxwhole;
lsfrac += a_sstepxfrac;
lptex += lsfrac >> 16;
lptex += lsfrac >> SHIFT16XYZ;
lsfrac &= 0xFFFF;
ltfrac += a_tstepxfrac;
if (ltfrac & 0x10000)
@ -656,7 +656,7 @@ void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage)
do
{
if ((lzi >> 16) >= *lpz)
if ((lzi >> SHIFT16XYZ) >= *lpz)
{
*lpdest = vid_alphamap[r_aliasblendcolor*256 + *lpdest];
}
@ -707,7 +707,7 @@ void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
do
{
if ((lzi >> 16) >= *lpz)
if ((lzi >> SHIFT16XYZ) >= *lpz)
{
//PGM
if(r_newrefdef.rdflags & RDF_IRGOGGLES && currententity->flags & RF_IR_VISIBLE)
@ -716,7 +716,7 @@ void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
*lpdest = ((byte *)vid_colormap)[*lptex + (llight & 0xFF00)];
//PGM
*lpz = lzi >> 16;
*lpz = lzi >> SHIFT16XYZ;
}
lpdest++;
lzi += r_zistepx;
@ -724,7 +724,7 @@ void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
llight += r_lstepx;
lptex += a_ststepxwhole;
lsfrac += a_sstepxfrac;
lptex += lsfrac >> 16;
lptex += lsfrac >> SHIFT16XYZ;
lsfrac &= 0xFFFF;
ltfrac += a_tstepxfrac;
if (ltfrac & 0x10000)
@ -777,8 +777,8 @@ R_RasterizeAliasPolySmooth (void)
ystart = plefttop[1];
d_aspancount = plefttop[0] - prighttop[0];
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) +
(plefttop[3] >> 16) * r_affinetridesc.skinwidth;
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> SHIFT16XYZ) +
(plefttop[3] >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
{
d_sfrac = plefttop[2] & 0xFFFF;
d_tfrac = plefttop[3] & 0xFFFF;
@ -828,8 +828,8 @@ R_RasterizeAliasPolySmooth (void)
working_lstepx = r_lstepx;
d_countextrastep = ubasestep + 1;
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
((r_tstepy + r_tstepx * ubasestep) >> 16) *
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> SHIFT16XYZ) +
((r_tstepy + r_tstepx * ubasestep) >> SHIFT16XYZ) *
r_affinetridesc.skinwidth;
{
d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
@ -838,8 +838,8 @@ R_RasterizeAliasPolySmooth (void)
d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> SHIFT16XYZ) +
((r_tstepy + r_tstepx * d_countextrastep) >> SHIFT16XYZ) *
r_affinetridesc.skinwidth;
{
d_sfracextrastep = (r_sstepy + r_sstepx*d_countextrastep) & 0xFFFF;
@ -869,8 +869,8 @@ R_RasterizeAliasPolySmooth (void)
ystart = plefttop[1];
d_aspancount = plefttop[0] - prighttop[0];
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) +
(plefttop[3] >> 16) * r_affinetridesc.skinwidth;
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> SHIFT16XYZ) +
(plefttop[3] >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
d_sfrac = 0;
d_tfrac = 0;
d_light = plefttop[4];
@ -914,8 +914,8 @@ R_RasterizeAliasPolySmooth (void)
working_lstepx = r_lstepx;
d_countextrastep = ubasestep + 1;
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
((r_tstepy + r_tstepx * ubasestep) >> 16) *
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> SHIFT16XYZ) +
((r_tstepy + r_tstepx * ubasestep) >> SHIFT16XYZ) *
r_affinetridesc.skinwidth;
{
d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
@ -924,8 +924,8 @@ R_RasterizeAliasPolySmooth (void)
d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> SHIFT16XYZ) +
((r_tstepy + r_tstepx * d_countextrastep) >> SHIFT16XYZ) *
r_affinetridesc.skinwidth;
{
d_sfracextrastep = (r_sstepy+r_sstepx*d_countextrastep) & 0xFFFF;

View file

@ -195,7 +195,7 @@ R_EmitSkyBox (void)
r_currentkey = 0x7ffffff0;
for (i=0 ; i<6 ; i++)
{
R_RenderFace (r_skyfaces + i, 15);
R_RenderFace (r_skyfaces + i, ALIAS_XY_CLIP_MASK);
}
r_currentkey = oldkey; // bsp sorting order
}

View file

@ -65,7 +65,7 @@ void D_WarpScreen (void)
int v2;
v2 = (int)((float)v/(h + AMP2 * 2) * r_refdef.vrect.height);
warp_rowptr[v] = r_warpbuffer + (WARP_WIDTH * v2);
warp_rowptr[v] = r_warpbuffer + (vid.width * v2);
}
for (u=0 ; u<w+AMP2*2 ; u++)
@ -149,7 +149,7 @@ void Turbulent8 (espan_t *pspan)
sdivz = d_sdivzorigin + dv*d_sdivzstepv + du*d_sdivzstepu;
tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
r_turb_s = (int)(sdivz * z) + sadjust;
if (r_turb_s > bbextents)
@ -180,7 +180,7 @@ void Turbulent8 (espan_t *pspan)
sdivz += sdivz16stepu;
tdivz += tdivz16stepu;
zi += zi16stepu;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
snext = (int)(sdivz * z) + sadjust;
if (snext > bbextents)
@ -209,7 +209,7 @@ void Turbulent8 (espan_t *pspan)
sdivz += d_sdivzstepu * spancountminus1;
tdivz += d_tdivzstepu * spancountminus1;
zi += d_zistepu * spancountminus1;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
snext = (int)(sdivz * z) + sadjust;
if (snext > bbextents)
snext = bbextents;
@ -285,7 +285,7 @@ void NonTurbulent8 (espan_t *pspan)
sdivz = d_sdivzorigin + dv*d_sdivzstepv + du*d_sdivzstepu;
tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
r_turb_s = (int)(sdivz * z) + sadjust;
if (r_turb_s > bbextents)
@ -316,7 +316,7 @@ void NonTurbulent8 (espan_t *pspan)
sdivz += sdivz16stepu;
tdivz += tdivz16stepu;
zi += zi16stepu;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
snext = (int)(sdivz * z) + sadjust;
if (snext > bbextents)
@ -345,7 +345,7 @@ void NonTurbulent8 (espan_t *pspan)
sdivz += d_sdivzstepu * spancountminus1;
tdivz += d_tdivzstepu * spancountminus1;
zi += d_zistepu * spancountminus1;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
snext = (int)(sdivz * z) + sadjust;
if (snext > bbextents)
snext = bbextents;
@ -382,6 +382,19 @@ void NonTurbulent8 (espan_t *pspan)
//PGM
//====================
// Enable custom filtering
extern cvar_t *sw_texture_filtering;
static int filtering_kernel[2][2][2] = {
{
{16384, 0},
{49152, 32768}
},
{
{32768, 49152},
{0, 16384}
}
};
/*
=============
D_DrawSpans16
@ -423,7 +436,7 @@ void D_DrawSpans16 (espan_t *pspan)
sdivz = d_sdivzorigin + dv*d_sdivzstepv + du*d_sdivzstepu;
tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
s = (int)(sdivz * z) + sadjust;
if (s > bbextents)
@ -454,7 +467,7 @@ void D_DrawSpans16 (espan_t *pspan)
sdivz += sdivz8stepu;
tdivz += tdivz8stepu;
zi += zi8stepu;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
snext = (int)(sdivz * z) + sadjust;
if (snext > bbextents)
@ -483,7 +496,7 @@ void D_DrawSpans16 (espan_t *pspan)
sdivz += d_sdivzstepu * spancountminus1;
tdivz += d_tdivzstepu * spancountminus1;
zi += d_zistepu * spancountminus1;
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
snext = (int)(sdivz * z) + sadjust;
if (snext > bbextents)
snext = bbextents;
@ -505,15 +518,46 @@ void D_DrawSpans16 (espan_t *pspan)
}
}
do
// Drawing phrase
if (sw_texture_filtering->value == 0.0f)
{
*pdest++ = *(pbase + (s >> 16) + (t >> 16) * cachewidth);
s += sstep;
t += tstep;
} while (--spancount > 0);
do
{
*pdest++ = *(pbase + (s >> SHIFT16XYZ) + (t >> SHIFT16XYZ) * cachewidth);
s += sstep;
t += tstep;
} while (--spancount > 0);
s = snext;
t = tnext;
s = snext;
t = tnext;
}
else if (sw_texture_filtering->value == 1.0f)
{
do
{
int idiths = s;
int iditht = t;
int X = (pspan->u + spancount) & 1;
int Y = (pspan->v)&1;
//Using the kernel
idiths += filtering_kernel[X][Y][0];
iditht += filtering_kernel[X][Y][1];
idiths = idiths >> SHIFT16XYZ;
idiths = idiths ? idiths -1 : idiths;
iditht = iditht >> SHIFT16XYZ;
iditht = iditht ? iditht -1 : iditht;
*pdest++ = *(pbase + idiths + iditht * cachewidth);
s += sstep;
t += tstep;
} while (--spancount > 0);
}
} while (count > 0);
@ -531,7 +575,7 @@ void D_DrawZSpans (espan_t *pspan)
// FIXME: check for clamping/range problems
// we count on FP exceptions being turned off to avoid range problems
izistep = (int)(d_zistepu * 0x8000 * 0x10000);
izistep = (int)(d_zistepu * 0x8000 * (float)SHIFT16XYZ_MULT);
do
{
@ -551,11 +595,11 @@ void D_DrawZSpans (espan_t *pspan)
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
// we count on FP exceptions being turned off to avoid range problems
izi = (int)(zi * 0x8000 * 0x10000);
izi = (int)(zi * 0x8000 * (float)SHIFT16XYZ_MULT);
while (count > 0)
{
*pdest++ = izi >> 16;
*pdest++ = izi >> SHIFT16XYZ;
izi += izistep;
count--;
}

View file

@ -96,7 +96,7 @@ static void R_DrawSurface (void)
texwidth = mt->width >> r_drawsurf.surfmip;
blocksize = 16 >> r_drawsurf.surfmip;
blockdivshift = 4 - r_drawsurf.surfmip;
blockdivshift = NUM_MIPS - r_drawsurf.surfmip;
r_lightwidth = (r_drawsurf.surf->extents[0]>>4)+1;
@ -120,9 +120,9 @@ static void R_DrawSurface (void)
basetoffset = r_drawsurf.surf->texturemins[1];
// << 16 components are to guarantee positive values for %
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax;
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << SHIFT16XYZ)) % smax;
basetptr = &r_source[((((basetoffset >> r_drawsurf.surfmip)
+ (tmax << 16)) % tmax) * twidth)];
+ (tmax << SHIFT16XYZ)) % tmax) * twidth)];
pcolumndest = r_drawsurf.surfdat;
@ -134,7 +134,7 @@ static void R_DrawSurface (void)
pbasesource = basetptr + soffset;
R_DrawSurfaceBlock8_anymip(4-r_drawsurf.surfmip);
R_DrawSurfaceBlock8_anymip(NUM_MIPS - r_drawsurf.surfmip);
soffset = soffset + blocksize;
if (soffset >= smax)

View file

@ -1007,7 +1007,7 @@ done:
return com_token;
}
int paged_total;
static int paged_total = 0;
void
Com_PageInMemory(byte *buffer, int size)