Add some comments from Fabien Sanglard article

This commit is contained in:
Denis Pauk 2018-05-20 13:06:26 +03:00
parent 1ea3fdc1a2
commit 2412363001
7 changed files with 44 additions and 23 deletions

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;

View file

@ -659,15 +659,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
@ -691,9 +694,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

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,10 +117,10 @@ 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++)
{
if (pic[i] == 255)
{
@ -129,8 +129,7 @@ R_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type)
}
}
memcpy(image->pixels[0], pic, c);
memcpy(image->pixels[0], pic, size);
return image;
}
@ -240,7 +239,7 @@ image_t *R_FindImage (char *name, imagetype_t type)
// fix backslashes
while ((ptr=strchr(name,'\\'))) {
*ptr = '/';
*ptr = '/';
}
#endif

View file

@ -186,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];
@ -311,7 +313,7 @@ static void
R_UnRegister (void)
{
ri.Cmd_RemoveCommand( "screenshot" );
ri.Cmd_RemoveCommand ("modellist");
ri.Cmd_RemoveCommand( "modellist" );
ri.Cmd_RemoveCommand( "imagelist" );
}
@ -783,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];
@ -866,6 +868,8 @@ static surf_t *lsurfs;
/*
================
R_EdgeDrawing
Render the map
================
*/
static void
@ -892,6 +896,7 @@ R_EdgeDrawing (void)
surfaces--;
}
// Set function pointer pdrawfunc used later in this function
R_BeginEdgeFrame ();
if (r_dspeeds->value)
@ -899,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)
@ -915,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 ();
}
@ -1018,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)
@ -1030,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)
@ -1038,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)
@ -1056,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)
@ -1314,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 );
}
}

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;
}

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 + (r_refdef.vrect.width * v2);
warp_rowptr[v] = r_warpbuffer + (vid.width * v2);
}
for (u=0 ; u<w+AMP2*2 ; u++)