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; float scale;
scale = (ALIAS_Z_CLIP_PLANE - pfv0->xyz[2]) / scale = ( ALIAS_Z_CLIP_PLANE - pfv0->xyz[2] )
(pfv1->xyz[2] - pfv0->xyz[2]); / ( pfv1->xyz[2] - pfv0->xyz[2] );
out->xyz[0] = pfv0->xyz[0] + ( pfv1->xyz[0] - pfv0->xyz[0] ) * scale; 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; 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 ) if( pfv0->v >= pfv1->v )
{ {
scale = (float)(RI.aliasvrect.x - pfv0->u) / scale = (float)( RI.aliasvrect.x - pfv0->u )
(pfv1->u - pfv0->u); / ( pfv1->u - pfv0->u );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f; out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * 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; 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 else
{ {
scale = (float)(RI.aliasvrect.x - pfv1->u) / scale = (float)( RI.aliasvrect.x - pfv1->u )
(pfv0->u - pfv1->u); / ( pfv0->u - pfv1->u );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f; out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * 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; 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 ) if( pfv0->v >= pfv1->v )
{ {
scale = (float)(RI.aliasvrectright - pfv0->u ) / scale = (float)( RI.aliasvrectright - pfv0->u )
(pfv1->u - pfv0->u ); / ( pfv1->u - pfv0->u );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f; out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * 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; 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 else
{ {
scale = (float)(RI.aliasvrectright - pfv1->u ) / scale = (float)( RI.aliasvrectright - pfv1->u )
(pfv0->u - pfv1->u ); / ( pfv0->u - pfv1->u );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f; out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * 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; 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 ) if( pfv0->v >= pfv1->v )
{ {
scale = (float)(RI.aliasvrect.y - pfv0->v) / scale = (float)( RI.aliasvrect.y - pfv0->v )
(pfv1->v - pfv0->v); / ( pfv1->v - pfv0->v );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f; out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * 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; 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 else
{ {
scale = (float)(RI.aliasvrect.y - pfv1->v) / scale = (float)( RI.aliasvrect.y - pfv1->v )
(pfv0->v - pfv1->v); / ( pfv0->v - pfv1->v );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f; out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * 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; 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 ) if( pfv0->v >= pfv1->v )
{ {
scale = (float)(RI.aliasvrectbottom - pfv0->v) / scale = (float)( RI.aliasvrectbottom - pfv0->v )
(pfv1->v - pfv0->v); / ( pfv1->v - pfv0->v );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f; out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * 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 else
{ {
scale = (float)(RI.aliasvrectbottom - pfv1->v) / scale = (float)( RI.aliasvrectbottom - pfv1->v )
(pfv0->v - pfv1->v); / ( pfv0->v - pfv1->v );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f; out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * 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; int div2;
div2 = divs >> 1; div2 = divs >> 1;
if( divs < 2 ) return; if( divs < 2 )
return;
// noise is normalized to +/- scale // noise is normalized to +/- scale
noise[div2] = ( noise[0] + noise[divs] ) * 0.5f + divs * gEngfuncs.COM_RandomFloat( -0.125f, 0.125f ); 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 }; vec3_t perp1, vLastNormal = { 0.0f };
beamseg_t curSeg; beamseg_t curSeg;
if( segments < 2 ) return; if( segments < 2 )
return;
length = VectorLength( delta ); length = VectorLength( delta );
flMaxWidth = width * 0.5f; 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 // here, we have too many segments; we could get overlap... so lets have less segments
segments = (int)( length / ( flMaxWidth * 1.414f )) + 1.0f; segments = (int)( length / ( flMaxWidth * 1.414f )) + 1.0f;
if( segments < 2 ) segments = 2; if( segments < 2 )
segments = 2;
} }
if( segments > NOISE_DIVISIONS ) 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( FBitSet( flags, FBEAM_SHADEIN ) && FBitSet( flags, FBEAM_SHADEOUT ))
{ {
if( fraction < 0.5f ) brightness = fraction; if( fraction < 0.5f )
else brightness = ( 1.0f - fraction ); brightness = fraction;
else
brightness = ( 1.0f - fraction );
} }
else if( FBitSet( flags, FBEAM_SHADEIN )) 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; segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01f; 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 ); 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; segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01f; 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 ); div = 1.0f / ( segments - 1 );
vStep = length * div; // Texture length texels per space pixel 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; segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01f; 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 ); div = 1.0f / ( segments - 1 );
vStep = length * div; // texture length texels per space pixel vStep = length * div; // texture length texels per space pixel
@ -620,7 +628,8 @@ static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
} }
// nothing to draw // nothing to draw
if( !particles ) return; if( !particles )
return;
if( !pnew && div != 0 ) 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; segments = NOISE_DIVISIONS * 8;
length = VectorLength( delta ) * 0.01f * M_PI_F; 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 ); div = 1.0f / ( segments - 1 );
@ -868,7 +878,8 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
if( beamEnt < 0 ) if( beamEnt < 0 )
attach = BEAMENT_ATTACHMENT( -beamEnt ); attach = BEAMENT_ATTACHMENT( -beamEnt );
else attach = BEAMENT_ATTACHMENT( beamEnt ); else
attach = BEAMENT_ATTACHMENT( beamEnt );
if( !ent ) if( !ent )
{ {
@ -882,7 +893,8 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
VectorCopy( ent->attachment[attach - 1], pt ); VectorCopy( ent->attachment[attach - 1], pt );
else if( ent->index == ( gp_cl->playernum + 1 )) else if( ent->index == ( gp_cl->playernum + 1 ))
VectorCopy( gp_cl->simorg, pt ); VectorCopy( gp_cl->simorg, pt );
else VectorCopy( ent->origin, pt ); else
VectorCopy( ent->origin, pt );
return true; return true;
} }
@ -976,7 +988,8 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
{ {
if( FBitSet( pbeam->flags, FBEAM_SINENOISE )) if( FBitSet( pbeam->flags, FBEAM_SINENOISE ))
SineNoise( rgNoise, NOISE_DIVISIONS ); SineNoise( rgNoise, NOISE_DIVISIONS );
else FracNoise( rgNoise, NOISE_DIVISIONS ); else
FracNoise( rgNoise, NOISE_DIVISIONS );
} }
// update end points // update end points
@ -998,7 +1011,8 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
if( pbeam->amplitude >= 0.50f ) if( pbeam->amplitude >= 0.50f )
pbeam->segments = VectorLength( pbeam->delta ) * 0.25f + 3.0f; // one per 4 pixels 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 )) 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 // update life cycle
pbeam->t = pbeam->freq + ( pbeam->die - gp_cl->time ); 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 ) if( pbeam->type == TE_BEAMHOSE )
@ -1050,8 +1065,10 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
if( flDistance > 30 ) if( flDistance > 30 )
{ {
flDistance = 1.0f - (( flDistance - 30.0f ) / 64.0f ); flDistance = 1.0f - (( flDistance - 30.0f ) / 64.0f );
if( flDistance <= 0 ) flFade = 0; if( flDistance <= 0 )
else flFade *= pow( flDistance, 3 ); flFade = 0;
else
flFade *= pow( flDistance, 3 );
} }
if( flFade < ( 1.0f / 255.0f )) 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 ); TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->t * pbeam->brightness );
else if( FBitSet( pbeam->flags, FBEAM_FADEOUT )) else if( FBitSet( pbeam->flags, FBEAM_FADEOUT ))
TriColor4f( pbeam->r, pbeam->g, pbeam->b, ( 1.0f - pbeam->t ) * pbeam->brightness ); 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 ) 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 ); model_t *sprite = CL_ModelHandle( modelIndex );
if( !sprite ) return; if( !sprite )
return;
pbeam->type = BEAM_POINTS; pbeam->type = BEAM_POINTS;
pbeam->modelIndex = modelIndex; 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 ) if( amplitude >= 0.50f )
pbeam->segments = VectorLength( pbeam->delta ) * 0.25f + 3.0f; // one per 4 pixels 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->pFollowModel = NULL;
pbeam->flags = 0; 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] ) 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] + out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0]
in1[0][2] * in2[2][0]; + in1[0][2] * in2[2][0];
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1]
in1[0][2] * in2[2][1]; + in1[0][2] * in2[2][1];
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2]
in1[0][2] * in2[2][2]; + in1[0][2] * in2[2][2];
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0]
in1[1][2] * in2[2][0]; + in1[1][2] * in2[2][0];
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1]
in1[1][2] * in2[2][1]; + in1[1][2] * in2[2][1];
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2]
in1[1][2] * in2[2][2]; + in1[1][2] * in2[2][2];
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0]
in1[2][2] * in2[2][0]; + in1[2][2] * in2[2][0];
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1]
in1[2][2] * in2[2][1]; + in1[2][2] * in2[2][1];
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2]
in1[2][2] * in2[2][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 // transform the BSP plane into model space
// FIXME: cache these? // FIXME: cache these?
splitplane = pnode->plane; splitplane = pnode->plane;
tplane.dist = splitplane->dist - tplane.dist = splitplane->dist
DotProduct(r_entorigin, splitplane->normal); - DotProduct( r_entorigin, splitplane->normal );
tplane.normal[0] = DotProduct( entity_rotation[0], splitplane->normal ); tplane.normal[0] = DotProduct( entity_rotation[0], splitplane->normal );
tplane.normal[1] = DotProduct( entity_rotation[1], splitplane->normal ); tplane.normal[1] = DotProduct( entity_rotation[1], splitplane->normal );
tplane.normal[2] = DotProduct( entity_rotation[2], 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 // set the status for the last point as the previous point
// FIXME: cache this stuff somehow? // FIXME: cache this stuff somehow?
plastvert = pedges->v[0]; plastvert = pedges->v[0];
lastdist = DotProduct (plastvert->position, tplane.normal) - lastdist = DotProduct( plastvert->position, tplane.normal )
tplane.dist; - tplane.dist;
if( lastdist > 0 ) if( lastdist > 0 )
lastside = 0; lastside = 0;
@ -231,15 +231,15 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
// generate the clipped vertex // generate the clipped vertex
frac = lastdist / ( lastdist - dist ); frac = lastdist / ( lastdist - dist );
ptvert = &pbverts[numbverts++]; ptvert = &pbverts[numbverts++];
ptvert->position[0] = plastvert->position[0] + ptvert->position[0] = plastvert->position[0]
frac * (pvert->position[0] - + frac * ( pvert->position[0]
plastvert->position[0]); - plastvert->position[0] );
ptvert->position[1] = plastvert->position[1] + ptvert->position[1] = plastvert->position[1]
frac * (pvert->position[1] - + frac * ( pvert->position[1]
plastvert->position[1]); - plastvert->position[1] );
ptvert->position[2] = plastvert->position[2] + ptvert->position[2] = plastvert->position[2]
frac * (pvert->position[2] - + frac * ( pvert->position[2]
plastvert->position[2]); - plastvert->position[2] );
// split into two edges, one on each side, and remember entering // split into two edges, one on each side, and remember entering
// and exiting points // and exiting points
@ -379,8 +379,8 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist; dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
// draw the polygon // draw the polygon
if (( !(psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) || if(( !( psurf->flags & SURF_PLANEBACK ) && ( dot < -BACKFACE_EPSILON ))
((psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) || (( psurf->flags & SURF_PLANEBACK ) && ( dot > BACKFACE_EPSILON )))
continue; continue;
// FIXME: use bounding-box-based frustum clipping info? // 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; dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
// draw the polygon // draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) || if((( psurf->flags & SURF_PLANEBACK ) && ( dot < -BACKFACE_EPSILON ))
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) || ( !( psurf->flags & SURF_PLANEBACK ) && ( dot > BACKFACE_EPSILON )))
{ {
r_currentkey = LEAF_KEY(((mleaf_t *)topnode )); 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 )->visframe = tr.framecount;
mark++; mark++;
} while (--c); }
while( --c );
} }
// deal with model fragments in this leaf // deal with model fragments in this leaf
@ -605,27 +606,29 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
{ {
do do
{ {
if ((surf->flags & SURF_PLANEBACK) && if(( surf->flags & SURF_PLANEBACK )
(surf->visframe == tr.framecount)) && ( surf->visframe == tr.framecount ))
{ {
R_RenderFace( surf, clipflags ); R_RenderFace( surf, clipflags );
} }
surf++; surf++;
} while (--c); }
while( --c );
} }
else if( dot > BACKFACE_EPSILON ) else if( dot > BACKFACE_EPSILON )
{ {
do do
{ {
if (!(surf->flags & SURF_PLANEBACK) && if( !( surf->flags & SURF_PLANEBACK )
(surf->visframe == tr.framecount)) && ( surf->visframe == tr.framecount ))
{ {
R_RenderFace( surf, clipflags ); R_RenderFace( surf, clipflags );
} }
surf++; surf++;
} while (--c); }
while( --c );
} }
// all surfaces on the same node share the same sequence number // 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 ); image_t *glt = R_GetTexture( texture );
if( xScale ) *xScale = glt->xscale; if( xScale )
if( yScale ) *yScale = glt->yscale; *xScale = glt->xscale;
if( yScale )
*yScale = glt->yscale;
} }
static void GAME_EXPORT R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density ) static void GAME_EXPORT R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
{ {
image_t *glt = R_GetTexture( texture ); image_t *glt = R_GetTexture( texture );
if( red ) *red = glt->fogParams[0]; if( red )
if( green ) *green = glt->fogParams[1]; *red = glt->fogParams[0];
if( blue ) *blue = glt->fogParams[2]; if( green )
if( density ) *density = glt->fogParams[3]; *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 else
{ {
tmp = pdecal->psurface->pdecals; 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 ) while( tmp->pnext )
{ {
@ -105,7 +106,8 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
if( r_decals->value < limit ) if( r_decals->value < limit )
limit = r_decals->value; limit = r_decals->value;
if( !limit ) return NULL; if( !limit )
return NULL;
if( !pdecal ) if( !pdecal )
{ {
@ -120,7 +122,8 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
pdecal = &gDecalPool[gDecalCount]; // reuse next decal pdecal = &gDecalPool[gDecalCount]; // reuse next decal
gDecalCount++; gDecalCount++;
count++; 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. // 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 ) static void R_GetDecalDimensions( int texture, int *width, int *height )
{ {
if( width ) *width = 1; // to avoid divide by zero if( width )
if( height ) *height = 1; *width = 1; // to avoid divide by zero
if( height )
*height = 1;
R_GetTextureParms( width, height, texture ); R_GetTextureParms( width, height, texture );
} }
@ -150,7 +155,8 @@ void R_DecalComputeBasis( msurface_t *surf, int flags, vec3_t textureSpaceBasis[
// setup normal // setup normal
if( surf->flags & SURF_PLANEBACK ) if( surf->flags & SURF_PLANEBACK )
VectorNegate( surf->plane->normal, surfaceNormal ); VectorNegate( surf->plane->normal, surfaceNormal );
else VectorCopy( surf->plane->normal, surfaceNormal ); else
VectorCopy( surf->plane->normal, surfaceNormal );
VectorNormalize2( surfaceNormal, textureSpaceBasis[2] ); VectorNormalize2( surfaceNormal, textureSpaceBasis[2] );
VectorNormalize2( surf->texinfo->vecs[0], textureSpaceBasis[0] ); 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; return pdecal->polys;
v = R_DecalSetupVerts( pdecal, surf, pdecal->texture, &lnumverts ); 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 // allocate glpoly
// REFTODO: com_studiocache pool! // 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; decal_t *pdecal, *pold;
int count, vertCount; int count, vertCount;
if( !surf ) return; // ??? if( !surf )
return; // ???
pold = R_DecalIntersect( decalinfo, surf, &count ); pold = R_DecalIntersect( decalinfo, surf, &count );
if( count < MAX_OVERLAP_DECALS ) pold = NULL; if( count < MAX_OVERLAP_DECALS )
pold = NULL;
pdecal = R_DecalAlloc( pold ); pdecal = R_DecalAlloc( pold );
if( !pdecal ) return; // r_decals == 0 ??? if( !pdecal )
return; // r_decals == 0 ???
pdecal->flags = decalinfo->m_Flags; 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]) // (decalWidth * decalBasis[0], decalHeight * decalBasis[1])
// in texture coordinates: // in texture coordinates:
w = fabs( decalinfo->m_decalWidth * DotProduct( textureU, decalinfo->m_Basis[0] )) + w = fabs( decalinfo->m_decalWidth * DotProduct( textureU, decalinfo->m_Basis[0] ))
fabs( decalinfo->m_decalHeight * DotProduct( textureU, decalinfo->m_Basis[1] )); + fabs( decalinfo->m_decalHeight * DotProduct( textureU, decalinfo->m_Basis[1] ));
h = fabs( decalinfo->m_decalWidth * DotProduct( textureV, decalinfo->m_Basis[0] )) + h = fabs( decalinfo->m_decalWidth * DotProduct( textureV, decalinfo->m_Basis[0] ))
fabs( decalinfo->m_decalHeight * DotProduct( textureV, decalinfo->m_Basis[1] )); + fabs( decalinfo->m_decalHeight * DotProduct( textureV, decalinfo->m_Basis[1] ));
// move s,t to upper left corner // move s,t to upper left corner
s -= ( w * 0.5f ); s -= ( w * 0.5f );
@ -754,15 +764,20 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
{ {
ent = CL_GetEntityByIndex( entityIndex ); ent = CL_GetEntityByIndex( entityIndex );
if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex ); if( modelIndex > 0 )
else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex ); model = CL_ModelHandle( modelIndex );
else return; else if( ent != NULL )
model = CL_ModelHandle( ent->curstate.modelindex );
else
return;
} }
else if( modelIndex > 0 ) else if( modelIndex > 0 )
model = CL_ModelHandle( modelIndex ); model = CL_ModelHandle( modelIndex );
else model = WORLDMODEL; else
model = WORLDMODEL;
if( !model ) return; if( !model )
return;
if( model->type != mod_brush ) if( model->type != mod_brush )
{ {
@ -884,7 +899,8 @@ static qboolean R_DecalUnProject( decal_t *pdecal, decallist_t *entry )
// Grab surface plane equation // Grab surface plane equation
if( pdecal->psurface->flags & SURF_PLANEBACK ) if( pdecal->psurface->flags & SURF_PLANEBACK )
VectorNegate( pdecal->psurface->plane->normal, entry->impactPlaneNormal ); 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; return true;
} }

View file

@ -25,8 +25,10 @@ void R_GetTextureParms( int *w, int *h, int texnum )
image_t *glt; image_t *glt;
glt = R_GetTexture( texnum ); glt = R_GetTexture( texnum );
if( w ) *w = glt->srcWidth; if( w )
if( h ) *h = glt->srcHeight; *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; 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 ); pFrame = R_GetSpriteFrame( pSprite, currentFrame, 0.0f );
if( frameWidth ) *frameWidth = pFrame->width; if( frameWidth )
if( frameHeight ) *frameHeight = pFrame->height; *frameWidth = pFrame->width;
if( numFrames ) *numFrames = pSprite->numframes; if( frameHeight )
*frameHeight = pFrame->height;
if( numFrames )
*numFrames = pSprite->numframes;
} }
int GAME_EXPORT R_GetSpriteTexture( const model_t *m_pSpriteModel, int frame ) int GAME_EXPORT R_GetSpriteTexture( const model_t *m_pSpriteModel, int frame )

View file

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

View file

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

View file

@ -99,7 +99,8 @@ static void GL_UpdateTextureParams( int iTexture )
Assert( tex != NULL ); Assert( tex != NULL );
if( !tex->pixels) return; // free slot if( !tex->pixels )
return; // free slot
GL_Bind( XASH_TEXTURE0, iTexture ); GL_Bind( XASH_TEXTURE0, iTexture );
} }
@ -271,7 +272,8 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
vec3_t normal; vec3_t normal;
int i, x, y; int i, x, y;
if( !source ) return NULL; if( !source )
return NULL;
scaledImage = Mem_Realloc( r_temppool, scaledImage, outWidth * outHeight * 4 ); scaledImage = Mem_Realloc( r_temppool, scaledImage, outWidth * outHeight * 4 );
fracStep = inWidth * 0x10000 / outWidth; 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; int row, x, y, z;
vec3_t normal; vec3_t normal;
if( !in ) return; if( !in )
return;
mipWidth = Q_max( 1, ( srcWidth >> 1 )); mipWidth = Q_max( 1, ( srcWidth >> 1 ));
mipHeight = Q_max( 1, ( srcHeight >> 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 // NOTE: only single uncompressed textures can be resamples, no mips, no layers, no sides
if((( pic->width != tex->width ) || ( pic->height != tex->height ))) if((( pic->width != tex->width ) || ( pic->height != tex->height )))
data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap ); 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 )) // if( !ImageCompressed( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
// data = GL_ApplyFilter( data, tex->width, tex->height ); // 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; uint img_flags = 0;
// force upload texture as RGB or RGBA (detail textures requires this) // force upload texture as RGB or RGBA (detail textures requires this)
if( tex->flags & TF_FORCE_COLOR ) pic->flags |= IMAGE_HAS_COLOR; if( tex->flags & TF_FORCE_COLOR )
if( pic->flags & IMAGE_HAS_ALPHA ) tex->flags |= TF_HAS_ALPHA; pic->flags |= IMAGE_HAS_COLOR;
if( pic->flags & IMAGE_HAS_ALPHA )
tex->flags |= TF_HAS_ALPHA;
if( ImageCompressed( pic->type )) 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 // find a free texture_t slot
for( i = 0, tex = r_images; i < r_numImages; i++, tex++ ) 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 ) if( i == r_numImages )
{ {
@ -758,7 +765,8 @@ static void GL_DeleteTexture( image_t *tex )
ASSERT( tex != NULL ); ASSERT( tex != NULL );
// already freed? // already freed?
if( !tex->pixels[0]) return; if( !tex->pixels[0] )
return;
// debug // debug
if( !tex->name[0] ) if( !tex->name[0] )
@ -773,7 +781,8 @@ static void GL_DeleteTexture( image_t *tex )
while( 1 ) while( 1 )
{ {
cur = *prev; cur = *prev;
if( !cur ) break; if( !cur )
break;
if( cur == tex ) if( cur == tex )
{ {
@ -788,8 +797,10 @@ static void GL_DeleteTexture( image_t *tex )
gEngfuncs.FS_FreeImage( tex->original ); gEngfuncs.FS_FreeImage( tex->original );
for( i = 0; i < 4; i++ ) for( i = 0; i < 4; i++ )
if( tex->pixels[i]) Mem_Free(tex->pixels[i]); if( tex->pixels[i] )
if( tex->alpha_pixels ) Mem_Free(tex->alpha_pixels); Mem_Free( tex->pixels[i] );
if( tex->alpha_pixels )
Mem_Free( tex->alpha_pixels );
memset( tex, 0, sizeof( *tex )); 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 ); gEngfuncs.Image_SetForceFlags( picFlags );
pic = gEngfuncs.FS_LoadImage( name, buf, size ); 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 // allocate the new one
tex = GL_AllocTexture( name, flags ); 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 ); return( tex - r_images );
// couldn't loading image // couldn't loading image
if( !pic ) return 0; if( !pic )
return 0;
if( update ) if( update )
{ {
@ -1166,7 +1179,8 @@ static void GL_CreateInternalTextures( void )
{ {
if(( y < 8 ) ^ ( x < 8 )) if(( y < 8 ) ^ ( x < 8 ))
((uint *)pic->buffer )[y * 16 + x] = 0xFFFF00FF; ((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++ ) for( i = texCount = 0, image = r_images; i < r_numImages; i++, image++ )
{ {
if( !image->pixels ) continue; if( !image->pixels )
continue;
bytes += image->size; bytes += image->size;
texCount++; texCount++;
@ -1239,13 +1254,15 @@ void R_TextureList_f( void )
if( image->flags & TF_NORMALMAP ) if( image->flags & TF_NORMALMAP )
gEngfuncs.Con_Printf( "normal " ); gEngfuncs.Con_Printf( "normal " );
else gEngfuncs.Con_Printf( "diffuse " ); else
gEngfuncs.Con_Printf( "diffuse " );
if( image->flags & TF_CLAMP ) if( image->flags & TF_CLAMP )
gEngfuncs.Con_Printf( "clamp " ); gEngfuncs.Con_Printf( "clamp " );
else if( image->flags & TF_BORDER ) else if( image->flags & TF_BORDER )
gEngfuncs.Con_Printf( "border " ); gEngfuncs.Con_Printf( "border " );
else gEngfuncs.Con_Printf( "repeat " ); else
gEngfuncs.Con_Printf( "repeat " );
gEngfuncs.Con_Printf( " %d ", image->depth ); gEngfuncs.Con_Printf( " %d ", image->depth );
gEngfuncs.Con_Printf( " %s\n", image->name ); 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 )) if( FBitSet( surf->flags, SURF_PLANEBACK ))
VectorNegate( surf->plane->normal, faceNormal ); VectorNegate( surf->plane->normal, faceNormal );
else VectorCopy( surf->plane->normal, faceNormal ); else
VectorCopy( surf->plane->normal, faceNormal );
// compute face TBN // compute face TBN
#if 1 #if 1
@ -345,8 +346,10 @@ static colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t
int i, maxEnts = 1; int i, maxEnts = 1;
colorVec light, cv; colorVec light, cv;
if( lspot ) VectorClear( lspot ); if( lspot )
if( lvec ) VectorClear( lvec ); VectorClear( lspot );
if( lvec )
VectorClear( lvec );
if( WORLDMODEL && WORLDMODEL->lightdata ) 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( g_trace_fraction < last_fraction )
{ {
if( lspot ) VectorCopy( g_trace_lightspot, lspot ); if( lspot )
if( lvec ) VectorNormalize2( g_trace_lightvec, lvec ); VectorCopy( g_trace_lightspot, lspot );
if( lvec )
VectorNormalize2( g_trace_lightvec, lvec );
light.r = Q_min(( cv.r >> 8 ), 255 ); light.r = Q_min(( cv.r >> 8 ), 255 );
light.g = Q_min(( cv.g >> 8 ), 255 ); light.g = Q_min(( cv.g >> 8 ), 255 );
light.b = Q_min(( cv.b >> 8 ), 255 ); light.b = Q_min(( cv.b >> 8 ), 255 );

View file

@ -498,7 +498,8 @@ void Mod_StudioUnloadTextures( void *data );
// r_polyse.c // r_polyse.c
// //
// !!! if this is changed, it must be changed in asm_draw.h too !!! // !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct { typedef struct
{
void *pdest; void *pdest;
short *pz; short *pz;
int count; int count;
@ -757,7 +758,8 @@ typedef struct
#if SMALL_FINALVERT #if SMALL_FINALVERT
typedef struct finalvert_s { typedef struct finalvert_s
{
short u, v, s, t; short u, v, s, t;
int l; int l;
int zi; int zi;
@ -779,7 +781,8 @@ typedef struct finalvert_s {
#else #else
typedef struct finalvert_s { typedef struct finalvert_s
{
int u, v, s, t; int u, v, s, t;
int l; int l;
int zi; int zi;
@ -1055,7 +1058,8 @@ extern convar_t r_traceglow;
extern convar_t sw_noalphabrushes; extern convar_t sw_noalphabrushes;
extern convar_t r_studio_sort_textures; extern convar_t r_studio_sort_textures;
extern struct qfrustum_s { extern struct qfrustum_s
{
mplane_t screenedge[4]; mplane_t screenedge[4];
clipplane_t view_clipplanes[4]; clipplane_t view_clipplanes[4];
int frustum_indexes[4 * 6]; int frustum_indexes[4 * 6];
@ -1116,7 +1120,8 @@ qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int
// //
// r_edge.c // r_edge.c
// //
static inline void R_SurfacePatch (void) { } static inline void R_SurfacePatch( void ) {
}
void R_BeginEdgeFrame( void ); void R_BeginEdgeFrame( void );
void R_RenderWorld( void ); void R_RenderWorld( void );
void R_ScanEdges( 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 ); VectorSubtract( RI.vieworg, org, vecLen );
dist1 = DotProduct( vecLen, vecLen ); dist1 = DotProduct( vecLen, vecLen );
} }
else dist1 = 1000000000; else
dist1 = 1000000000;
if(( ent1->model && ent2->model->type != mod_brush ) || rendermode2 != kRenderTransAlpha ) 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 ); VectorSubtract( RI.vieworg, org, vecLen );
dist2 = DotProduct( vecLen, vecLen ); dist2 = DotProduct( vecLen, vecLen );
} }
else dist2 = 1000000000; else
dist2 = 1000000000;
if( dist1 > dist2 ) if( dist1 > dist2 )
return -1; 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[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]; 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]; 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 )) if( node->children[0] && ( node->children[0] != ignore ))
{ {
tex = R_RecursiveFindWaterTexture( node->children[0], node, true ); tex = R_RecursiveFindWaterTexture( node->children[0], node, true );
if( tex ) return tex; if( tex )
return tex;
} }
if( node->children[1] && ( node->children[1] != ignore )) if( node->children[1] && ( node->children[1] != ignore ))
{ {
tex = R_RecursiveFindWaterTexture( node->children[1], node, true ); tex = R_RecursiveFindWaterTexture( node->children[1], node, true );
if( tex ) return tex; if( tex )
return tex;
} }
// for down recursion, return immediately // for down recursion, return immediately
if( down ) return NULL; if( down )
return NULL;
// texture not found, step up if any // texture not found, step up if any
if( node->parent ) if( node->parent )
@ -659,9 +665,11 @@ static void R_DrawEntitiesOnList( void )
// handle studiomodels with custom rendermodes on texture // handle studiomodels with custom rendermodes on texture
if( RI.currententity->curstate.rendermode != kRenderNormal ) if( RI.currententity->curstate.rendermode != kRenderNormal )
tr.blend = CL_FxBlend( RI.currententity ) / 255.0f; 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.currententity != NULL );
Assert( RI.currentmodel != NULL ); Assert( RI.currentmodel != NULL );
@ -966,10 +974,10 @@ void R_DrawBrushModel(cl_entity_t *pent)
float minmaxs[6]; float minmaxs[6];
mnode_t *topnode; mnode_t *topnode;
int k; int k;
edge_t ledges[NUMSTACKEDGES + edge_t ledges[NUMSTACKEDGES
((CACHE_SIZE - 1) / sizeof(edge_t)) + 1]; + (( CACHE_SIZE - 1 ) / sizeof( edge_t )) + 1];
surf_t lsurfs[NUMSTACKSURFACES + surf_t lsurfs[NUMSTACKSURFACES
((CACHE_SIZE - 1) / sizeof(surf_t)) + 1]; + (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
if( !RI.drawWorld ) if( !RI.drawWorld )
return; return;
@ -1087,10 +1095,10 @@ R_EdgeDrawing
*/ */
static void R_EdgeDrawing( void ) static void R_EdgeDrawing( void )
{ {
edge_t ledges[NUMSTACKEDGES + edge_t ledges[NUMSTACKEDGES
((CACHE_SIZE - 1) / sizeof(edge_t)) + 1]; + (( CACHE_SIZE - 1 ) / sizeof( edge_t )) + 1];
surf_t lsurfs[NUMSTACKSURFACES + surf_t lsurfs[NUMSTACKSURFACES
((CACHE_SIZE - 1) / sizeof(surf_t)) + 1]; + (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
if( !RI.drawWorld ) if( !RI.drawWorld )
return; return;
@ -1161,7 +1169,8 @@ static void R_MarkLeaves (void)
break; break;
node->visframe = tr.visframecount; node->visframe = tr.visframecount;
node = node->parent; node = node->parent;
} while (node); }
while( node );
} }
} }
} }
@ -1181,7 +1190,8 @@ void GAME_EXPORT R_RenderScene( void )
// frametime is valid only for normal pass // frametime is valid only for normal pass
if( RP_NORMALPASS( )) if( RP_NORMALPASS( ))
tr.frametime = gp_cl->time - gp_cl->oldtime; tr.frametime = gp_cl->time - gp_cl->oldtime;
else tr.frametime = 0.0; else
tr.frametime = 0.0;
// begin a new frame // begin a new frame
tr.framecount++; tr.framecount++;
@ -1262,7 +1272,8 @@ void R_SetupRefParams( const ref_viewpass_t *rvp )
if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP )) if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP ))
RI.drawOrtho = FBitSet( rvp->flags, RF_DRAW_OVERVIEW ); RI.drawOrtho = FBitSet( rvp->flags, RF_DRAW_OVERVIEW );
else RI.drawOrtho = false; else
RI.drawOrtho = false;
// setup viewport // setup viewport
RI.viewport[0] = rvp->viewport[0]; RI.viewport[0] = rvp->viewport[0];
@ -1439,7 +1450,8 @@ void GAME_EXPORT R_NewMap (void)
tr.sample_bits = 0; 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 ); 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 ) if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1; e->curstate.renderamt -= 1;
else e->curstate.renderamt = 0; else
e->curstate.renderamt = 0;
} }
blend = e->curstate.renderamt; blend = e->curstate.renderamt;
break; break;
@ -1589,7 +1602,8 @@ int CL_FxBlend( cl_entity_t *e )
{ {
if( e->curstate.renderamt > 3 ) if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4; e->curstate.renderamt -= 4;
else e->curstate.renderamt = 0; else
e->curstate.renderamt = 0;
} }
blend = e->curstate.renderamt; blend = e->curstate.renderamt;
break; break;
@ -1598,7 +1612,8 @@ int CL_FxBlend( cl_entity_t *e )
{ {
if( e->curstate.renderamt < 255 ) if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1; e->curstate.renderamt += 1;
else e->curstate.renderamt = 255; else
e->curstate.renderamt = 255;
} }
blend = e->curstate.renderamt; blend = e->curstate.renderamt;
break; break;
@ -1607,34 +1622,45 @@ int CL_FxBlend( cl_entity_t *e )
{ {
if( e->curstate.renderamt < 252 ) if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4; e->curstate.renderamt += 4;
else e->curstate.renderamt = 255; else
e->curstate.renderamt = 255;
} }
blend = e->curstate.renderamt; blend = e->curstate.renderamt;
break; break;
case kRenderFxStrobeSlow: case kRenderFxStrobeSlow:
blend = 20 * sin( gp_cl->time * 4 + offset ); blend = 20 * sin( gp_cl->time * 4 + offset );
if( blend < 0 ) blend = 0; if( blend < 0 )
else blend = e->curstate.renderamt; blend = 0;
else
blend = e->curstate.renderamt;
break; break;
case kRenderFxStrobeFast: case kRenderFxStrobeFast:
blend = 20 * sin( gp_cl->time * 16 + offset ); blend = 20 * sin( gp_cl->time * 16 + offset );
if( blend < 0 ) blend = 0; if( blend < 0 )
else blend = e->curstate.renderamt; blend = 0;
else
blend = e->curstate.renderamt;
break; break;
case kRenderFxStrobeFaster: case kRenderFxStrobeFaster:
blend = 20 * sin( gp_cl->time * 36 + offset ); blend = 20 * sin( gp_cl->time * 36 + offset );
if( blend < 0 ) blend = 0; if( blend < 0 )
else blend = e->curstate.renderamt; blend = 0;
else
blend = e->curstate.renderamt;
break; break;
case kRenderFxFlickerSlow: case kRenderFxFlickerSlow:
blend = 20 * ( sin( gp_cl->time * 2 ) + sin( gp_cl->time * 17 + offset )); blend = 20 * ( sin( gp_cl->time * 2 ) + sin( gp_cl->time * 17 + offset ));
if( blend < 0 ) blend = 0; if( blend < 0 )
else blend = e->curstate.renderamt; blend = 0;
else
blend = e->curstate.renderamt;
break; break;
case kRenderFxFlickerFast: case kRenderFxFlickerFast:
blend = 20 * ( sin( gp_cl->time * 16 ) + sin( gp_cl->time * 23 + offset )); blend = 20 * ( sin( gp_cl->time * 16 ) + sin( gp_cl->time * 23 + offset ));
if( blend < 0 ) blend = 0; if( blend < 0 )
else blend = e->curstate.renderamt; blend = 0;
else
blend = e->curstate.renderamt;
break; break;
case kRenderFxHologram: case kRenderFxHologram:
case kRenderFxDistort: case kRenderFxDistort:
@ -1653,8 +1679,10 @@ int CL_FxBlend( cl_entity_t *e )
else else
{ {
e->curstate.renderamt = 180; e->curstate.renderamt = 180;
if( dist <= 100 ) blend = e->curstate.renderamt; if( dist <= 100 )
else blend = (int) ((1.0f - ( dist - 100 ) * ( 1.0f / 400.0f )) * e->curstate.renderamt ); blend = e->curstate.renderamt;
else
blend = (int) (( 1.0f - ( dist - 100 ) * ( 1.0f / 400.0f )) * e->curstate.renderamt );
blend += gEngfuncs.COM_RandomLong( -32, 31 ); blend += gEngfuncs.COM_RandomLong( -32, 31 );
} }
break; break;

View file

@ -124,7 +124,8 @@ void Matrix4x4_CreateRotate( matrix4x4 out, float angle, float x, float y, float
float len, c, s; float len, c, s;
len = x * x + y * y + z * z; 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; x *= len;
y *= len; y *= len;
z *= 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.y = (int)( RI.vrect.y * r_aliasuvscale );
RI.aliasvrect.width = (int)( RI.vrect.width * r_aliasuvscale ); RI.aliasvrect.width = (int)( RI.vrect.width * r_aliasuvscale );
RI.aliasvrect.height = (int)( RI.vrect.height * r_aliasuvscale ); RI.aliasvrect.height = (int)( RI.vrect.height * r_aliasuvscale );
RI.aliasvrectright = RI.aliasvrect.x + RI.aliasvrectright = RI.aliasvrect.x
RI.aliasvrect.width; + RI.aliasvrect.width;
RI.aliasvrectbottom = RI.aliasvrect.y + RI.aliasvrectbottom = RI.aliasvrect.y
RI.aliasvrect.height; + RI.aliasvrect.height;
xOrigin = XCENTERING; xOrigin = XCENTERING;
yOrigin = YCENTERING; 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 // 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 // but will definately render in the [range] row and column, so adjust the
// buffer origin to get an exact edge to edge fill // buffer origin to get an exact edge to edge fill
xcenter = ((float)RI.vrect.width * XCENTERING) + xcenter = ((float)RI.vrect.width * XCENTERING )
RI.vrect.x - 0.5f; + RI.vrect.x - 0.5f;
aliasxcenter = xcenter * r_aliasuvscale; aliasxcenter = xcenter * r_aliasuvscale;
ycenter = ((float)RI.vrect.height * YCENTERING) + ycenter = ((float)RI.vrect.height * YCENTERING )
RI.vrect.y - 0.5f; + RI.vrect.y - 0.5f;
aliasycenter = ycenter * r_aliasuvscale; aliasycenter = ycenter * r_aliasuvscale;
xscale = RI.vrect.width / horizontalFieldOfView; xscale = RI.vrect.width / horizontalFieldOfView;
@ -243,8 +243,8 @@ static void R_ViewChanged (vrect_t *vr)
qfrustum.screenedge[0].type = PLANE_ANYZ; qfrustum.screenedge[0].type = PLANE_ANYZ;
// right side clip // right side clip
qfrustum.screenedge[1].normal[0] = qfrustum.screenedge[1].normal[0]
1.0f / ((1.0f-xOrigin)*horizontalFieldOfView); = 1.0f / (( 1.0f - xOrigin ) * horizontalFieldOfView );
qfrustum.screenedge[1].normal[1] = 0; qfrustum.screenedge[1].normal[1] = 0;
qfrustum.screenedge[1].normal[2] = 1; qfrustum.screenedge[1].normal[2] = 1;
qfrustum.screenedge[1].type = PLANE_ANYZ; 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[1] - RI.vieworg[1] ) * RI.cull_vforward[1];
size += ( p->org[2] - RI.vieworg[2] ) * RI.cull_vforward[2]; size += ( p->org[2] - RI.vieworg[2] ) * RI.cull_vforward[2];
if( size < 20.0f ) size = partsize; if( size < 20.0f )
else size = partsize + size * 0.002f; size = partsize;
else
size = partsize + size * 0.002f;
// scale the axes by radius // scale the axes by radius
VectorScale( RI.cull_vright, size, right ); 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; gravity = frametime * tr.movevars->gravity;
scale = 1.0 - ( frametime * 0.9 ); 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 ) for( p = cl_active_tracers; p; p = p->next )
{ {
atten = ( p->die - gp_cl->time ); 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 ); VectorScale( p->vel, ( p->ramp * atten ), delta );
VectorAdd( p->org, delta, end ); 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->vel[2] -= gravity;
p->packedColor = 255 * ( p->die - gp_cl->time ) * 2; 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 ) 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 #define DPS_MAXSPANS MAXHEIGHT + 1
// 1 extra for spanpackage that marks end // 1 extra for spanpackage that marks end
typedef struct { typedef struct
{
int isflattop; int isflattop;
int numleftedges; int numleftedges;
int *pleftedgevert0; int *pleftedgevert0;
@ -83,7 +84,8 @@ int d_pzextrastep, d_pzbasestep;
static int ubasestep, errorterm, erroradjustup, erroradjustdown; static int ubasestep, errorterm, erroradjustup, erroradjustdown;
typedef struct { typedef struct
{
int quotient; int quotient;
int remainder; int remainder;
} adivtab_t; } adivtab_t;
@ -272,7 +274,8 @@ qboolean R_PolysetScanLeftEdge_C(int height)
d_light += d_lightbasestep; d_light += d_lightbasestep;
d_zi += d_zibasestep; d_zi += d_zibasestep;
} }
} while (--height); }
while( --height );
return true; return true;
} }
@ -353,8 +356,8 @@ static void R_PolysetSetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv,
tm = endvertu - startvertu; tm = endvertu - startvertu;
tn = endvertv - startvertv; tn = endvertv - startvertv;
if (((tm <= 16) && (tm >= -15)) && if((( tm <= 16 ) && ( tm >= -15 ))
((tn <= 16) && (tn >= -15))) && (( tn <= 16 ) && ( tn >= -15 )))
{ {
ptemp = &adivtab[(( tm + 15 ) << 5 ) + ( tn + 15 )]; ptemp = &adivtab[(( tm + 15 ) << 5 ) + ( tn + 15 )];
ubasestep = ptemp->quotient; ubasestep = ptemp->quotient;
@ -410,24 +413,24 @@ qboolean R_PolysetCalcGradients (int skinwidth)
t0 = r_p0[2] - r_p2[2]; t0 = r_p0[2] - r_p2[2];
t1 = r_p1[2] - r_p2[2]; t1 = r_p1[2] - r_p2[2];
r_sstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) * r_sstepx = (int)(( t1 * p01_minus_p21 - t0 * p11_minus_p21 )
xstepdenominv); * xstepdenominv );
r_sstepy = (int)((t1 * p00_minus_p20 - t0* p10_minus_p20) * r_sstepy = (int)(( t1 * p00_minus_p20 - t0 * p10_minus_p20 )
ystepdenominv); * ystepdenominv );
t0 = r_p0[3] - r_p2[3]; t0 = r_p0[3] - r_p2[3];
t1 = r_p1[3] - r_p2[3]; t1 = r_p1[3] - r_p2[3];
r_tstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) * r_tstepx = (int)(( t1 * p01_minus_p21 - t0 * p11_minus_p21 )
xstepdenominv); * xstepdenominv );
r_tstepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) * r_tstepy = (int)(( t1 * p00_minus_p20 - t0 * p10_minus_p20 )
ystepdenominv); * ystepdenominv );
t0 = r_p0[5] - r_p2[5]; t0 = r_p0[5] - r_p2[5];
t1 = r_p1[5] - r_p2[5]; t1 = r_p1[5] - r_p2[5];
r_zistepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) * r_zistepx = (int)(( t1 * p01_minus_p21 - t0 * p11_minus_p21 )
xstepdenominv); * xstepdenominv );
r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) * r_zistepy = (int)(( t1 * p00_minus_p20 - t0 * p10_minus_p20 )
ystepdenominv); * ystepdenominv );
{ {
a_sstepxfrac = r_sstepx & 0xFFFF; a_sstepxfrac = r_sstepx & 0xFFFF;
@ -517,10 +520,13 @@ void R_PolysetDrawSpansBlended( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth; lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF; ltfrac &= 0xFFFF;
} }
} while (--lcount);
} }
else pspanpackage++; while( --lcount );
} while (pspanpackage->count != -999999); }
else
pspanpackage++;
}
while( pspanpackage->count != -999999 );
} }
@ -598,10 +604,13 @@ void R_PolysetDrawSpansAdditive( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth; lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF; ltfrac &= 0xFFFF;
} }
} while (--lcount);
} }
else pspanpackage++; while( --lcount );
} while (pspanpackage->count != -999999); }
else
pspanpackage++;
}
while( pspanpackage->count != -999999 );
} }
@ -677,11 +686,13 @@ void R_PolysetDrawSpansGlow( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth; lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF; ltfrac &= 0xFFFF;
} }
} while (--lcount); }
while( --lcount );
} }
else else
pspanpackage++; pspanpackage++;
} while (pspanpackage->count != -999999); }
while( pspanpackage->count != -999999 );
} }
@ -762,11 +773,13 @@ void R_PolysetDrawSpansTextureBlended( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth; lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF; ltfrac &= 0xFFFF;
} }
} while (--lcount); }
while( --lcount );
} }
else else
pspanpackage++; pspanpackage++;
} while (pspanpackage->count != -999999); }
while( pspanpackage->count != -999999 );
} }
@ -837,11 +850,13 @@ void R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth; lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF; ltfrac &= 0xFFFF;
} }
} while (--lcount); }
while( --lcount );
} }
pspanpackage++; pspanpackage++;
} while (pspanpackage->count != -999999); }
while( pspanpackage->count != -999999 );
} }
void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage ) void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage )
@ -881,11 +896,13 @@ void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage)
lpdest++; lpdest++;
lzi += r_zistepx; lzi += r_zistepx;
lpz++; lpz++;
} while (--lcount); }
while( --lcount );
} }
pspanpackage++; pspanpackage++;
} while (pspanpackage->count != -999999); }
while( pspanpackage->count != -999999 );
} }
void R_PolysetDrawSpans8_66( spanpackage_t *pspanpackage ) void R_PolysetDrawSpans8_66( spanpackage_t *pspanpackage )
@ -946,11 +963,13 @@ void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth; lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF; ltfrac &= 0xFFFF;
} }
} while (--lcount); }
while( --lcount );
} }
pspanpackage++; pspanpackage++;
} while (pspanpackage->count != -999999); }
while( pspanpackage->count != -999999 );
} }
static void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage ) static void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage )
@ -990,11 +1009,13 @@ static void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage)
lpdest++; lpdest++;
lzi += r_zistepx; lzi += r_zistepx;
lpz++; lpz++;
} while (--lcount); }
while( --lcount );
} }
pspanpackage++; pspanpackage++;
} while (pspanpackage->count != -999999); }
while( pspanpackage->count != -999999 );
} }
void R_PolysetDrawSpans8_Opaque( spanpackage_t *pspanpackage ) void R_PolysetDrawSpans8_Opaque( spanpackage_t *pspanpackage )
@ -1059,11 +1080,13 @@ void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth; lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF; ltfrac &= 0xFFFF;
} }
} while (--lcount); }
while( --lcount );
} }
pspanpackage++; pspanpackage++;
} while (pspanpackage->count != -999999); }
while( pspanpackage->count != -999999 );
} }
void R_PolysetFillSpans8( spanpackage_t *pspanpackage ) void R_PolysetFillSpans8( spanpackage_t *pspanpackage )
@ -1139,10 +1162,13 @@ void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
lptex += r_affinetridesc.skinwidth; lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF; ltfrac &= 0xFFFF;
} }
} while (--lcount);
} }
else pspanpackage++; while( --lcount );
} while (pspanpackage->count != -999999); }
else
pspanpackage++;
}
while( pspanpackage->count != -999999 );
} }
/* /*
@ -1183,8 +1209,8 @@ void R_RasterizeAliasPolySmooth (void)
ystart = plefttop[1]; ystart = plefttop[1];
d_aspancount = plefttop[0] - prighttop[0]; d_aspancount = plefttop[0] - prighttop[0];
d_ptex = (pixel_t*)r_affinetridesc.pskin + (plefttop[2] >> 16) + d_ptex = (pixel_t *)r_affinetridesc.pskin + ( plefttop[2] >> 16 )
(plefttop[3] >> 16) * r_affinetridesc.skinwidth; + ( plefttop[3] >> 16 ) * r_affinetridesc.skinwidth;
{ {
d_sfrac = plefttop[2] & 0xFFFF; d_sfrac = plefttop[2] & 0xFFFF;
@ -1193,8 +1219,8 @@ void R_RasterizeAliasPolySmooth (void)
d_light = plefttop[4]; d_light = plefttop[4];
d_zi = plefttop[5]; d_zi = plefttop[5];
d_pdest = (pixel_t *)d_viewbuffer + d_pdest = (pixel_t *)d_viewbuffer
ystart * r_screenwidth + plefttop[0]; + ystart * r_screenwidth + plefttop[0];
d_pz = d_pzbuffer + ystart * d_zwidth + plefttop[0]; d_pz = d_pzbuffer + ystart * d_zwidth + plefttop[0];
if( initialleftheight == 1 ) if( initialleftheight == 1 )
@ -1237,9 +1263,9 @@ void R_RasterizeAliasPolySmooth (void)
working_lstepx = r_lstepx; working_lstepx = r_lstepx;
d_countextrastep = ubasestep + 1; d_countextrastep = ubasestep + 1;
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) + d_ptexbasestep = (( r_sstepy + r_sstepx * ubasestep ) >> 16 )
((r_tstepy + r_tstepx * ubasestep) >> 16) * + (( r_tstepy + r_tstepx * ubasestep ) >> 16 )
r_affinetridesc.skinwidth; * r_affinetridesc.skinwidth;
{ {
d_sfracbasestep = ( r_sstepy + r_sstepx * ubasestep ) & 0xFFFF; d_sfracbasestep = ( r_sstepy + r_sstepx * ubasestep ) & 0xFFFF;
d_tfracbasestep = ( r_tstepy + r_tstepx * 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_lightbasestep = r_lstepy + working_lstepx * ubasestep;
d_zibasestep = r_zistepy + r_zistepx * ubasestep; d_zibasestep = r_zistepy + r_zistepx * ubasestep;
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) + d_ptexextrastep = (( r_sstepy + r_sstepx * d_countextrastep ) >> 16 )
((r_tstepy + r_tstepx * d_countextrastep) >> 16) * + (( r_tstepy + r_tstepx * d_countextrastep ) >> 16 )
r_affinetridesc.skinwidth; * r_affinetridesc.skinwidth;
{ {
d_sfracextrastep = ( r_sstepy + r_sstepx * d_countextrastep ) & 0xFFFF; d_sfracextrastep = ( r_sstepy + r_sstepx * d_countextrastep ) & 0xFFFF;
d_tfracextrastep = ( r_tstepy + r_tstepx * d_countextrastep ) & 0xFFFF; d_tfracextrastep = ( r_tstepy + r_tstepx * d_countextrastep ) & 0xFFFF;
@ -1279,8 +1305,8 @@ void R_RasterizeAliasPolySmooth (void)
ystart = plefttop[1]; ystart = plefttop[1];
d_aspancount = plefttop[0] - prighttop[0]; d_aspancount = plefttop[0] - prighttop[0];
d_ptex = (pixel_t*)r_affinetridesc.pskin + (plefttop[2] >> 16) + d_ptex = (pixel_t *)r_affinetridesc.pskin + ( plefttop[2] >> 16 )
(plefttop[3] >> 16) * r_affinetridesc.skinwidth; + ( plefttop[3] >> 16 ) * r_affinetridesc.skinwidth;
d_sfrac = 0; d_sfrac = 0;
d_tfrac = 0; d_tfrac = 0;
@ -1326,9 +1352,9 @@ void R_RasterizeAliasPolySmooth (void)
working_lstepx = r_lstepx; working_lstepx = r_lstepx;
d_countextrastep = ubasestep + 1; d_countextrastep = ubasestep + 1;
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) + d_ptexbasestep = (( r_sstepy + r_sstepx * ubasestep ) >> 16 )
((r_tstepy + r_tstepx * ubasestep) >> 16) * + (( r_tstepy + r_tstepx * ubasestep ) >> 16 )
r_affinetridesc.skinwidth; * r_affinetridesc.skinwidth;
{ {
d_sfracbasestep = ( r_sstepy + r_sstepx * ubasestep ) & 0xFFFF; d_sfracbasestep = ( r_sstepy + r_sstepx * ubasestep ) & 0xFFFF;
d_tfracbasestep = ( r_tstepy + r_tstepx * 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_lightbasestep = r_lstepy + working_lstepx * ubasestep;
d_zibasestep = r_zistepy + r_zistepx * ubasestep; d_zibasestep = r_zistepy + r_zistepx * ubasestep;
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) + d_ptexextrastep = (( r_sstepy + r_sstepx * d_countextrastep ) >> 16 )
((r_tstepy + r_tstepx * d_countextrastep) >> 16) * + (( r_tstepy + r_tstepx * d_countextrastep ) >> 16 )
r_affinetridesc.skinwidth; * r_affinetridesc.skinwidth;
{ {
d_sfracextrastep = ( r_sstepy + r_sstepx * d_countextrastep ) & 0xFFFF; d_sfracextrastep = ( r_sstepy + r_sstepx * d_countextrastep ) & 0xFFFF;
d_tfracextrastep = ( r_tstepy + r_tstepx * 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 // we cache unclipped horizontal edges as fully clipped
if( cacheoffset != 0x7FFFFFFF ) if( cacheoffset != 0x7FFFFFFF )
{ {
cacheoffset = FULLY_CLIPPED_CACHED | cacheoffset = FULLY_CLIPPED_CACHED
(tr.framecount & FRAMECOUNT_MASK); | ( tr.framecount & FRAMECOUNT_MASK );
} }
return; // horizontal edge return; // horizontal edge
@ -333,12 +333,12 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
cacheoffset = 0x7FFFFFFF; cacheoffset = 0x7FFFFFFF;
f = d0 / ( d0 - d1 ); f = d0 / ( d0 - d1 );
clipvert.position[0] = pv0->position[0] + clipvert.position[0] = pv0->position[0]
f * (pv1->position[0] - pv0->position[0]); + f * ( pv1->position[0] - pv0->position[0] );
clipvert.position[1] = pv0->position[1] + clipvert.position[1] = pv0->position[1]
f * (pv1->position[1] - pv0->position[1]); + f * ( pv1->position[1] - pv0->position[1] );
clipvert.position[2] = pv0->position[2] + clipvert.position[2] = pv0->position[2]
f * (pv1->position[2] - pv0->position[2]); + f * ( pv1->position[2] - pv0->position[2] );
if( clip->leftedge ) if( clip->leftedge )
{ {
@ -362,8 +362,8 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
// both points are clipped // both points are clipped
// we do cache fully clipped edges // we do cache fully clipped edges
if( !r_leftclipped ) if( !r_leftclipped )
cacheoffset = FULLY_CLIPPED_CACHED | cacheoffset = FULLY_CLIPPED_CACHED
(tr.framecount & FRAMECOUNT_MASK); | ( tr.framecount & FRAMECOUNT_MASK );
return; return;
} }
@ -374,12 +374,12 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
cacheoffset = 0x7FFFFFFF; cacheoffset = 0x7FFFFFFF;
f = d0 / ( d0 - d1 ); f = d0 / ( d0 - d1 );
clipvert.position[0] = pv0->position[0] + clipvert.position[0] = pv0->position[0]
f * (pv1->position[0] - pv0->position[0]); + f * ( pv1->position[0] - pv0->position[0] );
clipvert.position[1] = pv0->position[1] + clipvert.position[1] = pv0->position[1]
f * (pv1->position[1] - pv0->position[1]); + f * ( pv1->position[1] - pv0->position[1] );
clipvert.position[2] = pv0->position[2] + clipvert.position[2] = pv0->position[2]
f * (pv1->position[2] - pv0->position[2]); + f * ( pv1->position[2] - pv0->position[2] );
if( clip->leftedge ) 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 ); R_ClipEdge( &clipvert, pv1, clip->next );
return; return;
} }
} while ((clip = clip->next) != NULL); }
while(( clip = clip->next ) != NULL );
} }
// add the edge // 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 & FULLY_CLIPPED_CACHED )
{ {
if ((r_pedge->cachededgeoffset & FRAMECOUNT_MASK) == if(( r_pedge->cachededgeoffset & FRAMECOUNT_MASK )
tr.framecount) == tr.framecount )
{ {
r_lastvertvalid = false; r_lastvertvalid = false;
continue; continue;
@ -514,10 +515,10 @@ void R_RenderFace (msurface_t *fa, int clipflags)
} }
else else
{ {
if ((((uintptr_t)edge_p - (uintptr_t)r_edges) > if((((uintptr_t)edge_p - (uintptr_t)r_edges )
r_pedge->cachededgeoffset) && > r_pedge->cachededgeoffset )
(((edge_t *)((uintptr_t)r_edges + && (((edge_t *)((uintptr_t)r_edges
r_pedge->cachededgeoffset))->owner == r_pedge)) + r_pedge->cachededgeoffset ))->owner == r_pedge ))
{ {
R_EmitCachedEdge(); R_EmitCachedEdge();
r_lastvertvalid = false; 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 & FULLY_CLIPPED_CACHED )
{ {
if ((r_pedge->cachededgeoffset & FRAMECOUNT_MASK) == if(( r_pedge->cachededgeoffset & FRAMECOUNT_MASK )
tr.framecount) == tr.framecount )
{ {
r_lastvertvalid = false; r_lastvertvalid = false;
continue; 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 // it's cached if the cached edge is valid and is owned
// by this medge_t // by this medge_t
if ((((uintptr_t)edge_p - (uintptr_t)r_edges) > if((((uintptr_t)edge_p - (uintptr_t)r_edges )
r_pedge->cachededgeoffset) && > r_pedge->cachededgeoffset )
(((edge_t *)((uintptr_t)r_edges + && (((edge_t *)((uintptr_t)r_edges
r_pedge->cachededgeoffset))->owner == r_pedge)) + r_pedge->cachededgeoffset ))->owner == r_pedge ))
{ {
R_EmitCachedEdge(); R_EmitCachedEdge();
r_lastvertvalid = false; 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_zistepu = p_normal[0] * xscaleinv * distinv;
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv; surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
surface_p->d_ziorigin = p_normal[2] * distinv - surface_p->d_ziorigin = p_normal[2] * distinv
xcenter * surface_p->d_zistepu - - xcenter * surface_p->d_zistepu
ycenter * surface_p->d_zistepv; - ycenter * surface_p->d_zistepv;
surface_p++; 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_zistepu = p_normal[0] * xscaleinv * distinv;
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv; surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
surface_p->d_ziorigin = p_normal[2] * distinv - surface_p->d_ziorigin = p_normal[2] * distinv
xcenter * surface_p->d_zistepu - - xcenter * surface_p->d_zistepu
ycenter * surface_p->d_zistepv; - ycenter * surface_p->d_zistepv;
surface_p++; surface_p++;
} }

View file

@ -47,7 +47,8 @@ void D_DrawTurbulent8Span (void)
*r_turb_pdest++ = *( r_turb_pbase + ( tturb << 6 ) + sturb ); *r_turb_pdest++ = *( r_turb_pbase + ( tturb << 6 ) + sturb );
r_turb_s += r_turb_sstep; r_turb_s += r_turb_sstep;
r_turb_t += r_turb_tstep; 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_izi += r_turb_izistep;
r_turb_s += r_turb_sstep; r_turb_s += r_turb_sstep;
r_turb_t += r_turb_tstep; 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 do
{ {
r_turb_pdest = (d_viewbuffer + r_turb_pdest = ( d_viewbuffer
(r_screenwidth * pspan->v) + pspan->u); + ( r_screenwidth * pspan->v ) + pspan->u );
count = pspan->count; count = pspan->count;
@ -206,9 +208,11 @@ void Turbulent8 (espan_t *pspan)
r_turb_s = snext; r_turb_s = snext;
r_turb_t = tnext; 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 do
{ {
r_turb_pdest = (d_viewbuffer + r_turb_pdest = ( d_viewbuffer
(r_screenwidth * pspan->v) + pspan->u); + ( r_screenwidth * pspan->v ) + pspan->u );
r_turb_pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u; r_turb_pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
count = pspan->count; count = pspan->count;
@ -348,9 +352,11 @@ void TurbulentZ8 (espan_t *pspan, int alpha1)
r_turb_s = snext; r_turb_s = snext;
r_turb_t = tnext; 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 do
{ {
r_turb_pdest = (d_viewbuffer + r_turb_pdest = ( d_viewbuffer
(r_screenwidth * pspan->v) + pspan->u); + ( r_screenwidth * pspan->v ) + pspan->u );
count = pspan->count; count = pspan->count;
@ -486,9 +492,11 @@ void NonTurbulent8 (espan_t *pspan)
r_turb_s = snext; r_turb_s = snext;
r_turb_t = tnext; r_turb_t = tnext;
} while (count > 0); }
while( count > 0 );
} while ((pspan = pspan->pnext) != NULL); }
while(( pspan = pspan->pnext ) != NULL );
} }
// PGM // PGM
// ==================== // ====================
@ -536,8 +544,8 @@ void D_DrawSpans16 (espan_t *pspan)
do do
{ {
pdest = (d_viewbuffer + pdest = ( d_viewbuffer
(r_screenwidth * pspan->v) + pspan->u); + ( r_screenwidth * pspan->v ) + pspan->u );
count = pspan->count; count = pspan->count;
@ -639,7 +647,8 @@ void D_DrawSpans16 (espan_t *pspan)
*pdest++ = *( pbase + ( s >> 16 ) + ( t >> 16 ) * cachewidth ); *pdest++ = *( pbase + ( s >> 16 ) + ( t >> 16 ) * cachewidth );
s += sstep; s += sstep;
t += tstep; t += tstep;
} while (--spancount > 0); }
while( --spancount > 0 );
} }
else else
{ {
@ -666,13 +675,16 @@ void D_DrawSpans16 (espan_t *pspan)
*pdest++ = *( pbase + idiths + iditht * cachewidth ); *pdest++ = *( pbase + idiths + iditht * cachewidth );
s += sstep; s += sstep;
t += tstep; 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 do
{ {
pdest = (d_viewbuffer + pdest = ( d_viewbuffer
(r_screenwidth * pspan->v) + pspan->u); + ( r_screenwidth * pspan->v ) + pspan->u );
pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u; pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
count = pspan->count; count = pspan->count;
@ -823,7 +835,8 @@ void D_AlphaSpans16 (espan_t *pspan)
izi += izistep; izi += izistep;
s += sstep; s += sstep;
t += tstep; t += tstep;
} while (--spancount > 0); }
while( --spancount > 0 );
} }
else else
{ {
@ -861,13 +874,16 @@ void D_AlphaSpans16 (espan_t *pspan)
pz++; pz++;
s += sstep; s += sstep;
t += tstep; 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 do
{ {
pdest = (d_viewbuffer + pdest = ( d_viewbuffer
(r_screenwidth * pspan->v) + pspan->u); + ( r_screenwidth * pspan->v ) + pspan->u );
pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u; pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
count = pspan->count; count = pspan->count;
@ -1027,7 +1043,8 @@ void D_BlendSpans16( espan_t *pspan, int alpha )
izi += izistep; izi += izistep;
s += sstep; s += sstep;
t += tstep; t += tstep;
} while (--spancount > 0); }
while( --spancount > 0 );
} }
else else
{ {
@ -1068,13 +1085,16 @@ void D_BlendSpans16( espan_t *pspan, int alpha )
izi += izistep; izi += izistep;
s += sstep; s += sstep;
t += tstep; 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 do
{ {
pdest = (d_viewbuffer + pdest = ( d_viewbuffer
(r_screenwidth * pspan->v) + pspan->u); + ( r_screenwidth * pspan->v ) + pspan->u );
pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u; pz = d_pzbuffer + ( d_zwidth * pspan->v ) + pspan->u;
count = pspan->count; count = pspan->count;
@ -1228,7 +1248,8 @@ void D_AddSpans16 (espan_t *pspan)
izi += izistep; izi += izistep;
s += sstep; s += sstep;
t += tstep; t += tstep;
} while (--spancount > 0); }
while( --spancount > 0 );
} }
else else
{ {
@ -1268,13 +1289,16 @@ void D_AddSpans16 (espan_t *pspan)
izi += izistep; izi += izistep;
s += sstep; s += sstep;
t += tstep; 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; izi += izistep;
*(int *)pdest = ltemp; *(int *)pdest = ltemp;
pdest += 2; pdest += 2;
} while (--doublecount > 0); }
while( --doublecount > 0 );
} }
if( count & 1 ) if( count & 1 )
*pdest = (short)( izi >> 16 ); *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 ); pframetype = R_SpriteLoadGroup( mod, pframetype + sizeof( dframetype_t ), &psprite->frames[i].frameptr, i );
break; 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; ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f; lerpFrac = 0.0f;
} }
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * 11.0f; else
lerpFrac = ( gp_cl->time - ent->latched.sequencetime ) * 11.0f;
} }
else else
{ {
@ -410,8 +413,10 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
} }
// get the interpolated frames // get the interpolated frames
if( oldframe ) *oldframe = psprite->frames[ent->latched.prevblending[0]].frameptr; if( oldframe )
if( curframe ) *curframe = psprite->frames[frame].frameptr; *oldframe = psprite->frames[ent->latched.prevblending[0]].frameptr;
if( curframe )
*curframe = psprite->frames[frame].frameptr;
} }
else if( psprite->frames[frame].type == FRAME_GROUP ) 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 ) if( m_fDoInterp )
lerpFrac = ( targettime - jtime ) / jinterval; lerpFrac = ( targettime - jtime ) / jinterval;
else j = i; // no lerping else
j = i; // no lerping
// get the interpolated frames // get the interpolated frames
if( oldframe ) *oldframe = pspritegroup->frames[j]; if( oldframe )
if( curframe ) *curframe = pspritegroup->frames[i]; *oldframe = pspritegroup->frames[j];
if( curframe )
*curframe = pspritegroup->frames[i];
} }
else if( psprite->frames[frame].type == FRAME_ANGLED ) 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; ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f; 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 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; 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; pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
if( curframe ) *curframe = pspritegroup->frames[angleframe]; if( curframe )
*curframe = pspritegroup->frames[angleframe];
} }
return lerpFrac; return lerpFrac;
@ -719,12 +730,14 @@ void R_DrawSpriteModel( cl_entity_t *e )
int num = bound( 1, e->curstate.body, MAXSTUDIOATTACHMENTS ); int num = bound( 1, e->curstate.body, MAXSTUDIOATTACHMENTS );
VectorCopy( parent->attachment[num - 1], origin ); VectorCopy( parent->attachment[num - 1], origin );
} }
else VectorCopy( parent->origin, origin ); else
VectorCopy( parent->origin, origin );
} }
} }
scale = e->curstate.scale; scale = e->curstate.scale;
if( !scale ) scale = 1.0f; if( !scale )
scale = 1.0f;
if( R_SpriteOccluded( e, origin, &scale )) if( R_SpriteOccluded( e, origin, &scale ))
return; // sprite culled return; // sprite culled
@ -763,7 +776,8 @@ void R_DrawSpriteModel( cl_entity_t *e )
if( R_SpriteAllowLerping( e, psprite )) if( R_SpriteAllowLerping( e, psprite ))
lerp = R_GetSpriteFrameInterpolant( e, &oldframe, &frame ); 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; type = psprite->type;

View file

@ -242,7 +242,8 @@ static qboolean R_StudioComputeBBox( vec3_t bbox[8] )
Matrix3x4_VectorTransform( g_studio.rotationmatrix, p1, p2 ); Matrix3x4_VectorTransform( g_studio.rotationmatrix, p1, p2 );
AddPointToBounds( p2, studio_mins, studio_maxs ); 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 )) 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; flWeight3 = boneweights->weight[3] / 255.0f;
flTotal = flWeight0 + flWeight1 + flWeight2 + flWeight3; 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][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; 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; flWeight2 = boneweights->weight[2] / 255.0f;
flTotal = flWeight0 + flWeight1 + flWeight2; 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][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; 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; flWeight1 = boneweights->weight[1] / 255.0f;
flTotal = flWeight0 + flWeight1; 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][0] = boneMat0[0][0] * flWeight0 + boneMat1[0][0] * flWeight1;
result[0][1] = boneMat0[0][1] * flWeight0 + boneMat1[0][1] * 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 ) static void pfnGetEngineTimes( int *framecount, double *current, double *old )
{ {
if( framecount ) *framecount = tr.realframecount; if( framecount )
if( current ) *current = gp_cl->time; *framecount = tr.realframecount;
if( old ) *old = gp_cl->oldtime; 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 ) static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *forwardv )
{ {
if( origin ) VectorCopy( RI.vieworg, origin ); if( origin )
if( forwardv ) VectorCopy( RI.vforward, forwardv ); VectorCopy( RI.vieworg, origin );
if( rightv ) VectorCopy( RI.vright, rightv ); if( forwardv )
if( upv ) VectorCopy( RI.vup, upv ); 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 ) static void pfnGetAliasScale( float *x, float *y )
{ {
if( x ) *x = 1.0f; if( x )
if( y ) *y = 1.0f; *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 if( pseqdesc->blendend[0] - pseqdesc->blendstart[0] < 0.1f ) // catch qc error
*pBlend = 127; *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; *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 ); QuaternionSlerp( q2, q1, f, q );
QuaternionAngle( q, angles ); 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 angles[PITCH] = -angles[PITCH]; // stupid quake bug
// don't rotate clients, only aim // 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 ); 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( g_studio.interpolate )
{ {
if( time < e->curstate.animtime ) dfdt = 0.0; if( time < e->curstate.animtime )
else dfdt = (time - e->curstate.animtime) * e->curstate.framerate * pseqdesc->fps; 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; if( pseqdesc->numframes <= 1 )
else f = (e->curstate.frame * (pseqdesc->numframes - 1)) / 256.0; f = 0.0;
else
f = ( e->curstate.frame * ( pseqdesc->numframes - 1 )) / 256.0;
f += dfdt; f += dfdt;
@ -632,13 +653,15 @@ float GAME_EXPORT R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqd
{ {
if( pseqdesc->numframes > 1 ) if( pseqdesc->numframes > 1 )
f -= (int)( f / ( pseqdesc->numframes - 1 )) * ( 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 else
{ {
if( f >= pseqdesc->numframes - 1.001 ) if( f >= pseqdesc->numframes - 1.001 )
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; 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 )) if( g_studio.interpolate && ( e->curstate.animtime >= e->latched.prevanimtime + 0.01f ))
{ {
dadt = ( g_studio.time - e->curstate.animtime ) / 0.1f; 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; return dadt;
@ -678,7 +702,8 @@ static void R_StudioFxTransform( cl_entity_t *ent, matrix3x4 transform )
{ {
int axis = gEngfuncs.COM_RandomLong( 0, 1 ); 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] ); VectorScale( transform[axis], gEngfuncs.COM_RandomFloat( 1.0f, 1.484f ), transform[axis] );
} }
else if( !gEngfuncs.COM_RandomLong( 0, 49 )) else if( !gEngfuncs.COM_RandomLong( 0, 49 ))
@ -686,7 +711,8 @@ static void R_StudioFxTransform( cl_entity_t *ent, matrix3x4 transform )
float offset; float offset;
int axis = gEngfuncs.COM_RandomLong( 0, 1 ); 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 ); offset = gEngfuncs.COM_RandomFloat( -10.0f, 10.0f );
transform[gEngfuncs.COM_RandomLong( 0, 2 )][3] += offset; transform[gEngfuncs.COM_RandomLong( 0, 2 )][3] += offset;
} }
@ -696,7 +722,8 @@ static void R_StudioFxTransform( cl_entity_t *ent, matrix3x4 transform )
float scale; float scale;
scale = 1.0f + ( g_studio.time - ent->curstate.animtime ) * 10.0f; 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[0][1] *= scale;
transform[1][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] ); R_StudioCalcBonePosition( frame, s, pbone, panim, adj, pos[i] );
} }
if( pseqdesc->motiontype & STUDIO_X ) pos[pseqdesc->motionbone][0] = 0.0f; if( pseqdesc->motiontype & STUDIO_X )
if( pseqdesc->motiontype & STUDIO_Y ) pos[pseqdesc->motionbone][1] = 0.0f; pos[pseqdesc->motionbone][0] = 0.0f;
if( pseqdesc->motiontype & STUDIO_Z ) pos[pseqdesc->motionbone][2] = 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" )) else if( !Q_strcmp( pbones[pbones[i].parent].name, "Bip01 Pelvis" ))
copy_bones = true; copy_bones = true;
if( !copy_bones ) continue; if( !copy_bones )
continue;
VectorCopy( pos2[i], pos[i] ); VectorCopy( pos2[i], pos[i] );
Vector4Copy( q2[i], q[i] ); Vector4Copy( q2[i], q[i] );
@ -1088,7 +1119,8 @@ static void R_StudioBuildNormalTable( void )
while(( i = *( ptricmds++ ))) while(( i = *( ptricmds++ )))
{ {
if( i < 0 ) i = -i; if( i < 0 )
i = -i;
for( ; i > 0; i--, ptricmds += 4 ) 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 ) 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 ); 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[v1], norm, g_studio.norms[v1] );
VectorAdd( g_studio.norms[v2], norm, g_studio.norms[v2] ); VectorAdd( g_studio.norms[v2], norm, g_studio.norms[v2] );
if( odd ) v1 = v2; if( odd )
else v0 = v2; v1 = v2;
else
v0 = v2;
odd = !odd; 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; m_pSubModel = (mstudiomodel_t *)((byte *)m_pStudioHeader + m_pBodyPart->modelindex ) + index;
if( ppbodypart ) *ppbodypart = m_pBodyPart; if( ppbodypart )
if( ppsubmodel ) *ppsubmodel = m_pSubModel; *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 // determine plane to get lightvalues from: ceil or floor
if( FBitSet( ent->curstate.effects, EF_INVLIGHT )) if( FBitSet( ent->curstate.effects, EF_INVLIGHT ))
VectorSet( lightDir, 0.0f, 0.0f, 1.0f ); 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 ); 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 ); trace = gEngfuncs.CL_TraceLine( vecSrc, vecEnd, PM_WORLD_ONLY );
if( trace.ent > 0 ) psurf = gEngfuncs.EV_TraceSurface( trace.ent, vecSrc, vecEnd ); if( trace.ent > 0 )
else psurf = gEngfuncs.EV_TraceSurface( 0, vecSrc, vecEnd ); 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 ))) 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; ent->cvFloorColor = light;
total = Q_max( Q_max( light.r, light.g ), light.b ); 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 // scale lightdir by light intentsity
VectorScale( lightDir, total, lightDir ); VectorScale( lightDir, total, lightDir );
@ -1465,7 +1506,8 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
if( radius > 1.0f ) if( radius > 1.0f )
VectorScale( dist, ( add / radius ), dist ); VectorScale( dist, ( add / radius ), dist );
else VectorScale( dist, add, dist ); else
VectorScale( dist, add, dist );
VectorAdd( lightDir, dist, lightDir ); 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 )) if( FBitSet( ent->model->flags, STUDIO_AMBIENT_LIGHT ))
add = 0.6f; 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 ); 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[1] = finalLight[1] * ( 1.0f / total );
plight->color[2] = finalLight[2] * ( 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 ) if( plight->ambientlight > 128 )
plight->ambientlight = 128; plight->ambientlight = 128;
@ -1541,8 +1585,10 @@ static void R_StudioEntityLight( alight_t *lightinfo )
{ {
int att = ( el->key >> 12 ) & 0xF; int att = ( el->key >> 12 ) & 0xF;
if( att ) VectorCopy( ent->attachment[att], el->origin ); if( att )
else VectorCopy( ent->origin, el->origin ); VectorCopy( ent->attachment[att], el->origin );
else
VectorCopy( ent->origin, el->origin );
} }
VectorCopy( el->origin, pos ); VectorCopy( el->origin, pos );
@ -1551,8 +1597,10 @@ static void R_StudioEntityLight( alight_t *lightinfo )
f = DotProduct( mid, mid ); f = DotProduct( mid, mid );
r2 = el->radius * el->radius; r2 = el->radius * el->radius;
if( f > r2 ) minstrength = r2 / f; if( f > r2 )
else minstrength = 1.0f; minstrength = r2 / f;
else
minstrength = 1.0f;
if( minstrength > 0.05f ) 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 ) if( k != -1 )
{ {
@ -1609,7 +1658,8 @@ static void R_StudioSetupLighting( alight_t *plight )
for( i = 0; i < m_pStudioHeader->numbones; i++ ) for( i = 0; i < m_pStudioHeader->numbones; i++ )
{ {
Matrix3x4_VectorIRotate( g_studio.lighttransform[i], plight->plightvec, g_studio.blightvec[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 ); 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; float r, lightcos;
if( bone != -1 ) lightcos = DotProduct( normal, g_studio.blightvec[bone] ); if( bone != -1 )
else lightcos = DotProduct( normal, g_studio.lightvec ); // -1 colinear, 1 opposite lightcos = DotProduct( normal, g_studio.blightvec[bone] );
if( lightcos > 1.0f ) lightcos = 1.0f; else
lightcos = DotProduct( normal, g_studio.lightvec ); // -1 colinear, 1 opposite
if( lightcos > 1.0f )
lightcos = 1.0f;
illum += g_studio.shadelight; 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 ) if( r2 > 0.0f )
light[i][3] = g_studio.locallightR2[i] / ( r2 * sqrt( r2 )); 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]; temp = r * light[i][3];
@ -1798,12 +1852,15 @@ static void R_StudioSetupSkin( studiohdr_t *ptexturehdr, int index )
return; return;
// NOTE: user may ignore to call StudioRemapColors and remap_info will be unavailable // NOTE: user may ignore to call StudioRemapColors and remap_info will be unavailable
if( m_fDoRemap ) ptexture = gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity )->ptexture; if( m_fDoRemap )
if( !ptexture ) ptexture = (mstudiotexture_t *)((byte *)ptexturehdr + ptexturehdr->textureindex); // fallback ptexture = gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity )->ptexture;
if( !ptexture )
ptexture = (mstudiotexture_t *)((byte *)ptexturehdr + ptexturehdr->textureindex ); // fallback
if( r_lightmap->value && !r_fullbright->value ) if( r_lightmap->value && !r_fullbright->value )
GL_Bind( XASH_TEXTURE0, tr.whiteTexture ); 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; return NULL;
thdr = m_pStudioHeader; thdr = m_pStudioHeader;
if( !thdr ) return NULL; if( !thdr )
return NULL;
if( m_fDoRemap ) ptexture = gEngfuncs.CL_GetRemapInfoForEntity( e )->ptexture; if( m_fDoRemap )
else ptexture = (mstudiotexture_t *)((byte *)thdr + thdr->textureindex); ptexture = gEngfuncs.CL_GetRemapInfoForEntity( e )->ptexture;
else
ptexture = (mstudiotexture_t *)((byte *)thdr + thdr->textureindex );
return ptexture; return ptexture;
} }
static void R_StudioSetRenderamt( int iRenderamt ) static void R_StudioSetRenderamt( int iRenderamt )
{ {
if( !RI.currententity ) return; if( !RI.currententity )
return;
RI.currententity->curstate.renderamt = iRenderamt; RI.currententity->curstate.renderamt = iRenderamt;
tr.blend = CL_FxBlend( RI.currententity ) / 255.0f; 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 ); TriBegin( TRI_TRIANGLE_FAN );
i = -i; i = -i;
} }
else TriBegin( TRI_TRIANGLE_STRIP ); else
TriBegin( TRI_TRIANGLE_STRIP );
for( ; i > 0; i--, ptricmds += 4 ) for( ; i > 0; i--, ptricmds += 4 )
{ {
@ -1952,7 +2014,8 @@ static void R_StudioDrawFloatMesh( short *ptricmds, vec3_t *pstudionorms )
TriBegin( TRI_TRIANGLE_FAN ); TriBegin( TRI_TRIANGLE_FAN );
i = -i; i = -i;
} }
else TriBegin( TRI_TRIANGLE_STRIP ); else
TriBegin( TRI_TRIANGLE_STRIP );
for( ; i > 0; i--, ptricmds += 4 ) for( ; i > 0; i--, ptricmds += 4 )
{ {
@ -1986,7 +2049,8 @@ static void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, float
TriBegin( TRI_TRIANGLE_FAN ); TriBegin( TRI_TRIANGLE_FAN );
i = -i; i = -i;
} }
else TriBegin( TRI_TRIANGLE_STRIP ); else
TriBegin( TRI_TRIANGLE_STRIP );
for( ; i > 0; i--, ptricmds += 4 ) for( ; i > 0; i--, ptricmds += 4 )
{ {
@ -2037,7 +2101,8 @@ static void R_StudioDrawPoints( void )
short *pskinref; short *pskinref;
float lv_tmp; float lv_tmp;
if( !m_pStudioHeader ) return; if( !m_pStudioHeader )
return;
m_skinnum = RI.currententity->curstate.skin; m_skinnum = RI.currententity->curstate.skin;
ptexture = (mstudiotexture_t *)((byte *)m_pStudioHeader + m_pStudioHeader->textureindex ); 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 )) if( FBitSet( m_pStudioHeader->flags, STUDIO_HAS_BONEWEIGHTS ))
R_StudioLighting( &lv_tmp, -1, g_nFaceFlags, g_studio.norms[k] ); 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 )) if( FBitSet( g_nFaceFlags, STUDIO_NF_CHROME ))
R_StudioSetupChrome( g_studio.chrome[k], *pnormbone, (float *)pstudionorms ); 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 ); R_StudioDrawChromeMesh( ptricmds, pstudionorms, s, t, shellscale );
else if( FBitSet( g_nFaceFlags, STUDIO_NF_UV_COORDS )) else if( FBitSet( g_nFaceFlags, STUDIO_NF_UV_COORDS ))
R_StudioDrawFloatMesh( ptricmds, pstudionorms ); 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 )) 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 )) if( gEngfuncs.fsapi->FileExists( state->modelname, false ))
state->model = gEngfuncs.Mod_ForName( state->modelname, false, true ); state->model = gEngfuncs.Mod_ForName( state->modelname, false, true );
else state->model = NULL; else
state->model = NULL;
if( !state->model ) if( !state->model )
state->model = RI.currententity->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 if( ent->player ) // check it for real playermodel
model = R_StudioSetupPlayerModel( ent->curstate.number - 1 ); model = R_StudioSetupPlayerModel( ent->curstate.number - 1 );
else model = ent->model; else
model = ent->model;
RI.currententity = oldent; RI.currententity = oldent;
@ -2357,7 +2426,8 @@ int R_GetEntityRenderMode( cl_entity_t *ent )
// ignore chrome & additive it's just a specular-like effect // ignore chrome & additive it's just a specular-like effect
if( FBitSet( ptexture->flags, STUDIO_NF_ADDITIVE ) && !FBitSet( ptexture->flags, STUDIO_NF_CHROME )) if( FBitSet( ptexture->flags, STUDIO_NF_ADDITIVE ) && !FBitSet( ptexture->flags, STUDIO_NF_CHROME ))
trans++; trans++;
else opaque++; else
opaque++;
} }
// if model is more additive than opaque // if model is more additive than opaque
@ -2490,7 +2560,8 @@ static void R_StudioSetupRenderer( int rendermode )
studiohdr_t *phdr = m_pStudioHeader; studiohdr_t *phdr = m_pStudioHeader;
int i; int i;
if( rendermode > kRenderTransAdd ) rendermode = 0; if( rendermode > kRenderTransAdd )
rendermode = 0;
g_studio.rendermode = bound( 0, rendermode, kRenderTransAdd ); g_studio.rendermode = bound( 0, rendermode, kRenderTransAdd );
// a point to setup local to world transform for boneweighted models // 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; float flYawDiff = RI.currententity->angles[YAW] - m_pPlayerInfo->gaityaw;
flYawDiff = flYawDiff - (int)( flYawDiff / 360 ) * 360; flYawDiff = flYawDiff - (int)( flYawDiff / 360 ) * 360;
if( flYawDiff > 180.0f ) flYawDiff -= 360.0f; if( flYawDiff > 180.0f )
if( flYawDiff < -180.0f ) flYawDiff += 360.0f; flYawDiff -= 360.0f;
if( flYawDiff < -180.0f )
flYawDiff += 360.0f;
if( dt < 0.25f ) if( dt < 0.25f )
flYawDiff *= dt * 4.0f; flYawDiff *= dt * 4.0f;
else flYawDiff *= dt; else
flYawDiff *= dt;
m_pPlayerInfo->gaityaw += flYawDiff; m_pPlayerInfo->gaityaw += flYawDiff;
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)( m_pPlayerInfo->gaityaw / 360 ) * 360; 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 else
{ {
m_pPlayerInfo->gaityaw = ( atan2( est_velocity[1], est_velocity[0] ) * 180 / M_PI_F ); 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 )
if( m_pPlayerInfo->gaityaw < -180.0f ) 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 // calc side to side turning
flYaw = RI.currententity->angles[YAW] - m_pPlayerInfo->gaityaw; flYaw = RI.currententity->angles[YAW] - m_pPlayerInfo->gaityaw;
flYaw = flYaw - (int)( flYaw / 360 ) * 360; flYaw = flYaw - (int)( flYaw / 360 ) * 360;
if( flYaw < -180.0f ) flYaw = flYaw + 360.0f; if( flYaw < -180.0f )
if( flYaw > 180.0f ) flYaw = flYaw - 360.0f; flYaw = flYaw + 360.0f;
if( flYaw > 180.0f )
flYaw = flYaw - 360.0f;
if( flYaw > 120.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->latched.prevcontroller[3] = RI.currententity->curstate.controller[3];
RI.currententity->angles[YAW] = m_pPlayerInfo->gaityaw; 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]; RI.currententity->latched.prevangles[YAW] = RI.currententity->angles[YAW];
if( pplayer->gaitsequence >= m_pStudioHeader->numseq ) if( pplayer->gaitsequence >= m_pStudioHeader->numseq )
@ -2833,11 +2912,13 @@ static void R_StudioProcessGait( entity_state_t *pplayer )
// calc gait frame // calc gait frame
if( pseqdesc->linearmovement[0] > 0 ) if( pseqdesc->linearmovement[0] > 0 )
m_pPlayerInfo->gaitframe += ( m_flGaitMovement / pseqdesc->linearmovement[0] ) * pseqdesc->numframes; 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 // do modulo
m_pPlayerInfo->gaitframe = m_pPlayerInfo->gaitframe - (int)( m_pPlayerInfo->gaitframe / pseqdesc->numframes ) * pseqdesc->numframes; 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_nTopColor = m_pPlayerInfo->topcolor;
g_nBottomColor = m_pPlayerInfo->bottomcolor; g_nBottomColor = m_pPlayerInfo->bottomcolor;
if( g_nTopColor < 0 ) g_nTopColor = 0; if( g_nTopColor < 0 )
if( g_nTopColor > 360 ) g_nTopColor = 360; g_nTopColor = 0;
if( g_nBottomColor < 0 ) g_nBottomColor = 0; if( g_nTopColor > 360 )
if( g_nBottomColor > 360 ) g_nBottomColor = 360; g_nTopColor = 360;
if( g_nBottomColor < 0 )
g_nBottomColor = 0;
if( g_nBottomColor > 360 )
g_nBottomColor = 360;
R_StudioSetRemapColors( g_nTopColor, g_nBottomColor ); R_StudioSetRemapColors( g_nTopColor, g_nBottomColor );
@ -2999,8 +3084,8 @@ static int R_StudioDrawModel( int flags )
entity_state_t deadplayer; entity_state_t deadplayer;
int result; int result;
if( RI.currententity->curstate.renderamt <= 0 || if( RI.currententity->curstate.renderamt <= 0
RI.currententity->curstate.renderamt > gp_cl->maxclients ) || RI.currententity->curstate.renderamt > gp_cl->maxclients )
return 0; return 0;
// get copy of player // get copy of player
@ -3041,7 +3126,8 @@ static int R_StudioDrawModel( int flags )
if( RI.currententity->curstate.movetype == MOVETYPE_FOLLOW ) if( RI.currententity->curstate.movetype == MOVETYPE_FOLLOW )
R_StudioMergeBones( RI.currententity, RI.currentmodel ); R_StudioMergeBones( RI.currententity, RI.currentmodel );
else R_StudioSetupBones( RI.currententity ); else
R_StudioSetupBones( RI.currententity );
R_StudioSaveBones(); R_StudioSaveBones();
@ -3091,14 +3177,16 @@ static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
{ {
if( e->player ) if( e->player )
R_StudioDrawPlayer( flags, &e->curstate ); R_StudioDrawPlayer( flags, &e->curstate );
else R_StudioDrawModel( flags ); else
R_StudioDrawModel( flags );
} }
else else
{ {
// select the properly method // select the properly method
if( e->player ) if( e->player )
pStudioDraw->StudioDrawPlayer( flags, R_StudioGetPlayerState( e->index - 1 )); 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; sample_frac = surf->texinfo->faceinfo->texture_step;
else if( FBitSet( surf->texinfo->flags, TEX_EXTRA_LIGHTMAP )) else if( FBitSet( surf->texinfo->flags, TEX_EXTRA_LIGHTMAP ))
sample_frac = LM_SAMPLE_EXTRASIZE; sample_frac = LM_SAMPLE_EXTRASIZE;
else sample_frac = LM_SAMPLE_SIZE; else
sample_frac = LM_SAMPLE_SIZE;
} }
for( lnum = 0; lnum < MAX_DLIGHTS; lnum++ ) 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 // transform light origin to local bmodel space
if( !tr.modelviewIdentity ) if( !tr.modelviewIdentity )
Matrix4x4_VectorITransform( RI.objectMatrix, dl->origin, origin_l ); Matrix4x4_VectorITransform( RI.objectMatrix, dl->origin, origin_l );
else VectorCopy( dl->origin, origin_l ); else
VectorCopy( dl->origin, origin_l );
rad = dl->radius; rad = dl->radius;
dist = PlaneDiff( origin_l, surf->plane ); dist = PlaneDiff( origin_l, surf->plane );
@ -130,7 +132,8 @@ static void R_AddDynamicLights( const msurface_t *surf )
VectorCopy( origin_l, impact ); VectorCopy( origin_l, impact );
impact[surf->plane->type] -= dist; 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]; 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]; 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 ) if( blocklights[i] < 65280 )
t = LightToTexGamma( blocklights[i] >> 6 ) << 6; t = LightToTexGamma( blocklights[i] >> 6 ) << 6;
else t = (int)blocklights[i]; else
t = (int)blocklights[i];
t = bound( 0, t, 65535 * 3 ); t = bound( 0, t, 65535 * 3 );
t = t / 2048 / 3; // (255*256 - t) >> (8 - VID_CBITS); 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 // Quake1 textures uses 10 frames per second
if( FBitSet( R_GetTexture( base->gl_texturenum )->flags, TF_QUAKEPAL )) if( FBitSet( R_GetTexture( base->gl_texturenum )->flags, TF_QUAKEPAL ))
speed = 10; speed = 10;
else speed = 20; else
speed = 20;
reletive = (int)( gp_cl->time * speed ) % base->anim_total; 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 // Quake1 textures uses 10 frames per second
if( FBitSet( R_GetTexture( base->gl_texturenum )->flags, TF_QUAKEPAL )) if( FBitSet( R_GetTexture( base->gl_texturenum )->flags, TF_QUAKEPAL ))
speed = 10; speed = 10;
else speed = 20; else
speed = 20;
reletive = (int)( gp_cl->time * speed ) % base->anim_total; reletive = (int)( gp_cl->time * speed ) % base->anim_total;
} }
@ -381,7 +387,8 @@ void R_DrawSurface (void)
if( sample_bits == -1 ) if( sample_bits == -1 )
{ {
sample_bits = 0; 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 else
sample_pot = 1 << sample_bits; sample_pot = 1 << sample_bits;
@ -1005,10 +1012,10 @@ static void R_DrawSurfaceDecals( void )
R_DecalComputeBasis( fa, 0, basis ); R_DecalComputeBasis( fa, 0, basis );
w = fabs( tex->width * DotProduct( textureU, basis[0] )) + w = fabs( tex->width * DotProduct( textureU, basis[0] ))
fabs( tex->height * DotProduct( textureU, basis[1] )); + fabs( tex->height * DotProduct( textureU, basis[1] ));
h = fabs( tex->width * DotProduct( textureV, basis[0] )) + h = fabs( tex->width * DotProduct( textureV, basis[0] ))
fabs( tex->height * DotProduct( textureV, basis[1] )); + fabs( tex->height * DotProduct( textureV, basis[1] ));
// project decal center into the texture space of the surface // project decal center into the texture space of the surface
x = DotProduct( p->position, textureU ) + textureU[3] - fa->texturemins[0] - w / 2; 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; // a = 1;
if( ds.renderMode == kRenderTransAlpha ) if( ds.renderMode == kRenderTransAlpha )
TriColor4ub( r * 255.0f, g * 255.0f, b * 255.0f, a * 255.0f ); 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[0] = r;
ds.triRGBA[1] = g; ds.triRGBA[1] = g;