mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
ref: soft: refactor variable declarations
This commit is contained in:
@@ -43,10 +43,8 @@ pfv0 is the unclipped vertex, pfv1 is the z-clipped vertex
|
||||
*/
|
||||
static void R_Alias_clip_z( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out )
|
||||
{
|
||||
float scale;
|
||||
|
||||
scale = ( ALIAS_Z_CLIP_PLANE - pfv0->xyz[2] )
|
||||
/ ( pfv1->xyz[2] - pfv0->xyz[2] );
|
||||
float scale = ( ALIAS_Z_CLIP_PLANE - pfv0->xyz[2] )
|
||||
/ ( pfv1->xyz[2] - pfv0->xyz[2] );
|
||||
|
||||
out->xyz[0] = pfv0->xyz[0] + ( pfv1->xyz[0] - pfv0->xyz[0] ) * scale;
|
||||
out->xyz[1] = pfv0->xyz[1] + ( pfv1->xyz[1] - pfv0->xyz[1] ) * scale;
|
||||
@@ -177,15 +175,13 @@ void R_Alias_clip_bottom( finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
static int R_AliasClip( finalvert_t *in, finalvert_t *out, int flag, int count,
|
||||
void ( *clip )( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out ))
|
||||
{
|
||||
int i, j, k;
|
||||
int flags, oldflags;
|
||||
int j = count - 1;
|
||||
int k = 0;
|
||||
|
||||
j = count - 1;
|
||||
k = 0;
|
||||
for( i = 0; i < count; j = i, i++ )
|
||||
for( int i = 0; i < count; j = i, i++ )
|
||||
{
|
||||
oldflags = in[j].flags & flag;
|
||||
flags = in[i].flags & flag;
|
||||
int oldflags = in[j].flags & flag;
|
||||
int flags = in[i].flags & flag;
|
||||
|
||||
if( flags && oldflags )
|
||||
continue;
|
||||
@@ -220,7 +216,7 @@ R_AliasClipTriangle
|
||||
*/
|
||||
void R_AliasClipTriangle( finalvert_t *index0, finalvert_t *index1, finalvert_t *index2 )
|
||||
{
|
||||
int i, k, pingpong;
|
||||
int k, pingpong;
|
||||
unsigned clipflags;
|
||||
|
||||
// copy vertexes and fix seam texture coordinates
|
||||
@@ -286,7 +282,7 @@ void R_AliasClipTriangle( finalvert_t *index0, finalvert_t *index1, finalvert_t
|
||||
pingpong ^= 1;
|
||||
}
|
||||
|
||||
for( i = 0; i < k; i++ )
|
||||
for( int i = 0; i < k; i++ )
|
||||
{
|
||||
if( fv[pingpong][i].u < RI.aliasvrect.x )
|
||||
fv[pingpong][i].u = RI.aliasvrect.x;
|
||||
@@ -302,7 +298,7 @@ void R_AliasClipTriangle( finalvert_t *index0, finalvert_t *index1, finalvert_t
|
||||
}
|
||||
|
||||
// draw triangles
|
||||
for( i = 1; i < k - 1; i++ )
|
||||
for( int i = 1; i < k - 1; i++ )
|
||||
{
|
||||
aliastriangleparms.a = &fv[pingpong][0];
|
||||
aliastriangleparms.b = &fv[pingpong][i];
|
||||
|
||||
@@ -45,9 +45,8 @@ static float rgNoise[NOISE_DIVISIONS + 1]; // global noise array
|
||||
// Fractal noise generator, power of 2 wavelength
|
||||
static void FracNoise( float *noise, int divs )
|
||||
{
|
||||
int div2;
|
||||
int div2 = divs >> 1;
|
||||
|
||||
div2 = divs >> 1;
|
||||
if( divs < 2 )
|
||||
return;
|
||||
|
||||
@@ -65,9 +64,8 @@ static void SineNoise( float *noise, int divs )
|
||||
{
|
||||
float freq = 0;
|
||||
float step = M_PI_F / (float)divs;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < divs; i++ )
|
||||
for( int i = 0; i < divs; i++ )
|
||||
{
|
||||
noise[i] = sin( freq );
|
||||
freq += step;
|
||||
@@ -138,19 +136,16 @@ general code for drawing beams
|
||||
*/
|
||||
static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments, int flags )
|
||||
{
|
||||
int noiseIndex, noiseStep;
|
||||
int i, total_segs, segs_drawn;
|
||||
float div, length, fraction, factor;
|
||||
float flMaxWidth, vLast, vStep, brightness;
|
||||
float brightness;
|
||||
vec3_t perp1, vLastNormal = { 0.0f };
|
||||
beamseg_t curSeg;
|
||||
|
||||
if( segments < 2 )
|
||||
return;
|
||||
|
||||
length = VectorLength( delta );
|
||||
flMaxWidth = width * 0.5f;
|
||||
div = 1.0f / ( segments - 1 );
|
||||
float length = VectorLength( delta );
|
||||
float flMaxWidth = width * 0.5f;
|
||||
float div = 1.0f / ( segments - 1 );
|
||||
|
||||
if( length * div < flMaxWidth * 1.414f )
|
||||
{
|
||||
@@ -165,10 +160,10 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
||||
|
||||
div = 1.0f / ( segments - 1 );
|
||||
length *= 0.01f;
|
||||
vStep = length * div; // Texture length texels per space pixel
|
||||
float vStep = length * div; // Texture length texels per space pixel
|
||||
|
||||
// Scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
|
||||
vLast = fmod( freq * speed, 1 );
|
||||
float vLast = fmod( freq * speed, 1 );
|
||||
|
||||
if( flags & FBEAM_SINENOISE )
|
||||
{
|
||||
@@ -186,9 +181,9 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
||||
}
|
||||
|
||||
// Iterator to resample noise waveform (it needs to be generated in powers of 2)
|
||||
noiseStep = (int)((float)( NOISE_DIVISIONS - 1 ) * div * 65536.0f );
|
||||
int noiseStep = (int)((float)( NOISE_DIVISIONS - 1 ) * div * 65536.0f );
|
||||
brightness = 1.0f;
|
||||
noiseIndex = 0;
|
||||
int noiseIndex = 0;
|
||||
|
||||
if( FBitSet( flags, FBEAM_SHADEIN ))
|
||||
brightness = 0;
|
||||
@@ -196,25 +191,25 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
||||
// Choose two vectors that are perpendicular to the beam
|
||||
R_BeamComputePerpendicular( delta, perp1 );
|
||||
|
||||
total_segs = segments;
|
||||
segs_drawn = 0;
|
||||
int total_segs = segments;
|
||||
int segs_drawn = 0;
|
||||
|
||||
// specify all the segments.
|
||||
for( i = 0; i < segments; i++ )
|
||||
for( int i = 0; i < segments; i++ )
|
||||
{
|
||||
beamseg_t nextSeg;
|
||||
vec3_t vPoint1, vPoint2;
|
||||
|
||||
Assert( noiseIndex < ( NOISE_DIVISIONS << 16 ));
|
||||
|
||||
fraction = i * div;
|
||||
float fraction = i * div;
|
||||
|
||||
VectorMA( source, fraction, delta, nextSeg.pos );
|
||||
|
||||
// distort using noise
|
||||
if( scale != 0 )
|
||||
{
|
||||
factor = rgNoise[noiseIndex >> 16] * scale;
|
||||
float factor = rgNoise[noiseIndex >> 16] * scale;
|
||||
|
||||
if( FBitSet( flags, FBEAM_SINENOISE ))
|
||||
{
|
||||
@@ -324,8 +319,6 @@ Draw beamtours
|
||||
*/
|
||||
static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
|
||||
{
|
||||
int i, noiseIndex, noiseStep;
|
||||
float div, length, fraction, factor, vLast, vStep;
|
||||
vec3_t last1, last2, point, screen, screenLast, tmp, normal;
|
||||
|
||||
if( segments < 2 )
|
||||
@@ -334,27 +327,27 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
|
||||
if( segments > NOISE_DIVISIONS )
|
||||
segments = NOISE_DIVISIONS;
|
||||
|
||||
length = VectorLength( delta ) * 0.01f;
|
||||
float length = VectorLength( delta ) * 0.01f;
|
||||
if( length < 0.5f )
|
||||
length = 0.5f; // don't lose all of the noise/texture on short beams
|
||||
|
||||
div = 1.0f / ( segments - 1 );
|
||||
float div = 1.0f / ( segments - 1 );
|
||||
|
||||
vStep = length * div; // Texture length texels per space pixel
|
||||
float vStep = length * div; // Texture length texels per space pixel
|
||||
|
||||
// Scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
|
||||
vLast = fmod( freq * speed, 1 );
|
||||
float vLast = fmod( freq * speed, 1 );
|
||||
scale = scale * length;
|
||||
|
||||
// Iterator to resample noise waveform (it needs to be generated in powers of 2)
|
||||
noiseStep = (int)((float)( NOISE_DIVISIONS - 1 ) * div * 65536.0f );
|
||||
noiseIndex = 0;
|
||||
int noiseStep = (int)((float)( NOISE_DIVISIONS - 1 ) * div * 65536.0f );
|
||||
int noiseIndex = 0;
|
||||
|
||||
for( i = 0; i < segments; i++ )
|
||||
for( int i = 0; i < segments; i++ )
|
||||
{
|
||||
float s, c;
|
||||
|
||||
fraction = i * div;
|
||||
float fraction = i * div;
|
||||
SinCos( fraction * M_PI2, &s, &c );
|
||||
|
||||
point[0] = s * freq * delta[2] + source[0];
|
||||
@@ -366,7 +359,7 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
|
||||
{
|
||||
if(( noiseIndex >> 16 ) < NOISE_DIVISIONS )
|
||||
{
|
||||
factor = rgNoise[noiseIndex >> 16] * scale;
|
||||
float factor = rgNoise[noiseIndex >> 16] * scale;
|
||||
VectorMA( point, factor, RI.vup, point );
|
||||
|
||||
// rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
|
||||
@@ -414,10 +407,7 @@ Draw beamdisk
|
||||
*/
|
||||
static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
|
||||
{
|
||||
float div, length, fraction;
|
||||
float w, vLast, vStep;
|
||||
vec3_t point;
|
||||
int i;
|
||||
|
||||
if( segments < 2 )
|
||||
return;
|
||||
@@ -425,26 +415,26 @@ static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, f
|
||||
if( segments > NOISE_DIVISIONS ) // UNDONE: Allow more segments?
|
||||
segments = NOISE_DIVISIONS;
|
||||
|
||||
length = VectorLength( delta ) * 0.01f;
|
||||
float length = VectorLength( delta ) * 0.01f;
|
||||
if( length < 0.5f )
|
||||
length = 0.5f; // don't lose all of the noise/texture on short beams
|
||||
|
||||
div = 1.0f / ( segments - 1 );
|
||||
vStep = length * div; // Texture length texels per space pixel
|
||||
float div = 1.0f / ( segments - 1 );
|
||||
float vStep = length * div; // Texture length texels per space pixel
|
||||
|
||||
// scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
|
||||
vLast = fmod( freq * speed, 1 );
|
||||
float vLast = fmod( freq * speed, 1 );
|
||||
scale = scale * length;
|
||||
|
||||
// clamp the beam width
|
||||
w = fmod( freq, width ) * delta[2];
|
||||
float w = fmod( freq, width ) * delta[2];
|
||||
|
||||
// NOTE: we must force the degenerate triangles to be on the edge
|
||||
for( i = 0; i < segments; i++ )
|
||||
for( int i = 0; i < segments; i++ )
|
||||
{
|
||||
float s, c;
|
||||
|
||||
fraction = i * div;
|
||||
float fraction = i * div;
|
||||
VectorCopy( source, point );
|
||||
|
||||
TriBrightness( 1.0f );
|
||||
@@ -473,10 +463,7 @@ Draw beam cylinder
|
||||
*/
|
||||
static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
|
||||
{
|
||||
float div, length, fraction;
|
||||
float vLast, vStep;
|
||||
vec3_t point;
|
||||
int i;
|
||||
|
||||
if( segments < 2 )
|
||||
return;
|
||||
@@ -484,22 +471,22 @@ static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scal
|
||||
if( segments > NOISE_DIVISIONS )
|
||||
segments = NOISE_DIVISIONS;
|
||||
|
||||
length = VectorLength( delta ) * 0.01f;
|
||||
float length = VectorLength( delta ) * 0.01f;
|
||||
if( length < 0.5f )
|
||||
length = 0.5f; // don't lose all of the noise/texture on short beams
|
||||
|
||||
div = 1.0f / ( segments - 1 );
|
||||
vStep = length * div; // texture length texels per space pixel
|
||||
float div = 1.0f / ( segments - 1 );
|
||||
float vStep = length * div; // texture length texels per space pixel
|
||||
|
||||
// Scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
|
||||
vLast = fmod( freq * speed, 1 );
|
||||
float vLast = fmod( freq * speed, 1 );
|
||||
scale = scale * length;
|
||||
|
||||
for( i = 0; i < segments; i++ )
|
||||
for( int i = 0; i < segments; i++ )
|
||||
{
|
||||
float s, c;
|
||||
|
||||
fraction = i * div;
|
||||
float fraction = i * div;
|
||||
SinCos( fraction * M_PI2, &s, &c );
|
||||
|
||||
point[0] = s * freq * delta[2] + source[0];
|
||||
@@ -692,11 +679,8 @@ Draw beamring
|
||||
*/
|
||||
static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, float freq, float speed, int segments )
|
||||
{
|
||||
int i, j, noiseIndex, noiseStep;
|
||||
float div, length, fraction, factor, vLast, vStep;
|
||||
vec3_t last1, last2, point, screen, screenLast;
|
||||
vec3_t tmp, normal, center, xaxis, yaxis;
|
||||
float radius, x, y, scale;
|
||||
|
||||
if( segments < 2 )
|
||||
return;
|
||||
@@ -707,27 +691,27 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
|
||||
if( segments > NOISE_DIVISIONS * 8 )
|
||||
segments = NOISE_DIVISIONS * 8;
|
||||
|
||||
length = VectorLength( delta ) * 0.01f * M_PI_F;
|
||||
float length = VectorLength( delta ) * 0.01f * M_PI_F;
|
||||
if( length < 0.5f )
|
||||
length = 0.5f; // Don't lose all of the noise/texture on short beams
|
||||
|
||||
div = 1.0f / ( segments - 1 );
|
||||
float div = 1.0f / ( segments - 1 );
|
||||
|
||||
vStep = length * div / 8.0f; // texture length texels per space pixel
|
||||
float vStep = length * div / 8.0f; // texture length texels per space pixel
|
||||
|
||||
// Scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
|
||||
vLast = fmod( freq * speed, 1.0f );
|
||||
scale = amplitude * length / 8.0f;
|
||||
float vLast = fmod( freq * speed, 1.0f );
|
||||
float scale = amplitude * length / 8.0f;
|
||||
|
||||
// Iterator to resample noise waveform (it needs to be generated in powers of 2)
|
||||
noiseStep = (int)((float)( NOISE_DIVISIONS - 1 ) * div * 65536.0f ) * 8;
|
||||
noiseIndex = 0;
|
||||
int noiseStep = (int)((float)( NOISE_DIVISIONS - 1 ) * div * 65536.0f ) * 8;
|
||||
int noiseIndex = 0;
|
||||
|
||||
VectorScale( delta, 0.5f, delta );
|
||||
VectorAdd( source, delta, center );
|
||||
|
||||
VectorCopy( delta, xaxis );
|
||||
radius = VectorLength( xaxis );
|
||||
float radius = VectorLength( xaxis );
|
||||
|
||||
// cull beamring
|
||||
// --------------------------------
|
||||
@@ -749,17 +733,18 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
|
||||
VectorNormalize( yaxis );
|
||||
VectorScale( yaxis, radius, yaxis );
|
||||
|
||||
j = segments / 8;
|
||||
int j = segments / 8;
|
||||
|
||||
for( i = 0; i < segments + 1; i++ )
|
||||
for( int i = 0; i < segments + 1; i++ )
|
||||
{
|
||||
fraction = i * div;
|
||||
float x, y;
|
||||
float fraction = i * div;
|
||||
SinCos( fraction * M_PI2, &x, &y );
|
||||
|
||||
VectorMAMAM( x, xaxis, y, yaxis, 1.0f, center, point );
|
||||
|
||||
// distort using noise
|
||||
factor = rgNoise[( noiseIndex >> 16 ) & ( NOISE_DIVISIONS - 1 )] * scale;
|
||||
float factor = rgNoise[( noiseIndex >> 16 ) & ( NOISE_DIVISIONS - 1 )] * scale;
|
||||
VectorMA( point, factor, RI.vup, point );
|
||||
|
||||
// Rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
|
||||
@@ -815,10 +800,9 @@ compute attachment point for beam
|
||||
*/
|
||||
static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
|
||||
{
|
||||
cl_entity_t *ent;
|
||||
int attach;
|
||||
int attach;
|
||||
|
||||
ent = gEngfuncs.R_BeamGetEntity( beamEnt );
|
||||
cl_entity_t *ent = gEngfuncs.R_BeamGetEntity( beamEnt );
|
||||
|
||||
if( beamEnt < 0 )
|
||||
attach = BEAMENT_ATTACHMENT( -beamEnt );
|
||||
@@ -905,10 +889,9 @@ Update beam vars and draw it
|
||||
*/
|
||||
static void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||
{
|
||||
model_t *model;
|
||||
vec3_t delta;
|
||||
vec3_t delta;
|
||||
|
||||
model = CL_ModelHandle( pbeam->modelIndex );
|
||||
model_t *model = CL_ModelHandle( pbeam->modelIndex );
|
||||
SetBits( pbeam->flags, FBEAM_ISACTIVE );
|
||||
|
||||
if( !model || model->type != mod_sprite )
|
||||
@@ -1033,10 +1016,8 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||
|
||||
if( pbeam->type == TE_BEAMFOLLOW )
|
||||
{
|
||||
cl_entity_t *pStart;
|
||||
|
||||
// XASH SPECIFIC: get brightness from head entity
|
||||
pStart = gEngfuncs.R_BeamGetEntity( pbeam->startEntity );
|
||||
cl_entity_t *pStart = gEngfuncs.R_BeamGetEntity( pbeam->startEntity );
|
||||
if( pStart && pStart->curstate.rendermode != kRenderNormal )
|
||||
pbeam->brightness = CL_FxBlend( pStart ) / 255.0f;
|
||||
}
|
||||
@@ -1162,12 +1143,9 @@ static void R_BeamDrawCustomEntity( cl_entity_t *ent )
|
||||
BEAM beam;
|
||||
float amp = ent->curstate.body / 100.0f;
|
||||
float blend = CL_FxBlend( ent ) / 255.0f;
|
||||
float r, g, b;
|
||||
int beamFlags;
|
||||
|
||||
r = ent->curstate.rendercolor.r / 255.0f;
|
||||
g = ent->curstate.rendercolor.g / 255.0f;
|
||||
b = ent->curstate.rendercolor.b / 255.0f;
|
||||
float r = ent->curstate.rendercolor.r / 255.0f;
|
||||
float g = ent->curstate.rendercolor.g / 255.0f;
|
||||
float b = ent->curstate.rendercolor.b / 255.0f;
|
||||
|
||||
R_BeamSetup( &beam, ent->origin, ent->curstate.angles, ent->curstate.modelindex, 0, ent->curstate.scale, amp, blend, ent->curstate.animtime );
|
||||
R_BeamSetAttributes( &beam, r, g, b, ent->curstate.framerate, ent->curstate.frame );
|
||||
@@ -1202,7 +1180,7 @@ static void R_BeamDrawCustomEntity( cl_entity_t *ent )
|
||||
break;
|
||||
}
|
||||
|
||||
beamFlags = ( ent->curstate.rendermode & 0xF0 );
|
||||
int beamFlags = ( ent->curstate.rendermode & 0xF0 );
|
||||
|
||||
if( FBitSet( beamFlags, BEAM_FSINE ))
|
||||
SetBits( beam.flags, FBEAM_SINENOISE );
|
||||
@@ -1230,18 +1208,15 @@ draw beam loop
|
||||
*/
|
||||
void GAME_EXPORT CL_DrawBeams( int fTrans, BEAM *active_beams )
|
||||
{
|
||||
BEAM *pBeam;
|
||||
int i, flags;
|
||||
|
||||
// pglShadeModel( GL_SMOOTH );
|
||||
// pglDepthMask( fTrans ? GL_FALSE : GL_TRUE );
|
||||
|
||||
// server beams don't allocate beam chains
|
||||
// all params are stored in cl_entity_t
|
||||
for( i = 0; i < tr.draw_list->num_beam_entities; i++ )
|
||||
for( int i = 0; i < tr.draw_list->num_beam_entities; i++ )
|
||||
{
|
||||
RI.currentbeam = tr.draw_list->beam_entities[i];
|
||||
flags = RI.currentbeam->curstate.rendermode & 0xF0;
|
||||
int flags = RI.currentbeam->curstate.rendermode & 0xF0;
|
||||
|
||||
if( fTrans && FBitSet( flags, FBEAM_SOLID ))
|
||||
continue;
|
||||
@@ -1256,7 +1231,7 @@ void GAME_EXPORT CL_DrawBeams( int fTrans, BEAM *active_beams )
|
||||
RI.currentbeam = NULL;
|
||||
|
||||
// draw temporary entity beams
|
||||
for( pBeam = active_beams; pBeam; pBeam = pBeam->next )
|
||||
for( BEAM *pBeam = active_beams; pBeam; pBeam = pBeam->next )
|
||||
{
|
||||
if( fTrans && FBitSet( pBeam->flags, FBEAM_SOLID ))
|
||||
continue;
|
||||
|
||||
@@ -172,11 +172,10 @@ R_RecursiveClipBPoly
|
||||
static void R_RecursiveClipBPoly( model_t *mod, bedge_t *pedges, mnode_t *pnode, msurface_t *psurf )
|
||||
{
|
||||
bedge_t *psideedges[2], *pnextedge, *ptedge;
|
||||
int i, side, lastside;
|
||||
int side, lastside;
|
||||
float dist, frac, lastdist;
|
||||
mplane_t *splitplane, tplane;
|
||||
mplane_t tplane;
|
||||
mvertex_t *pvert, *plastvert, *ptvert;
|
||||
mnode_t *pn;
|
||||
|
||||
psideedges[0] = psideedges[1] = NULL;
|
||||
|
||||
@@ -184,7 +183,7 @@ static void R_RecursiveClipBPoly( model_t *mod, bedge_t *pedges, mnode_t *pnode,
|
||||
|
||||
// transform the BSP plane into model space
|
||||
// FIXME: cache these?
|
||||
splitplane = pnode->plane;
|
||||
mplane_t *splitplane = pnode->plane;
|
||||
tplane.dist = splitplane->dist
|
||||
- DotProduct( r_entorigin, splitplane->normal );
|
||||
tplane.normal[0] = DotProduct( entity_rotation[0], splitplane->normal );
|
||||
@@ -304,13 +303,13 @@ static void R_RecursiveClipBPoly( model_t *mod, bedge_t *pedges, mnode_t *pnode,
|
||||
}
|
||||
|
||||
// draw or recurse further
|
||||
for( i = 0; i < 2; i++ )
|
||||
for( int i = 0; i < 2; i++ )
|
||||
{
|
||||
if( psideedges[i] )
|
||||
{
|
||||
// draw if we've reached a non-solid leaf, done if all that's left is a
|
||||
// solid leaf, and continue down the tree if it's not a leaf
|
||||
pn = node_child( pnode, i, mod );
|
||||
mnode_t *pn = node_child( pnode, i, mod );
|
||||
|
||||
// we're done with this branch if the node or leaf isn't in the PVS
|
||||
if( pn->visframe == tr.visframecount )
|
||||
@@ -342,22 +341,17 @@ Bmodel crosses multiple leafs
|
||||
*/
|
||||
void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode )
|
||||
{
|
||||
int i, j, lindex;
|
||||
vec_t dot;
|
||||
msurface_t *psurf;
|
||||
int numsurfaces;
|
||||
mplane_t *pplane;
|
||||
mvertex_t bverts[MAX_BMODEL_VERTS];
|
||||
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
|
||||
medge16_t *pedge, *pedges;
|
||||
int j;
|
||||
mvertex_t bverts[MAX_BMODEL_VERTS];
|
||||
bedge_t bedges[MAX_BMODEL_EDGES];
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
pedges = pmodel->edges16;
|
||||
msurface_t *psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
int numsurfaces = pmodel->nummodelsurfaces;
|
||||
medge16_t *pedges = pmodel->edges16;
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, psurf++ )
|
||||
for( int i = 0; i < numsurfaces; i++, psurf++ )
|
||||
{
|
||||
if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !FBitSet( gp_host->features, ENGINE_QUAKE_COMPATIBLE ))
|
||||
{
|
||||
@@ -367,9 +361,9 @@ void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode )
|
||||
continue;
|
||||
}
|
||||
// find which side of the node we are on
|
||||
pplane = psurf->plane;
|
||||
mplane_t *pplane = psurf->plane;
|
||||
|
||||
dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
|
||||
vec_t dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
|
||||
|
||||
// draw the polygon
|
||||
if(( !( psurf->flags & SURF_PLANEBACK ) && ( dot < -BACKFACE_EPSILON ))
|
||||
@@ -385,12 +379,13 @@ void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode )
|
||||
pbverts = bverts;
|
||||
pbedges = bedges;
|
||||
numbverts = numbedges = 0;
|
||||
pbedge = &bedges[numbedges];
|
||||
bedge_t *pbedge = &bedges[numbedges];
|
||||
numbedges += psurf->numedges;
|
||||
|
||||
for( j = 0; j < psurf->numedges; j++ )
|
||||
{
|
||||
lindex = pmodel->surfedges[psurf->firstedge + j];
|
||||
int lindex = pmodel->surfedges[psurf->firstedge + j];
|
||||
medge16_t *pedge;
|
||||
|
||||
if( lindex > 0 )
|
||||
{
|
||||
@@ -428,18 +423,12 @@ All in one leaf
|
||||
*/
|
||||
void R_DrawSubmodelPolygons( model_t *pmodel, int clipflags, mnode_t *topnode )
|
||||
{
|
||||
int i;
|
||||
vec_t dot;
|
||||
msurface_t *psurf;
|
||||
int numsurfaces;
|
||||
mplane_t *pplane;
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
msurface_t *psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
int numsurfaces = pmodel->nummodelsurfaces;
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, psurf++ )
|
||||
for( int i = 0; i < numsurfaces; i++, psurf++ )
|
||||
{
|
||||
if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !FBitSet( gp_host->features, ENGINE_QUAKE_COMPATIBLE ))
|
||||
{
|
||||
@@ -449,9 +438,9 @@ void R_DrawSubmodelPolygons( model_t *pmodel, int clipflags, mnode_t *topnode )
|
||||
continue;
|
||||
}
|
||||
// find which side of the node we are on
|
||||
pplane = psurf->plane;
|
||||
mplane_t *pplane = psurf->plane;
|
||||
|
||||
dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
|
||||
vec_t dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
|
||||
|
||||
// draw the polygon
|
||||
if((( psurf->flags & SURF_PLANEBACK ) && ( dot < -BACKFACE_EPSILON ))
|
||||
@@ -477,12 +466,9 @@ R_RecursiveWorldNode
|
||||
*/
|
||||
static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
{
|
||||
int i, c, side, *pindex;
|
||||
vec3_t acceptpt, rejectpt;
|
||||
mplane_t *plane;
|
||||
msurface_t *surf, **mark;
|
||||
mleaf_t *pleaf;
|
||||
double d, dot;
|
||||
int c, side;
|
||||
vec3_t acceptpt, rejectpt;
|
||||
double d, dot;
|
||||
|
||||
if( node->contents == CONTENTS_SOLID )
|
||||
return; // solid
|
||||
@@ -495,7 +481,7 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
// twice as fast in ASM
|
||||
if( clipflags )
|
||||
{
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
if( !( clipflags & ( 1 << i )))
|
||||
continue; // don't need to clip against it
|
||||
@@ -504,7 +490,7 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
// FIXME: do with fast look-ups or integer tests based on the sign bit
|
||||
// of the floating point values
|
||||
|
||||
pindex = qfrustum.pfrustum_indexes[i];
|
||||
int *pindex = qfrustum.pfrustum_indexes[i];
|
||||
|
||||
rejectpt[0] = (float)node->minmaxs[pindex[0]];
|
||||
rejectpt[1] = (float)node->minmaxs[pindex[1]];
|
||||
@@ -531,9 +517,9 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
// if a leaf node, draw stuff
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
pleaf = (mleaf_t *)node;
|
||||
mleaf_t *pleaf = (mleaf_t *)node;
|
||||
|
||||
mark = pleaf->firstmarksurface;
|
||||
msurface_t **mark = pleaf->firstmarksurface;
|
||||
c = pleaf->nummarksurfaces;
|
||||
|
||||
if( c )
|
||||
@@ -559,12 +545,10 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
}
|
||||
else
|
||||
{
|
||||
int firstsurface;
|
||||
|
||||
// node is just a decision point, so go down the apropriate sides
|
||||
|
||||
// find which side of the node we are on
|
||||
plane = node->plane;
|
||||
mplane_t *plane = node->plane;
|
||||
|
||||
switch( plane->type )
|
||||
{
|
||||
@@ -592,11 +576,11 @@ static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
|
||||
// draw stuff
|
||||
c = node_numsurfaces( node, WORLDMODEL );
|
||||
firstsurface = node_firstsurface( node, WORLDMODEL );
|
||||
int firstsurface = node_firstsurface( node, WORLDMODEL );
|
||||
|
||||
if( c )
|
||||
{
|
||||
surf = WORLDMODEL->surfaces + firstsurface;
|
||||
msurface_t *surf = WORLDMODEL->surfaces + firstsurface;
|
||||
|
||||
if( dot < -BACKFACE_EPSILON )
|
||||
{
|
||||
|
||||
@@ -50,12 +50,10 @@ static void GAME_EXPORT CL_FillRGBA( int rendermode, float _x, float _y, float _
|
||||
|
||||
static void Mod_BrushUnloadTextures( model_t *mod )
|
||||
{
|
||||
int i;
|
||||
|
||||
gEngfuncs.Con_Printf( "Unloading world\n" );
|
||||
tr.map_unload = true;
|
||||
|
||||
for( i = 0; i < mod->numtextures; i++ )
|
||||
for( int i = 0; i < mod->numtextures; i++ )
|
||||
{
|
||||
texture_t *tx = mod->textures[i];
|
||||
if( !tx || tx->gl_texturenum == tr.defaultTexture )
|
||||
@@ -297,13 +295,11 @@ static void GAME_EXPORT R_ShowTextures( void )
|
||||
|
||||
static void GAME_EXPORT R_SetupSky( int *skyboxTextures )
|
||||
{
|
||||
int i;
|
||||
|
||||
// TODO: R_UnloadSkybox();
|
||||
if( !skyboxTextures )
|
||||
return;
|
||||
|
||||
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
|
||||
for( int i = 0; i < SKYBOX_MAX_SIDES; i++ )
|
||||
tr.skyboxTextures[i] = skyboxTextures[i];
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,6 @@ void R_ClearDecals( void )
|
||||
// unlink pdecal from any surface it's attached to
|
||||
static void R_DecalUnlink( decal_t *pdecal )
|
||||
{
|
||||
decal_t *tmp;
|
||||
|
||||
if( pdecal->psurface )
|
||||
{
|
||||
if( pdecal->psurface->pdecals == pdecal )
|
||||
@@ -73,7 +71,7 @@ static void R_DecalUnlink( decal_t *pdecal )
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = pdecal->psurface->pdecals;
|
||||
decal_t *tmp = pdecal->psurface->pdecals;
|
||||
if( !tmp )
|
||||
gEngfuncs.Host_Error( "%s: bad decal list\n", __func__ );
|
||||
|
||||
@@ -293,16 +291,12 @@ static void R_ClipIntersect( float *one, float *two, float *out, int edge )
|
||||
|
||||
static int SHClip( float *vert, int vertCount, float *out, int edge )
|
||||
{
|
||||
int j, outCount;
|
||||
float *s, *p;
|
||||
int outCount = 0;
|
||||
float *s = &vert[( vertCount - 1 ) * VERTEXSIZE];
|
||||
|
||||
outCount = 0;
|
||||
|
||||
s = &vert[( vertCount - 1 ) * VERTEXSIZE];
|
||||
|
||||
for( j = 0; j < vertCount; j++ )
|
||||
for( int j = 0; j < vertCount; j++ )
|
||||
{
|
||||
p = &vert[j * VERTEXSIZE];
|
||||
float *p = &vert[j * VERTEXSIZE];
|
||||
|
||||
if( R_ClipInside( p, edge ))
|
||||
{
|
||||
@@ -343,10 +337,9 @@ static int SHClip( float *vert, int vertCount, float *out, int edge )
|
||||
static float *R_DoDecalSHClip( float *pInVerts, decal_t *pDecal, int nStartVerts, int *pVertCount )
|
||||
{
|
||||
float *pOutVerts = g_DecalClipVerts[0];
|
||||
int outCount;
|
||||
|
||||
// clip the polygon to the decal texture space
|
||||
outCount = SHClip( pInVerts, nStartVerts, g_DecalClipVerts2[0], LEFT_EDGE );
|
||||
int outCount = SHClip( pInVerts, nStartVerts, g_DecalClipVerts2[0], LEFT_EDGE );
|
||||
outCount = SHClip( g_DecalClipVerts2[0], outCount, g_DecalClipVerts[0], RIGHT_EDGE );
|
||||
outCount = SHClip( g_DecalClipVerts[0], outCount, g_DecalClipVerts2[0], TOP_EDGE );
|
||||
outCount = SHClip( g_DecalClipVerts2[0], outCount, pOutVerts, BOTTOM_EDGE );
|
||||
@@ -407,24 +400,22 @@ static void R_DecalVertsLight( float *v, msurface_t *surf, int vertCount )
|
||||
// Check for intersecting decals on this surface
|
||||
static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int *pcount )
|
||||
{
|
||||
int texture;
|
||||
decal_t *plast, *pDecal;
|
||||
decal_t *plast = NULL;
|
||||
vec3_t decalExtents[2];
|
||||
float lastArea = 2;
|
||||
int mapSize[2];
|
||||
|
||||
plast = NULL;
|
||||
*pcount = 0;
|
||||
|
||||
// (Same as R_SetupDecalClip).
|
||||
texture = decalinfo->m_iTexture;
|
||||
int texture = decalinfo->m_iTexture;
|
||||
|
||||
// precalculate the extents of decalinfo's decal in world space.
|
||||
R_GetDecalDimensions( texture, &mapSize[0], &mapSize[1] );
|
||||
VectorScale( decalinfo->m_Basis[0], (( mapSize[0] / decalinfo->m_scale ) * 0.5f ), decalExtents[0] );
|
||||
VectorScale( decalinfo->m_Basis[1], (( mapSize[1] / decalinfo->m_scale ) * 0.5f ), decalExtents[1] );
|
||||
|
||||
pDecal = surf->pdecals;
|
||||
decal_t *pDecal = surf->pdecals;
|
||||
|
||||
while( pDecal )
|
||||
{
|
||||
@@ -495,28 +486,25 @@ creates mesh for decal on first rendering
|
||||
*/
|
||||
static glpoly2_t *R_DecalCreatePoly( decalinfo_t *decalinfo, decal_t *pdecal, msurface_t *surf )
|
||||
{
|
||||
int lnumverts;
|
||||
glpoly2_t *poly;
|
||||
float *v;
|
||||
int i;
|
||||
int lnumverts;
|
||||
|
||||
return NULL;
|
||||
if( pdecal->polys ) // already created?
|
||||
return pdecal->polys;
|
||||
|
||||
v = R_DecalSetupVerts( pdecal, surf, pdecal->texture, &lnumverts );
|
||||
float *v = R_DecalSetupVerts( pdecal, surf, pdecal->texture, &lnumverts );
|
||||
if( !lnumverts )
|
||||
return NULL; // probably this never happens
|
||||
|
||||
// allocate glpoly
|
||||
// REFTODO: com_studiocache pool!
|
||||
poly = Mem_Calloc( r_temppool, sizeof( glpoly2_t ) + lnumverts * VERTEXSIZE * sizeof( float ));
|
||||
glpoly2_t *poly = Mem_Calloc( r_temppool, sizeof( glpoly2_t ) + lnumverts * VERTEXSIZE * sizeof( float ));
|
||||
poly->next = pdecal->polys;
|
||||
poly->flags = surf->flags;
|
||||
pdecal->polys = poly;
|
||||
poly->numverts = lnumverts;
|
||||
|
||||
for( i = 0; i < lnumverts; i++, v += VERTEXSIZE )
|
||||
for( int i = 0; i < lnumverts; i++, v += VERTEXSIZE )
|
||||
{
|
||||
VectorCopy( v, poly->verts[i] );
|
||||
poly->verts[i][3] = v[3];
|
||||
@@ -531,10 +519,8 @@ static glpoly2_t *R_DecalCreatePoly( decalinfo_t *decalinfo, decal_t *pdecal, ms
|
||||
// Add the decal to the surface's list of decals.
|
||||
static void R_AddDecalToSurface( decal_t *pdecal, msurface_t *surf, decalinfo_t *decalinfo )
|
||||
{
|
||||
decal_t *pold;
|
||||
|
||||
pdecal->pnext = NULL;
|
||||
pold = surf->pdecals;
|
||||
decal_t *pold = surf->pdecals;
|
||||
|
||||
if( pold )
|
||||
{
|
||||
@@ -564,17 +550,16 @@ static void R_AddDecalToSurface( decal_t *pdecal, msurface_t *surf, decalinfo_t
|
||||
|
||||
static void R_DecalCreate( decalinfo_t *decalinfo, msurface_t *surf, float x, float y )
|
||||
{
|
||||
decal_t *pdecal, *pold;
|
||||
int count, vertCount;
|
||||
int count, vertCount;
|
||||
|
||||
if( !surf )
|
||||
return; // ???
|
||||
|
||||
pold = R_DecalIntersect( decalinfo, surf, &count );
|
||||
decal_t *pold = R_DecalIntersect( decalinfo, surf, &count );
|
||||
if( count < MAX_OVERLAP_DECALS )
|
||||
pold = NULL;
|
||||
|
||||
pdecal = R_DecalAlloc( pold );
|
||||
decal_t *pdecal = R_DecalAlloc( pold );
|
||||
if( !pdecal )
|
||||
return; // r_decals == 0 ???
|
||||
|
||||
@@ -610,7 +595,6 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
|
||||
mtexinfo_t *tex = surf->texinfo;
|
||||
decal_t *decal = surf->pdecals;
|
||||
vec4_t textureU, textureV;
|
||||
float s, t, w, h;
|
||||
connstate_t state = ENGINE_GET_PARM( PARM_CONNSTATE );
|
||||
|
||||
// we in restore mode
|
||||
@@ -630,8 +614,8 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
|
||||
Vector4Copy( tex->vecs[1], textureV );
|
||||
|
||||
// project decal center into the texture space of the surface
|
||||
s = DotProduct( decalinfo->m_Position, textureU ) + textureU[3] - surf->texturemins[0];
|
||||
t = DotProduct( decalinfo->m_Position, textureV ) + textureV[3] - surf->texturemins[1];
|
||||
float s = DotProduct( decalinfo->m_Position, textureU ) + textureU[3] - surf->texturemins[0];
|
||||
float t = DotProduct( decalinfo->m_Position, textureV ) + textureV[3] - surf->texturemins[1];
|
||||
|
||||
// Determine the decal basis (measured in world space)
|
||||
// Note that the decal basis vectors 0 and 1 will always lie in the same
|
||||
@@ -651,11 +635,11 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
|
||||
// (decalWidth * decalBasis[0], decalHeight * decalBasis[1])
|
||||
// in texture coordinates:
|
||||
|
||||
w = fabs( decalinfo->m_decalWidth * DotProduct( textureU, decalinfo->m_Basis[0] ))
|
||||
+ fabs( decalinfo->m_decalHeight * DotProduct( textureU, decalinfo->m_Basis[1] ));
|
||||
float w = fabs( decalinfo->m_decalWidth * DotProduct( textureU, decalinfo->m_Basis[0] ))
|
||||
+ fabs( decalinfo->m_decalHeight * DotProduct( textureU, decalinfo->m_Basis[1] ));
|
||||
|
||||
h = fabs( decalinfo->m_decalWidth * DotProduct( textureV, decalinfo->m_Basis[0] ))
|
||||
+ fabs( decalinfo->m_decalHeight * DotProduct( textureV, decalinfo->m_Basis[1] ));
|
||||
float h = fabs( decalinfo->m_decalWidth * DotProduct( textureV, decalinfo->m_Basis[0] ))
|
||||
+ fabs( decalinfo->m_decalHeight * DotProduct( textureV, decalinfo->m_Basis[1] ));
|
||||
|
||||
// move s,t to upper left corner
|
||||
s -= ( w * 0.5f );
|
||||
@@ -677,16 +661,12 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
|
||||
static void R_DecalNodeSurfaces( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
{
|
||||
// iterate over all surfaces in the node
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
int firstsurface, numsurfaces;
|
||||
int firstsurface = node_firstsurface( node, model );
|
||||
int numsurfaces = node_numsurfaces( node, model );
|
||||
|
||||
firstsurface = node_firstsurface( node, model );
|
||||
numsurfaces = node_numsurfaces( node, model );
|
||||
msurface_t *surf = model->surfaces + firstsurface;
|
||||
|
||||
surf = model->surfaces + firstsurface;
|
||||
|
||||
for( i = 0; i < numsurfaces; i++, surf++ )
|
||||
for( int i = 0; i < numsurfaces; i++, surf++ )
|
||||
{
|
||||
// never apply decals on the water or sky surfaces
|
||||
if( surf->flags & (SURF_DRAWTURB|SURF_DRAWSKY|SURF_CONVEYOR))
|
||||
@@ -704,17 +684,14 @@ static void R_DecalNodeSurfaces( model_t *model, mnode_t *node, decalinfo_t *dec
|
||||
// -----------------------------------------------------------------------------
|
||||
static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
float dist;
|
||||
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
// hit a leaf
|
||||
return;
|
||||
}
|
||||
|
||||
splitplane = node->plane;
|
||||
dist = DotProduct( decalinfo->m_Position, splitplane->normal ) - splitplane->dist;
|
||||
mplane_t *splitplane = node->plane;
|
||||
float dist = DotProduct( decalinfo->m_Position, splitplane->normal ) - splitplane->dist;
|
||||
|
||||
if( dist > decalinfo->m_Size )
|
||||
{
|
||||
@@ -741,7 +718,6 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
|
||||
cl_entity_t *ent = NULL;
|
||||
model_t *model = NULL;
|
||||
int width, height;
|
||||
hull_t *hull;
|
||||
|
||||
if( textureIndex <= 0 || textureIndex >= MAX_TEXTURES )
|
||||
{
|
||||
@@ -775,7 +751,7 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
|
||||
}
|
||||
|
||||
decalInfo.m_pModel = model;
|
||||
hull = &model->hulls[0]; // always use #0 hull
|
||||
hull_t *hull = &model->hulls[0]; // always use #0 hull
|
||||
|
||||
// NOTE: all the decals at 'first shoot' placed into local space of parent entity
|
||||
// and won't transform again on a next restore, levelchange etc
|
||||
@@ -836,17 +812,17 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
|
||||
float * GAME_EXPORT R_DecalSetupVerts( decal_t *pDecal, msurface_t *surf, int texture, int *outCount )
|
||||
{
|
||||
glpoly2_t *p = pDecal->polys;
|
||||
int i, count;
|
||||
float *v, *v2;
|
||||
int count;
|
||||
float *v;
|
||||
|
||||
if( p )
|
||||
{
|
||||
v = g_DecalClipVerts[0];
|
||||
count = p->numverts;
|
||||
v2 = p->verts[0];
|
||||
float *v2 = p->verts[0];
|
||||
|
||||
// if we have mesh so skip clipping and just copy vertexes out (perf)
|
||||
for( i = 0; i < count; i++, v += VERTEXSIZE, v2 += VERTEXSIZE )
|
||||
for( int i = 0; i < count; i++, v += VERTEXSIZE, v2 += VERTEXSIZE )
|
||||
{
|
||||
VectorCopy( v2, v );
|
||||
v[3] = v2[3];
|
||||
@@ -902,13 +878,11 @@ static qboolean R_DecalUnProject( decal_t *pdecal, decallist_t *entry )
|
||||
// -----------------------------------------------------------------------------
|
||||
static int DecalListAdd( decallist_t *pList, int count )
|
||||
{
|
||||
vec3_t tmp;
|
||||
decallist_t *pdecal;
|
||||
int i;
|
||||
vec3_t tmp;
|
||||
|
||||
pdecal = pList + count;
|
||||
decallist_t *pdecal = pList + count;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
if( !Q_strcmp( pdecal->name, pList[i].name ) && pdecal->entityIndex == pList[i].entityIndex )
|
||||
{
|
||||
@@ -925,10 +899,8 @@ static int DecalListAdd( decallist_t *pList, int count )
|
||||
|
||||
static int DecalDepthCompare( const void *a, const void *b )
|
||||
{
|
||||
const decallist_t *elem1, *elem2;
|
||||
|
||||
elem1 = (const decallist_t *)a;
|
||||
elem2 = (const decallist_t *)b;
|
||||
const decallist_t *elem1 = (const decallist_t *)a;
|
||||
const decallist_t *elem2 = (const decallist_t *)b;
|
||||
|
||||
if( elem1->depth > elem2->depth )
|
||||
return 1;
|
||||
@@ -946,24 +918,22 @@ static int DecalDepthCompare( const void *a, const void *b )
|
||||
int GAME_EXPORT R_CreateDecalList( decallist_t *pList )
|
||||
{
|
||||
int total = 0;
|
||||
int i, depth;
|
||||
|
||||
// return 0; // crash on changelevel. API bug?
|
||||
|
||||
if( WORLDMODEL )
|
||||
{
|
||||
for( i = 0; i < MAX_RENDER_DECALS; i++ )
|
||||
for( int i = 0; i < MAX_RENDER_DECALS; i++ )
|
||||
{
|
||||
decal_t *decal = &gDecalPool[i];
|
||||
decal_t *pdecals;
|
||||
|
||||
// decal is in use and is not a custom decal
|
||||
if( decal->psurface == NULL || FBitSet( decal->flags, FDECAL_DONTSAVE ))
|
||||
continue;
|
||||
|
||||
// compute depth
|
||||
depth = 0;
|
||||
pdecals = decal->psurface->pdecals;
|
||||
int depth = 0;
|
||||
decal_t *pdecals = decal->psurface->pdecals;
|
||||
|
||||
while( pdecals && pdecals != decal )
|
||||
{
|
||||
@@ -1003,15 +973,12 @@ remove all decals with specified texture
|
||||
*/
|
||||
void GAME_EXPORT R_DecalRemoveAll( int textureIndex )
|
||||
{
|
||||
decal_t *pdecal;
|
||||
int i;
|
||||
|
||||
if( textureIndex < 0 || textureIndex >= MAX_TEXTURES )
|
||||
return; // out of bounds
|
||||
|
||||
for( i = 0; i < gDecalCount; i++ )
|
||||
for( int i = 0; i < gDecalCount; i++ )
|
||||
{
|
||||
pdecal = &gDecalPool[i];
|
||||
decal_t *pdecal = &gDecalPool[i];
|
||||
|
||||
// don't remove permanent decals
|
||||
if( FBitSet( pdecal->flags, FDECAL_PERMANENT ))
|
||||
@@ -1031,17 +998,13 @@ remove all decals from specified entity
|
||||
*/
|
||||
void GAME_EXPORT R_EntityRemoveDecals( model_t *mod )
|
||||
{
|
||||
msurface_t *psurf;
|
||||
decal_t *p;
|
||||
int i;
|
||||
|
||||
if( !mod || mod->type != mod_brush )
|
||||
return;
|
||||
|
||||
psurf = &mod->surfaces[mod->firstmodelsurface];
|
||||
for( i = 0; i < mod->nummodelsurfaces; i++, psurf++ )
|
||||
msurface_t *psurf = &mod->surfaces[mod->firstmodelsurface];
|
||||
for( int i = 0; i < mod->nummodelsurfaces; i++, psurf++ )
|
||||
{
|
||||
for( p = psurf->pdecals; p; p = p->pnext )
|
||||
for( decal_t *p = psurf->pdecals; p; p = p->pnext )
|
||||
R_DecalUnlink( p );
|
||||
}
|
||||
}
|
||||
@@ -1056,13 +1019,10 @@ used for full decals restart
|
||||
*/
|
||||
void GAME_EXPORT R_ClearAllDecals( void )
|
||||
{
|
||||
decal_t *pdecal;
|
||||
int i;
|
||||
|
||||
// because gDecalCount may be zeroed after recach the decal limit
|
||||
for( i = 0; i < MAX_RENDER_DECALS; i++ )
|
||||
for( int i = 0; i < MAX_RENDER_DECALS; i++ )
|
||||
{
|
||||
pdecal = &gDecalPool[i];
|
||||
decal_t *pdecal = &gDecalPool[i];
|
||||
R_DecalUnlink( pdecal );
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,8 @@ R_GetImageParms
|
||||
*/
|
||||
void R_GetTextureParms( int *w, int *h, int texnum )
|
||||
{
|
||||
image_t *glt;
|
||||
image_t *glt = R_GetTexture( texnum );
|
||||
|
||||
glt = R_GetTexture( texnum );
|
||||
if( w )
|
||||
*w = glt->srcWidth;
|
||||
if( h )
|
||||
@@ -38,10 +37,9 @@ Draw_StretchPicImplementation
|
||||
*/
|
||||
static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1, int t1, int s2, int t2, image_t *pic )
|
||||
{
|
||||
unsigned int height;
|
||||
int skip, v;
|
||||
qboolean transparent = false;
|
||||
pixel_t *buffer;
|
||||
int skip;
|
||||
qboolean transparent = false;
|
||||
pixel_t *buffer;
|
||||
|
||||
if( x < 0 )
|
||||
{
|
||||
@@ -64,7 +62,7 @@ static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1,
|
||||
|
||||
// gEngfuncs.Con_Printf ("pixels is %p\n", pic->pixels[0] );
|
||||
|
||||
height = h;
|
||||
unsigned int height = h;
|
||||
|
||||
if( y < -h ) // out of display, out of bounds
|
||||
return;
|
||||
@@ -88,18 +86,17 @@ static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1,
|
||||
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for( v = 0; v < height; v++ )
|
||||
for( int v = 0; v < height; v++ )
|
||||
{
|
||||
int alpha1 = vid.alpha;
|
||||
pixel_t *dest = vid.buffer + ( y + v ) * vid.rowbytes + x;
|
||||
uint sv = ( skip + v ) * ( t2 - t1 ) / h + t1;
|
||||
uint u, f, fstep;
|
||||
pixel_t *source = buffer + sv * pic->width + s1;
|
||||
|
||||
f = 0;
|
||||
fstep = (( s2 - s1 ) << 16 ) / w;
|
||||
uint f = 0;
|
||||
uint fstep = (( s2 - s1 ) << 16 ) / w;
|
||||
|
||||
for( u = 0; u < w; u++ )
|
||||
for( uint u = 0; u < w; u++ )
|
||||
{
|
||||
pixel_t src = source[f >> 16];
|
||||
int alpha = alpha1;
|
||||
@@ -161,10 +158,8 @@ void GAME_EXPORT R_DrawStretchPic( float x, float y, float w, float h, float s1,
|
||||
|
||||
void Draw_Fill( int x, int y, int w, int h )
|
||||
{
|
||||
unsigned int height;
|
||||
int v;
|
||||
pixel_t src = vid.color;
|
||||
int alpha = vid.alpha;
|
||||
pixel_t src = vid.color;
|
||||
int alpha = vid.alpha;
|
||||
|
||||
if( x < 0 )
|
||||
x = 0;
|
||||
@@ -181,7 +176,7 @@ void Draw_Fill( int x, int y, int w, int h )
|
||||
if( h <= 0 )
|
||||
return;
|
||||
|
||||
height = h;
|
||||
unsigned int height = h;
|
||||
if( y < 0 )
|
||||
{
|
||||
if( h <= -y )
|
||||
@@ -191,12 +186,11 @@ void Draw_Fill( int x, int y, int w, int h )
|
||||
}
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for( v = 0; v < height; v++ )
|
||||
for( int v = 0; v < height; v++ )
|
||||
{
|
||||
pixel_t *dest = vid.buffer + ( y + v ) * vid.rowbytes + x;
|
||||
uint u;
|
||||
|
||||
for( u = 0; u < w; u++ )
|
||||
for( uint u = 0; u < w; u++ )
|
||||
{
|
||||
if( alpha == 0 )
|
||||
continue;
|
||||
|
||||
@@ -80,8 +80,6 @@ R_BeginEdgeFrame
|
||||
*/
|
||||
void R_BeginEdgeFrame( void )
|
||||
{
|
||||
int v;
|
||||
|
||||
edge_p = r_edges;
|
||||
edge_max = &r_edges[r_numallocatededges];
|
||||
|
||||
@@ -105,7 +103,7 @@ void R_BeginEdgeFrame( void )
|
||||
}
|
||||
|
||||
// FIXME: set with memset
|
||||
for( v = RI.vrect.y; v < RI.vrectbottom; v++ )
|
||||
for( int v = RI.vrect.y; v < RI.vrectbottom; v++ )
|
||||
{
|
||||
newedges[v] = removeedges[v] = NULL;
|
||||
}
|
||||
@@ -250,17 +248,13 @@ R_CleanupSpan
|
||||
*/
|
||||
static void R_CleanupSpan( void )
|
||||
{
|
||||
surf_t *surf;
|
||||
int iu;
|
||||
espan_t *span;
|
||||
|
||||
// now that we've reached the right edge of the screen, we're done with any
|
||||
// unfinished surfaces, so emit a span for whatever's on top
|
||||
surf = surfaces[1].next;
|
||||
iu = edge_tail_u_shift20;
|
||||
surf_t *surf = surfaces[1].next;
|
||||
int iu = edge_tail_u_shift20;
|
||||
if( iu > surf->last_u )
|
||||
{
|
||||
span = span_p++;
|
||||
espan_t *span = span_p++;
|
||||
span->u = surf->last_u;
|
||||
span->count = iu - span->u;
|
||||
span->v = current_iv;
|
||||
@@ -285,12 +279,11 @@ R_LeadingEdgeBackwards
|
||||
*/
|
||||
void R_LeadingEdgeBackwards( edge_t *edge )
|
||||
{
|
||||
espan_t *span;
|
||||
surf_t *surf, *surf2;
|
||||
int iu;
|
||||
surf_t *surf2;
|
||||
int iu;
|
||||
|
||||
// it's adding a new surface in, so find the correct place
|
||||
surf = &surfaces[edge->surfs[1]];
|
||||
surf_t *surf = &surfaces[edge->surfs[1]];
|
||||
|
||||
// don't start a span if this is an inverted span, with the end
|
||||
// edge preceding the start edge (that is, we've already seen the
|
||||
@@ -338,7 +331,7 @@ newtop:
|
||||
|
||||
if( iu > surf2->last_u )
|
||||
{
|
||||
span = span_p++;
|
||||
espan_t *span = span_p++;
|
||||
span->u = surf2->last_u;
|
||||
span->count = iu - span->u;
|
||||
span->v = current_iv;
|
||||
@@ -366,9 +359,6 @@ R_TrailingEdge
|
||||
*/
|
||||
void R_TrailingEdge( surf_t *surf, edge_t *edge )
|
||||
{
|
||||
espan_t *span;
|
||||
int iu;
|
||||
|
||||
// don't generate a span if this is an inverted span, with the end
|
||||
// edge preceding the start edge (that is, we haven't seen the
|
||||
// start edge yet)
|
||||
@@ -377,10 +367,10 @@ void R_TrailingEdge( surf_t *surf, edge_t *edge )
|
||||
if( surf == surfaces[1].next )
|
||||
{
|
||||
// emit a span (current top going away)
|
||||
iu = edge->u >> 20;
|
||||
int iu = edge->u >> 20;
|
||||
if( iu > surf->last_u )
|
||||
{
|
||||
span = span_p++;
|
||||
espan_t *span = span_p++;
|
||||
span->u = surf->last_u;
|
||||
span->count = iu - span->u;
|
||||
span->v = current_iv;
|
||||
@@ -530,20 +520,17 @@ R_GenerateSpans
|
||||
*/
|
||||
void R_GenerateSpans( void )
|
||||
{
|
||||
edge_t *edge;
|
||||
surf_t *surf;
|
||||
|
||||
// clear active surfaces to just the background surface
|
||||
surfaces[1].next = surfaces[1].prev = &surfaces[1];
|
||||
surfaces[1].last_u = edge_head_u_shift20;
|
||||
|
||||
// generate spans
|
||||
for( edge = edge_head.next; edge != &edge_tail; edge = edge->next )
|
||||
for( edge_t *edge = edge_head.next; edge != &edge_tail; edge = edge->next )
|
||||
{
|
||||
if( edge->surfs[0] )
|
||||
{
|
||||
// it has a left surface, so a surface is going away for this span
|
||||
surf = &surfaces[edge->surfs[0]];
|
||||
surf_t *surf = &surfaces[edge->surfs[0]];
|
||||
|
||||
R_TrailingEdge( surf, edge );
|
||||
|
||||
@@ -564,14 +551,12 @@ R_GenerateSpansBackward
|
||||
*/
|
||||
void R_GenerateSpansBackward( void )
|
||||
{
|
||||
edge_t *edge;
|
||||
|
||||
// clear active surfaces to just the background surface
|
||||
surfaces[1].next = surfaces[1].prev = &surfaces[1];
|
||||
surfaces[1].last_u = edge_head_u_shift20;
|
||||
|
||||
// generate spans
|
||||
for( edge = edge_head.next; edge != &edge_tail; edge = edge->next )
|
||||
for( edge_t *edge = edge_head.next; edge != &edge_tail; edge = edge->next )
|
||||
{
|
||||
if( edge->surfs[0] )
|
||||
R_TrailingEdge( &surfaces[edge->surfs[0]], edge );
|
||||
@@ -598,13 +583,11 @@ Each surface has a linked list of its visible spans
|
||||
*/
|
||||
void R_ScanEdges( void )
|
||||
{
|
||||
int iv, bottom;
|
||||
byte basespans[MAXSPANS * sizeof( espan_t ) + CACHE_SIZE];
|
||||
espan_t *basespan_p;
|
||||
surf_t *s;
|
||||
int iv;
|
||||
byte basespans[MAXSPANS * sizeof( espan_t ) + CACHE_SIZE];
|
||||
|
||||
basespan_p = (espan_t *)
|
||||
((uintptr_t)( basespans + CACHE_SIZE - 1 ) & ~( CACHE_SIZE - 1 ));
|
||||
espan_t *basespan_p = (espan_t *)
|
||||
((uintptr_t)( basespans + CACHE_SIZE - 1 ) & ~( CACHE_SIZE - 1 ));
|
||||
max_span_p = &basespan_p[MAXSPANS - RI.vrect.width];
|
||||
|
||||
span_p = basespan_p;
|
||||
@@ -639,7 +622,7 @@ void R_ScanEdges( void )
|
||||
//
|
||||
// process all scan lines
|
||||
//
|
||||
bottom = RI.vrectbottom - 1;
|
||||
int bottom = RI.vrectbottom - 1;
|
||||
|
||||
for( iv = 0; iv < bottom; iv++ )
|
||||
{
|
||||
@@ -662,7 +645,7 @@ void R_ScanEdges( void )
|
||||
D_DrawSurfaces();
|
||||
|
||||
// clear the surface span pointers
|
||||
for( s = &surfaces[1]; s < surface_p; s++ )
|
||||
for( surf_t *s = &surfaces[1]; s < surface_p; s++ )
|
||||
s->spans = NULL;
|
||||
|
||||
span_p = basespan_p;
|
||||
@@ -740,16 +723,11 @@ Simple single color fill with no texture mapping
|
||||
*/
|
||||
static void D_FlatFillSurface( surf_t *surf, int color )
|
||||
{
|
||||
espan_t *span;
|
||||
pixel_t *pdest;
|
||||
int u, u2;
|
||||
|
||||
for( span = surf->spans; span; span = span->pnext )
|
||||
for( espan_t *span = surf->spans; span; span = span->pnext )
|
||||
{
|
||||
pdest = d_viewbuffer + r_screenwidth * span->v;
|
||||
u = span->u;
|
||||
u2 = span->u + span->count - 1;
|
||||
for( ; u <= u2; u++ )
|
||||
pixel_t *pdest = d_viewbuffer + r_screenwidth * span->v;
|
||||
int u2 = span->u + span->count - 1;
|
||||
for( int u = span->u; u <= u2; u++ )
|
||||
pdest[u] = color;
|
||||
}
|
||||
}
|
||||
@@ -762,12 +740,11 @@ D_CalcGradients
|
||||
*/
|
||||
static void D_CalcGradients( msurface_t *pface )
|
||||
{
|
||||
float mipscale;
|
||||
vec3_t p_temp1;
|
||||
vec3_t p_saxis, p_taxis;
|
||||
float t;
|
||||
vec3_t p_temp1;
|
||||
vec3_t p_saxis, p_taxis;
|
||||
float t;
|
||||
|
||||
mipscale = 1.0f / (float)( 1 << miplevel );
|
||||
float mipscale = 1.0f / (float)( 1 << miplevel );
|
||||
|
||||
if( pface->texinfo->flags & TEX_WORLD_LUXELS )
|
||||
{
|
||||
@@ -926,8 +903,6 @@ Normal surface cached, texture mapped surface
|
||||
*/
|
||||
static void D_AlphaSurf( surf_t *s )
|
||||
{
|
||||
int alpha;
|
||||
|
||||
d_zistepu = s->d_zistepu;
|
||||
d_zistepv = s->d_zistepv;
|
||||
d_ziorigin = s->d_ziorigin;
|
||||
@@ -958,7 +933,7 @@ static void D_AlphaSurf( surf_t *s )
|
||||
else
|
||||
miplevel = 0;
|
||||
|
||||
alpha = RI.currententity->curstate.renderamt * 7 / 255;
|
||||
int alpha = RI.currententity->curstate.renderamt * 7 / 255;
|
||||
if( alpha <= 0 && RI.currententity->curstate.renderamt > 0 )
|
||||
alpha = 1;
|
||||
|
||||
@@ -1092,9 +1067,7 @@ To allow developers to see the polygon carving of the world
|
||||
*/
|
||||
static void D_DrawflatSurfaces( void )
|
||||
{
|
||||
surf_t *s;
|
||||
|
||||
for( s = &surfaces[1]; s < surface_p; s++ )
|
||||
for( surf_t *s = &surfaces[1]; s < surface_p; s++ )
|
||||
{
|
||||
if( !s->spans )
|
||||
continue;
|
||||
@@ -1120,8 +1093,6 @@ May be called more than once a frame if the surf list overflows (higher res)
|
||||
*/
|
||||
void D_DrawSurfaces( void )
|
||||
{
|
||||
surf_t *s;
|
||||
|
||||
// currententity = NULL; //&r_worldentity;
|
||||
VectorSubtract( RI.rvp.vieworigin, vec3_origin, tr.modelorg );
|
||||
TransformVector( tr.modelorg, transformed_modelorg );
|
||||
@@ -1129,7 +1100,7 @@ void D_DrawSurfaces( void )
|
||||
|
||||
if( !sw_drawflat.value )
|
||||
{
|
||||
for( s = &surfaces[1]; s < surface_p; s++ )
|
||||
for( surf_t *s = &surfaces[1]; s < surface_p; s++ )
|
||||
{
|
||||
if( !s->spans )
|
||||
continue;
|
||||
|
||||
@@ -346,7 +346,6 @@ static int COUNT_BITS( uint mask )
|
||||
|
||||
static void R_BuildScreenMap( void )
|
||||
{
|
||||
int i;
|
||||
uint rshift = FIRST_BIT( swblit.rmask ), gshift = FIRST_BIT( swblit.gmask ), bshift = FIRST_BIT( swblit.bmask );
|
||||
uint rbits = COUNT_BITS( swblit.rmask ), gbits = COUNT_BITS( swblit.gmask ), bbits = COUNT_BITS( swblit.bmask );
|
||||
uint rmult = BIT( rbits ), gmult = BIT( gbits ), bmult = BIT( bbits );
|
||||
@@ -355,7 +354,7 @@ static void R_BuildScreenMap( void )
|
||||
gEngfuncs.Con_Printf( "Blit table: %d %d %d %d %d %d\n", rmult, gmult, bmult, rdiv, gdiv, bdiv );
|
||||
|
||||
#ifdef SEPARATE_BLIT
|
||||
for( i = 0; i < 256; i++ )
|
||||
for( int i = 0; i < 256; i++ )
|
||||
{
|
||||
unsigned int r, g, b;
|
||||
|
||||
@@ -374,7 +373,7 @@ static void R_BuildScreenMap( void )
|
||||
|
||||
}
|
||||
#else
|
||||
for( i = 0; i < 256; i++ )
|
||||
for( int i = 0; i < 256; i++ )
|
||||
{
|
||||
unsigned int r, g, b, major, j;
|
||||
|
||||
@@ -413,7 +412,6 @@ static void R_BuildBlendMaps( void )
|
||||
{
|
||||
unsigned int r1, g1, b1;
|
||||
unsigned int r2, g2, b2;
|
||||
unsigned int i;
|
||||
|
||||
FOR_EACH_COLOR( 1 ) FOR_EACH_COLOR( 2 )
|
||||
{
|
||||
@@ -439,7 +437,7 @@ static void R_BuildBlendMaps( void )
|
||||
|
||||
vid.modmap[index2 | index1] = r << ( 2 + 3 ) | g << 2 | b;
|
||||
}
|
||||
for( i = 0; i < 8192; i++ )
|
||||
for( unsigned int i = 0; i < 8192; i++ )
|
||||
{
|
||||
unsigned int r, g, b;
|
||||
uint color = i << 3;
|
||||
@@ -471,7 +469,7 @@ static void R_BuildBlendMaps( void )
|
||||
}
|
||||
}
|
||||
|
||||
for( i = 0; i < 1024; i++ )
|
||||
for( unsigned int i = 0; i < 1024; i++ )
|
||||
{
|
||||
unsigned int r, g, b;
|
||||
uint color = i << 6 | BIT( 5 ) | BIT( 4 ) | BIT( 3 );
|
||||
@@ -592,7 +590,6 @@ static qboolean R_AllocScreen( void )
|
||||
|
||||
void R_BlitScreen( void )
|
||||
{
|
||||
int u, v;
|
||||
void *buffer = swblit.pLockBuffer();
|
||||
// gEngfuncs.Con_Printf("blit begin\n");
|
||||
// memset( vid.buffer, 10, vid.width * vid.height );
|
||||
@@ -614,12 +611,12 @@ void R_BlitScreen( void )
|
||||
if( swblit.bpp == 2 )
|
||||
{
|
||||
unsigned short *pbuf = buffer;
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
for( int v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint d = swblit.stride - v - 1;
|
||||
|
||||
for( u = 0; u < vid.width; u++ )
|
||||
for( int u = 0; u < vid.width; u++ )
|
||||
{
|
||||
unsigned int s = vid.screen[vid.buffer[start + u]];
|
||||
pbuf[d] = s;
|
||||
@@ -631,12 +628,12 @@ void R_BlitScreen( void )
|
||||
{
|
||||
unsigned int *pbuf = buffer;
|
||||
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
for( int v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint d = swblit.stride - v - 1;
|
||||
|
||||
for( u = 0; u < vid.width; u++ )
|
||||
for( int u = 0; u < vid.width; u++ )
|
||||
{
|
||||
unsigned int s = vid.screen32[vid.buffer[start + u]];
|
||||
pbuf[d] = s;
|
||||
@@ -647,12 +644,12 @@ void R_BlitScreen( void )
|
||||
else if( swblit.bpp == 3 )
|
||||
{
|
||||
byte *pbuf = buffer;
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
for( int v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint d = swblit.stride - v - 1;
|
||||
|
||||
for( u = 0; u < vid.width; u++ )
|
||||
for( int u = 0; u < vid.width; u++ )
|
||||
{
|
||||
unsigned int s = vid.screen32[vid.buffer[start + u]];
|
||||
pbuf[( d ) * 3] = s;
|
||||
@@ -670,12 +667,12 @@ void R_BlitScreen( void )
|
||||
if( swblit.bpp == 2 )
|
||||
{
|
||||
unsigned short *pbuf = buffer;
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
for( int v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint dstart = swblit.stride * v;
|
||||
|
||||
for( u = 0; u < vid.width; u++ )
|
||||
for( int u = 0; u < vid.width; u++ )
|
||||
{
|
||||
unsigned int s = vid.screen[vid.buffer[start + u]];
|
||||
pbuf[dstart + u] = s;
|
||||
@@ -686,12 +683,12 @@ void R_BlitScreen( void )
|
||||
{
|
||||
unsigned int *pbuf = buffer;
|
||||
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
for( int v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint dstart = swblit.stride * v;
|
||||
|
||||
for( u = 0; u < vid.width; u++ )
|
||||
for( int u = 0; u < vid.width; u++ )
|
||||
{
|
||||
unsigned int s = vid.screen32[vid.buffer[start + u]];
|
||||
pbuf[dstart + u] = s;
|
||||
@@ -701,12 +698,12 @@ void R_BlitScreen( void )
|
||||
else if( swblit.bpp == 3 )
|
||||
{
|
||||
byte *pbuf = buffer;
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
for( int v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint dstart = swblit.stride * v;
|
||||
|
||||
for( u = 0; u < vid.width; u++ )
|
||||
for( int u = 0; u < vid.width; u++ )
|
||||
{
|
||||
unsigned int s = vid.screen32[vid.buffer[start + u]];
|
||||
pbuf[( dstart + u ) * 3] = s;
|
||||
@@ -750,12 +747,10 @@ static uint32_t Get8888PixelAt( int u, int start )
|
||||
|
||||
qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
|
||||
{
|
||||
rgbdata_t *r_shot;
|
||||
uint flags = IMAGE_FLIP_Y;
|
||||
int width = 0, height = 0, u, v;
|
||||
qboolean result;
|
||||
uint flags = IMAGE_FLIP_Y;
|
||||
int width = 0, height = 0;
|
||||
|
||||
r_shot = Mem_Calloc( r_temppool, sizeof( rgbdata_t ));
|
||||
rgbdata_t *r_shot = Mem_Calloc( r_temppool, sizeof( rgbdata_t ));
|
||||
r_shot->width = ( vid.width + 3 ) & ~3;
|
||||
r_shot->height = ( vid.height + 3 ) & ~3;
|
||||
r_shot->flags = IMAGE_HAS_COLOR;
|
||||
@@ -769,12 +764,12 @@ qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
|
||||
{
|
||||
uint32_t *pbuf = (uint32_t *)r_shot->buffer;
|
||||
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
for( int v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * ( vid.height - v - 1 );
|
||||
uint d = swblit.stride - v - 1;
|
||||
|
||||
for( u = 0; u < vid.width; u++ )
|
||||
for( int u = 0; u < vid.width; u++ )
|
||||
{
|
||||
pbuf[d] = Get8888PixelAt( u, start );
|
||||
d += swblit.stride;
|
||||
@@ -785,12 +780,12 @@ qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
|
||||
{
|
||||
uint32_t *pbuf = (uint32_t *)r_shot->buffer;
|
||||
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
for( int v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * ( vid.height - v - 1 );
|
||||
uint dstart = swblit.stride * v;
|
||||
|
||||
for( u = 0; u < vid.width; u++ )
|
||||
for( int u = 0; u < vid.width; u++ )
|
||||
{
|
||||
pbuf[dstart + u] = Get8888PixelAt( u, start );
|
||||
}
|
||||
@@ -820,7 +815,7 @@ qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
|
||||
gEngfuncs.Image_Process( &r_shot, width, height, flags, 0.0f );
|
||||
|
||||
// write image
|
||||
result = gEngfuncs.FS_SaveImage( filename, r_shot );
|
||||
qboolean result = gEngfuncs.FS_SaveImage( filename, r_shot );
|
||||
gEngfuncs.fsapi->AllowDirectPaths( false ); // always reset after store screenshot
|
||||
gEngfuncs.FS_FreeImage( r_shot );
|
||||
|
||||
|
||||
@@ -126,17 +126,14 @@ static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth,
|
||||
{
|
||||
byte *out = in;
|
||||
int instride = ALIGN( srcWidth * 4, 1 );
|
||||
int mipWidth, mipHeight, outpadding;
|
||||
int row, x, y, z;
|
||||
vec3_t normal;
|
||||
|
||||
if( !in )
|
||||
return;
|
||||
|
||||
mipWidth = Q_max( 1, ( srcWidth >> 1 ));
|
||||
mipHeight = Q_max( 1, ( srcHeight >> 1 ));
|
||||
outpadding = ALIGN( mipWidth * 4, 1 ) - mipWidth * 4;
|
||||
row = srcWidth << 2;
|
||||
int mipWidth = Q_max( 1, ( srcWidth >> 1 ));
|
||||
int mipHeight = Q_max( 1, ( srcHeight >> 1 ));
|
||||
int outpadding = ALIGN( mipWidth * 4, 1 ) - mipWidth * 4;
|
||||
|
||||
if( FBitSet( flags, TF_ALPHACONTRAST ))
|
||||
{
|
||||
@@ -145,14 +142,14 @@ static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth,
|
||||
}
|
||||
|
||||
// move through all layers
|
||||
for( z = 0; z < srcDepth; z++ )
|
||||
for( int z = 0; z < srcDepth; z++ )
|
||||
{
|
||||
if( FBitSet( flags, TF_NORMALMAP ))
|
||||
{
|
||||
for( y = 0; y < mipHeight; y++, in += instride * 2, out += outpadding )
|
||||
for( int y = 0; y < mipHeight; y++, in += instride * 2, out += outpadding )
|
||||
{
|
||||
byte *next = ((( y << 1 ) + 1 ) < srcHeight ) ? ( in + instride ) : in;
|
||||
for( x = 0, row = 0; x < mipWidth; x++, row += 8, out += 4 )
|
||||
for( int x = 0, row = 0; x < mipWidth; x++, row += 8, out += 4 )
|
||||
{
|
||||
if((( x << 1 ) + 1 ) < srcWidth )
|
||||
{
|
||||
@@ -182,10 +179,10 @@ static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth,
|
||||
}
|
||||
else
|
||||
{
|
||||
for( y = 0; y < mipHeight; y++, in += instride * 2, out += outpadding )
|
||||
for( int y = 0; y < mipHeight; y++, in += instride * 2, out += outpadding )
|
||||
{
|
||||
byte *next = ((( y << 1 ) + 1 ) < srcHeight ) ? ( in + instride ) : in;
|
||||
for( x = 0, row = 0; x < mipWidth; x++, row += 8, out += 4 )
|
||||
for( int x = 0, row = 0; x < mipWidth; x++, row += 8, out += 4 )
|
||||
{
|
||||
if((( x << 1 ) + 1 ) < srcWidth )
|
||||
{
|
||||
@@ -216,12 +213,8 @@ upload texture into video memory
|
||||
*/
|
||||
static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
|
||||
{
|
||||
byte *buf, *data;
|
||||
size_t texsize;
|
||||
uint width, height;
|
||||
uint i, j;
|
||||
qboolean normalMap = false;
|
||||
int mipCount;
|
||||
byte *data;
|
||||
qboolean normalMap = false;
|
||||
|
||||
tex->fogParams[0] = pic->fogParams[0];
|
||||
tex->fogParams[1] = pic->fogParams[1];
|
||||
@@ -237,9 +230,9 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
|
||||
if( !pic->buffer )
|
||||
return true;
|
||||
|
||||
buf = pic->buffer;
|
||||
byte *buf = pic->buffer;
|
||||
|
||||
mipCount = 4;
|
||||
int mipCount = 4;
|
||||
|
||||
// NOTE: only single uncompressed textures can be resamples, no mips, no layers, no sides
|
||||
if((( pic->width != tex->width ) || ( pic->height != tex->height )))
|
||||
@@ -248,11 +241,11 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
|
||||
data = buf;
|
||||
|
||||
// mips will be auto-generated if desired
|
||||
for( j = 0; j < mipCount; j++ )
|
||||
for( uint j = 0; j < mipCount; j++ )
|
||||
{
|
||||
width = Q_max( 1, ( tex->width >> j ));
|
||||
height = Q_max( 1, ( tex->height >> j ));
|
||||
texsize = GL_CalcTextureSize( width, height, tex->depth );
|
||||
uint width = Q_max( 1, ( tex->width >> j ));
|
||||
uint height = Q_max( 1, ( tex->height >> j ));
|
||||
size_t texsize = GL_CalcTextureSize( width, height, tex->depth );
|
||||
|
||||
// increase size to workaround triangle renderer bugs
|
||||
// it seems to assume memory readable. maybe it was pointed to WAD?
|
||||
@@ -261,7 +254,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
|
||||
if( j == 0 && tex->flags & TF_HAS_ALPHA )
|
||||
tex->alpha_pixels = (pixel_t *)Mem_Calloc( r_temppool, width * height * sizeof( pixel_t ));
|
||||
|
||||
for( i = 0; i < height * width; i++ )
|
||||
for( uint i = 0; i < height * width; i++ )
|
||||
{
|
||||
unsigned int r, g, b, major, minor;
|
||||
// seems to look better
|
||||
@@ -356,12 +349,10 @@ GL_CheckTexName
|
||||
*/
|
||||
static qboolean GL_CheckTexName( const char *name )
|
||||
{
|
||||
int len;
|
||||
|
||||
if( COM_StringEmptyOrNULL( name ))
|
||||
return false;
|
||||
|
||||
len = Q_strlen( name );
|
||||
int len = Q_strlen( name );
|
||||
|
||||
// because multi-layered textures can exceed name string
|
||||
if( len >= sizeof( r_images->name ))
|
||||
@@ -380,13 +371,10 @@ GL_TextureForName
|
||||
*/
|
||||
static image_t *GL_TextureForName( const char *name )
|
||||
{
|
||||
image_t *tex;
|
||||
uint hash;
|
||||
|
||||
// find the texture in array
|
||||
hash = COM_HashKey( name, TEXTURES_HASH_SIZE );
|
||||
uint hash = COM_HashKey( name, TEXTURES_HASH_SIZE );
|
||||
|
||||
for( tex = r_imagesHashTable[hash]; tex != NULL; tex = tex->nextHash )
|
||||
for( image_t *tex = r_imagesHashTable[hash]; tex != NULL; tex = tex->nextHash )
|
||||
{
|
||||
if( !Q_stricmp( tex->name, name ))
|
||||
return tex;
|
||||
@@ -440,10 +428,6 @@ GL_DeleteTexture
|
||||
*/
|
||||
static void GL_DeleteTexture( image_t *tex )
|
||||
{
|
||||
image_t **prev;
|
||||
image_t *cur;
|
||||
int i;
|
||||
|
||||
ASSERT( tex != NULL );
|
||||
|
||||
// already freed?
|
||||
@@ -458,11 +442,11 @@ static void GL_DeleteTexture( image_t *tex )
|
||||
}
|
||||
|
||||
// remove from hash table
|
||||
prev = &r_imagesHashTable[tex->hashValue];
|
||||
image_t **prev = &r_imagesHashTable[tex->hashValue];
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
cur = *prev;
|
||||
image_t *cur = *prev;
|
||||
if( !cur )
|
||||
break;
|
||||
|
||||
@@ -478,7 +462,7 @@ static void GL_DeleteTexture( image_t *tex )
|
||||
if( tex->original )
|
||||
gEngfuncs.FS_FreeImage( tex->original );
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
if( tex->pixels[i] )
|
||||
Mem_Free( tex->pixels[i] );
|
||||
if( tex->alpha_pixels )
|
||||
@@ -496,25 +480,21 @@ recalc image room
|
||||
*/
|
||||
void GAME_EXPORT GL_UpdateTexSize( int texnum, int width, int height, int depth )
|
||||
{
|
||||
int i, j, texsize;
|
||||
int numSides;
|
||||
image_t *tex;
|
||||
|
||||
if( texnum <= 0 || texnum >= MAX_TEXTURES )
|
||||
return;
|
||||
|
||||
tex = &r_images[texnum];
|
||||
numSides = FBitSet( tex->flags, TF_CUBEMAP ) ? 6 : 1;
|
||||
image_t *tex = &r_images[texnum];
|
||||
int numSides = FBitSet( tex->flags, TF_CUBEMAP ) ? 6 : 1;
|
||||
GL_SetTextureDimensions( tex, width, height, depth );
|
||||
tex->size = 0; // recompute now
|
||||
|
||||
for( i = 0; i < numSides; i++ )
|
||||
for( int i = 0; i < numSides; i++ )
|
||||
{
|
||||
for( j = 0; j < Q_max( 1, tex->numMips ); j++ )
|
||||
for( int j = 0; j < Q_max( 1, tex->numMips ); j++ )
|
||||
{
|
||||
width = Q_max( 1, ( tex->width >> j ));
|
||||
height = Q_max( 1, ( tex->height >> j ));
|
||||
texsize = GL_CalcTextureSize( width, height, tex->depth );
|
||||
int texsize = GL_CalcTextureSize( width, height, tex->depth );
|
||||
tex->size += texsize;
|
||||
}
|
||||
}
|
||||
@@ -527,9 +507,8 @@ GL_LoadTexture
|
||||
*/
|
||||
int GAME_EXPORT GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags )
|
||||
{
|
||||
image_t *tex;
|
||||
rgbdata_t *pic;
|
||||
uint picFlags = 0;
|
||||
image_t *tex;
|
||||
uint picFlags = 0;
|
||||
|
||||
if( !GL_CheckTexName( name ))
|
||||
return 0;
|
||||
@@ -547,7 +526,7 @@ int GAME_EXPORT GL_LoadTexture( const char *name, const byte *buf, size_t size,
|
||||
// set some image flags
|
||||
gEngfuncs.Image_SetForceFlags( picFlags );
|
||||
|
||||
pic = gEngfuncs.FS_LoadImage( name, buf, size );
|
||||
rgbdata_t *pic = gEngfuncs.FS_LoadImage( name, buf, size );
|
||||
if( !pic )
|
||||
return 0; // couldn't loading image
|
||||
|
||||
@@ -727,13 +706,11 @@ GL_ProcessTexture
|
||||
*/
|
||||
void GAME_EXPORT GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor )
|
||||
{
|
||||
image_t *image;
|
||||
rgbdata_t *pic;
|
||||
int flags = 0;
|
||||
int flags = 0;
|
||||
|
||||
if( texnum <= 0 || texnum >= MAX_TEXTURES )
|
||||
return; // missed image
|
||||
image = &r_images[texnum];
|
||||
image_t *image = &r_images[texnum];
|
||||
|
||||
// select mode
|
||||
if( gamma != -1.0f )
|
||||
@@ -763,7 +740,7 @@ void GAME_EXPORT GL_ProcessTexture( int texnum, float gamma, int topColor, int b
|
||||
}
|
||||
|
||||
// all the operations makes over the image copy not an original
|
||||
pic = gEngfuncs.FS_CopyImage( image->original );
|
||||
rgbdata_t *pic = gEngfuncs.FS_CopyImage( image->original );
|
||||
|
||||
// we need to expand image into RGBA buffer
|
||||
if( pic->type == PF_INDEXED_24 || pic->type == PF_INDEXED_32 )
|
||||
@@ -785,9 +762,9 @@ return size of all uploaded textures
|
||||
*/
|
||||
int R_TexMemory( void )
|
||||
{
|
||||
int i, total = 0;
|
||||
int total = 0;
|
||||
|
||||
for( i = 0; i < r_numImages; i++ )
|
||||
for( int i = 0; i < r_numImages; i++ )
|
||||
total += r_images[i].size;
|
||||
|
||||
return total;
|
||||
@@ -898,11 +875,10 @@ R_ShutdownImages
|
||||
*/
|
||||
void R_ShutdownImages( void )
|
||||
{
|
||||
image_t *tex;
|
||||
int i;
|
||||
|
||||
gEngfuncs.Cmd_RemoveCommand( "texturelist" );
|
||||
|
||||
image_t *tex;
|
||||
int i;
|
||||
for( i = 0, tex = r_images; i < r_numImages; i++, tex++ )
|
||||
GL_DeleteTexture( tex );
|
||||
|
||||
|
||||
@@ -156,16 +156,13 @@ Sorting translucent entities by rendermode then by distance
|
||||
*/
|
||||
static int R_TransEntityCompare( const cl_entity_t **a, const cl_entity_t **b )
|
||||
{
|
||||
cl_entity_t *ent1, *ent2;
|
||||
vec3_t vecLen, org;
|
||||
float dist1, dist2;
|
||||
int rendermode1;
|
||||
int rendermode2;
|
||||
vec3_t vecLen, org;
|
||||
float dist1, dist2;
|
||||
|
||||
ent1 = (cl_entity_t *)*a;
|
||||
ent2 = (cl_entity_t *)*b;
|
||||
rendermode1 = R_GetEntityRenderMode( ent1 );
|
||||
rendermode2 = R_GetEntityRenderMode( ent2 );
|
||||
cl_entity_t *ent1 = (cl_entity_t *)*a;
|
||||
cl_entity_t *ent2 = (cl_entity_t *)*b;
|
||||
int rendermode1 = R_GetEntityRenderMode( ent1 );
|
||||
int rendermode2 = R_GetEntityRenderMode( ent2 );
|
||||
|
||||
// sort by distance
|
||||
if(( ent1->model && ent1->model->type != mod_brush ) || rendermode1 != kRenderTransAlpha )
|
||||
@@ -214,7 +211,6 @@ int R_WorldToScreen( const vec3_t point, vec3_t screen )
|
||||
{
|
||||
matrix4x4 worldToScreen;
|
||||
qboolean behind;
|
||||
float w;
|
||||
|
||||
if( !point || !screen )
|
||||
return true;
|
||||
@@ -222,7 +218,7 @@ int R_WorldToScreen( const vec3_t point, vec3_t screen )
|
||||
Matrix4x4_Copy( worldToScreen, RI.worldviewProjectionMatrix );
|
||||
screen[0] = worldToScreen[0][0] * point[0] + worldToScreen[0][1] * point[1] + worldToScreen[0][2] * point[2] + worldToScreen[0][3];
|
||||
screen[1] = worldToScreen[1][0] * point[0] + worldToScreen[1][1] * point[1] + worldToScreen[1][2] * point[2] + worldToScreen[1][3];
|
||||
w = worldToScreen[3][0] * point[0] + worldToScreen[3][1] * point[1] + worldToScreen[3][2] * point[2] + worldToScreen[3][3];
|
||||
float w = worldToScreen[3][0] * point[0] + worldToScreen[3][1] * point[1] + worldToScreen[3][2] * point[2] + worldToScreen[3][3];
|
||||
screen[2] = 0.0f; // just so we have something valid here
|
||||
|
||||
if( w < 0.001f )
|
||||
@@ -250,7 +246,6 @@ Convert a given point from screen into world space
|
||||
void GAME_EXPORT R_ScreenToWorld( const vec3_t screen, vec3_t point )
|
||||
{
|
||||
matrix4x4 screenToWorld;
|
||||
float w;
|
||||
|
||||
if( !point || !screen )
|
||||
return;
|
||||
@@ -260,7 +255,7 @@ void GAME_EXPORT R_ScreenToWorld( const vec3_t screen, vec3_t point )
|
||||
point[0] = screen[0] * screenToWorld[0][0] + screen[1] * screenToWorld[0][1] + screen[2] * screenToWorld[0][2] + screenToWorld[0][3];
|
||||
point[1] = screen[0] * screenToWorld[1][0] + screen[1] * screenToWorld[1][1] + screen[2] * screenToWorld[1][2] + screenToWorld[1][3];
|
||||
point[2] = screen[0] * screenToWorld[2][0] + screen[1] * screenToWorld[2][1] + screen[2] * screenToWorld[2][2] + screenToWorld[2][3];
|
||||
w = screen[0] * screenToWorld[3][0] + screen[1] * screenToWorld[3][1] + screen[2] * screenToWorld[3][2] + screenToWorld[3][3];
|
||||
float w = screen[0] * screenToWorld[3][0] + screen[1] * screenToWorld[3][1] + screen[2] * screenToWorld[3][2] + screenToWorld[3][3];
|
||||
if( w != 0.0f )
|
||||
VectorScale( point, ( 1.0f / w ), point );
|
||||
}
|
||||
@@ -508,7 +503,6 @@ R_DrawEntitiesOnList
|
||||
*/
|
||||
static void R_DrawEntitiesOnList( void )
|
||||
{
|
||||
int i;
|
||||
// extern int d_aflatcolor;
|
||||
// d_aflatcolor = 0;
|
||||
tr.blend = 1.0f;
|
||||
@@ -517,7 +511,7 @@ static void R_DrawEntitiesOnList( void )
|
||||
d_pdrawspans = R_PolysetFillSpans8;
|
||||
GL_SetRenderMode( kRenderNormal );
|
||||
// first draw solid entities
|
||||
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||
for( int i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||
{
|
||||
RI.currententity = tr.draw_list->solid_entities[i];
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
@@ -545,7 +539,7 @@ static void R_DrawEntitiesOnList( void )
|
||||
|
||||
R_SetUpWorldTransform();
|
||||
// draw sprites seperately, because of alpha blending
|
||||
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||
for( int i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||
{
|
||||
RI.currententity = tr.draw_list->solid_entities[i];
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
@@ -571,7 +565,7 @@ static void R_DrawEntitiesOnList( void )
|
||||
|
||||
d_pdrawspans = R_PolysetDrawSpans8_33;
|
||||
// then draw translucent entities
|
||||
for( i = 0; i < tr.draw_list->num_trans_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||
for( int i = 0; i < tr.draw_list->num_trans_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||
{
|
||||
RI.currententity = tr.draw_list->trans_entities[i];
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
@@ -636,19 +630,18 @@ R_BmodelCheckBBox
|
||||
*/
|
||||
int R_BmodelCheckBBox( float *minmaxs )
|
||||
{
|
||||
int i, *pindex, clipflags;
|
||||
vec3_t acceptpt, rejectpt;
|
||||
float d;
|
||||
|
||||
clipflags = 0;
|
||||
int clipflags = 0;
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
// generate accept and reject points
|
||||
// FIXME: do with fast look-ups or integer tests based on the sign bit
|
||||
// of the floating point values
|
||||
|
||||
pindex = qfrustum.pfrustum_indexes[i];
|
||||
int *pindex = qfrustum.pfrustum_indexes[i];
|
||||
|
||||
rejectpt[0] = minmaxs[pindex[0]];
|
||||
rejectpt[1] = minmaxs[pindex[1]];
|
||||
@@ -681,11 +674,7 @@ R_FindTopNode
|
||||
*/
|
||||
static mnode_t *R_FindTopnode( vec3_t mins, vec3_t maxs )
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
int sides;
|
||||
mnode_t *node;
|
||||
|
||||
node = WORLDMODEL->nodes;
|
||||
mnode_t *node = WORLDMODEL->nodes;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
@@ -700,8 +689,8 @@ static mnode_t *R_FindTopnode( vec3_t mins, vec3_t maxs )
|
||||
return NULL; // in solid, so not visible
|
||||
}
|
||||
|
||||
splitplane = node->plane;
|
||||
sides = BOX_ON_PLANE_SIDE( mins, maxs, splitplane );
|
||||
mplane_t *splitplane = node->plane;
|
||||
int sides = BOX_ON_PLANE_SIDE( mins, maxs, splitplane );
|
||||
|
||||
if( sides == 3 )
|
||||
return node; // this is the splitter
|
||||
@@ -725,7 +714,6 @@ Returns an axially aligned box that contains the input box at the given rotation
|
||||
void RotatedBBox( vec3_t mins, vec3_t maxs, vec3_t angles, vec3_t tmins, vec3_t tmaxs )
|
||||
{
|
||||
vec3_t tmp, v;
|
||||
int i, j;
|
||||
vec3_t forward, right, up;
|
||||
|
||||
if( !angles[0] && !angles[1] && !angles[2] )
|
||||
@@ -735,7 +723,7 @@ void RotatedBBox( vec3_t mins, vec3_t maxs, vec3_t angles, vec3_t tmins, vec3_t
|
||||
return;
|
||||
}
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
tmins[i] = 99999;
|
||||
tmaxs[i] = -99999;
|
||||
@@ -743,7 +731,7 @@ void RotatedBBox( vec3_t mins, vec3_t maxs, vec3_t angles, vec3_t tmins, vec3_t
|
||||
|
||||
AngleVectors( angles, forward, right, up );
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if( i & 1 )
|
||||
tmp[0] = mins[0];
|
||||
@@ -765,7 +753,7 @@ void RotatedBBox( vec3_t mins, vec3_t maxs, vec3_t angles, vec3_t tmins, vec3_t
|
||||
VectorMA( v, -tmp[1], right, v );
|
||||
VectorMA( v, tmp[2], up, v );
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
if( v[j] < tmins[j] )
|
||||
tmins[j] = v[j];
|
||||
@@ -783,16 +771,14 @@ R_DrawBEntitiesOnList
|
||||
*/
|
||||
static void R_DrawBEntitiesOnList( void )
|
||||
{
|
||||
int i, clipflags;
|
||||
vec3_t oldorigin;
|
||||
vec3_t mins, maxs;
|
||||
float minmaxs[6];
|
||||
mnode_t *topnode;
|
||||
vec3_t oldorigin;
|
||||
vec3_t mins, maxs;
|
||||
float minmaxs[6];
|
||||
|
||||
VectorCopy( tr.modelorg, oldorigin );
|
||||
insubmodel = true;
|
||||
|
||||
for( i = 0; i < tr.draw_list->num_edge_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||
for( int i = 0; i < tr.draw_list->num_edge_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||
{
|
||||
RI.currententity = tr.draw_list->edge_entities[i];
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
@@ -809,12 +795,12 @@ static void R_DrawBEntitiesOnList( void )
|
||||
VectorAdd( mins, RI.currententity->origin, minmaxs );
|
||||
VectorAdd( maxs, RI.currententity->origin, ( minmaxs + 3 ));
|
||||
|
||||
clipflags = R_BmodelCheckBBox( minmaxs );
|
||||
int clipflags = R_BmodelCheckBBox( minmaxs );
|
||||
if( clipflags == BMODEL_FULLY_CLIPPED )
|
||||
continue; // off the edge of the screen
|
||||
// clipflags = 0;
|
||||
|
||||
topnode = R_FindTopnode( minmaxs, minmaxs + 3 );
|
||||
mnode_t *topnode = R_FindTopnode( minmaxs, minmaxs + 3 );
|
||||
if( !topnode )
|
||||
continue; // no part in a visible leaf
|
||||
|
||||
@@ -866,15 +852,13 @@ R_DrawBEntitiesOnList
|
||||
*/
|
||||
void R_DrawBrushModel( cl_entity_t *pent )
|
||||
{
|
||||
int clipflags;
|
||||
vec3_t oldorigin;
|
||||
vec3_t mins, maxs;
|
||||
float minmaxs[6];
|
||||
mnode_t *topnode;
|
||||
edge_t ledges[NUMSTACKEDGES
|
||||
+ (( CACHE_SIZE - 1 ) / sizeof( edge_t )) + 1];
|
||||
surf_t lsurfs[NUMSTACKSURFACES
|
||||
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
|
||||
vec3_t oldorigin;
|
||||
vec3_t mins, maxs;
|
||||
float minmaxs[6];
|
||||
edge_t ledges[NUMSTACKEDGES
|
||||
+ (( CACHE_SIZE - 1 ) / sizeof( edge_t )) + 1];
|
||||
surf_t lsurfs[NUMSTACKSURFACES
|
||||
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
|
||||
|
||||
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||
return;
|
||||
@@ -919,12 +903,12 @@ void R_DrawBrushModel( cl_entity_t *pent )
|
||||
VectorAdd( mins, RI.currententity->origin, minmaxs );
|
||||
VectorAdd( maxs, RI.currententity->origin, ( minmaxs + 3 ));
|
||||
|
||||
clipflags = R_BmodelCheckBBox( minmaxs );
|
||||
int clipflags = R_BmodelCheckBBox( minmaxs );
|
||||
if( clipflags == BMODEL_FULLY_CLIPPED )
|
||||
return; // off the edge of the screen
|
||||
// clipflags = 0;
|
||||
|
||||
topnode = R_FindTopnode( minmaxs, minmaxs + 3 );
|
||||
mnode_t *topnode = R_FindTopnode( minmaxs, minmaxs + 3 );
|
||||
if( !topnode )
|
||||
return; // no part in a visible leaf
|
||||
|
||||
@@ -1029,10 +1013,6 @@ R_MarkLeaves
|
||||
*/
|
||||
static void R_MarkLeaves( void )
|
||||
{
|
||||
byte *vis;
|
||||
mnode_t *node;
|
||||
int i;
|
||||
|
||||
if( r_oldviewcluster == r_viewcluster && !r_novis.value && r_viewcluster != -1 )
|
||||
return;
|
||||
|
||||
@@ -1040,13 +1020,13 @@ static void R_MarkLeaves( void )
|
||||
r_oldviewcluster = r_viewcluster;
|
||||
|
||||
gEngfuncs.R_FatPVS( RI.rvp.vieworigin, r_pvs_radius->value, RI.visbytes, false, false );
|
||||
vis = RI.visbytes;
|
||||
byte *vis = RI.visbytes;
|
||||
|
||||
for( i = 0; i < WORLDMODEL->numleafs; i++ )
|
||||
for( int i = 0; i < WORLDMODEL->numleafs; i++ )
|
||||
{
|
||||
if( vis[i >> 3] & ( 1 << ( i & 7 )))
|
||||
{
|
||||
node = (mnode_t *) &WORLDMODEL->leafs[i + 1];
|
||||
mnode_t *node = (mnode_t *) &WORLDMODEL->leafs[i + 1];
|
||||
do
|
||||
{
|
||||
if( node->visframe == tr.visframecount )
|
||||
@@ -1235,7 +1215,6 @@ R_NewMap
|
||||
*/
|
||||
void GAME_EXPORT R_NewMap( void )
|
||||
{
|
||||
int i;
|
||||
model_t *world = WORLDMODEL;
|
||||
|
||||
r_viewcluster = -1;
|
||||
@@ -1290,12 +1269,12 @@ void GAME_EXPORT R_NewMap( void )
|
||||
}
|
||||
|
||||
// clear out efrags in case the level hasn't been reloaded
|
||||
for( i = 0; i < world->numleafs; i++ )
|
||||
for( int i = 0; i < world->numleafs; i++ )
|
||||
world->leafs[i + 1].efrags = NULL;
|
||||
|
||||
tr.sample_size = gEngfuncs.Mod_SampleSizeForFace( &world->surfaces[0] );
|
||||
|
||||
for( i = 1; i < world->numsurfaces; i++ )
|
||||
for( int i = 1; i < world->numsurfaces; i++ )
|
||||
{
|
||||
int sample_size = gEngfuncs.Mod_SampleSizeForFace( &world->surfaces[i] );
|
||||
if( sample_size != tr.sample_size )
|
||||
@@ -1308,11 +1287,9 @@ void GAME_EXPORT R_NewMap( void )
|
||||
|
||||
if( tr.sample_size != -1 )
|
||||
{
|
||||
uint sample_pot;
|
||||
|
||||
tr.sample_bits = 0;
|
||||
|
||||
for( sample_pot = 1; sample_pot < tr.sample_size; sample_pot <<= 1, tr.sample_bits++ )
|
||||
for( uint sample_pot = 1; sample_pot < tr.sample_size; sample_pot <<= 1, tr.sample_bits++ )
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1327,9 +1304,7 @@ R_InitTurb
|
||||
*/
|
||||
static void R_InitTurb( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 1280; i++ )
|
||||
for( int i = 0; i < 1280; i++ )
|
||||
{
|
||||
sintable[i] = AMP + sin( i * 3.14159 * 2 / CYCLE ) * AMP;
|
||||
blanktable[i] = 0; // PGM
|
||||
@@ -1423,10 +1398,10 @@ CL_FxBlend
|
||||
int CL_FxBlend( cl_entity_t *e )
|
||||
{
|
||||
int blend = 0;
|
||||
float offset, dist;
|
||||
float dist;
|
||||
vec3_t tmp;
|
||||
|
||||
offset = ((int)e->index ) * 363.0f; // Use ent index to de-sync these fx
|
||||
float offset = ((int)e->index ) * 363.0f; // Use ent index to de-sync these fx
|
||||
|
||||
switch( e->curstate.renderfx )
|
||||
{
|
||||
|
||||
@@ -54,8 +54,6 @@ D_ViewChanged
|
||||
|
||||
void D_ViewChanged( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
scale_for_mip = xscale;
|
||||
if( yscale > xscale )
|
||||
scale_for_mip = yscale;
|
||||
@@ -78,7 +76,7 @@ void D_ViewChanged( void )
|
||||
// d_vrectbottom_particle =
|
||||
// gpGlobals->height - d_pix_max;
|
||||
|
||||
for( i = 0; i < vid.height; i++ )
|
||||
for( int i = 0; i < vid.height; i++ )
|
||||
{
|
||||
d_scantable[i] = i * r_screenwidth;
|
||||
zspantable[i] = d_pzbuffer + i * d_zwidth;
|
||||
@@ -102,11 +100,10 @@ R_TransformFrustum
|
||||
*/
|
||||
void R_TransformFrustum( void )
|
||||
{
|
||||
int i;
|
||||
vec3_t v, v2;
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
vec3_t v, v2;
|
||||
|
||||
v[0] = qfrustum.screenedge[i].normal[2];
|
||||
v[1] = -qfrustum.screenedge[i].normal[0];
|
||||
v[2] = qfrustum.screenedge[i].normal[1];
|
||||
@@ -141,13 +138,11 @@ R_SetUpFrustumIndexes
|
||||
*/
|
||||
static void R_SetUpFrustumIndexes( void )
|
||||
{
|
||||
int i, j, *pindex;
|
||||
int *pindex = qfrustum.frustum_indexes;
|
||||
|
||||
pindex = qfrustum.frustum_indexes;
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
if( qfrustum.view_clipplanes[i].normal[j] < 0 )
|
||||
{
|
||||
@@ -177,13 +172,10 @@ Guaranteed to be called before the first refresh
|
||||
*/
|
||||
static void R_ViewChanged( vrect_t *vr )
|
||||
{
|
||||
int i;
|
||||
float verticalFieldOfView, horizontalFieldOfView, xOrigin, yOrigin;
|
||||
|
||||
RI.vrect = *vr;
|
||||
|
||||
horizontalFieldOfView = 2 * tan((float)RI.rvp.fov_x / 360.0f * M_PI_F );
|
||||
verticalFieldOfView = 2 * tan((float)RI.rvp.fov_y / 360.0f * M_PI_F );
|
||||
float horizontalFieldOfView = 2 * tan((float)RI.rvp.fov_x / 360.0f * M_PI_F );
|
||||
float verticalFieldOfView = 2 * tan((float)RI.rvp.fov_y / 360.0f * M_PI_F );
|
||||
|
||||
RI.fvrectx = (float)RI.vrect.x;
|
||||
RI.fvrectx_adj = (float)RI.vrect.x - 0.5f;
|
||||
@@ -208,8 +200,8 @@ static void R_ViewChanged( vrect_t *vr )
|
||||
RI.aliasvrectbottom = RI.aliasvrect.y
|
||||
+ RI.aliasvrect.height;
|
||||
|
||||
xOrigin = XCENTERING;
|
||||
yOrigin = YCENTERING;
|
||||
float xOrigin = XCENTERING;
|
||||
float yOrigin = YCENTERING;
|
||||
#define PLANE_ANYZ 5
|
||||
// values for perspective projection
|
||||
// if math were exact, the values would range from 0.5 to to range+0.5
|
||||
@@ -259,7 +251,7 @@ static void R_ViewChanged( vrect_t *vr )
|
||||
qfrustum.screenedge[3].normal[2] = 1;
|
||||
qfrustum.screenedge[3].type = PLANE_ANYZ;
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
VectorNormalize( qfrustum.screenedge[i].normal );
|
||||
|
||||
D_ViewChanged();
|
||||
@@ -273,7 +265,6 @@ R_SetupFrame
|
||||
*/
|
||||
void R_SetupFrameQ( void )
|
||||
{
|
||||
int i;
|
||||
vrect_t vrect;
|
||||
|
||||
if( r_fullbright->flags & FCVAR_CHANGED )
|
||||
@@ -344,7 +335,7 @@ void R_SetupFrameQ( void )
|
||||
else if( d_minmip < 0 )
|
||||
d_minmip = 0;
|
||||
|
||||
for( i = 0; i < ( NUM_MIPS - 1 ); i++ )
|
||||
for( int i = 0; i < ( NUM_MIPS - 1 ); i++ )
|
||||
d_scalemip[i] = basemip[i] * sw_mipscale.value;
|
||||
|
||||
// d_aflatcolor = 0;
|
||||
|
||||
@@ -47,11 +47,7 @@ update particle color, position, free expired and draw it
|
||||
*/
|
||||
void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_particles, float partsize )
|
||||
{
|
||||
particle_t *p;
|
||||
vec3_t right, up;
|
||||
color24 color;
|
||||
int alpha;
|
||||
float size;
|
||||
vec3_t right, up;
|
||||
|
||||
if( !cl_active_particles )
|
||||
return; // nothing to draw?
|
||||
@@ -65,11 +61,11 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
||||
// pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
// pglDepthMask( GL_FALSE );
|
||||
|
||||
for( p = cl_active_particles; p; p = p->next )
|
||||
for( particle_t *p = cl_active_particles; p; p = p->next )
|
||||
{
|
||||
if(( p->type != pt_blob ) || ( p->unused == 255 ))
|
||||
{
|
||||
size = partsize; // get initial size of particle
|
||||
float size = partsize; // get initial size of particle
|
||||
|
||||
// scale up to keep particles from disappearing
|
||||
size += ( p->org[0] - RI.rvp.vieworigin[0] ) * RI.cull_vforward[0];
|
||||
@@ -86,9 +82,9 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
||||
VectorScale( RI.cull_vup, size, up );
|
||||
|
||||
p->color = bound( 0, p->color, 255 );
|
||||
color = tr.palette[p->color];
|
||||
color24 color = tr.palette[p->color];
|
||||
|
||||
alpha = 255 * ( p->die - gp_cl->time ) * 16.0f;
|
||||
int alpha = 255 * ( p->die - gp_cl->time ) * 16.0f;
|
||||
if( alpha > 255 || p->type == pt_static )
|
||||
alpha = 255;
|
||||
|
||||
@@ -140,10 +136,8 @@ update tracer color, position, free expired and draw it
|
||||
*/
|
||||
void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
|
||||
{
|
||||
float scale, atten, gravity;
|
||||
vec3_t screenLast, screen;
|
||||
vec3_t start, end, delta;
|
||||
particle_t *p;
|
||||
vec3_t screenLast, screen;
|
||||
vec3_t start, end, delta;
|
||||
|
||||
// update tracer color if this is changed
|
||||
if( FBitSet( tracerred->flags | tracergreen->flags | tracerblue->flags | traceralpha->flags, FCVAR_CHANGED ))
|
||||
@@ -171,14 +165,14 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
||||
// pglDisable( GL_ALPHA_TEST );
|
||||
// pglDepthMask( GL_FALSE );
|
||||
|
||||
gravity = frametime * gp_movevars->gravity;
|
||||
scale = 1.0 - ( frametime * 0.9 );
|
||||
float gravity = frametime * gp_movevars->gravity;
|
||||
float scale = 1.0 - ( frametime * 0.9 );
|
||||
if( scale < 0.0f )
|
||||
scale = 0.0f;
|
||||
|
||||
for( p = cl_active_tracers; p; p = p->next )
|
||||
for( particle_t *p = cl_active_tracers; p; p = p->next )
|
||||
{
|
||||
atten = ( p->die - gp_cl->time );
|
||||
float atten = ( p->die - gp_cl->time );
|
||||
if( atten > 0.1f )
|
||||
atten = 0.1f;
|
||||
|
||||
@@ -188,10 +182,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
||||
|
||||
if( !CL_CullTracer( p, start, end ))
|
||||
{
|
||||
vec3_t verts[4], tmp2;
|
||||
vec3_t tmp, normal;
|
||||
color24 color;
|
||||
short alpha = p->unused;
|
||||
vec3_t verts[4], tmp2;
|
||||
vec3_t tmp, normal;
|
||||
short alpha = p->unused;
|
||||
|
||||
// Transform point into screen space
|
||||
TriWorldToScreen( start, screen );
|
||||
@@ -220,7 +213,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
||||
p->color = TRACER_COLORINDEX_DEFAULT;
|
||||
}
|
||||
|
||||
color = gTracerColors[p->color];
|
||||
color24 color = gTracerColors[p->color];
|
||||
// TriColor4ub( color.r, color.g, color.b, p->packedColor );
|
||||
_TriColor4f( 1.0f * alpha / 255 / 255 * color.r, 1.0f * alpha / 255 / 255 * color.g, 1.0f * alpha / 255 / 255 * color.b, 1.0f );
|
||||
|
||||
|
||||
@@ -106,9 +106,7 @@ R_PolysetSetEdgeTable
|
||||
*/
|
||||
static void R_PolysetSetEdgeTable( void )
|
||||
{
|
||||
int edgetableindex;
|
||||
|
||||
edgetableindex = 0; // assume the vertices are already in
|
||||
int edgetableindex = 0; // assume the vertices are already in
|
||||
// top to bottom order
|
||||
|
||||
//
|
||||
@@ -392,18 +390,16 @@ R_RasterizeAliasPolySmooth
|
||||
*/
|
||||
static void R_RasterizeAliasPolySmooth( void )
|
||||
{
|
||||
int initialleftheight, initialrightheight;
|
||||
int *plefttop, *prighttop, *pleftbottom, *prightbottom;
|
||||
int working_lstepx, originalcount;
|
||||
|
||||
plefttop = pedgetable->pleftedgevert0;
|
||||
prighttop = pedgetable->prightedgevert0;
|
||||
int *plefttop = pedgetable->pleftedgevert0;
|
||||
int *prighttop = pedgetable->prightedgevert0;
|
||||
|
||||
pleftbottom = pedgetable->pleftedgevert1;
|
||||
prightbottom = pedgetable->prightedgevert1;
|
||||
int *pleftbottom = pedgetable->pleftedgevert1;
|
||||
int *prightbottom = pedgetable->prightedgevert1;
|
||||
|
||||
initialleftheight = pleftbottom[1] - plefttop[1];
|
||||
initialrightheight = prightbottom[1] - prighttop[1];
|
||||
int initialleftheight = pleftbottom[1] - plefttop[1];
|
||||
int initialrightheight = prightbottom[1] - prighttop[1];
|
||||
|
||||
//
|
||||
// set the s, t, and light gradients, which are consistent across the triangle
|
||||
@@ -641,22 +637,19 @@ void R_DrawTriangle( void )
|
||||
{
|
||||
spanpackage_t spans[DPS_MAXSPANS];
|
||||
|
||||
int dv1_ab, dv0_ac;
|
||||
int dv0_ab, dv1_ac;
|
||||
|
||||
/*
|
||||
d_xdenom = ( aliastriangleparms.a->v[1] - aliastriangleparms.b->v[1] ) * ( aliastriangleparms.a->v[0] - aliastriangleparms.c->v[0] ) -
|
||||
( aliastriangleparms.a->v[0] - aliastriangleparms.b->v[0] ) * ( aliastriangleparms.a->v[1] - aliastriangleparms.c->v[1] );
|
||||
*/
|
||||
|
||||
dv0_ab = aliastriangleparms.a->u - aliastriangleparms.b->u;
|
||||
dv1_ab = aliastriangleparms.a->v - aliastriangleparms.b->v;
|
||||
int dv0_ab = aliastriangleparms.a->u - aliastriangleparms.b->u;
|
||||
int dv1_ab = aliastriangleparms.a->v - aliastriangleparms.b->v;
|
||||
|
||||
if( !( dv0_ab | dv1_ab ))
|
||||
return;
|
||||
|
||||
dv0_ac = aliastriangleparms.a->u - aliastriangleparms.c->u;
|
||||
dv1_ac = aliastriangleparms.a->v - aliastriangleparms.c->v;
|
||||
int dv0_ac = aliastriangleparms.a->u - aliastriangleparms.c->u;
|
||||
int dv1_ac = aliastriangleparms.a->v - aliastriangleparms.c->v;
|
||||
|
||||
if( !( dv0_ac | dv1_ac ))
|
||||
return;
|
||||
|
||||
@@ -362,9 +362,7 @@ R_EmitCachedEdge
|
||||
*/
|
||||
static void R_EmitCachedEdge( void )
|
||||
{
|
||||
edge_t *pedge_t;
|
||||
|
||||
pedge_t = (edge_t *)((uintptr_t)r_edges + r_pedge->cachededgeoffset );
|
||||
edge_t *pedge_t = (edge_t *)((uintptr_t)r_edges + r_pedge->cachededgeoffset );
|
||||
|
||||
if( !pedge_t->surfs[0] )
|
||||
pedge_t->surfs[0] = surface_p - surfaces;
|
||||
@@ -385,13 +383,9 @@ R_RenderFace
|
||||
*/
|
||||
void R_RenderFace( msurface_t *fa, int clipflags )
|
||||
{
|
||||
int i, lindex;
|
||||
unsigned mask;
|
||||
mplane_t *pplane;
|
||||
float distinv;
|
||||
vec3_t p_normal;
|
||||
medge16_t *pedges, tedge;
|
||||
clipplane_t *pclip;
|
||||
int lindex;
|
||||
vec3_t p_normal;
|
||||
medge16_t *pedges, tedge;
|
||||
|
||||
// translucent surfaces are not drawn by the edge renderer
|
||||
if( fa->flags & ( SURF_DRAWTURB | SURF_TRANSPARENT ))
|
||||
@@ -426,9 +420,9 @@ void R_RenderFace( msurface_t *fa, int clipflags )
|
||||
c_faceclip++;
|
||||
|
||||
// set up clip planes
|
||||
pclip = NULL;
|
||||
clipplane_t *pclip = NULL;
|
||||
|
||||
for( i = 3, mask = 0x08; i >= 0; i--, mask >>= 1 )
|
||||
for( int i = 3, mask = 0x08; i >= 0; i--, mask >>= 1 )
|
||||
{
|
||||
if( clipflags & mask )
|
||||
{
|
||||
@@ -445,7 +439,7 @@ void R_RenderFace( msurface_t *fa, int clipflags )
|
||||
pedges = RI.currentmodel->edges16;
|
||||
r_lastvertvalid = false;
|
||||
|
||||
for( i = 0; i < fa->numedges; i++ )
|
||||
for( int i = 0; i < fa->numedges; i++ )
|
||||
{
|
||||
lindex = RI.currentmodel->surfedges[fa->firstedge + i];
|
||||
|
||||
@@ -575,11 +569,11 @@ void R_RenderFace( msurface_t *fa, int clipflags )
|
||||
surface_p->key = r_currentkey++;
|
||||
surface_p->spans = NULL;
|
||||
|
||||
pplane = fa->plane;
|
||||
mplane_t *pplane = fa->plane;
|
||||
// FIXME: cache this?
|
||||
TransformVector( pplane->normal, p_normal );
|
||||
// FIXME: cache this?
|
||||
distinv = 1.0f / ( pplane->dist - DotProduct( tr.modelorg, pplane->normal ));
|
||||
float distinv = 1.0f / ( pplane->dist - DotProduct( tr.modelorg, pplane->normal ));
|
||||
|
||||
surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv;
|
||||
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
|
||||
@@ -598,13 +592,8 @@ R_RenderBmodelFace
|
||||
*/
|
||||
void R_RenderBmodelFace( bedge_t *pedges, msurface_t *psurf )
|
||||
{
|
||||
int i;
|
||||
unsigned mask;
|
||||
mplane_t *pplane;
|
||||
float distinv;
|
||||
vec3_t p_normal;
|
||||
medge16_t tedge;
|
||||
clipplane_t *pclip;
|
||||
vec3_t p_normal;
|
||||
medge16_t tedge;
|
||||
|
||||
/*if (psurf->texinfo->flags & (SURF_TRANS33|SURF_TRANS66))
|
||||
{
|
||||
@@ -633,9 +622,9 @@ void R_RenderBmodelFace( bedge_t *pedges, msurface_t *psurf )
|
||||
r_pedge = &tedge;
|
||||
|
||||
// set up clip planes
|
||||
pclip = NULL;
|
||||
clipplane_t *pclip = NULL;
|
||||
|
||||
for( i = 3, mask = 0x08; i >= 0; i--, mask >>= 1 )
|
||||
for( int i = 3, mask = 0x08; i >= 0; i--, mask >>= 1 )
|
||||
{
|
||||
if( r_clipflags & mask )
|
||||
{
|
||||
@@ -696,11 +685,11 @@ void R_RenderBmodelFace( bedge_t *pedges, msurface_t *psurf )
|
||||
surface_p->key = r_currentbkey;
|
||||
surface_p->spans = NULL;
|
||||
|
||||
pplane = psurf->plane;
|
||||
mplane_t *pplane = psurf->plane;
|
||||
// FIXME: cache this?
|
||||
TransformVector( pplane->normal, p_normal );
|
||||
// FIXME: cache this?
|
||||
distinv = 1.0f / ( pplane->dist - DotProduct( tr.modelorg, pplane->normal ));
|
||||
float distinv = 1.0f / ( pplane->dist - DotProduct( tr.modelorg, pplane->normal ));
|
||||
|
||||
surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv;
|
||||
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
|
||||
|
||||
@@ -1308,30 +1308,23 @@ D_DrawZSpans
|
||||
*/
|
||||
void D_DrawZSpans( espan_t *pspan )
|
||||
{
|
||||
int count, doublecount, izistep;
|
||||
int izi;
|
||||
short *pdest;
|
||||
unsigned ltemp;
|
||||
float zi;
|
||||
float du, dv;
|
||||
|
||||
// FIXME: check for clamping/range problems
|
||||
// we count on FP exceptions being turned off to avoid range problems
|
||||
izistep = (int)( d_zistepu * 0x8000 * 0x10000 );
|
||||
int izistep = (int)( d_zistepu * 0x8000 * 0x10000 );
|
||||
|
||||
do
|
||||
{
|
||||
pdest = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
|
||||
short *pdest = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
|
||||
|
||||
count = pspan->count;
|
||||
int count = pspan->count;
|
||||
|
||||
// calculate the initial 1/z
|
||||
du = (float)pspan->u;
|
||||
dv = (float)pspan->v;
|
||||
float du = (float)pspan->u;
|
||||
float dv = (float)pspan->v;
|
||||
|
||||
zi = d_ziorigin + dv * d_zistepv + du * d_zistepu;
|
||||
float 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 );
|
||||
int izi = (int)( zi * 0x8000 * 0x10000 );
|
||||
|
||||
if((uintptr_t)pdest & 0x02 )
|
||||
{
|
||||
@@ -1340,11 +1333,12 @@ void D_DrawZSpans( espan_t *pspan )
|
||||
count--;
|
||||
}
|
||||
|
||||
int doublecount;
|
||||
if(( doublecount = count >> 1 ) > 0 )
|
||||
{
|
||||
do
|
||||
{
|
||||
ltemp = izi >> 16;
|
||||
unsigned ltemp = izi >> 16;
|
||||
izi += izistep;
|
||||
ltemp |= izi & 0xFFFF0000;
|
||||
izi += izistep;
|
||||
|
||||
@@ -157,15 +157,12 @@ R_DrawSpriteModel
|
||||
void R_DrawSpriteModel( cl_entity_t *e )
|
||||
{
|
||||
mspriteframe_t *frame = NULL;
|
||||
msprite_t *psprite;
|
||||
model_t *model;
|
||||
int i, type;
|
||||
float angle, dot, sr, cr, scale;
|
||||
float angle, dot, sr, cr;
|
||||
vec3_t v_forward, v_right, v_up;
|
||||
vec3_t origin, color;
|
||||
|
||||
model = e->model;
|
||||
psprite = (msprite_t *)model->cache.data;
|
||||
model_t *model = e->model;
|
||||
msprite_t *psprite = (msprite_t *)model->cache.data;
|
||||
VectorCopy( e->origin, origin ); // set render origin
|
||||
|
||||
// do movewith
|
||||
@@ -187,7 +184,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
||||
}
|
||||
}
|
||||
|
||||
scale = e->curstate.scale;
|
||||
float scale = e->curstate.scale;
|
||||
if( !scale )
|
||||
scale = 1.0f;
|
||||
|
||||
@@ -217,7 +214,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
||||
|
||||
frame = gEngfuncs.R_GetSpriteFrame( model, e->curstate.frame, e->angles[YAW] );
|
||||
|
||||
type = psprite->type;
|
||||
int type = psprite->type;
|
||||
|
||||
// automatically roll parallel sprites if requested
|
||||
if( e->angles[ROLL] != 0.0f && type == SPR_FWD_PARALLEL )
|
||||
@@ -246,7 +243,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
||||
case SPR_FWD_PARALLEL_ORIENTED:
|
||||
angle = e->angles[ROLL] * ( M_PI2 / 360.0f );
|
||||
SinCos( angle, &sr, &cr );
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
v_right[i] = ( RI.vright[i] * cr + RI.vup[i] * sr );
|
||||
v_up[i] = RI.vright[i] * -sr + RI.vup[i] * cr;
|
||||
|
||||
@@ -188,11 +188,9 @@ Compute a full bounding box for current sequence
|
||||
*/
|
||||
static qboolean R_StudioComputeBBox( vec3_t bbox[8] )
|
||||
{
|
||||
vec3_t studio_mins, studio_maxs;
|
||||
vec3_t mins, maxs, p1, p2;
|
||||
cl_entity_t *e = RI.currententity;
|
||||
mstudioseqdesc_t *pseqdesc;
|
||||
int i;
|
||||
vec3_t studio_mins, studio_maxs;
|
||||
vec3_t mins, maxs, p1, p2;
|
||||
cl_entity_t *e = RI.currententity;
|
||||
|
||||
if( !m_pStudioHeader )
|
||||
return false;
|
||||
@@ -213,7 +211,7 @@ static qboolean R_StudioComputeBBox( vec3_t bbox[8] )
|
||||
if( e->curstate.sequence < 0 || e->curstate.sequence >= m_pStudioHeader->numseq )
|
||||
e->curstate.sequence = 0;
|
||||
|
||||
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex ) + e->curstate.sequence;
|
||||
mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex ) + e->curstate.sequence;
|
||||
|
||||
// add sequence box to the model box
|
||||
AddPointToBounds( pseqdesc->bbmin, mins, maxs );
|
||||
@@ -221,7 +219,7 @@ static qboolean R_StudioComputeBBox( vec3_t bbox[8] )
|
||||
ClearBounds( studio_mins, studio_maxs );
|
||||
|
||||
// compute a full bounding box
|
||||
for( i = 0; i < 8; i++ )
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
p1[0] = ( i & 1 ) ? mins[0] : maxs[0];
|
||||
p1[1] = ( i & 2 ) ? mins[1] : maxs[1];
|
||||
@@ -241,10 +239,10 @@ static qboolean R_StudioComputeBBox( vec3_t bbox[8] )
|
||||
static void R_StudioComputeSkinMatrix( mstudioboneweight_t *boneweights, matrix3x4 result )
|
||||
{
|
||||
float flWeight0, flWeight1, flWeight2, flWeight3;
|
||||
int i, numbones = 0;
|
||||
int numbones = 0;
|
||||
float flTotal;
|
||||
|
||||
for( i = 0; i < MAXSTUDIOBONEWEIGHTS; i++ )
|
||||
for( int i = 0; i < MAXSTUDIOBONEWEIGHTS; i++ )
|
||||
{
|
||||
if( boneweights->bone[i] != -1 )
|
||||
numbones++;
|
||||
@@ -1000,13 +998,11 @@ StudioSaveBones
|
||||
*/
|
||||
static void R_StudioSaveBones( void )
|
||||
{
|
||||
mstudiobone_t *pbones;
|
||||
int i;
|
||||
mstudiobone_t *pbones = (mstudiobone_t *)((byte *)m_pStudioHeader + m_pStudioHeader->boneindex );
|
||||
|
||||
pbones = (mstudiobone_t *)((byte *)m_pStudioHeader + m_pStudioHeader->boneindex );
|
||||
g_studio.cached_numbones = m_pStudioHeader->numbones;
|
||||
|
||||
for( i = 0; i < m_pStudioHeader->numbones; i++ )
|
||||
for( int i = 0; i < m_pStudioHeader->numbones; i++ )
|
||||
{
|
||||
Matrix3x4_Copy( g_studio.cached_bonestransform[i], g_studio.bonestransform[i] );
|
||||
Matrix3x4_Copy( g_studio.cached_lighttransform[i], g_studio.lighttransform[i] );
|
||||
@@ -1216,15 +1212,13 @@ StudioCalcAttachments
|
||||
*/
|
||||
static void R_StudioCalcAttachments( void )
|
||||
{
|
||||
mstudioattachment_t *pAtt;
|
||||
vec3_t forward, bonepos;
|
||||
vec3_t localOrg, localAng;
|
||||
int i;
|
||||
|
||||
// calculate attachment points
|
||||
pAtt = (mstudioattachment_t *)((byte *)m_pStudioHeader + m_pStudioHeader->attachmentindex );
|
||||
mstudioattachment_t *pAtt = (mstudioattachment_t *)((byte *)m_pStudioHeader + m_pStudioHeader->attachmentindex );
|
||||
|
||||
for( i = 0; i < Q_min( MAXSTUDIOATTACHMENTS, m_pStudioHeader->numattachments ); i++ )
|
||||
for( int i = 0; i < Q_min( MAXSTUDIOATTACHMENTS, m_pStudioHeader->numattachments ); i++ )
|
||||
{
|
||||
Matrix3x4_VectorTransform( g_studio.lighttransform[pAtt[i].bone], pAtt[i].org, RI.currententity->attachment[i] );
|
||||
VectorSubtract( RI.currententity->attachment[i], RI.currententity->origin, localOrg );
|
||||
@@ -1243,14 +1237,12 @@ pfnStudioSetupModel
|
||||
*/
|
||||
static void R_StudioSetupModel( int bodypart, void **ppbodypart, void **ppsubmodel )
|
||||
{
|
||||
int index;
|
||||
|
||||
if( bodypart > m_pStudioHeader->numbodyparts )
|
||||
bodypart = 0;
|
||||
|
||||
m_pBodyPart = (mstudiobodyparts_t *)((byte *)m_pStudioHeader + m_pStudioHeader->bodypartindex ) + bodypart;
|
||||
|
||||
index = RI.currententity->curstate.body / m_pBodyPart->base;
|
||||
int index = RI.currententity->curstate.body / m_pBodyPart->base;
|
||||
index = index % m_pBodyPart->nummodels;
|
||||
|
||||
m_pSubModel = (mstudiomodel_t *)((byte *)m_pStudioHeader + m_pBodyPart->modelindex ) + index;
|
||||
@@ -1370,7 +1362,6 @@ R_StudioSetupLighting
|
||||
static void R_StudioSetupLighting( alight_t *plight )
|
||||
{
|
||||
float scale = 1.0f;
|
||||
int i;
|
||||
|
||||
if( !m_pStudioHeader || !plight )
|
||||
return;
|
||||
@@ -1382,7 +1373,7 @@ static void R_StudioSetupLighting( alight_t *plight )
|
||||
g_studio.shadelight = plight->shadelight;
|
||||
VectorCopy( plight->plightvec, g_studio.lightvec );
|
||||
|
||||
for( i = 0; i < m_pStudioHeader->numbones; i++ )
|
||||
for( int i = 0; i < m_pStudioHeader->numbones; i++ )
|
||||
{
|
||||
Matrix3x4_VectorIRotate( g_studio.lighttransform[i], plight->plightvec, g_studio.blightvec[i] );
|
||||
if( scale > 1.0f )
|
||||
@@ -1461,7 +1452,6 @@ R_LightLambert
|
||||
static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal, const vec3_t color, byte *out )
|
||||
{
|
||||
vec3_t finalLight;
|
||||
int i;
|
||||
|
||||
if( !g_studio.numlocallights )
|
||||
{
|
||||
@@ -1471,7 +1461,7 @@ static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal,
|
||||
|
||||
VectorSet( finalLight, 0, 0, 0 );
|
||||
|
||||
for( i = 0; i < g_studio.numlocallights; i++ )
|
||||
for( int i = 0; i < g_studio.numlocallights; i++ )
|
||||
{
|
||||
float r;
|
||||
|
||||
@@ -1503,7 +1493,7 @@ static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal,
|
||||
|
||||
if( !VectorIsNull( finalLight ))
|
||||
{
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
float c = finalLight[i] + LinearGammaTable( color[i] * 1023.0f );
|
||||
|
||||
@@ -3105,17 +3095,15 @@ Mod_StudioLoadTextures
|
||||
*/
|
||||
void GAME_EXPORT Mod_StudioLoadTextures( model_t *mod, void *data )
|
||||
{
|
||||
studiohdr_t *phdr = (studiohdr_t *)data;
|
||||
mstudiotexture_t *ptexture;
|
||||
int i;
|
||||
studiohdr_t *phdr = (studiohdr_t *)data;
|
||||
|
||||
if( !phdr )
|
||||
return;
|
||||
|
||||
ptexture = (mstudiotexture_t *)(((byte *)phdr ) + phdr->textureindex );
|
||||
mstudiotexture_t *ptexture = (mstudiotexture_t *)(((byte *)phdr ) + phdr->textureindex );
|
||||
if( phdr->textureindex > 0 )
|
||||
{
|
||||
for( i = 0; i < phdr->numtextures; i++ )
|
||||
for( int i = 0; i < phdr->numtextures; i++ )
|
||||
R_StudioLoadTexture( mod, phdr, &ptexture[i] );
|
||||
}
|
||||
}
|
||||
@@ -3127,17 +3115,15 @@ Mod_StudioUnloadTextures
|
||||
*/
|
||||
void Mod_StudioUnloadTextures( void *data )
|
||||
{
|
||||
studiohdr_t *phdr = (studiohdr_t *)data;
|
||||
mstudiotexture_t *ptexture;
|
||||
int i;
|
||||
studiohdr_t *phdr = (studiohdr_t *)data;
|
||||
|
||||
if( !phdr )
|
||||
return;
|
||||
|
||||
ptexture = (mstudiotexture_t *)(((byte *)phdr ) + phdr->textureindex );
|
||||
mstudiotexture_t *ptexture = (mstudiotexture_t *)(((byte *)phdr ) + phdr->textureindex );
|
||||
|
||||
// release all textures
|
||||
for( i = 0; i < phdr->numtextures; i++ )
|
||||
for( int i = 0; i < phdr->numtextures; i++ )
|
||||
{
|
||||
if( ptexture[i].index == tr.defaultTexture )
|
||||
continue;
|
||||
|
||||
@@ -72,19 +72,16 @@ R_AddDynamicLights
|
||||
static void R_AddDynamicLights( const msurface_t *surf )
|
||||
{
|
||||
const mextrasurf_t *info = surf->info;
|
||||
int lnum, smax, tmax;
|
||||
int sample_frac = 1.0;
|
||||
float sample_size;
|
||||
mtexinfo_t *tex;
|
||||
int sample_frac = 1.0;
|
||||
|
||||
// no dlighted surfaces here
|
||||
if( !surf->dlightbits )
|
||||
return;
|
||||
|
||||
sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
|
||||
smax = ( info->lightextents[0] / sample_size ) + 1;
|
||||
tmax = ( info->lightextents[1] / sample_size ) + 1;
|
||||
tex = surf->texinfo;
|
||||
float sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
|
||||
int smax = ( info->lightextents[0] / sample_size ) + 1;
|
||||
int tmax = ( info->lightextents[1] / sample_size ) + 1;
|
||||
mtexinfo_t *tex = surf->texinfo;
|
||||
|
||||
if( FBitSet( tex->flags, TEX_WORLD_LUXELS ))
|
||||
{
|
||||
@@ -96,18 +93,15 @@ static void R_AddDynamicLights( const msurface_t *surf )
|
||||
sample_frac = LM_SAMPLE_SIZE;
|
||||
}
|
||||
|
||||
for( lnum = 0; lnum < MAX_DLIGHTS; lnum++ )
|
||||
for( int lnum = 0; lnum < MAX_DLIGHTS; lnum++ )
|
||||
{
|
||||
dlight_t *dl;
|
||||
vec3_t impact, origin_l;
|
||||
float dist, rad, minlight;
|
||||
float sl, tl;
|
||||
int t, monolight;
|
||||
vec3_t impact, origin_l;
|
||||
float dist;
|
||||
|
||||
if( !FBitSet( surf->dlightbits, BIT( lnum )))
|
||||
continue; // not lit by this light
|
||||
|
||||
dl = &gp_dlights[lnum];
|
||||
dlight_t *dl = &gp_dlights[lnum];
|
||||
|
||||
// transform light origin to local bmodel space
|
||||
if( !tr.modelviewIdentity )
|
||||
@@ -115,12 +109,12 @@ static void R_AddDynamicLights( const msurface_t *surf )
|
||||
else
|
||||
VectorCopy( dl->origin, origin_l );
|
||||
|
||||
rad = dl->radius;
|
||||
float rad = dl->radius;
|
||||
dist = PlaneDiff( origin_l, surf->plane );
|
||||
rad -= fabs( dist );
|
||||
|
||||
// rad is now the highest intensity on the plane
|
||||
minlight = dl->minlight;
|
||||
float minlight = dl->minlight;
|
||||
if( rad < minlight )
|
||||
continue;
|
||||
|
||||
@@ -134,20 +128,19 @@ static void R_AddDynamicLights( const msurface_t *surf )
|
||||
else
|
||||
VectorMA( origin_l, -dist, surf->plane->normal, impact );
|
||||
|
||||
sl = DotProduct( impact, info->lmvecs[0] ) + info->lmvecs[0][3] - info->lightmapmins[0];
|
||||
tl = DotProduct( impact, info->lmvecs[1] ) + info->lmvecs[1][3] - info->lightmapmins[1];
|
||||
float sl = DotProduct( impact, info->lmvecs[0] ) + info->lmvecs[0][3] - info->lightmapmins[0];
|
||||
float tl = DotProduct( impact, info->lmvecs[1] ) + info->lmvecs[1][3] - info->lightmapmins[1];
|
||||
|
||||
monolight = LightToTexGamma(( dl->color.r + dl->color.g + dl->color.b ) / 3 * 4 ) * 3;
|
||||
int monolight = LightToTexGamma(( dl->color.r + dl->color.g + dl->color.b ) / 3 * 4 ) * 3;
|
||||
|
||||
for( t = 0; t < tmax; t++ )
|
||||
for( int t = 0; t < tmax; t++ )
|
||||
{
|
||||
int td = ( tl - sample_size * t ) * sample_frac;
|
||||
int s;
|
||||
|
||||
if( td < 0 )
|
||||
td = -td;
|
||||
|
||||
for( s = 0; s < smax; s++ )
|
||||
for( int s = 0; s < smax; s++ )
|
||||
{
|
||||
int sd = ( sl - sample_size * s ) * sample_frac;
|
||||
float dist;
|
||||
@@ -180,7 +173,6 @@ format in r_blocklights
|
||||
*/
|
||||
static void R_BuildLightMap( void )
|
||||
{
|
||||
int map, t, i;
|
||||
const msurface_t *surf = r_drawsurf.surf;
|
||||
const mextrasurf_t *info = surf->info;
|
||||
const int sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
|
||||
@@ -199,18 +191,16 @@ static void R_BuildLightMap( void )
|
||||
memset( blocklights, 0, sizeof( uint ) * size );
|
||||
|
||||
// add all the lightmaps
|
||||
for( map = 0; map < MAXLIGHTMAPS && surf->samples; map++ )
|
||||
for( int map = 0; map < MAXLIGHTMAPS && surf->samples; map++ )
|
||||
{
|
||||
const color24 *lm = &surf->samples[map * size];
|
||||
uint scale;
|
||||
int i;
|
||||
|
||||
if( surf->styles[map] >= 255 )
|
||||
break;
|
||||
|
||||
scale = g_lightstylevalue[surf->styles[map]];
|
||||
uint scale = g_lightstylevalue[surf->styles[map]];
|
||||
|
||||
for( i = 0; i < size; i++ )
|
||||
for( int i = 0; i < size; i++ )
|
||||
blocklights[i] += ( lm[i].r + lm[i].g + lm[i].b ) * scale;
|
||||
}
|
||||
|
||||
@@ -219,8 +209,9 @@ static void R_BuildLightMap( void )
|
||||
R_AddDynamicLights( surf );
|
||||
|
||||
// bound, invert, and shift
|
||||
for( i = 0; i < size; i++ )
|
||||
for( int i = 0; i < size; i++ )
|
||||
{
|
||||
int t;
|
||||
if( blocklights[i] < 65280 )
|
||||
t = LightToTexGamma( blocklights[i] >> 6 ) << 6;
|
||||
else
|
||||
@@ -248,7 +239,7 @@ Returns the proper texture for a given time and surface
|
||||
static texture_t *R_TextureAnimation( msurface_t *s )
|
||||
{
|
||||
texture_t *base = s->texinfo->texture;
|
||||
int count, reletive;
|
||||
int reletive;
|
||||
|
||||
if( RI.currententity && RI.currententity->curstate.frame )
|
||||
{
|
||||
@@ -279,7 +270,7 @@ static texture_t *R_TextureAnimation( msurface_t *s )
|
||||
reletive = (int)( gp_cl->time * speed ) % base->anim_total;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
int count = 0;
|
||||
|
||||
while( base->anim_min > reletive || base->anim_max <= reletive )
|
||||
{
|
||||
@@ -818,12 +809,10 @@ D_FlushCaches
|
||||
*/
|
||||
void D_FlushCaches( void )
|
||||
{
|
||||
surfcache_t *c;
|
||||
|
||||
// if newmap, surfaces already freed
|
||||
if( !tr.map_unload )
|
||||
{
|
||||
for( c = sc_base; c; c = c->next )
|
||||
for( surfcache_t *c = sc_base; c; c = c->next )
|
||||
{
|
||||
if( c->owner )
|
||||
*c->owner = NULL;
|
||||
@@ -925,9 +914,8 @@ static surfcache_t *D_SCAlloc( int width, int size )
|
||||
static void R_DrawSurfaceDecals( void )
|
||||
{
|
||||
msurface_t *fa = r_drawsurf.surf;
|
||||
decal_t *p;
|
||||
|
||||
for( p = fa->pdecals; p; p = p->pnext )
|
||||
for( decal_t *p = fa->pdecals; p; p = p->pnext )
|
||||
{
|
||||
pixel_t *dest, *source;
|
||||
vec4_t textureU, textureV;
|
||||
@@ -1066,7 +1054,6 @@ D_CacheSurface
|
||||
surfcache_t *D_CacheSurface( msurface_t *surface, int miplevel )
|
||||
{
|
||||
surfcache_t *cache;
|
||||
int maps;
|
||||
//
|
||||
// if the surface is animating or flashing, flush the cache
|
||||
//
|
||||
@@ -1101,7 +1088,7 @@ surfcache_t *D_CacheSurface( msurface_t *surface, int miplevel )
|
||||
cache = CACHESPOT( surface )[miplevel];
|
||||
|
||||
// check for lightmap modification
|
||||
for( maps = 0; maps < MAXLIGHTMAPS && surface->styles[maps] != 255; maps++ )
|
||||
for( int maps = 0; maps < MAXLIGHTMAPS && surface->styles[maps] != 255; maps++ )
|
||||
{
|
||||
if( g_lightstylevalue[surface->styles[maps]] != surface->cached_light[maps] )
|
||||
{
|
||||
@@ -1120,9 +1107,8 @@ surfcache_t *D_CacheSurface( msurface_t *surface, int miplevel )
|
||||
|
||||
if( surface->dlightframe == tr.framecount )
|
||||
{
|
||||
int i;
|
||||
// invalidate dlight cache
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
if( CACHESPOT( surface )[i] )
|
||||
CACHESPOT( surface )[i]->image = NULL;
|
||||
|
||||
@@ -51,7 +51,6 @@ R_SetUpWorldTransform
|
||||
*/
|
||||
void R_SetUpWorldTransform( void )
|
||||
{
|
||||
int i;
|
||||
static float viewmatrix[3][4];
|
||||
vec3_t angles;
|
||||
|
||||
@@ -71,7 +70,7 @@ void R_SetUpWorldTransform( void )
|
||||
memset( aliasworldtransform, 0, sizeof( aliasworldtransform ));
|
||||
memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ));
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][0] = s_alias_forward[i];
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][1] = -s_alias_right[i];
|
||||
@@ -123,14 +122,11 @@ R_AliasProjectAndClipTestFinalVert
|
||||
*/
|
||||
void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv )
|
||||
{
|
||||
float zi;
|
||||
float x, y, z;
|
||||
|
||||
// project points
|
||||
x = fv->xyz[0];
|
||||
y = fv->xyz[1];
|
||||
z = fv->xyz[2];
|
||||
zi = 1.0f / z;
|
||||
float x = fv->xyz[0];
|
||||
float y = fv->xyz[1];
|
||||
float z = fv->xyz[2];
|
||||
float zi = 1.0f / z;
|
||||
|
||||
fv->zi = zi * s_ziscale;
|
||||
|
||||
|
||||
@@ -83,9 +83,6 @@ _TriColor4f
|
||||
void GAME_EXPORT _TriColor4f( float rr, float gg, float bb, float aa )
|
||||
{
|
||||
// pglColor4f( r, g, b, a );
|
||||
unsigned short r, g, b;
|
||||
unsigned int major, minor;
|
||||
|
||||
if( vid.rendermode == kRenderTransAdd || vid.rendermode == kRenderGlow )
|
||||
rr *= aa, gg *= aa, bb *= aa;
|
||||
|
||||
@@ -107,7 +104,7 @@ void GAME_EXPORT _TriColor4f( float rr, float gg, float bb, float aa )
|
||||
vid.color = COLOR_WHITE;
|
||||
return;
|
||||
}
|
||||
r = rr * 31, g = gg * 63, b = bb * 31;
|
||||
unsigned short r = rr * 31, g = gg * 63, b = bb * 31;
|
||||
if( r > 31 )
|
||||
r = 31;
|
||||
if( g > 63 )
|
||||
@@ -116,10 +113,10 @@ void GAME_EXPORT _TriColor4f( float rr, float gg, float bb, float aa )
|
||||
b = 31;
|
||||
|
||||
|
||||
major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
|
||||
unsigned int major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
|
||||
|
||||
// save minor GBRGBRGB
|
||||
minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
|
||||
unsigned int minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
|
||||
|
||||
vid.color = major << 8 | ( minor & 0xFF );
|
||||
}
|
||||
@@ -349,11 +346,9 @@ TriBrightness
|
||||
*/
|
||||
void TriBrightness( float brightness )
|
||||
{
|
||||
float r, g, b;
|
||||
|
||||
r = ds.triRGBA[0] * ds.triRGBA[3] * brightness;
|
||||
g = ds.triRGBA[1] * ds.triRGBA[3] * brightness;
|
||||
b = ds.triRGBA[2] * ds.triRGBA[3] * brightness;
|
||||
float r = ds.triRGBA[0] * ds.triRGBA[3] * brightness;
|
||||
float g = ds.triRGBA[1] * ds.triRGBA[3] * brightness;
|
||||
float b = ds.triRGBA[2] * ds.triRGBA[3] * brightness;
|
||||
|
||||
_TriColor4f( r, g, b, 1.0f );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user