ref: soft: as an experiment, reformat ref_soft as it's easier to notice config inaccuracies

This commit is contained in:
Alibek Omarov 2024-11-06 02:41:38 +03:00
parent fbbafb45a3
commit a52c8aa291
23 changed files with 5299 additions and 5018 deletions

View file

@ -45,8 +45,8 @@ static void R_Alias_clip_z (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *o
{
float scale;
scale = (ALIAS_Z_CLIP_PLANE - pfv0->xyz[2]) /
(pfv1->xyz[2] - pfv0->xyz[2]);
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;
@ -65,8 +65,8 @@ void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
if( pfv0->v >= pfv1->v )
{
scale = (float)(RI.aliasvrect.x - pfv0->u) /
(pfv1->u - pfv0->u);
scale = (float)( RI.aliasvrect.x - pfv0->u )
/ ( pfv1->u - pfv0->u );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
@ -76,8 +76,8 @@ void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
}
else
{
scale = (float)(RI.aliasvrect.x - pfv1->u) /
(pfv0->u - pfv1->u);
scale = (float)( RI.aliasvrect.x - pfv1->u )
/ ( pfv0->u - pfv1->u );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
@ -93,8 +93,8 @@ void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
if( pfv0->v >= pfv1->v )
{
scale = (float)(RI.aliasvrectright - pfv0->u ) /
(pfv1->u - pfv0->u );
scale = (float)( RI.aliasvrectright - pfv0->u )
/ ( pfv1->u - pfv0->u );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
@ -104,8 +104,8 @@ void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
}
else
{
scale = (float)(RI.aliasvrectright - pfv1->u ) /
(pfv0->u - pfv1->u );
scale = (float)( RI.aliasvrectright - pfv1->u )
/ ( pfv0->u - pfv1->u );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
@ -121,8 +121,8 @@ void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
if( pfv0->v >= pfv1->v )
{
scale = (float)(RI.aliasvrect.y - pfv0->v) /
(pfv1->v - pfv0->v);
scale = (float)( RI.aliasvrect.y - pfv0->v )
/ ( pfv1->v - pfv0->v );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
@ -132,8 +132,8 @@ void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
}
else
{
scale = (float)(RI.aliasvrect.y - pfv1->v) /
(pfv0->v - pfv1->v);
scale = (float)( RI.aliasvrect.y - pfv1->v )
/ ( pfv0->v - pfv1->v );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
@ -150,8 +150,8 @@ void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
if( pfv0->v >= pfv1->v )
{
scale = (float)(RI.aliasvrectbottom - pfv0->v) /
(pfv1->v - pfv0->v);
scale = (float)( RI.aliasvrectbottom - pfv0->v )
/ ( pfv1->v - pfv0->v );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
@ -162,8 +162,8 @@ void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
}
else
{
scale = (float)(RI.aliasvrectbottom - pfv1->v) /
(pfv0->v - pfv1->v);
scale = (float)( RI.aliasvrectbottom - pfv1->v )
/ ( pfv0->v - pfv1->v );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;

View file

@ -48,7 +48,8 @@ static void FracNoise( float *noise, int divs )
int div2;
div2 = divs >> 1;
if( divs < 2 ) return;
if( divs < 2 )
return;
// noise is normalized to +/- scale
noise[div2] = ( noise[0] + noise[divs] ) * 0.5f + divs * gEngfuncs.COM_RandomFloat( -0.125f, 0.125f );
@ -200,7 +201,8 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
vec3_t perp1, vLastNormal = { 0.0f };
beamseg_t curSeg;
if( segments < 2 ) return;
if( segments < 2 )
return;
length = VectorLength( delta );
flMaxWidth = width * 0.5f;
@ -210,7 +212,8 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
{
// here, we have too many segments; we could get overlap... so lets have less segments
segments = (int)( length / ( flMaxWidth * 1.414f )) + 1.0f;
if( segments < 2 ) segments = 2;
if( segments < 2 )
segments = 2;
}
if( segments > NOISE_DIVISIONS )
@ -331,8 +334,10 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
if( FBitSet( flags, FBEAM_SHADEIN ) && FBitSet( flags, FBEAM_SHADEOUT ))
{
if( fraction < 0.5f ) brightness = fraction;
else brightness = ( 1.0f - fraction );
if( fraction < 0.5f )
brightness = fraction;
else
brightness = ( 1.0f - fraction );
}
else if( FBitSet( flags, FBEAM_SHADEIN ))
{
@ -386,7 +391,8 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01f;
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
if( length < 0.5f )
length = 0.5f; // don't lose all of the noise/texture on short beams
div = 1.0f / ( segments - 1 );
@ -476,7 +482,8 @@ static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, f
segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01f;
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
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
@ -534,7 +541,8 @@ static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scal
segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01f;
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
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
@ -620,7 +628,8 @@ static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
}
// nothing to draw
if( !particles ) return;
if( !particles )
return;
if( !pnew && div != 0 )
{
@ -755,7 +764,8 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
segments = NOISE_DIVISIONS * 8;
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
if( length < 0.5f )
length = 0.5f; // Don't lose all of the noise/texture on short beams
div = 1.0f / ( segments - 1 );
@ -868,7 +878,8 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
if( beamEnt < 0 )
attach = BEAMENT_ATTACHMENT( -beamEnt );
else attach = BEAMENT_ATTACHMENT( beamEnt );
else
attach = BEAMENT_ATTACHMENT( beamEnt );
if( !ent )
{
@ -882,7 +893,8 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
VectorCopy( ent->attachment[attach - 1], pt );
else if( ent->index == ( gp_cl->playernum + 1 ))
VectorCopy( gp_cl->simorg, pt );
else VectorCopy( ent->origin, pt );
else
VectorCopy( ent->origin, pt );
return true;
}
@ -976,7 +988,8 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
{
if( FBitSet( pbeam->flags, FBEAM_SINENOISE ))
SineNoise( rgNoise, NOISE_DIVISIONS );
else FracNoise( rgNoise, NOISE_DIVISIONS );
else
FracNoise( rgNoise, NOISE_DIVISIONS );
}
// update end points
@ -998,7 +1011,8 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
if( pbeam->amplitude >= 0.50f )
pbeam->segments = VectorLength( pbeam->delta ) * 0.25f + 3.0f; // one per 4 pixels
else pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
else
pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
}
if( pbeam->type == TE_BEAMPOINTS && R_BeamCull( pbeam->source, pbeam->target, 0 ))
@ -1017,7 +1031,8 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
{
// update life cycle
pbeam->t = pbeam->freq + ( pbeam->die - gp_cl->time );
if( pbeam->t != 0.0f ) pbeam->t = 1.0f - pbeam->freq / pbeam->t;
if( pbeam->t != 0.0f )
pbeam->t = 1.0f - pbeam->freq / pbeam->t;
}
if( pbeam->type == TE_BEAMHOSE )
@ -1050,8 +1065,10 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
if( flDistance > 30 )
{
flDistance = 1.0f - (( flDistance - 30.0f ) / 64.0f );
if( flDistance <= 0 ) flFade = 0;
else flFade *= pow( flDistance, 3 );
if( flDistance <= 0 )
flFade = 0;
else
flFade *= pow( flDistance, 3 );
}
if( flFade < ( 1.0f / 255.0f ))
@ -1084,7 +1101,8 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->t * pbeam->brightness );
else if( FBitSet( pbeam->flags, FBEAM_FADEOUT ))
TriColor4f( pbeam->r, pbeam->g, pbeam->b, ( 1.0f - pbeam->t ) * pbeam->brightness );
else TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->brightness );
else
TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->brightness );
switch( pbeam->type )
{
@ -1157,7 +1175,8 @@ static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex,
{
model_t *sprite = CL_ModelHandle( modelIndex );
if( !sprite ) return;
if( !sprite )
return;
pbeam->type = BEAM_POINTS;
pbeam->modelIndex = modelIndex;
@ -1178,7 +1197,8 @@ static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex,
if( amplitude >= 0.50f )
pbeam->segments = VectorLength( pbeam->delta ) * 0.25f + 3.0f; // one per 4 pixels
else pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
else
pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
pbeam->pFollowModel = NULL;
pbeam->flags = 0;

View file

@ -53,24 +53,24 @@ R_ConcatRotations
*/
static void R_ConcatRotations( float in1[3][3], float in2[3][3], float out[3][3] )
{
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
in1[0][2] * in2[2][0];
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
in1[0][2] * in2[2][1];
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
in1[0][2] * in2[2][2];
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
in1[1][2] * in2[2][0];
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
in1[1][2] * in2[2][1];
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
in1[1][2] * in2[2][2];
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
in1[2][2] * in2[2][0];
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
in1[2][2] * in2[2][1];
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
in1[2][2] * in2[2][2];
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0]
+ in1[0][2] * in2[2][0];
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1]
+ in1[0][2] * in2[2][1];
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2]
+ in1[0][2] * in2[2][2];
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0]
+ in1[1][2] * in2[2][0];
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1]
+ in1[1][2] * in2[2][1];
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2]
+ in1[1][2] * in2[2][2];
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0]
+ in1[2][2] * in2[2][0];
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1]
+ in1[2][2] * in2[2][1];
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2]
+ in1[2][2] * in2[2][2];
}
@ -191,8 +191,8 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
// transform the BSP plane into model space
// FIXME: cache these?
splitplane = pnode->plane;
tplane.dist = splitplane->dist -
DotProduct(r_entorigin, splitplane->normal);
tplane.dist = splitplane->dist
- DotProduct( r_entorigin, splitplane->normal );
tplane.normal[0] = DotProduct( entity_rotation[0], splitplane->normal );
tplane.normal[1] = DotProduct( entity_rotation[1], splitplane->normal );
tplane.normal[2] = DotProduct( entity_rotation[2], splitplane->normal );
@ -205,8 +205,8 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
// set the status for the last point as the previous point
// FIXME: cache this stuff somehow?
plastvert = pedges->v[0];
lastdist = DotProduct (plastvert->position, tplane.normal) -
tplane.dist;
lastdist = DotProduct( plastvert->position, tplane.normal )
- tplane.dist;
if( lastdist > 0 )
lastside = 0;
@ -231,15 +231,15 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
// generate the clipped vertex
frac = lastdist / ( lastdist - dist );
ptvert = &pbverts[numbverts++];
ptvert->position[0] = plastvert->position[0] +
frac * (pvert->position[0] -
plastvert->position[0]);
ptvert->position[1] = plastvert->position[1] +
frac * (pvert->position[1] -
plastvert->position[1]);
ptvert->position[2] = plastvert->position[2] +
frac * (pvert->position[2] -
plastvert->position[2]);
ptvert->position[0] = plastvert->position[0]
+ frac * ( pvert->position[0]
- plastvert->position[0] );
ptvert->position[1] = plastvert->position[1]
+ frac * ( pvert->position[1]
- plastvert->position[1] );
ptvert->position[2] = plastvert->position[2]
+ frac * ( pvert->position[2]
- plastvert->position[2] );
// split into two edges, one on each side, and remember entering
// and exiting points
@ -379,8 +379,8 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
// draw the polygon
if (( !(psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
((psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
if(( !( psurf->flags & SURF_PLANEBACK ) && ( dot < -BACKFACE_EPSILON ))
|| (( psurf->flags & SURF_PLANEBACK ) && ( dot > BACKFACE_EPSILON )))
continue;
// FIXME: use bounding-box-based frustum clipping info?
@ -461,8 +461,8 @@ void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags, mnode_t *topnode)
dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
// draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
if((( psurf->flags & SURF_PLANEBACK ) && ( dot < -BACKFACE_EPSILON ))
|| ( !( psurf->flags & SURF_PLANEBACK ) && ( dot > BACKFACE_EPSILON )))
{
r_currentkey = LEAF_KEY(((mleaf_t *)topnode ));
@ -549,7 +549,8 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
{
( *mark )->visframe = tr.framecount;
mark++;
} while (--c);
}
while( --c );
}
// deal with model fragments in this leaf
@ -605,27 +606,29 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
{
do
{
if ((surf->flags & SURF_PLANEBACK) &&
(surf->visframe == tr.framecount))
if(( surf->flags & SURF_PLANEBACK )
&& ( surf->visframe == tr.framecount ))
{
R_RenderFace( surf, clipflags );
}
surf++;
} while (--c);
}
while( --c );
}
else if( dot > BACKFACE_EPSILON )
{
do
{
if (!(surf->flags & SURF_PLANEBACK) &&
(surf->visframe == tr.framecount))
if( !( surf->flags & SURF_PLANEBACK )
&& ( surf->visframe == tr.framecount ))
{
R_RenderFace( surf, clipflags );
}
surf++;
} while (--c);
}
while( --c );
}
// all surfaces on the same node share the same sequence number

View file

@ -176,18 +176,24 @@ static void GAME_EXPORT R_GetDetailScaleForTexture( int texture, float *xScale,
{
image_t *glt = R_GetTexture( texture );
if( xScale ) *xScale = glt->xscale;
if( yScale ) *yScale = glt->yscale;
if( xScale )
*xScale = glt->xscale;
if( yScale )
*yScale = glt->yscale;
}
static void GAME_EXPORT R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
{
image_t *glt = R_GetTexture( texture );
if( red ) *red = glt->fogParams[0];
if( green ) *green = glt->fogParams[1];
if( blue ) *blue = glt->fogParams[2];
if( density ) *density = glt->fogParams[3];
if( red )
*red = glt->fogParams[0];
if( green )
*green = glt->fogParams[1];
if( blue )
*blue = glt->fogParams[2];
if( density )
*density = glt->fogParams[3];
}

View file

@ -74,7 +74,8 @@ static void R_DecalUnlink( decal_t *pdecal )
else
{
tmp = pdecal->psurface->pdecals;
if( !tmp ) gEngfuncs.Host_Error( "%s: bad decal list\n", __func__ );
if( !tmp )
gEngfuncs.Host_Error( "%s: bad decal list\n", __func__ );
while( tmp->pnext )
{
@ -105,7 +106,8 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
if( r_decals->value < limit )
limit = r_decals->value;
if( !limit ) return NULL;
if( !limit )
return NULL;
if( !pdecal )
{
@ -120,7 +122,8 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
pdecal = &gDecalPool[gDecalCount]; // reuse next decal
gDecalCount++;
count++;
} while( FBitSet( pdecal->flags, FDECAL_PERMANENT ) && count < limit );
}
while( FBitSet( pdecal->flags, FDECAL_PERMANENT ) && count < limit );
}
// if decal is already linked to a surface, unlink it.
@ -134,8 +137,10 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
// -----------------------------------------------------------------------------
static void R_GetDecalDimensions( int texture, int *width, int *height )
{
if( width ) *width = 1; // to avoid divide by zero
if( height ) *height = 1;
if( width )
*width = 1; // to avoid divide by zero
if( height )
*height = 1;
R_GetTextureParms( width, height, texture );
}
@ -150,7 +155,8 @@ void R_DecalComputeBasis( msurface_t *surf, int flags, vec3_t textureSpaceBasis[
// setup normal
if( surf->flags & SURF_PLANEBACK )
VectorNegate( surf->plane->normal, surfaceNormal );
else VectorCopy( surf->plane->normal, surfaceNormal );
else
VectorCopy( surf->plane->normal, surfaceNormal );
VectorNormalize2( surfaceNormal, textureSpaceBasis[2] );
VectorNormalize2( surf->texinfo->vecs[0], textureSpaceBasis[0] );
@ -501,7 +507,8 @@ static glpoly2_t *R_DecalCreatePoly( decalinfo_t *decalinfo, decal_t *pdecal, ms
return pdecal->polys;
v = R_DecalSetupVerts( pdecal, surf, pdecal->texture, &lnumverts );
if( !lnumverts ) return NULL; // probably this never happens
if( !lnumverts )
return NULL; // probably this never happens
// allocate glpoly
// REFTODO: com_studiocache pool!
@ -562,13 +569,16 @@ static void R_DecalCreate( decalinfo_t *decalinfo, msurface_t *surf, float x, fl
decal_t *pdecal, *pold;
int count, vertCount;
if( !surf ) return; // ???
if( !surf )
return; // ???
pold = R_DecalIntersect( decalinfo, surf, &count );
if( count < MAX_OVERLAP_DECALS ) pold = NULL;
if( count < MAX_OVERLAP_DECALS )
pold = NULL;
pdecal = R_DecalAlloc( pold );
if( !pdecal ) return; // r_decals == 0 ???
if( !pdecal )
return; // r_decals == 0 ???
pdecal->flags = decalinfo->m_Flags;
@ -643,11 +653,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] ));
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] ));
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 );
@ -754,15 +764,20 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
{
ent = CL_GetEntityByIndex( entityIndex );
if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
else return;
if( modelIndex > 0 )
model = CL_ModelHandle( modelIndex );
else if( ent != NULL )
model = CL_ModelHandle( ent->curstate.modelindex );
else
return;
}
else if( modelIndex > 0 )
model = CL_ModelHandle( modelIndex );
else model = WORLDMODEL;
else
model = WORLDMODEL;
if( !model ) return;
if( !model )
return;
if( model->type != mod_brush )
{
@ -884,7 +899,8 @@ static qboolean R_DecalUnProject( decal_t *pdecal, decallist_t *entry )
// Grab surface plane equation
if( pdecal->psurface->flags & SURF_PLANEBACK )
VectorNegate( pdecal->psurface->plane->normal, entry->impactPlaneNormal );
else VectorCopy( pdecal->psurface->plane->normal, entry->impactPlaneNormal );
else
VectorCopy( pdecal->psurface->plane->normal, entry->impactPlaneNormal );
return true;
}

View file

@ -25,8 +25,10 @@ void R_GetTextureParms( int *w, int *h, int texnum )
image_t *glt;
glt = R_GetTexture( texnum );
if( w ) *w = glt->srcWidth;
if( h ) *h = glt->srcHeight;
if( w )
*w = glt->srcWidth;
if( h )
*h = glt->srcHeight;
}
/*
@ -41,12 +43,16 @@ void GAME_EXPORT R_GetSpriteParms( int *frameWidth, int *frameHeight, int *numFr
{
mspriteframe_t *pFrame;
if( !pSprite || pSprite->type != mod_sprite ) return; // bad model ?
if( !pSprite || pSprite->type != mod_sprite )
return; // bad model ?
pFrame = R_GetSpriteFrame( pSprite, currentFrame, 0.0f );
if( frameWidth ) *frameWidth = pFrame->width;
if( frameHeight ) *frameHeight = pFrame->height;
if( numFrames ) *numFrames = pSprite->numframes;
if( frameWidth )
*frameWidth = pFrame->width;
if( frameHeight )
*frameHeight = pFrame->height;
if( numFrames )
*numFrames = pSprite->numframes;
}
int GAME_EXPORT R_GetSpriteTexture( const model_t *m_pSpriteModel, int frame )

View file

@ -158,7 +158,8 @@ addedge:
edgestoadd->prev = edgelist->prev;
edgelist->prev->next = edgestoadd;
edgelist->prev = edgestoadd;
} while ((edgestoadd = next_edge) != NULL);
}
while(( edgestoadd = next_edge ) != NULL );
}
/*
@ -173,7 +174,8 @@ static void R_RemoveEdges (edge_t *pedge)
{
pedge->next->prev = pedge->prev;
pedge->prev->next = pedge->next;
} while ((pedge = pedge->nextremove) != NULL);
}
while(( pedge = pedge->nextremove ) != NULL );
}
/*
@ -275,7 +277,8 @@ static void R_CleanupSpan (void)
{
surf->spanstate = 0;
surf = surf->next;
} while (surf != &surfaces[1]);
}
while( surf != &surfaces[1] );
}
@ -317,7 +320,8 @@ continue_search:
do
{
surf2 = surf2->next;
} while (surf->key < surf2->key);
}
while( surf->key < surf2->key );
if( surf->key == surf2->key )
{
@ -430,12 +434,12 @@ void R_LeadingEdge (edge_t *edge)
{
// must be two bmodels in the same leaf; sort on 1/z
fu = (float)( edge->u - 0xFFFFF ) * ( 1.0f / 0x100000 );
newzi = surf->d_ziorigin + fv*surf->d_zistepv +
fu*surf->d_zistepu;
newzi = surf->d_ziorigin + fv * surf->d_zistepv
+ fu * surf->d_zistepu;
newzibottom = newzi * 0.99f;
testzi = surf2->d_ziorigin + fv*surf2->d_zistepv +
fu*surf2->d_zistepu;
testzi = surf2->d_ziorigin + fv * surf2->d_zistepv
+ fu * surf2->d_zistepu;
if( newzibottom >= testzi )
{
@ -457,7 +461,8 @@ continue_search:
do
{
surf2 = surf2->next;
} while (surf->key > surf2->key);
}
while( surf->key > surf2->key );
if( surf->key == surf2->key )
{
@ -468,12 +473,12 @@ continue_search:
// must be two bmodels in the same leaf; sort on 1/z
fu = (float)( edge->u - 0xFFFFF ) * ( 1.0f / 0x100000 );
newzi = surf->d_ziorigin + fv*surf->d_zistepv +
fu*surf->d_zistepu;
newzi = surf->d_ziorigin + fv * surf->d_zistepv
+ fu * surf->d_zistepu;
newzibottom = newzi * 0.99f;
testzi = surf2->d_ziorigin + fv*surf2->d_zistepv +
fu*surf2->d_zistepu;
testzi = surf2->d_ziorigin + fv * surf2->d_zistepv
+ fu * surf2->d_zistepu;
if( newzibottom >= testzi )
{
@ -791,30 +796,30 @@ static void D_CalcGradients (msurface_t *pface)
d_sdivzstepv = -p_saxis[1] * t;
d_tdivzstepv = -p_taxis[1] * t;
d_sdivzorigin = p_saxis[2] * mipscale - xcenter * d_sdivzstepu -
ycenter * d_sdivzstepv;
d_tdivzorigin = p_taxis[2] * mipscale - xcenter * d_tdivzstepu -
ycenter * d_tdivzstepv;
d_sdivzorigin = p_saxis[2] * mipscale - xcenter * d_sdivzstepu
- ycenter * d_sdivzstepv;
d_tdivzorigin = p_taxis[2] * mipscale - xcenter * d_tdivzstepu
- ycenter * d_tdivzstepv;
VectorScale( transformed_modelorg, mipscale, p_temp1 );
t = 0x10000 * mipscale;
if( pface->texinfo->flags & TEX_WORLD_LUXELS )
{
sadjust = ((fixed16_t)(DotProduct (p_temp1, p_saxis) * 0x10000 + 0.5f)) -
((pface->texturemins[0] << 16) >> miplevel)
sadjust = ((fixed16_t)( DotProduct( p_temp1, p_saxis ) * 0x10000 + 0.5f ))
- (( pface->texturemins[0] << 16 ) >> miplevel )
+ pface->texinfo->vecs[0][3] * t;
tadjust = ((fixed16_t)(DotProduct (p_temp1, p_taxis) * 0x10000 + 0.5f)) -
((pface->texturemins[1] << 16) >> miplevel)
tadjust = ((fixed16_t)( DotProduct( p_temp1, p_taxis ) * 0x10000 + 0.5f ))
- (( pface->texturemins[1] << 16 ) >> miplevel )
+ pface->texinfo->vecs[1][3] * t;
}
else
{
sadjust = ((fixed16_t)(DotProduct (p_temp1, p_saxis) * 0x10000 + 0.5f)) -
((pface->info->lightmapmins[0] << 16) >> miplevel)
sadjust = ((fixed16_t)( DotProduct( p_temp1, p_saxis ) * 0x10000 + 0.5f ))
- (( pface->info->lightmapmins[0] << 16 ) >> miplevel )
+ pface->info->lmvecs[0][3] * t;
tadjust = ((fixed16_t)(DotProduct (p_temp1, p_taxis) * 0x10000 + 0.5f)) -
((pface->info->lightmapmins[1] << 16) >> miplevel)
tadjust = ((fixed16_t)( DotProduct( p_temp1, p_taxis ) * 0x10000 + 0.5f ))
- (( pface->info->lightmapmins[1] << 16 ) >> miplevel )
+ pface->info->lmvecs[1][3] * t;
}
// PGM - changing flow speed for non-warping textures.

View file

@ -417,7 +417,8 @@ static int FIRST_BIT( uint mask )
{
uint i;
for( i = 0; !(BIT(i) & mask); i++ );
for( i = 0; !( BIT( i ) & mask ); i++ )
;
return i;
}

View file

@ -99,7 +99,8 @@ static void GL_UpdateTextureParams( int iTexture )
Assert( tex != NULL );
if( !tex->pixels) return; // free slot
if( !tex->pixels )
return; // free slot
GL_Bind( XASH_TEXTURE0, iTexture );
}
@ -271,7 +272,8 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
vec3_t normal;
int i, x, y;
if( !source ) return NULL;
if( !source )
return NULL;
scaledImage = Mem_Realloc( r_temppool, scaledImage, outWidth * outHeight * 4 );
fracStep = inWidth * 0x10000 / outWidth;
@ -431,7 +433,8 @@ static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth,
int row, x, y, z;
vec3_t normal;
if( !in ) return;
if( !in )
return;
mipWidth = Q_max( 1, ( srcWidth >> 1 ));
mipHeight = Q_max( 1, ( srcHeight >> 1 ));
@ -547,7 +550,8 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
// NOTE: only single uncompressed textures can be resamples, no mips, no layers, no sides
if((( pic->width != tex->width ) || ( pic->height != tex->height )))
data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap );
else data = buf;
else
data = buf;
// if( !ImageCompressed( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
// data = GL_ApplyFilter( data, tex->width, tex->height );
@ -622,8 +626,10 @@ static void GL_ProcessImage( image_t *tex, rgbdata_t *pic )
uint img_flags = 0;
// force upload texture as RGB or RGBA (detail textures requires this)
if( tex->flags & TF_FORCE_COLOR ) pic->flags |= IMAGE_HAS_COLOR;
if( pic->flags & IMAGE_HAS_ALPHA ) tex->flags |= TF_HAS_ALPHA;
if( tex->flags & TF_FORCE_COLOR )
pic->flags |= IMAGE_HAS_COLOR;
if( pic->flags & IMAGE_HAS_ALPHA )
tex->flags |= TF_HAS_ALPHA;
if( ImageCompressed( pic->type ))
{
@ -719,7 +725,8 @@ static image_t *GL_AllocTexture( const char *name, texFlags_t flags )
// find a free texture_t slot
for( i = 0, tex = r_images; i < r_numImages; i++, tex++ )
if( !tex->name[0] ) break;
if( !tex->name[0] )
break;
if( i == r_numImages )
{
@ -758,7 +765,8 @@ static void GL_DeleteTexture( image_t *tex )
ASSERT( tex != NULL );
// already freed?
if( !tex->pixels[0]) return;
if( !tex->pixels[0] )
return;
// debug
if( !tex->name[0] )
@ -773,7 +781,8 @@ static void GL_DeleteTexture( image_t *tex )
while( 1 )
{
cur = *prev;
if( !cur ) break;
if( !cur )
break;
if( cur == tex )
{
@ -788,8 +797,10 @@ static void GL_DeleteTexture( image_t *tex )
gEngfuncs.FS_FreeImage( tex->original );
for( i = 0; i < 4; i++ )
if( tex->pixels[i]) Mem_Free(tex->pixels[i]);
if( tex->alpha_pixels ) Mem_Free(tex->alpha_pixels);
if( tex->pixels[i] )
Mem_Free( tex->pixels[i] );
if( tex->alpha_pixels )
Mem_Free( tex->alpha_pixels );
memset( tex, 0, sizeof( *tex ));
}
@ -855,7 +866,8 @@ int GAME_EXPORT GL_LoadTexture( const char *name, const byte *buf, size_t size,
gEngfuncs.Image_SetForceFlags( picFlags );
pic = gEngfuncs.FS_LoadImage( name, buf, size );
if( !pic ) return 0; // couldn't loading image
if( !pic )
return 0; // couldn't loading image
// allocate the new one
tex = GL_AllocTexture( name, flags );
@ -902,7 +914,8 @@ int GAME_EXPORT GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texF
return( tex - r_images );
// couldn't loading image
if( !pic ) return 0;
if( !pic )
return 0;
if( update )
{
@ -1166,7 +1179,8 @@ static void GL_CreateInternalTextures( void )
{
if(( y < 8 ) ^ ( x < 8 ))
((uint *)pic->buffer )[y * 16 + x] = 0xFFFF00FF;
else ((uint *)pic->buffer)[y*16+x] = 0xFF000000;
else
((uint *)pic->buffer )[y * 16 + x] = 0xFF000000;
}
}
@ -1228,7 +1242,8 @@ void R_TextureList_f( void )
for( i = texCount = 0, image = r_images; i < r_numImages; i++, image++ )
{
if( !image->pixels ) continue;
if( !image->pixels )
continue;
bytes += image->size;
texCount++;
@ -1239,13 +1254,15 @@ void R_TextureList_f( void )
if( image->flags & TF_NORMALMAP )
gEngfuncs.Con_Printf( "normal " );
else gEngfuncs.Con_Printf( "diffuse " );
else
gEngfuncs.Con_Printf( "diffuse " );
if( image->flags & TF_CLAMP )
gEngfuncs.Con_Printf( "clamp " );
else if( image->flags & TF_BORDER )
gEngfuncs.Con_Printf( "border " );
else gEngfuncs.Con_Printf( "repeat " );
else
gEngfuncs.Con_Printf( "repeat " );
gEngfuncs.Con_Printf( " %d ", image->depth );
gEngfuncs.Con_Printf( " %s\n", image->name );
}

View file

@ -284,7 +284,8 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
if( FBitSet( surf->flags, SURF_PLANEBACK ))
VectorNegate( surf->plane->normal, faceNormal );
else VectorCopy( surf->plane->normal, faceNormal );
else
VectorCopy( surf->plane->normal, faceNormal );
// compute face TBN
#if 1
@ -345,8 +346,10 @@ static colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t
int i, maxEnts = 1;
colorVec light, cv;
if( lspot ) VectorClear( lspot );
if( lvec ) VectorClear( lvec );
if( lspot )
VectorClear( lspot );
if( lvec )
VectorClear( lvec );
if( WORLDMODEL && WORLDMODEL->lightdata )
{
@ -394,8 +397,10 @@ static colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t
if( g_trace_fraction < last_fraction )
{
if( lspot ) VectorCopy( g_trace_lightspot, lspot );
if( lvec ) VectorNormalize2( g_trace_lightvec, lvec );
if( lspot )
VectorCopy( g_trace_lightspot, lspot );
if( lvec )
VectorNormalize2( g_trace_lightvec, lvec );
light.r = Q_min(( cv.r >> 8 ), 255 );
light.g = Q_min(( cv.g >> 8 ), 255 );
light.b = Q_min(( cv.b >> 8 ), 255 );

View file

@ -498,7 +498,8 @@ void Mod_StudioUnloadTextures( void *data );
// r_polyse.c
//
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct {
typedef struct
{
void *pdest;
short *pz;
int count;
@ -757,7 +758,8 @@ typedef struct
#if SMALL_FINALVERT
typedef struct finalvert_s {
typedef struct finalvert_s
{
short u, v, s, t;
int l;
int zi;
@ -779,7 +781,8 @@ typedef struct finalvert_s {
#else
typedef struct finalvert_s {
typedef struct finalvert_s
{
int u, v, s, t;
int l;
int zi;
@ -1055,7 +1058,8 @@ extern convar_t r_traceglow;
extern convar_t sw_noalphabrushes;
extern convar_t r_studio_sort_textures;
extern struct qfrustum_s {
extern struct qfrustum_s
{
mplane_t screenedge[4];
clipplane_t view_clipplanes[4];
int frustum_indexes[4 * 6];
@ -1116,7 +1120,8 @@ qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int
//
// r_edge.c
//
static inline void R_SurfacePatch (void) { }
static inline void R_SurfacePatch( void ) {
}
void R_BeginEdgeFrame( void );
void R_RenderWorld( void );
void R_ScanEdges( void );

View file

@ -177,7 +177,8 @@ static int R_TransEntityCompare( const cl_entity_t **a, const cl_entity_t **b )
VectorSubtract( RI.vieworg, org, vecLen );
dist1 = DotProduct( vecLen, vecLen );
}
else dist1 = 1000000000;
else
dist1 = 1000000000;
if(( ent1->model && ent2->model->type != mod_brush ) || rendermode2 != kRenderTransAlpha )
{
@ -186,7 +187,8 @@ static int R_TransEntityCompare( const cl_entity_t **a, const cl_entity_t **b )
VectorSubtract( RI.vieworg, org, vecLen );
dist2 = DotProduct( vecLen, vecLen );
}
else dist2 = 1000000000;
else
dist2 = 1000000000;
if( dist1 > dist2 )
return -1;
@ -261,7 +263,8 @@ void GAME_EXPORT R_ScreenToWorld( const vec3_t screen, vec3_t point )
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];
if( w != 0.0f ) VectorScale( point, ( 1.0f / w ), point );
if( w != 0.0f )
VectorScale( point, ( 1.0f / w ), point );
}
/*
@ -561,17 +564,20 @@ static image_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mnode_t
if( node->children[0] && ( node->children[0] != ignore ))
{
tex = R_RecursiveFindWaterTexture( node->children[0], node, true );
if( tex ) return tex;
if( tex )
return tex;
}
if( node->children[1] && ( node->children[1] != ignore ))
{
tex = R_RecursiveFindWaterTexture( node->children[1], node, true );
if( tex ) return tex;
if( tex )
return tex;
}
// for down recursion, return immediately
if( down ) return NULL;
if( down )
return NULL;
// texture not found, step up if any
if( node->parent )
@ -659,9 +665,11 @@ static void R_DrawEntitiesOnList( void )
// handle studiomodels with custom rendermodes on texture
if( RI.currententity->curstate.rendermode != kRenderNormal )
tr.blend = CL_FxBlend( RI.currententity ) / 255.0f;
else tr.blend = 1.0f; // draw as solid but sorted by distance
else
tr.blend = 1.0f; // draw as solid but sorted by distance
if( tr.blend <= 0.0f ) continue;
if( tr.blend <= 0.0f )
continue;
Assert( RI.currententity != NULL );
Assert( RI.currentmodel != NULL );
@ -966,10 +974,10 @@ void R_DrawBrushModel(cl_entity_t *pent)
float minmaxs[6];
mnode_t *topnode;
int k;
edge_t ledges[NUMSTACKEDGES +
((CACHE_SIZE - 1) / sizeof(edge_t)) + 1];
surf_t lsurfs[NUMSTACKSURFACES +
((CACHE_SIZE - 1) / sizeof(surf_t)) + 1];
edge_t ledges[NUMSTACKEDGES
+ (( CACHE_SIZE - 1 ) / sizeof( edge_t )) + 1];
surf_t lsurfs[NUMSTACKSURFACES
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
if( !RI.drawWorld )
return;
@ -1087,10 +1095,10 @@ R_EdgeDrawing
*/
static void R_EdgeDrawing( void )
{
edge_t ledges[NUMSTACKEDGES +
((CACHE_SIZE - 1) / sizeof(edge_t)) + 1];
surf_t lsurfs[NUMSTACKSURFACES +
((CACHE_SIZE - 1) / sizeof(surf_t)) + 1];
edge_t ledges[NUMSTACKEDGES
+ (( CACHE_SIZE - 1 ) / sizeof( edge_t )) + 1];
surf_t lsurfs[NUMSTACKSURFACES
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
if( !RI.drawWorld )
return;
@ -1161,7 +1169,8 @@ static void R_MarkLeaves (void)
break;
node->visframe = tr.visframecount;
node = node->parent;
} while (node);
}
while( node );
}
}
}
@ -1181,7 +1190,8 @@ void GAME_EXPORT R_RenderScene( void )
// frametime is valid only for normal pass
if( RP_NORMALPASS( ))
tr.frametime = gp_cl->time - gp_cl->oldtime;
else tr.frametime = 0.0;
else
tr.frametime = 0.0;
// begin a new frame
tr.framecount++;
@ -1262,7 +1272,8 @@ void R_SetupRefParams( const ref_viewpass_t *rvp )
if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP ))
RI.drawOrtho = FBitSet( rvp->flags, RF_DRAW_OVERVIEW );
else RI.drawOrtho = false;
else
RI.drawOrtho = false;
// setup viewport
RI.viewport[0] = rvp->viewport[0];
@ -1439,7 +1450,8 @@ void GAME_EXPORT R_NewMap (void)
tr.sample_bits = 0;
for( sample_pot = 1; sample_pot < tr.sample_size; sample_pot <<= 1, tr.sample_bits++ );
for( sample_pot = 1; sample_pot < tr.sample_size; sample_pot <<= 1, tr.sample_bits++ )
;
}
gEngfuncs.Con_Printf( "Map sample size is %d\n", tr.sample_size );
@ -1580,7 +1592,8 @@ int CL_FxBlend( cl_entity_t *e )
{
if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1;
else e->curstate.renderamt = 0;
else
e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
@ -1589,7 +1602,8 @@ int CL_FxBlend( cl_entity_t *e )
{
if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4;
else e->curstate.renderamt = 0;
else
e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
@ -1598,7 +1612,8 @@ int CL_FxBlend( cl_entity_t *e )
{
if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1;
else e->curstate.renderamt = 255;
else
e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
@ -1607,34 +1622,45 @@ int CL_FxBlend( cl_entity_t *e )
{
if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4;
else e->curstate.renderamt = 255;
else
e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeSlow:
blend = 20 * sin( gp_cl->time * 4 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
if( blend < 0 )
blend = 0;
else
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFast:
blend = 20 * sin( gp_cl->time * 16 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
if( blend < 0 )
blend = 0;
else
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFaster:
blend = 20 * sin( gp_cl->time * 36 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
if( blend < 0 )
blend = 0;
else
blend = e->curstate.renderamt;
break;
case kRenderFxFlickerSlow:
blend = 20 * ( sin( gp_cl->time * 2 ) + sin( gp_cl->time * 17 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
if( blend < 0 )
blend = 0;
else
blend = e->curstate.renderamt;
break;
case kRenderFxFlickerFast:
blend = 20 * ( sin( gp_cl->time * 16 ) + sin( gp_cl->time * 23 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
if( blend < 0 )
blend = 0;
else
blend = e->curstate.renderamt;
break;
case kRenderFxHologram:
case kRenderFxDistort:
@ -1653,8 +1679,10 @@ int CL_FxBlend( cl_entity_t *e )
else
{
e->curstate.renderamt = 180;
if( dist <= 100 ) blend = e->curstate.renderamt;
else blend = (int) ((1.0f - ( dist - 100 ) * ( 1.0f / 400.0f )) * e->curstate.renderamt );
if( dist <= 100 )
blend = e->curstate.renderamt;
else
blend = (int) (( 1.0f - ( dist - 100 ) * ( 1.0f / 400.0f )) * e->curstate.renderamt );
blend += gEngfuncs.COM_RandomLong( -32, 31 );
}
break;

View file

@ -124,7 +124,8 @@ void Matrix4x4_CreateRotate( matrix4x4 out, float angle, float x, float y, float
float len, c, s;
len = x * x + y * y + z * z;
if( len != 0.0f ) len = 1.0f / sqrt( len );
if( len != 0.0f )
len = 1.0f / sqrt( len );
x *= len;
y *= len;
z *= len;

View file

@ -205,10 +205,10 @@ static void R_ViewChanged (vrect_t *vr)
RI.aliasvrect.y = (int)( RI.vrect.y * r_aliasuvscale );
RI.aliasvrect.width = (int)( RI.vrect.width * r_aliasuvscale );
RI.aliasvrect.height = (int)( RI.vrect.height * r_aliasuvscale );
RI.aliasvrectright = RI.aliasvrect.x +
RI.aliasvrect.width;
RI.aliasvrectbottom = RI.aliasvrect.y +
RI.aliasvrect.height;
RI.aliasvrectright = RI.aliasvrect.x
+ RI.aliasvrect.width;
RI.aliasvrectbottom = RI.aliasvrect.y
+ RI.aliasvrect.height;
xOrigin = XCENTERING;
yOrigin = YCENTERING;
@ -219,11 +219,11 @@ static void R_ViewChanged (vrect_t *vr)
// the polygon rasterization will never render in the first row or column
// but will definately render in the [range] row and column, so adjust the
// buffer origin to get an exact edge to edge fill
xcenter = ((float)RI.vrect.width * XCENTERING) +
RI.vrect.x - 0.5f;
xcenter = ((float)RI.vrect.width * XCENTERING )
+ RI.vrect.x - 0.5f;
aliasxcenter = xcenter * r_aliasuvscale;
ycenter = ((float)RI.vrect.height * YCENTERING) +
RI.vrect.y - 0.5f;
ycenter = ((float)RI.vrect.height * YCENTERING )
+ RI.vrect.y - 0.5f;
aliasycenter = ycenter * r_aliasuvscale;
xscale = RI.vrect.width / horizontalFieldOfView;
@ -243,8 +243,8 @@ static void R_ViewChanged (vrect_t *vr)
qfrustum.screenedge[0].type = PLANE_ANYZ;
// right side clip
qfrustum.screenedge[1].normal[0] =
1.0f / ((1.0f-xOrigin)*horizontalFieldOfView);
qfrustum.screenedge[1].normal[0]
= 1.0f / (( 1.0f - xOrigin ) * horizontalFieldOfView );
qfrustum.screenedge[1].normal[1] = 0;
qfrustum.screenedge[1].normal[2] = 1;
qfrustum.screenedge[1].type = PLANE_ANYZ;

View file

@ -76,8 +76,10 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
size += ( p->org[1] - RI.vieworg[1] ) * RI.cull_vforward[1];
size += ( p->org[2] - RI.vieworg[2] ) * RI.cull_vforward[2];
if( size < 20.0f ) size = partsize;
else size = partsize + size * 0.002f;
if( size < 20.0f )
size = partsize;
else
size = partsize + size * 0.002f;
// scale the axes by radius
VectorScale( RI.cull_vright, size, right );
@ -196,12 +198,14 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
gravity = frametime * tr.movevars->gravity;
scale = 1.0 - ( frametime * 0.9 );
if( scale < 0.0f ) scale = 0.0f;
if( scale < 0.0f )
scale = 0.0f;
for( p = cl_active_tracers; p; p = p->next )
{
atten = ( p->die - gp_cl->time );
if( atten > 0.1f ) atten = 0.1f;
if( atten > 0.1f )
atten = 0.1f;
VectorScale( p->vel, ( p->ramp * atten ), delta );
VectorAdd( p->org, delta, end );
@ -268,7 +272,8 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
p->vel[2] -= gravity;
p->packedColor = 255 * ( p->die - gp_cl->time ) * 2;
if( p->packedColor > 255 ) p->packedColor = 255;
if( p->packedColor > 255 )
p->packedColor = 255;
}
else if( p->type == pt_slowgrav )
{

View file

@ -27,7 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DPS_MAXSPANS MAXHEIGHT + 1
// 1 extra for spanpackage that marks end
typedef struct {
typedef struct
{
int isflattop;
int numleftedges;
int *pleftedgevert0;
@ -83,7 +84,8 @@ int d_pzextrastep, d_pzbasestep;
static int ubasestep, errorterm, erroradjustup, erroradjustdown;
typedef struct {
typedef struct
{
int quotient;
int remainder;
} adivtab_t;
@ -272,7 +274,8 @@ qboolean R_PolysetScanLeftEdge_C(int height)
d_light += d_lightbasestep;
d_zi += d_zibasestep;
}
} while (--height);
}
while( --height );
return true;
}
@ -353,8 +356,8 @@ static void R_PolysetSetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv,
tm = endvertu - startvertu;
tn = endvertv - startvertv;
if (((tm <= 16) && (tm >= -15)) &&
((tn <= 16) && (tn >= -15)))
if((( tm <= 16 ) && ( tm >= -15 ))
&& (( tn <= 16 ) && ( tn >= -15 )))
{
ptemp = &adivtab[(( tm + 15 ) << 5 ) + ( tn + 15 )];
ubasestep = ptemp->quotient;
@ -410,24 +413,24 @@ qboolean R_PolysetCalcGradients (int skinwidth)
t0 = r_p0[2] - r_p2[2];
t1 = r_p1[2] - r_p2[2];
r_sstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
xstepdenominv);
r_sstepy = (int)((t1 * p00_minus_p20 - t0* p10_minus_p20) *
ystepdenominv);
r_sstepx = (int)(( t1 * p01_minus_p21 - t0 * p11_minus_p21 )
* xstepdenominv );
r_sstepy = (int)(( t1 * p00_minus_p20 - t0 * p10_minus_p20 )
* ystepdenominv );
t0 = r_p0[3] - r_p2[3];
t1 = r_p1[3] - r_p2[3];
r_tstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
xstepdenominv);
r_tstepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
ystepdenominv);
r_tstepx = (int)(( t1 * p01_minus_p21 - t0 * p11_minus_p21 )
* xstepdenominv );
r_tstepy = (int)(( t1 * p00_minus_p20 - t0 * p10_minus_p20 )
* ystepdenominv );
t0 = r_p0[5] - r_p2[5];
t1 = r_p1[5] - r_p2[5];
r_zistepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
xstepdenominv);
r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
ystepdenominv);
r_zistepx = (int)(( t1 * p01_minus_p21 - t0 * p11_minus_p21 )
* xstepdenominv );
r_zistepy = (int)(( t1 * p00_minus_p20 - t0 * p10_minus_p20 )
* ystepdenominv );
{
a_sstepxfrac = r_sstepx & 0xFFFF;
@ -517,10 +520,13 @@ void R_PolysetDrawSpansBlended( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF;
}
} while (--lcount);
}
else pspanpackage++;
} while (pspanpackage->count != -999999);
while( --lcount );
}
else
pspanpackage++;
}
while( pspanpackage->count != -999999 );
}
@ -598,10 +604,13 @@ void R_PolysetDrawSpansAdditive( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF;
}
} while (--lcount);
}
else pspanpackage++;
} while (pspanpackage->count != -999999);
while( --lcount );
}
else
pspanpackage++;
}
while( pspanpackage->count != -999999 );
}
@ -677,11 +686,13 @@ void R_PolysetDrawSpansGlow( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF;
}
} while (--lcount);
}
while( --lcount );
}
else
pspanpackage++;
} while (pspanpackage->count != -999999);
}
while( pspanpackage->count != -999999 );
}
@ -762,11 +773,13 @@ void R_PolysetDrawSpansTextureBlended( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF;
}
} while (--lcount);
}
while( --lcount );
}
else
pspanpackage++;
} while (pspanpackage->count != -999999);
}
while( pspanpackage->count != -999999 );
}
@ -837,11 +850,13 @@ void R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF;
}
} while (--lcount);
}
while( --lcount );
}
pspanpackage++;
} while (pspanpackage->count != -999999);
}
while( pspanpackage->count != -999999 );
}
void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage )
@ -881,11 +896,13 @@ void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage)
lpdest++;
lzi += r_zistepx;
lpz++;
} while (--lcount);
}
while( --lcount );
}
pspanpackage++;
} while (pspanpackage->count != -999999);
}
while( pspanpackage->count != -999999 );
}
void R_PolysetDrawSpans8_66( spanpackage_t *pspanpackage )
@ -946,11 +963,13 @@ void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF;
}
} while (--lcount);
}
while( --lcount );
}
pspanpackage++;
} while (pspanpackage->count != -999999);
}
while( pspanpackage->count != -999999 );
}
static void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage )
@ -990,11 +1009,13 @@ static void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage)
lpdest++;
lzi += r_zistepx;
lpz++;
} while (--lcount);
}
while( --lcount );
}
pspanpackage++;
} while (pspanpackage->count != -999999);
}
while( pspanpackage->count != -999999 );
}
void R_PolysetDrawSpans8_Opaque( spanpackage_t *pspanpackage )
@ -1059,11 +1080,13 @@ void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF;
}
} while (--lcount);
}
while( --lcount );
}
pspanpackage++;
} while (pspanpackage->count != -999999);
}
while( pspanpackage->count != -999999 );
}
void R_PolysetFillSpans8( spanpackage_t *pspanpackage )
@ -1139,10 +1162,13 @@ void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF;
}
} while (--lcount);
}
else pspanpackage++;
} while (pspanpackage->count != -999999);
while( --lcount );
}
else
pspanpackage++;
}
while( pspanpackage->count != -999999 );
}
/*
@ -1183,8 +1209,8 @@ void R_RasterizeAliasPolySmooth (void)
ystart = plefttop[1];
d_aspancount = plefttop[0] - prighttop[0];
d_ptex = (pixel_t*)r_affinetridesc.pskin + (plefttop[2] >> 16) +
(plefttop[3] >> 16) * r_affinetridesc.skinwidth;
d_ptex = (pixel_t *)r_affinetridesc.pskin + ( plefttop[2] >> 16 )
+ ( plefttop[3] >> 16 ) * r_affinetridesc.skinwidth;
{
d_sfrac = plefttop[2] & 0xFFFF;
@ -1193,8 +1219,8 @@ void R_RasterizeAliasPolySmooth (void)
d_light = plefttop[4];
d_zi = plefttop[5];
d_pdest = (pixel_t *)d_viewbuffer +
ystart * r_screenwidth + plefttop[0];
d_pdest = (pixel_t *)d_viewbuffer
+ ystart * r_screenwidth + plefttop[0];
d_pz = d_pzbuffer + ystart * d_zwidth + plefttop[0];
if( initialleftheight == 1 )
@ -1237,9 +1263,9 @@ void R_RasterizeAliasPolySmooth (void)
working_lstepx = r_lstepx;
d_countextrastep = ubasestep + 1;
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
((r_tstepy + r_tstepx * ubasestep) >> 16) *
r_affinetridesc.skinwidth;
d_ptexbasestep = (( r_sstepy + r_sstepx * ubasestep ) >> 16 )
+ (( r_tstepy + r_tstepx * ubasestep ) >> 16 )
* r_affinetridesc.skinwidth;
{
d_sfracbasestep = ( r_sstepy + r_sstepx * ubasestep ) & 0xFFFF;
d_tfracbasestep = ( r_tstepy + r_tstepx * ubasestep ) & 0xFFFF;
@ -1247,9 +1273,9 @@ void R_RasterizeAliasPolySmooth (void)
d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
r_affinetridesc.skinwidth;
d_ptexextrastep = (( r_sstepy + r_sstepx * d_countextrastep ) >> 16 )
+ (( r_tstepy + r_tstepx * d_countextrastep ) >> 16 )
* r_affinetridesc.skinwidth;
{
d_sfracextrastep = ( r_sstepy + r_sstepx * d_countextrastep ) & 0xFFFF;
d_tfracextrastep = ( r_tstepy + r_tstepx * d_countextrastep ) & 0xFFFF;
@ -1279,8 +1305,8 @@ void R_RasterizeAliasPolySmooth (void)
ystart = plefttop[1];
d_aspancount = plefttop[0] - prighttop[0];
d_ptex = (pixel_t*)r_affinetridesc.pskin + (plefttop[2] >> 16) +
(plefttop[3] >> 16) * r_affinetridesc.skinwidth;
d_ptex = (pixel_t *)r_affinetridesc.pskin + ( plefttop[2] >> 16 )
+ ( plefttop[3] >> 16 ) * r_affinetridesc.skinwidth;
d_sfrac = 0;
d_tfrac = 0;
@ -1326,9 +1352,9 @@ void R_RasterizeAliasPolySmooth (void)
working_lstepx = r_lstepx;
d_countextrastep = ubasestep + 1;
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
((r_tstepy + r_tstepx * ubasestep) >> 16) *
r_affinetridesc.skinwidth;
d_ptexbasestep = (( r_sstepy + r_sstepx * ubasestep ) >> 16 )
+ (( r_tstepy + r_tstepx * ubasestep ) >> 16 )
* r_affinetridesc.skinwidth;
{
d_sfracbasestep = ( r_sstepy + r_sstepx * ubasestep ) & 0xFFFF;
d_tfracbasestep = ( r_tstepy + r_tstepx * ubasestep ) & 0xFFFF;
@ -1336,9 +1362,9 @@ void R_RasterizeAliasPolySmooth (void)
d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
r_affinetridesc.skinwidth;
d_ptexextrastep = (( r_sstepy + r_sstepx * d_countextrastep ) >> 16 )
+ (( r_tstepy + r_tstepx * d_countextrastep ) >> 16 )
* r_affinetridesc.skinwidth;
{
d_sfracextrastep = ( r_sstepy + r_sstepx * d_countextrastep ) & 0xFFFF;
d_tfracextrastep = ( r_tstepy + r_tstepx * d_countextrastep ) & 0xFFFF;

View file

@ -203,8 +203,8 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
// we cache unclipped horizontal edges as fully clipped
if( cacheoffset != 0x7FFFFFFF )
{
cacheoffset = FULLY_CLIPPED_CACHED |
(tr.framecount & FRAMECOUNT_MASK);
cacheoffset = FULLY_CLIPPED_CACHED
| ( tr.framecount & FRAMECOUNT_MASK );
}
return; // horizontal edge
@ -333,12 +333,12 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
cacheoffset = 0x7FFFFFFF;
f = d0 / ( d0 - d1 );
clipvert.position[0] = pv0->position[0] +
f * (pv1->position[0] - pv0->position[0]);
clipvert.position[1] = pv0->position[1] +
f * (pv1->position[1] - pv0->position[1]);
clipvert.position[2] = pv0->position[2] +
f * (pv1->position[2] - pv0->position[2]);
clipvert.position[0] = pv0->position[0]
+ f * ( pv1->position[0] - pv0->position[0] );
clipvert.position[1] = pv0->position[1]
+ f * ( pv1->position[1] - pv0->position[1] );
clipvert.position[2] = pv0->position[2]
+ f * ( pv1->position[2] - pv0->position[2] );
if( clip->leftedge )
{
@ -362,8 +362,8 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
// both points are clipped
// we do cache fully clipped edges
if( !r_leftclipped )
cacheoffset = FULLY_CLIPPED_CACHED |
(tr.framecount & FRAMECOUNT_MASK);
cacheoffset = FULLY_CLIPPED_CACHED
| ( tr.framecount & FRAMECOUNT_MASK );
return;
}
@ -374,12 +374,12 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
cacheoffset = 0x7FFFFFFF;
f = d0 / ( d0 - d1 );
clipvert.position[0] = pv0->position[0] +
f * (pv1->position[0] - pv0->position[0]);
clipvert.position[1] = pv0->position[1] +
f * (pv1->position[1] - pv0->position[1]);
clipvert.position[2] = pv0->position[2] +
f * (pv1->position[2] - pv0->position[2]);
clipvert.position[0] = pv0->position[0]
+ f * ( pv1->position[0] - pv0->position[0] );
clipvert.position[1] = pv0->position[1]
+ f * ( pv1->position[1] - pv0->position[1] );
clipvert.position[2] = pv0->position[2]
+ f * ( pv1->position[2] - pv0->position[2] );
if( clip->leftedge )
{
@ -395,7 +395,8 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
R_ClipEdge( &clipvert, pv1, clip->next );
return;
}
} while ((clip = clip->next) != NULL);
}
while(( clip = clip->next ) != NULL );
}
// add the edge
@ -505,8 +506,8 @@ void R_RenderFace (msurface_t *fa, int clipflags)
{
if( r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED )
{
if ((r_pedge->cachededgeoffset & FRAMECOUNT_MASK) ==
tr.framecount)
if(( r_pedge->cachededgeoffset & FRAMECOUNT_MASK )
== tr.framecount )
{
r_lastvertvalid = false;
continue;
@ -514,10 +515,10 @@ void R_RenderFace (msurface_t *fa, int clipflags)
}
else
{
if ((((uintptr_t)edge_p - (uintptr_t)r_edges) >
r_pedge->cachededgeoffset) &&
(((edge_t *)((uintptr_t)r_edges +
r_pedge->cachededgeoffset))->owner == r_pedge))
if((((uintptr_t)edge_p - (uintptr_t)r_edges )
> r_pedge->cachededgeoffset )
&& (((edge_t *)((uintptr_t)r_edges
+ r_pedge->cachededgeoffset ))->owner == r_pedge ))
{
R_EmitCachedEdge();
r_lastvertvalid = false;
@ -549,8 +550,8 @@ void R_RenderFace (msurface_t *fa, int clipflags)
{
if( r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED )
{
if ((r_pedge->cachededgeoffset & FRAMECOUNT_MASK) ==
tr.framecount)
if(( r_pedge->cachededgeoffset & FRAMECOUNT_MASK )
== tr.framecount )
{
r_lastvertvalid = false;
continue;
@ -560,10 +561,10 @@ void R_RenderFace (msurface_t *fa, int clipflags)
{
// it's cached if the cached edge is valid and is owned
// by this medge_t
if ((((uintptr_t)edge_p - (uintptr_t)r_edges) >
r_pedge->cachededgeoffset) &&
(((edge_t *)((uintptr_t)r_edges +
r_pedge->cachededgeoffset))->owner == r_pedge))
if((((uintptr_t)edge_p - (uintptr_t)r_edges )
> r_pedge->cachededgeoffset )
&& (((edge_t *)((uintptr_t)r_edges
+ r_pedge->cachededgeoffset ))->owner == r_pedge ))
{
R_EmitCachedEdge();
r_lastvertvalid = false;
@ -630,9 +631,9 @@ void R_RenderFace (msurface_t *fa, int clipflags)
surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv;
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
surface_p->d_ziorigin = p_normal[2] * distinv -
xcenter * surface_p->d_zistepu -
ycenter * surface_p->d_zistepv;
surface_p->d_ziorigin = p_normal[2] * distinv
- xcenter * surface_p->d_zistepu
- ycenter * surface_p->d_zistepv;
surface_p++;
}
@ -751,9 +752,9 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv;
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
surface_p->d_ziorigin = p_normal[2] * distinv -
xcenter * surface_p->d_zistepu -
ycenter * surface_p->d_zistepv;
surface_p->d_ziorigin = p_normal[2] * distinv
- xcenter * surface_p->d_zistepu
- ycenter * surface_p->d_zistepv;
surface_p++;
}

View file

@ -47,7 +47,8 @@ void D_DrawTurbulent8Span (void)
*r_turb_pdest++ = *( r_turb_pbase + ( tturb << 6 ) + sturb );
r_turb_s += r_turb_sstep;
r_turb_t += r_turb_tstep;
} while (--r_turb_spancount > 0);
}
while( --r_turb_spancount > 0 );
}
/*
@ -76,7 +77,8 @@ static void D_DrawTurbulent8ZSpan (void)
r_turb_izi += r_turb_izistep;
r_turb_s += r_turb_sstep;
r_turb_t += r_turb_tstep;
} while (--r_turb_spancount > 0);
}
while( --r_turb_spancount > 0 );
}
/*
@ -104,8 +106,8 @@ void Turbulent8 (espan_t *pspan)
do
{
r_turb_pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
r_turb_pdest = ( d_viewbuffer
+ ( r_screenwidth * pspan->v ) + pspan->u );
count = pspan->count;
@ -206,9 +208,11 @@ void Turbulent8 (espan_t *pspan)
r_turb_s = snext;
r_turb_t = tnext;
} while (count > 0);
}
while( count > 0 );
} while ((pspan = pspan->pnext) != NULL);
}
while(( pspan = pspan->pnext ) != NULL );
}
/*
@ -243,8 +247,8 @@ void TurbulentZ8 (espan_t *pspan, int alpha1)
do
{
r_turb_pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
r_turb_pdest = ( d_viewbuffer
+ ( r_screenwidth * pspan->v ) + pspan->u );
r_turb_pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
count = pspan->count;
@ -348,9 +352,11 @@ void TurbulentZ8 (espan_t *pspan, int alpha1)
r_turb_s = snext;
r_turb_t = tnext;
} while (count > 0);
}
while( count > 0 );
} while ((pspan = pspan->pnext) != NULL);
}
while(( pspan = pspan->pnext ) != NULL );
}
@ -384,8 +390,8 @@ void NonTurbulent8 (espan_t *pspan)
do
{
r_turb_pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
r_turb_pdest = ( d_viewbuffer
+ ( r_screenwidth * pspan->v ) + pspan->u );
count = pspan->count;
@ -486,9 +492,11 @@ void NonTurbulent8 (espan_t *pspan)
r_turb_s = snext;
r_turb_t = tnext;
} while (count > 0);
}
while( count > 0 );
} while ((pspan = pspan->pnext) != NULL);
}
while(( pspan = pspan->pnext ) != NULL );
}
// PGM
// ====================
@ -536,8 +544,8 @@ void D_DrawSpans16 (espan_t *pspan)
do
{
pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
pdest = ( d_viewbuffer
+ ( r_screenwidth * pspan->v ) + pspan->u );
count = pspan->count;
@ -639,7 +647,8 @@ void D_DrawSpans16 (espan_t *pspan)
*pdest++ = *( pbase + ( s >> 16 ) + ( t >> 16 ) * cachewidth );
s += sstep;
t += tstep;
} while (--spancount > 0);
}
while( --spancount > 0 );
}
else
{
@ -666,13 +675,16 @@ void D_DrawSpans16 (espan_t *pspan)
*pdest++ = *( pbase + idiths + iditht * cachewidth );
s += sstep;
t += tstep;
} while (--spancount > 0);
}
while( --spancount > 0 );
}
} while (count > 0);
}
while( count > 0 );
} while ((pspan = pspan->pnext) != NULL);
}
while(( pspan = pspan->pnext ) != NULL );
}
@ -705,8 +717,8 @@ void D_AlphaSpans16 (espan_t *pspan)
do
{
pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
pdest = ( d_viewbuffer
+ ( r_screenwidth * pspan->v ) + pspan->u );
pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
count = pspan->count;
@ -823,7 +835,8 @@ void D_AlphaSpans16 (espan_t *pspan)
izi += izistep;
s += sstep;
t += tstep;
} while (--spancount > 0);
}
while( --spancount > 0 );
}
else
{
@ -861,13 +874,16 @@ void D_AlphaSpans16 (espan_t *pspan)
pz++;
s += sstep;
t += tstep;
} while (--spancount > 0);
}
while( --spancount > 0 );
}
} while (count > 0);
}
while( count > 0 );
} while ((pspan = pspan->pnext) != NULL);
}
while(( pspan = pspan->pnext ) != NULL );
}
@ -906,8 +922,8 @@ void D_BlendSpans16( espan_t *pspan, int alpha )
do
{
pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
pdest = ( d_viewbuffer
+ ( r_screenwidth * pspan->v ) + pspan->u );
pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
count = pspan->count;
@ -1027,7 +1043,8 @@ void D_BlendSpans16( espan_t *pspan, int alpha )
izi += izistep;
s += sstep;
t += tstep;
} while (--spancount > 0);
}
while( --spancount > 0 );
}
else
{
@ -1068,13 +1085,16 @@ void D_BlendSpans16( espan_t *pspan, int alpha )
izi += izistep;
s += sstep;
t += tstep;
} while (--spancount > 0);
}
while( --spancount > 0 );
}
} while (count > 0);
}
while( count > 0 );
} while ((pspan = pspan->pnext) != NULL);
}
while(( pspan = pspan->pnext ) != NULL );
}
@ -1108,8 +1128,8 @@ void D_AddSpans16 (espan_t *pspan)
do
{
pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
pdest = ( d_viewbuffer
+ ( r_screenwidth * pspan->v ) + pspan->u );
pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
count = pspan->count;
@ -1228,7 +1248,8 @@ void D_AddSpans16 (espan_t *pspan)
izi += izistep;
s += sstep;
t += tstep;
} while (--spancount > 0);
}
while( --spancount > 0 );
}
else
{
@ -1268,13 +1289,16 @@ void D_AddSpans16 (espan_t *pspan)
izi += izistep;
s += sstep;
t += tstep;
} while (--spancount > 0);
}
while( --spancount > 0 );
}
} while (count > 0);
}
while( count > 0 );
} while ((pspan = pspan->pnext) != NULL);
}
while(( pspan = pspan->pnext ) != NULL );
}
/*
@ -1326,12 +1350,14 @@ void D_DrawZSpans (espan_t *pspan)
izi += izistep;
*(int *)pdest = ltemp;
pdest += 2;
} while (--doublecount > 0);
}
while( --doublecount > 0 );
}
if( count & 1 )
*pdest = (short)( izi >> 16 );
} while ((pspan = pspan->pnext) != NULL);
}
while(( pspan = pspan->pnext ) != NULL );
}

View file

@ -220,10 +220,12 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
pframetype = R_SpriteLoadGroup( mod, pframetype + sizeof( dframetype_t ), &psprite->frames[i].frameptr, i );
break;
}
if( pframetype == NULL ) break; // technically an error
if( pframetype == NULL )
break; // technically an error
}
if( loaded ) *loaded = true; // done
if( loaded )
*loaded = true; // done
}
/*
@ -386,7 +388,8 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * 11.0f;
else
lerpFrac = ( gp_cl->time - ent->latched.sequencetime ) * 11.0f;
}
else
{
@ -410,8 +413,10 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
}
// get the interpolated frames
if( oldframe ) *oldframe = psprite->frames[ent->latched.prevblending[0]].frameptr;
if( curframe ) *curframe = psprite->frames[frame].frameptr;
if( oldframe )
*oldframe = psprite->frames[ent->latched.prevblending[0]].frameptr;
if( curframe )
*curframe = psprite->frames[frame].frameptr;
}
else if( psprite->frames[frame].type == FRAME_GROUP )
{
@ -440,11 +445,14 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
if( m_fDoInterp )
lerpFrac = ( targettime - jtime ) / jinterval;
else j = i; // no lerping
else
j = i; // no lerping
// get the interpolated frames
if( oldframe ) *oldframe = pspritegroup->frames[j];
if( curframe ) *curframe = pspritegroup->frames[i];
if( oldframe )
*oldframe = pspritegroup->frames[j];
if( curframe )
*curframe = pspritegroup->frames[i];
}
else if( psprite->frames[frame].type == FRAME_ANGLED )
{
@ -472,7 +480,8 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * ent->curstate.framerate;
else
lerpFrac = ( gp_cl->time - ent->latched.sequencetime ) * ent->curstate.framerate;
}
else
{
@ -488,10 +497,12 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
}
pspritegroup = (mspritegroup_t *)psprite->frames[ent->latched.prevblending[0]].frameptr;
if( oldframe ) *oldframe = pspritegroup->frames[angleframe];
if( oldframe )
*oldframe = pspritegroup->frames[angleframe];
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
if( curframe ) *curframe = pspritegroup->frames[angleframe];
if( curframe )
*curframe = pspritegroup->frames[angleframe];
}
return lerpFrac;
@ -719,12 +730,14 @@ void R_DrawSpriteModel( cl_entity_t *e )
int num = bound( 1, e->curstate.body, MAXSTUDIOATTACHMENTS );
VectorCopy( parent->attachment[num - 1], origin );
}
else VectorCopy( parent->origin, origin );
else
VectorCopy( parent->origin, origin );
}
}
scale = e->curstate.scale;
if( !scale ) scale = 1.0f;
if( !scale )
scale = 1.0f;
if( R_SpriteOccluded( e, origin, &scale ))
return; // sprite culled
@ -763,7 +776,8 @@ void R_DrawSpriteModel( cl_entity_t *e )
if( R_SpriteAllowLerping( e, psprite ))
lerp = R_GetSpriteFrameInterpolant( e, &oldframe, &frame );
else frame = oldframe = R_GetSpriteFrame( model, e->curstate.frame, e->angles[YAW] );
else
frame = oldframe = R_GetSpriteFrame( model, e->curstate.frame, e->angles[YAW] );
type = psprite->type;

View file

@ -242,7 +242,8 @@ static qboolean R_StudioComputeBBox( vec3_t bbox[8] )
Matrix3x4_VectorTransform( g_studio.rotationmatrix, p1, p2 );
AddPointToBounds( p2, studio_mins, studio_maxs );
if( bbox ) VectorCopy( p2, bbox[i] );
if( bbox )
VectorCopy( p2, bbox[i] );
}
if( !bbox && R_CullModel( e, studio_mins, studio_maxs ))
@ -274,7 +275,8 @@ static void R_StudioComputeSkinMatrix( mstudioboneweight_t *boneweights, matrix3
flWeight3 = boneweights->weight[3] / 255.0f;
flTotal = flWeight0 + flWeight1 + flWeight2 + flWeight3;
if( flTotal < 1.0f ) flWeight0 += 1.0f - flTotal; // compensate rounding error
if( flTotal < 1.0f )
flWeight0 += 1.0f - flTotal; // compensate rounding error
result[0][0] = boneMat0[0][0] * flWeight0 + boneMat1[0][0] * flWeight1 + boneMat2[0][0] * flWeight2 + boneMat3[0][0] * flWeight3;
result[0][1] = boneMat0[0][1] * flWeight0 + boneMat1[0][1] * flWeight1 + boneMat2[0][1] * flWeight2 + boneMat3[0][1] * flWeight3;
@ -299,7 +301,8 @@ static void R_StudioComputeSkinMatrix( mstudioboneweight_t *boneweights, matrix3
flWeight2 = boneweights->weight[2] / 255.0f;
flTotal = flWeight0 + flWeight1 + flWeight2;
if( flTotal < 1.0f ) flWeight0 += 1.0f - flTotal; // compensate rounding error
if( flTotal < 1.0f )
flWeight0 += 1.0f - flTotal; // compensate rounding error
result[0][0] = boneMat0[0][0] * flWeight0 + boneMat1[0][0] * flWeight1 + boneMat2[0][0] * flWeight2;
result[0][1] = boneMat0[0][1] * flWeight0 + boneMat1[0][1] * flWeight1 + boneMat2[0][1] * flWeight2;
@ -322,7 +325,8 @@ static void R_StudioComputeSkinMatrix( mstudioboneweight_t *boneweights, matrix3
flWeight1 = boneweights->weight[1] / 255.0f;
flTotal = flWeight0 + flWeight1;
if( flTotal < 1.0f ) flWeight0 += 1.0f - flTotal; // compensate rounding error
if( flTotal < 1.0f )
flWeight0 += 1.0f - flTotal; // compensate rounding error
result[0][0] = boneMat0[0][0] * flWeight0 + boneMat1[0][0] * flWeight1;
result[0][1] = boneMat0[0][1] * flWeight0 + boneMat1[0][1] * flWeight1;
@ -412,9 +416,12 @@ pfnGetEngineTimes
*/
static void pfnGetEngineTimes( int *framecount, double *current, double *old )
{
if( framecount ) *framecount = tr.realframecount;
if( current ) *current = gp_cl->time;
if( old ) *old = gp_cl->oldtime;
if( framecount )
*framecount = tr.realframecount;
if( current )
*current = gp_cl->time;
if( old )
*old = gp_cl->oldtime;
}
/*
@ -425,10 +432,14 @@ pfnGetViewInfo
*/
static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *forwardv )
{
if( origin ) VectorCopy( RI.vieworg, origin );
if( forwardv ) VectorCopy( RI.vforward, forwardv );
if( rightv ) VectorCopy( RI.vright, rightv );
if( upv ) VectorCopy( RI.vup, upv );
if( origin )
VectorCopy( RI.vieworg, origin );
if( forwardv )
VectorCopy( RI.vforward, forwardv );
if( rightv )
VectorCopy( RI.vright, rightv );
if( upv )
VectorCopy( RI.vup, upv );
}
/*
@ -462,8 +473,10 @@ pfnGetAliasScale
*/
static void pfnGetAliasScale( float *x, float *y )
{
if( x ) *x = 1.0f;
if( y ) *y = 1.0f;
if( x )
*x = 1.0f;
if( y )
*y = 1.0f;
}
/*
@ -535,7 +548,8 @@ static void R_StudioPlayerBlend( mstudioseqdesc_t *pseqdesc, int *pBlend, float
{
if( pseqdesc->blendend[0] - pseqdesc->blendstart[0] < 0.1f ) // catch qc error
*pBlend = 127;
else *pBlend = 255 * (*pBlend - pseqdesc->blendstart[0]) / (pseqdesc->blendend[0] - pseqdesc->blendstart[0]);
else
*pBlend = 255 * ( *pBlend - pseqdesc->blendstart[0] ) / ( pseqdesc->blendend[0] - pseqdesc->blendstart[0] );
*pPitch = 0.0f;
}
}
@ -568,7 +582,8 @@ void GAME_EXPORT R_StudioLerpMovement( cl_entity_t *e, double time, vec3_t origi
QuaternionSlerp( q2, q1, f, q );
QuaternionAngle( q, angles );
}
else VectorCopy( e->curstate.angles, angles );
else
VectorCopy( e->curstate.angles, angles );
}
/*
@ -594,7 +609,8 @@ static void R_StudioSetUpTransform( cl_entity_t *e )
angles[PITCH] = -angles[PITCH]; // stupid quake bug
// don't rotate clients, only aim
if( e->player ) angles[PITCH] = 0.0f;
if( e->player )
angles[PITCH] = 0.0f;
Matrix3x4_CreateFromEntity( g_studio.rotationmatrix, angles, origin, 1.0f );
@ -618,13 +634,18 @@ float GAME_EXPORT R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqd
if( g_studio.interpolate )
{
if( time < e->curstate.animtime ) dfdt = 0.0;
else dfdt = (time - e->curstate.animtime) * e->curstate.framerate * pseqdesc->fps;
if( time < e->curstate.animtime )
dfdt = 0.0;
else
dfdt = ( time - e->curstate.animtime ) * e->curstate.framerate * pseqdesc->fps;
}
else dfdt = 0;
else
dfdt = 0;
if( pseqdesc->numframes <= 1 ) f = 0.0;
else f = (e->curstate.frame * (pseqdesc->numframes - 1)) / 256.0;
if( pseqdesc->numframes <= 1 )
f = 0.0;
else
f = ( e->curstate.frame * ( pseqdesc->numframes - 1 )) / 256.0;
f += dfdt;
@ -632,13 +653,15 @@ float GAME_EXPORT R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqd
{
if( pseqdesc->numframes > 1 )
f -= (int)( f / ( pseqdesc->numframes - 1 )) * ( pseqdesc->numframes - 1 );
if( f < 0 ) f += (pseqdesc->numframes - 1);
if( f < 0 )
f += ( pseqdesc->numframes - 1 );
}
else
{
if( f >= pseqdesc->numframes - 1.001 )
f = pseqdesc->numframes - 1.001;
if( f < 0.0 ) f = 0.0;
if( f < 0.0 )
f = 0.0;
}
return f;
}
@ -656,7 +679,8 @@ static float R_StudioEstimateInterpolant( cl_entity_t *e )
if( g_studio.interpolate && ( e->curstate.animtime >= e->latched.prevanimtime + 0.01f ))
{
dadt = ( g_studio.time - e->curstate.animtime ) / 0.1f;
if( dadt > 2.0f ) dadt = 2.0f;
if( dadt > 2.0f )
dadt = 2.0f;
}
return dadt;
@ -678,7 +702,8 @@ static void R_StudioFxTransform( cl_entity_t *ent, matrix3x4 transform )
{
int axis = gEngfuncs.COM_RandomLong( 0, 1 );
if( axis == 1 ) axis = 2; // choose between x & z
if( axis == 1 )
axis = 2; // choose between x & z
VectorScale( transform[axis], gEngfuncs.COM_RandomFloat( 1.0f, 1.484f ), transform[axis] );
}
else if( !gEngfuncs.COM_RandomLong( 0, 49 ))
@ -686,7 +711,8 @@ static void R_StudioFxTransform( cl_entity_t *ent, matrix3x4 transform )
float offset;
int axis = gEngfuncs.COM_RandomLong( 0, 1 );
if( axis == 1 ) axis = 2; // choose between x & z
if( axis == 1 )
axis = 2; // choose between x & z
offset = gEngfuncs.COM_RandomFloat( -10.0f, 10.0f );
transform[gEngfuncs.COM_RandomLong( 0, 2 )][3] += offset;
}
@ -696,7 +722,8 @@ static void R_StudioFxTransform( cl_entity_t *ent, matrix3x4 transform )
float scale;
scale = 1.0f + ( g_studio.time - ent->curstate.animtime ) * 10.0f;
if( scale > 2.0f ) scale = 2.0f; // don't blow up more than 200%
if( scale > 2.0f )
scale = 2.0f; // don't blow up more than 200%
transform[0][1] *= scale;
transform[1][1] *= scale;
@ -813,9 +840,12 @@ static void R_StudioCalcRotations( cl_entity_t *e, float pos[][3], vec4_t *q, ms
R_StudioCalcBonePosition( frame, s, pbone, panim, adj, pos[i] );
}
if( pseqdesc->motiontype & STUDIO_X ) pos[pseqdesc->motionbone][0] = 0.0f;
if( pseqdesc->motiontype & STUDIO_Y ) pos[pseqdesc->motionbone][1] = 0.0f;
if( pseqdesc->motiontype & STUDIO_Z ) pos[pseqdesc->motionbone][2] = 0.0f;
if( pseqdesc->motiontype & STUDIO_X )
pos[pseqdesc->motionbone][0] = 0.0f;
if( pseqdesc->motiontype & STUDIO_Y )
pos[pseqdesc->motionbone][1] = 0.0f;
if( pseqdesc->motiontype & STUDIO_Z )
pos[pseqdesc->motionbone][2] = 0.0f;
}
/*
@ -1008,7 +1038,8 @@ static void R_StudioSetupBones( cl_entity_t *e )
else if( !Q_strcmp( pbones[pbones[i].parent].name, "Bip01 Pelvis" ))
copy_bones = true;
if( !copy_bones ) continue;
if( !copy_bones )
continue;
VectorCopy( pos2[i], pos[i] );
Vector4Copy( q2[i], q[i] );
@ -1088,7 +1119,8 @@ static void R_StudioBuildNormalTable( void )
while(( i = *( ptricmds++ )))
{
if( i < 0 ) i = -i;
if( i < 0 )
i = -i;
for( ; i > 0; i--, ptricmds += 4 )
{
@ -1104,7 +1136,8 @@ static void R_StudioBuildNormalTable( void )
if( e->curstate.rendercolor.r || e->curstate.rendercolor.g || e->curstate.rendercolor.b )
TriColor4ub( e->curstate.rendercolor.r, e->curstate.rendercolor.g, e->curstate.rendercolor.b, 255 );
else TriColor4ub( 255, 255, 255, 255 );
else
TriColor4ub( 255, 255, 255, 255 );
}
/*
@ -1186,8 +1219,10 @@ static void R_StudioGenerateNormals( void )
VectorAdd( g_studio.norms[v1], norm, g_studio.norms[v1] );
VectorAdd( g_studio.norms[v2], norm, g_studio.norms[v2] );
if( odd ) v1 = v2;
else v0 = v2;
if( odd )
v1 = v2;
else
v0 = v2;
odd = !odd;
}
@ -1294,8 +1329,10 @@ static void R_StudioSetupModel( int bodypart, void **ppbodypart, void **ppsubmod
m_pSubModel = (mstudiomodel_t *)((byte *)m_pStudioHeader + m_pBodyPart->modelindex ) + index;
if( ppbodypart ) *ppbodypart = m_pBodyPart;
if( ppsubmodel ) *ppsubmodel = m_pSubModel;
if( ppbodypart )
*ppbodypart = m_pBodyPart;
if( ppsubmodel )
*ppsubmodel = m_pSubModel;
}
/*
@ -1344,7 +1381,8 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
// determine plane to get lightvalues from: ceil or floor
if( FBitSet( ent->curstate.effects, EF_INVLIGHT ))
VectorSet( lightDir, 0.0f, 0.0f, 1.0f );
else VectorSet( lightDir, 0.0f, 0.0f, -1.0f );
else
VectorSet( lightDir, 0.0f, 0.0f, -1.0f );
VectorCopy( ent->origin, origin );
@ -1370,8 +1408,10 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
}
trace = gEngfuncs.CL_TraceLine( vecSrc, vecEnd, PM_WORLD_ONLY );
if( trace.ent > 0 ) psurf = gEngfuncs.EV_TraceSurface( trace.ent, vecSrc, vecEnd );
else psurf = gEngfuncs.EV_TraceSurface( 0, vecSrc, vecEnd );
if( trace.ent > 0 )
psurf = gEngfuncs.EV_TraceSurface( trace.ent, vecSrc, vecEnd );
else
psurf = gEngfuncs.EV_TraceSurface( 0, vecSrc, vecEnd );
if( FBitSet( ent->model->flags, STUDIO_FORCE_SKYLIGHT ) || ( psurf && FBitSet( psurf->flags, SURF_DRAWSKY )))
{
@ -1442,7 +1482,8 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
ent->cvFloorColor = light;
total = Q_max( Q_max( light.r, light.g ), light.b );
if( total == 0.0f ) total = 1.0f;
if( total == 0.0f )
total = 1.0f;
// scale lightdir by light intentsity
VectorScale( lightDir, total, lightDir );
@ -1465,7 +1506,8 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
if( radius > 1.0f )
VectorScale( dist, ( add / radius ), dist );
else VectorScale( dist, add, dist );
else
VectorScale( dist, add, dist );
VectorAdd( lightDir, dist, lightDir );
@ -1477,7 +1519,8 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
if( FBitSet( ent->model->flags, STUDIO_AMBIENT_LIGHT ))
add = 0.6f;
else add = bound( 0.75f, v_direct->value, 1.0f );
else
add = bound( 0.75f, v_direct->value, 1.0f );
VectorScale( lightDir, add, lightDir );
@ -1492,7 +1535,8 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
plight->color[1] = finalLight[1] * ( 1.0f / total );
plight->color[2] = finalLight[2] * ( 1.0f / total );
}
else VectorSet( plight->color, 1.0f, 1.0f, 1.0f );
else
VectorSet( plight->color, 1.0f, 1.0f, 1.0f );
if( plight->ambientlight > 128 )
plight->ambientlight = 128;
@ -1541,8 +1585,10 @@ static void R_StudioEntityLight( alight_t *lightinfo )
{
int att = ( el->key >> 12 ) & 0xF;
if( att ) VectorCopy( ent->attachment[att], el->origin );
else VectorCopy( ent->origin, el->origin );
if( att )
VectorCopy( ent->attachment[att], el->origin );
else
VectorCopy( ent->origin, el->origin );
}
VectorCopy( el->origin, pos );
@ -1551,8 +1597,10 @@ static void R_StudioEntityLight( alight_t *lightinfo )
f = DotProduct( mid, mid );
r2 = el->radius * el->radius;
if( f > r2 ) minstrength = r2 / f;
else minstrength = 1.0f;
if( f > r2 )
minstrength = r2 / f;
else
minstrength = 1.0f;
if( minstrength > 0.05f )
{
@ -1567,7 +1615,8 @@ static void R_StudioEntityLight( alight_t *lightinfo )
}
}
}
else k = g_studio.numlocallights;
else
k = g_studio.numlocallights;
if( k != -1 )
{
@ -1609,7 +1658,8 @@ static void R_StudioSetupLighting( alight_t *plight )
for( i = 0; i < m_pStudioHeader->numbones; i++ )
{
Matrix3x4_VectorIRotate( g_studio.lighttransform[i], plight->plightvec, g_studio.blightvec[i] );
if( scale > 1.0f ) VectorNormalize( g_studio.blightvec[i] ); // in case model may be scaled
if( scale > 1.0f )
VectorNormalize( g_studio.blightvec[i] ); // in case model may be scaled
}
VectorCopy( plight->color, g_studio.lightcolor );
@ -1641,9 +1691,12 @@ static void R_StudioLighting( float *lv, int bone, int flags, vec3_t normal )
{
float r, lightcos;
if( bone != -1 ) lightcos = DotProduct( normal, g_studio.blightvec[bone] );
else lightcos = DotProduct( normal, g_studio.lightvec ); // -1 colinear, 1 opposite
if( lightcos > 1.0f ) lightcos = 1.0f;
if( bone != -1 )
lightcos = DotProduct( normal, g_studio.blightvec[bone] );
else
lightcos = DotProduct( normal, g_studio.lightvec ); // -1 colinear, 1 opposite
if( lightcos > 1.0f )
lightcos = 1.0f;
illum += g_studio.shadelight;
@ -1710,7 +1763,8 @@ static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal,
if( r2 > 0.0f )
light[i][3] = g_studio.locallightR2[i] / ( r2 * sqrt( r2 ));
else light[i][3] = 0.0001f;
else
light[i][3] = 0.0001f;
}
temp = r * light[i][3];
@ -1798,12 +1852,15 @@ static void R_StudioSetupSkin( studiohdr_t *ptexturehdr, int index )
return;
// NOTE: user may ignore to call StudioRemapColors and remap_info will be unavailable
if( m_fDoRemap ) ptexture = gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity )->ptexture;
if( !ptexture ) ptexture = (mstudiotexture_t *)((byte *)ptexturehdr + ptexturehdr->textureindex); // fallback
if( m_fDoRemap )
ptexture = gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity )->ptexture;
if( !ptexture )
ptexture = (mstudiotexture_t *)((byte *)ptexturehdr + ptexturehdr->textureindex ); // fallback
if( r_lightmap->value && !r_fullbright->value )
GL_Bind( XASH_TEXTURE0, tr.whiteTexture );
else GL_Bind( XASH_TEXTURE0, ptexture[index].index );
else
GL_Bind( XASH_TEXTURE0, ptexture[index].index );
}
/*
@ -1822,17 +1879,21 @@ mstudiotexture_t * GAME_EXPORT R_StudioGetTexture( cl_entity_t *e )
return NULL;
thdr = m_pStudioHeader;
if( !thdr ) return NULL;
if( !thdr )
return NULL;
if( m_fDoRemap ) ptexture = gEngfuncs.CL_GetRemapInfoForEntity( e )->ptexture;
else ptexture = (mstudiotexture_t *)((byte *)thdr + thdr->textureindex);
if( m_fDoRemap )
ptexture = gEngfuncs.CL_GetRemapInfoForEntity( e )->ptexture;
else
ptexture = (mstudiotexture_t *)((byte *)thdr + thdr->textureindex );
return ptexture;
}
static void R_StudioSetRenderamt( int iRenderamt )
{
if( !RI.currententity ) return;
if( !RI.currententity )
return;
RI.currententity->curstate.renderamt = iRenderamt;
tr.blend = CL_FxBlend( RI.currententity ) / 255.0f;
@ -1919,7 +1980,8 @@ static void R_StudioDrawNormalMesh( short *ptricmds, vec3_t *pstudionorms, float
TriBegin( TRI_TRIANGLE_FAN );
i = -i;
}
else TriBegin( TRI_TRIANGLE_STRIP );
else
TriBegin( TRI_TRIANGLE_STRIP );
for( ; i > 0; i--, ptricmds += 4 )
{
@ -1952,7 +2014,8 @@ static void R_StudioDrawFloatMesh( short *ptricmds, vec3_t *pstudionorms )
TriBegin( TRI_TRIANGLE_FAN );
i = -i;
}
else TriBegin( TRI_TRIANGLE_STRIP );
else
TriBegin( TRI_TRIANGLE_STRIP );
for( ; i > 0; i--, ptricmds += 4 )
{
@ -1986,7 +2049,8 @@ static void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, float
TriBegin( TRI_TRIANGLE_FAN );
i = -i;
}
else TriBegin( TRI_TRIANGLE_STRIP );
else
TriBegin( TRI_TRIANGLE_STRIP );
for( ; i > 0; i--, ptricmds += 4 )
{
@ -2037,7 +2101,8 @@ static void R_StudioDrawPoints( void )
short *pskinref;
float lv_tmp;
if( !m_pStudioHeader ) return;
if( !m_pStudioHeader )
return;
m_skinnum = RI.currententity->curstate.skin;
ptexture = (mstudiotexture_t *)((byte *)m_pStudioHeader + m_pStudioHeader->textureindex );
@ -2115,7 +2180,8 @@ static void R_StudioDrawPoints( void )
{
if( FBitSet( m_pStudioHeader->flags, STUDIO_HAS_BONEWEIGHTS ))
R_StudioLighting( &lv_tmp, -1, g_nFaceFlags, g_studio.norms[k] );
else R_StudioLighting( &lv_tmp, *pnormbone, g_nFaceFlags, (float *)pstudionorms );
else
R_StudioLighting( &lv_tmp, *pnormbone, g_nFaceFlags, (float *)pstudionorms );
if( FBitSet( g_nFaceFlags, STUDIO_NF_CHROME ))
R_StudioSetupChrome( g_studio.chrome[k], *pnormbone, (float *)pstudionorms );
@ -2174,7 +2240,8 @@ static void R_StudioDrawPoints( void )
R_StudioDrawChromeMesh( ptricmds, pstudionorms, s, t, shellscale );
else if( FBitSet( g_nFaceFlags, STUDIO_NF_UV_COORDS ))
R_StudioDrawFloatMesh( ptricmds, pstudionorms );
else R_StudioDrawNormalMesh( ptricmds, pstudionorms, s, t );
else
R_StudioDrawNormalMesh( ptricmds, pstudionorms, s, t );
}
if( FBitSet( g_nFaceFlags, STUDIO_NF_MASKED ))
@ -2300,7 +2367,8 @@ static model_t *R_StudioSetupPlayerModel( int index )
if( gEngfuncs.fsapi->FileExists( state->modelname, false ))
state->model = gEngfuncs.Mod_ForName( state->modelname, false, true );
else state->model = NULL;
else
state->model = NULL;
if( !state->model )
state->model = RI.currententity->model;
@ -2336,7 +2404,8 @@ int R_GetEntityRenderMode( cl_entity_t *ent )
if( ent->player ) // check it for real playermodel
model = R_StudioSetupPlayerModel( ent->curstate.number - 1 );
else model = ent->model;
else
model = ent->model;
RI.currententity = oldent;
@ -2357,7 +2426,8 @@ int R_GetEntityRenderMode( cl_entity_t *ent )
// ignore chrome & additive it's just a specular-like effect
if( FBitSet( ptexture->flags, STUDIO_NF_ADDITIVE ) && !FBitSet( ptexture->flags, STUDIO_NF_CHROME ))
trans++;
else opaque++;
else
opaque++;
}
// if model is more additive than opaque
@ -2490,7 +2560,8 @@ static void R_StudioSetupRenderer( int rendermode )
studiohdr_t *phdr = m_pStudioHeader;
int i;
if( rendermode > kRenderTransAdd ) rendermode = 0;
if( rendermode > kRenderTransAdd )
rendermode = 0;
g_studio.rendermode = bound( 0, rendermode, kRenderTransAdd );
// a point to setup local to world transform for boneweighted models
@ -2744,12 +2815,15 @@ static void R_StudioEstimateGait( entity_state_t *pplayer )
float flYawDiff = RI.currententity->angles[YAW] - m_pPlayerInfo->gaityaw;
flYawDiff = flYawDiff - (int)( flYawDiff / 360 ) * 360;
if( flYawDiff > 180.0f ) flYawDiff -= 360.0f;
if( flYawDiff < -180.0f ) flYawDiff += 360.0f;
if( flYawDiff > 180.0f )
flYawDiff -= 360.0f;
if( flYawDiff < -180.0f )
flYawDiff += 360.0f;
if( dt < 0.25f )
flYawDiff *= dt * 4.0f;
else flYawDiff *= dt;
else
flYawDiff *= dt;
m_pPlayerInfo->gaityaw += flYawDiff;
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)( m_pPlayerInfo->gaityaw / 360 ) * 360;
@ -2759,8 +2833,10 @@ static void R_StudioEstimateGait( entity_state_t *pplayer )
else
{
m_pPlayerInfo->gaityaw = ( atan2( est_velocity[1], est_velocity[0] ) * 180 / M_PI_F );
if( m_pPlayerInfo->gaityaw > 180.0f ) m_pPlayerInfo->gaityaw = 180.0f;
if( m_pPlayerInfo->gaityaw < -180.0f ) m_pPlayerInfo->gaityaw = -180.0f;
if( m_pPlayerInfo->gaityaw > 180.0f )
m_pPlayerInfo->gaityaw = 180.0f;
if( m_pPlayerInfo->gaityaw < -180.0f )
m_pPlayerInfo->gaityaw = -180.0f;
}
}
@ -2795,8 +2871,10 @@ static void R_StudioProcessGait( entity_state_t *pplayer )
// calc side to side turning
flYaw = RI.currententity->angles[YAW] - m_pPlayerInfo->gaityaw;
flYaw = flYaw - (int)( flYaw / 360 ) * 360;
if( flYaw < -180.0f ) flYaw = flYaw + 360.0f;
if( flYaw > 180.0f ) flYaw = flYaw - 360.0f;
if( flYaw < -180.0f )
flYaw = flYaw + 360.0f;
if( flYaw > 180.0f )
flYaw = flYaw - 360.0f;
if( flYaw > 120.0f )
{
@ -2822,7 +2900,8 @@ static void R_StudioProcessGait( entity_state_t *pplayer )
RI.currententity->latched.prevcontroller[3] = RI.currententity->curstate.controller[3];
RI.currententity->angles[YAW] = m_pPlayerInfo->gaityaw;
if( RI.currententity->angles[YAW] < -0 ) RI.currententity->angles[YAW] += 360.0f;
if( RI.currententity->angles[YAW] < -0 )
RI.currententity->angles[YAW] += 360.0f;
RI.currententity->latched.prevangles[YAW] = RI.currententity->angles[YAW];
if( pplayer->gaitsequence >= m_pStudioHeader->numseq )
@ -2833,11 +2912,13 @@ static void R_StudioProcessGait( entity_state_t *pplayer )
// calc gait frame
if( pseqdesc->linearmovement[0] > 0 )
m_pPlayerInfo->gaitframe += ( m_flGaitMovement / pseqdesc->linearmovement[0] ) * pseqdesc->numframes;
else m_pPlayerInfo->gaitframe += pseqdesc->fps * dt;
else
m_pPlayerInfo->gaitframe += pseqdesc->fps * dt;
// do modulo
m_pPlayerInfo->gaitframe = m_pPlayerInfo->gaitframe - (int)( m_pPlayerInfo->gaitframe / pseqdesc->numframes ) * pseqdesc->numframes;
if( m_pPlayerInfo->gaitframe < 0 ) m_pPlayerInfo->gaitframe += pseqdesc->numframes;
if( m_pPlayerInfo->gaitframe < 0 )
m_pPlayerInfo->gaitframe += pseqdesc->numframes;
}
/*
@ -2954,10 +3035,14 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
g_nTopColor = m_pPlayerInfo->topcolor;
g_nBottomColor = m_pPlayerInfo->bottomcolor;
if( g_nTopColor < 0 ) g_nTopColor = 0;
if( g_nTopColor > 360 ) g_nTopColor = 360;
if( g_nBottomColor < 0 ) g_nBottomColor = 0;
if( g_nBottomColor > 360 ) g_nBottomColor = 360;
if( g_nTopColor < 0 )
g_nTopColor = 0;
if( g_nTopColor > 360 )
g_nTopColor = 360;
if( g_nBottomColor < 0 )
g_nBottomColor = 0;
if( g_nBottomColor > 360 )
g_nBottomColor = 360;
R_StudioSetRemapColors( g_nTopColor, g_nBottomColor );
@ -2999,8 +3084,8 @@ static int R_StudioDrawModel( int flags )
entity_state_t deadplayer;
int result;
if( RI.currententity->curstate.renderamt <= 0 ||
RI.currententity->curstate.renderamt > gp_cl->maxclients )
if( RI.currententity->curstate.renderamt <= 0
|| RI.currententity->curstate.renderamt > gp_cl->maxclients )
return 0;
// get copy of player
@ -3041,7 +3126,8 @@ static int R_StudioDrawModel( int flags )
if( RI.currententity->curstate.movetype == MOVETYPE_FOLLOW )
R_StudioMergeBones( RI.currententity, RI.currentmodel );
else R_StudioSetupBones( RI.currententity );
else
R_StudioSetupBones( RI.currententity );
R_StudioSaveBones();
@ -3091,14 +3177,16 @@ static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
{
if( e->player )
R_StudioDrawPlayer( flags, &e->curstate );
else R_StudioDrawModel( flags );
else
R_StudioDrawModel( flags );
}
else
{
// select the properly method
if( e->player )
pStudioDraw->StudioDrawPlayer( flags, R_StudioGetPlayerState( e->index - 1 ));
else pStudioDraw->StudioDrawModel( flags );
else
pStudioDraw->StudioDrawModel( flags );
}
}

View file

@ -93,7 +93,8 @@ static void R_AddDynamicLights( const msurface_t *surf )
sample_frac = surf->texinfo->faceinfo->texture_step;
else if( FBitSet( surf->texinfo->flags, TEX_EXTRA_LIGHTMAP ))
sample_frac = LM_SAMPLE_EXTRASIZE;
else sample_frac = LM_SAMPLE_SIZE;
else
sample_frac = LM_SAMPLE_SIZE;
}
for( lnum = 0; lnum < MAX_DLIGHTS; lnum++ )
@ -112,7 +113,8 @@ static void R_AddDynamicLights( const msurface_t *surf )
// transform light origin to local bmodel space
if( !tr.modelviewIdentity )
Matrix4x4_VectorITransform( RI.objectMatrix, dl->origin, origin_l );
else VectorCopy( dl->origin, origin_l );
else
VectorCopy( dl->origin, origin_l );
rad = dl->radius;
dist = PlaneDiff( origin_l, surf->plane );
@ -130,7 +132,8 @@ static void R_AddDynamicLights( const msurface_t *surf )
VectorCopy( origin_l, impact );
impact[surf->plane->type] -= dist;
}
else VectorMA( origin_l, -dist, surf->plane->normal, impact );
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];
@ -221,7 +224,8 @@ static void R_BuildLightMap( void )
{
if( blocklights[i] < 65280 )
t = LightToTexGamma( blocklights[i] >> 6 ) << 6;
else t = (int)blocklights[i];
else
t = (int)blocklights[i];
t = bound( 0, t, 65535 * 3 );
t = t / 2048 / 3; // (255*256 - t) >> (8 - VID_CBITS);
@ -280,7 +284,8 @@ static texture_t *R_TextureAnim( texture_t *b )
// Quake1 textures uses 10 frames per second
if( FBitSet( R_GetTexture( base->gl_texturenum )->flags, TF_QUAKEPAL ))
speed = 10;
else speed = 20;
else
speed = 20;
reletive = (int)( gp_cl->time * speed ) % base->anim_total;
}
@ -334,7 +339,8 @@ static texture_t *R_TextureAnimation( msurface_t *s )
// Quake1 textures uses 10 frames per second
if( FBitSet( R_GetTexture( base->gl_texturenum )->flags, TF_QUAKEPAL ))
speed = 10;
else speed = 20;
else
speed = 20;
reletive = (int)( gp_cl->time * speed ) % base->anim_total;
}
@ -381,7 +387,8 @@ void R_DrawSurface (void)
if( sample_bits == -1 )
{
sample_bits = 0;
for( sample_pot = 1; sample_pot < sample_size; sample_pot <<= 1, sample_bits++ );
for( sample_pot = 1; sample_pot < sample_size; sample_pot <<= 1, sample_bits++ )
;
}
else
sample_pot = 1 << sample_bits;
@ -1005,10 +1012,10 @@ static void R_DrawSurfaceDecals( void )
R_DecalComputeBasis( fa, 0, basis );
w = fabs( tex->width * DotProduct( textureU, basis[0] )) +
fabs( tex->height * DotProduct( textureU, basis[1] ));
h = fabs( tex->width * DotProduct( textureV, basis[0] )) +
fabs( tex->height * DotProduct( textureV, basis[1] ));
w = fabs( tex->width * DotProduct( textureU, basis[0] ))
+ fabs( tex->height * DotProduct( textureU, basis[1] ));
h = fabs( tex->width * DotProduct( textureV, basis[0] ))
+ fabs( tex->height * DotProduct( textureV, basis[1] ));
// project decal center into the texture space of the surface
x = DotProduct( p->position, textureU ) + textureU[3] - fa->texturemins[0] - w / 2;

View file

@ -165,7 +165,8 @@ void TriColor4f( float r, float g, float b, float a )
// a = 1;
if( ds.renderMode == kRenderTransAlpha )
TriColor4ub( r * 255.0f, g * 255.0f, b * 255.0f, a * 255.0f );
else _TriColor4f( r * a, g * a, b * a, 1.0 );
else
_TriColor4f( r * a, g * a, b * a, 1.0 );
ds.triRGBA[0] = r;
ds.triRGBA[1] = g;