ref: soft: as an experiment, reformat ref_soft as it's easier to notice config inaccuracies
This commit is contained in:
parent
fbbafb45a3
commit
a52c8aa291
23 changed files with 5299 additions and 5018 deletions
|
@ -21,17 +21,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "r_local.h"
|
||||
|
||||
static finalvert_t fv[2][8];
|
||||
static finalvert_t fv[2][8];
|
||||
|
||||
void R_AliasProjectAndClipTestFinalVert (finalvert_t *fv);
|
||||
void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out);
|
||||
void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out);
|
||||
void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out);
|
||||
void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out);
|
||||
void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv );
|
||||
void R_Alias_clip_top( finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out );
|
||||
void R_Alias_clip_bottom( finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out );
|
||||
void R_Alias_clip_left( finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out );
|
||||
void R_Alias_clip_right( finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out );
|
||||
|
||||
|
||||
/*
|
||||
|
@ -41,169 +41,169 @@ R_Alias_clip_z
|
|||
pfv0 is the unclipped vertex, pfv1 is the z-clipped vertex
|
||||
================
|
||||
*/
|
||||
static void R_Alias_clip_z (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
|
||||
static void R_Alias_clip_z( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out )
|
||||
{
|
||||
float scale;
|
||||
float scale;
|
||||
|
||||
scale = (ALIAS_Z_CLIP_PLANE - pfv0->xyz[2]) /
|
||||
(pfv1->xyz[2] - pfv0->xyz[2]);
|
||||
scale = ( ALIAS_Z_CLIP_PLANE - pfv0->xyz[2] )
|
||||
/ ( pfv1->xyz[2] - pfv0->xyz[2] );
|
||||
|
||||
out->xyz[0] = pfv0->xyz[0] + (pfv1->xyz[0] - pfv0->xyz[0]) * scale;
|
||||
out->xyz[1] = pfv0->xyz[1] + (pfv1->xyz[1] - pfv0->xyz[1]) * scale;
|
||||
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[2] = ALIAS_Z_CLIP_PLANE;
|
||||
|
||||
out->s = pfv0->s + (pfv1->s - pfv0->s) * scale;
|
||||
out->t = pfv0->t + (pfv1->t - pfv0->t) * scale;
|
||||
out->l = pfv0->l + (pfv1->l - pfv0->l) * scale;
|
||||
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale;
|
||||
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale;
|
||||
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale;
|
||||
|
||||
R_AliasProjectAndClipTestFinalVert (out);
|
||||
R_AliasProjectAndClipTestFinalVert( out );
|
||||
}
|
||||
|
||||
void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
|
||||
void R_Alias_clip_left( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out )
|
||||
{
|
||||
float scale;
|
||||
float scale;
|
||||
|
||||
if (pfv0->v >= pfv1->v )
|
||||
if( pfv0->v >= pfv1->v )
|
||||
{
|
||||
scale = (float)(RI.aliasvrect.x - pfv0->u) /
|
||||
(pfv1->u - pfv0->u);
|
||||
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
|
||||
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
|
||||
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
|
||||
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
|
||||
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
|
||||
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi) * scale + 0.5f;
|
||||
scale = (float)( RI.aliasvrect.x - pfv0->u )
|
||||
/ ( pfv1->u - pfv0->u );
|
||||
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
|
||||
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
|
||||
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
|
||||
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
|
||||
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
|
||||
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi ) * scale + 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = (float)(RI.aliasvrect.x - pfv1->u) /
|
||||
(pfv0->u - pfv1->u);
|
||||
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
|
||||
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
|
||||
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
|
||||
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
|
||||
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
|
||||
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi) * scale + 0.5f;
|
||||
scale = (float)( RI.aliasvrect.x - pfv1->u )
|
||||
/ ( pfv0->u - pfv1->u );
|
||||
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
|
||||
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
|
||||
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
|
||||
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
|
||||
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
|
||||
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi ) * scale + 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
|
||||
void R_Alias_clip_right( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out )
|
||||
{
|
||||
float scale;
|
||||
float scale;
|
||||
|
||||
if ( pfv0->v >= pfv1->v )
|
||||
if( pfv0->v >= pfv1->v )
|
||||
{
|
||||
scale = (float)(RI.aliasvrectright - pfv0->u ) /
|
||||
(pfv1->u - pfv0->u );
|
||||
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
|
||||
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
|
||||
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
|
||||
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
|
||||
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
|
||||
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi) * scale + 0.5f;
|
||||
scale = (float)( RI.aliasvrectright - pfv0->u )
|
||||
/ ( pfv1->u - pfv0->u );
|
||||
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
|
||||
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
|
||||
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
|
||||
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
|
||||
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
|
||||
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi ) * scale + 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = (float)(RI.aliasvrectright - pfv1->u ) /
|
||||
(pfv0->u - pfv1->u );
|
||||
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
|
||||
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
|
||||
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
|
||||
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
|
||||
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
|
||||
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi) * scale + 0.5f;
|
||||
scale = (float)( RI.aliasvrectright - pfv1->u )
|
||||
/ ( pfv0->u - pfv1->u );
|
||||
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
|
||||
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
|
||||
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
|
||||
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
|
||||
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
|
||||
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi ) * scale + 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
|
||||
void R_Alias_clip_top( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out )
|
||||
{
|
||||
float scale;
|
||||
float scale;
|
||||
|
||||
if (pfv0->v >= pfv1->v)
|
||||
if( pfv0->v >= pfv1->v )
|
||||
{
|
||||
scale = (float)(RI.aliasvrect.y - pfv0->v) /
|
||||
(pfv1->v - pfv0->v);
|
||||
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
|
||||
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
|
||||
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
|
||||
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
|
||||
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
|
||||
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi) * scale + 0.5f;
|
||||
scale = (float)( RI.aliasvrect.y - pfv0->v )
|
||||
/ ( pfv1->v - pfv0->v );
|
||||
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
|
||||
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
|
||||
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
|
||||
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
|
||||
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
|
||||
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi ) * scale + 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = (float)(RI.aliasvrect.y - pfv1->v) /
|
||||
(pfv0->v - pfv1->v);
|
||||
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
|
||||
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
|
||||
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
|
||||
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
|
||||
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
|
||||
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi) * scale + 0.5f;
|
||||
scale = (float)( RI.aliasvrect.y - pfv1->v )
|
||||
/ ( pfv0->v - pfv1->v );
|
||||
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
|
||||
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
|
||||
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
|
||||
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
|
||||
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
|
||||
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi ) * scale + 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out)
|
||||
void R_Alias_clip_bottom( finalvert_t *pfv0, finalvert_t *pfv1,
|
||||
finalvert_t *out )
|
||||
{
|
||||
float scale;
|
||||
float scale;
|
||||
|
||||
if (pfv0->v >= pfv1->v)
|
||||
if( pfv0->v >= pfv1->v )
|
||||
{
|
||||
scale = (float)(RI.aliasvrectbottom - pfv0->v) /
|
||||
(pfv1->v - pfv0->v);
|
||||
scale = (float)( RI.aliasvrectbottom - pfv0->v )
|
||||
/ ( pfv1->v - pfv0->v );
|
||||
|
||||
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
|
||||
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
|
||||
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
|
||||
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
|
||||
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
|
||||
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi) * 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->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
|
||||
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
|
||||
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
|
||||
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi ) * scale + 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = (float)(RI.aliasvrectbottom - pfv1->v) /
|
||||
(pfv0->v - pfv1->v);
|
||||
scale = (float)( RI.aliasvrectbottom - pfv1->v )
|
||||
/ ( pfv0->v - pfv1->v );
|
||||
|
||||
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
|
||||
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
|
||||
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
|
||||
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
|
||||
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
|
||||
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi) * 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->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
|
||||
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
|
||||
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
|
||||
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi ) * scale + 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
static int R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
|
||||
void(*clip)(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out) )
|
||||
static int R_AliasClip( finalvert_t *in, finalvert_t *out, int flag, int count,
|
||||
void ( *clip )( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out ))
|
||||
{
|
||||
int i,j,k;
|
||||
int flags, oldflags;
|
||||
int i, j, k;
|
||||
int flags, oldflags;
|
||||
|
||||
j = count-1;
|
||||
j = count - 1;
|
||||
k = 0;
|
||||
for (i=0 ; i<count ; j = i, i++)
|
||||
for( i = 0; i < count; j = i, i++ )
|
||||
{
|
||||
oldflags = in[j].flags & flag;
|
||||
flags = in[i].flags & flag;
|
||||
|
||||
if (flags && oldflags)
|
||||
if( flags && oldflags )
|
||||
continue;
|
||||
if (oldflags ^ flags)
|
||||
if( oldflags ^ flags )
|
||||
{
|
||||
clip (&in[j], &in[i], &out[k]);
|
||||
clip( &in[j], &in[i], &out[k] );
|
||||
out[k].flags = 0;
|
||||
if (out[k].u < RI.aliasvrect.x)
|
||||
if( out[k].u < RI.aliasvrect.x )
|
||||
out[k].flags |= ALIAS_LEFT_CLIP;
|
||||
if (out[k].v < RI.aliasvrect.y)
|
||||
if( out[k].v < RI.aliasvrect.y )
|
||||
out[k].flags |= ALIAS_TOP_CLIP;
|
||||
if (out[k].u > RI.aliasvrectright)
|
||||
if( out[k].u > RI.aliasvrectright )
|
||||
out[k].flags |= ALIAS_RIGHT_CLIP;
|
||||
if (out[k].v > RI.aliasvrectbottom)
|
||||
if( out[k].v > RI.aliasvrectbottom )
|
||||
out[k].flags |= ALIAS_BOTTOM_CLIP;
|
||||
k++;
|
||||
}
|
||||
if (!flags)
|
||||
if( !flags )
|
||||
{
|
||||
out[k] = in[i];
|
||||
k++;
|
||||
|
@ -218,10 +218,10 @@ static int R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
|
|||
R_AliasClipTriangle
|
||||
================
|
||||
*/
|
||||
void R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t *index2)
|
||||
void R_AliasClipTriangle( finalvert_t *index0, finalvert_t *index1, finalvert_t *index2 )
|
||||
{
|
||||
int i, k, pingpong;
|
||||
unsigned clipflags;
|
||||
int i, k, pingpong;
|
||||
unsigned clipflags;
|
||||
|
||||
// copy vertexes and fix seam texture coordinates
|
||||
fv[0][0] = *index0;
|
||||
|
@ -231,10 +231,10 @@ void R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t
|
|||
// clip
|
||||
clipflags = fv[0][0].flags | fv[0][1].flags | fv[0][2].flags;
|
||||
|
||||
if (clipflags & ALIAS_Z_CLIP)
|
||||
if( clipflags & ALIAS_Z_CLIP )
|
||||
{
|
||||
k = R_AliasClip (fv[0], fv[1], ALIAS_Z_CLIP, 3, R_Alias_clip_z);
|
||||
if (k == 0)
|
||||
k = R_AliasClip( fv[0], fv[1], ALIAS_Z_CLIP, 3, R_Alias_clip_z );
|
||||
if( k == 0 )
|
||||
return;
|
||||
|
||||
pingpong = 1;
|
||||
|
@ -246,67 +246,67 @@ void R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t
|
|||
k = 3;
|
||||
}
|
||||
|
||||
if (clipflags & ALIAS_LEFT_CLIP)
|
||||
if( clipflags & ALIAS_LEFT_CLIP )
|
||||
{
|
||||
k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
|
||||
ALIAS_LEFT_CLIP, k, R_Alias_clip_left);
|
||||
if (k == 0)
|
||||
k = R_AliasClip( fv[pingpong], fv[pingpong ^ 1],
|
||||
ALIAS_LEFT_CLIP, k, R_Alias_clip_left );
|
||||
if( k == 0 )
|
||||
return;
|
||||
|
||||
pingpong ^= 1;
|
||||
}
|
||||
|
||||
if (clipflags & ALIAS_RIGHT_CLIP)
|
||||
if( clipflags & ALIAS_RIGHT_CLIP )
|
||||
{
|
||||
k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
|
||||
ALIAS_RIGHT_CLIP, k, R_Alias_clip_right);
|
||||
if (k == 0)
|
||||
k = R_AliasClip( fv[pingpong], fv[pingpong ^ 1],
|
||||
ALIAS_RIGHT_CLIP, k, R_Alias_clip_right );
|
||||
if( k == 0 )
|
||||
return;
|
||||
|
||||
pingpong ^= 1;
|
||||
}
|
||||
|
||||
if (clipflags & ALIAS_BOTTOM_CLIP)
|
||||
if( clipflags & ALIAS_BOTTOM_CLIP )
|
||||
{
|
||||
k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
|
||||
ALIAS_BOTTOM_CLIP, k, R_Alias_clip_bottom);
|
||||
if (k == 0)
|
||||
k = R_AliasClip( fv[pingpong], fv[pingpong ^ 1],
|
||||
ALIAS_BOTTOM_CLIP, k, R_Alias_clip_bottom );
|
||||
if( k == 0 )
|
||||
return;
|
||||
|
||||
pingpong ^= 1;
|
||||
}
|
||||
|
||||
if (clipflags & ALIAS_TOP_CLIP)
|
||||
if( clipflags & ALIAS_TOP_CLIP )
|
||||
{
|
||||
k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
|
||||
ALIAS_TOP_CLIP, k, R_Alias_clip_top);
|
||||
if (k == 0)
|
||||
k = R_AliasClip( fv[pingpong], fv[pingpong ^ 1],
|
||||
ALIAS_TOP_CLIP, k, R_Alias_clip_top );
|
||||
if( k == 0 )
|
||||
return;
|
||||
|
||||
pingpong ^= 1;
|
||||
}
|
||||
|
||||
for (i=0 ; i<k ; i++)
|
||||
for( i = 0; i < k; i++ )
|
||||
{
|
||||
if (fv[pingpong][i].u < RI.aliasvrect.x)
|
||||
if( fv[pingpong][i].u < RI.aliasvrect.x )
|
||||
fv[pingpong][i].u = RI.aliasvrect.x;
|
||||
else if (fv[pingpong][i].u > RI.aliasvrectright)
|
||||
else if( fv[pingpong][i].u > RI.aliasvrectright )
|
||||
fv[pingpong][i].u = RI.aliasvrectright;
|
||||
|
||||
if (fv[pingpong][i].v < RI.aliasvrect.y)
|
||||
if( fv[pingpong][i].v < RI.aliasvrect.y )
|
||||
fv[pingpong][i].v = RI.aliasvrect.y;
|
||||
else if (fv[pingpong][i].v > RI.aliasvrectbottom)
|
||||
else if( fv[pingpong][i].v > RI.aliasvrectbottom )
|
||||
fv[pingpong][i].v = RI.aliasvrectbottom;
|
||||
|
||||
fv[pingpong][i].flags = 0;
|
||||
}
|
||||
|
||||
// draw triangles
|
||||
for (i=1 ; i<k-1 ; i++)
|
||||
for( i = 1; i < k - 1; i++ )
|
||||
{
|
||||
aliastriangleparms.a = &fv[pingpong][0];
|
||||
aliastriangleparms.b = &fv[pingpong][i];
|
||||
aliastriangleparms.c = &fv[pingpong][i+1];
|
||||
aliastriangleparms.c = &fv[pingpong][i + 1];
|
||||
R_DrawTriangle();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ GNU General Public License for more details.
|
|||
#include "triangleapi.h"
|
||||
#include "studio.h"
|
||||
|
||||
#define NOISE_DIVISIONS 64 // don't touch - many tripmines cause the crash when it equal 128
|
||||
#define NOISE_DIVISIONS 64 // don't touch - many tripmines cause the crash when it equal 128
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t pos;
|
||||
float texcoord; // Y texture coordinate
|
||||
float width;
|
||||
vec3_t pos;
|
||||
float texcoord; // Y texture coordinate
|
||||
float width;
|
||||
} beamseg_t;
|
||||
|
||||
/*
|
||||
|
@ -39,16 +39,17 @@ FRACTAL NOISE
|
|||
|
||||
==============================================================
|
||||
*/
|
||||
static float rgNoise[NOISE_DIVISIONS+1]; // global noise array
|
||||
static float rgNoise[NOISE_DIVISIONS + 1]; // global noise array
|
||||
|
||||
// freq2 += step * 0.1;
|
||||
// Fractal noise generator, power of 2 wavelength
|
||||
static void FracNoise( float *noise, int divs )
|
||||
{
|
||||
int div2;
|
||||
int div2;
|
||||
|
||||
div2 = divs >> 1;
|
||||
if( divs < 2 ) return;
|
||||
if( divs < 2 )
|
||||
return;
|
||||
|
||||
// noise is normalized to +/- scale
|
||||
noise[div2] = ( noise[0] + noise[divs] ) * 0.5f + divs * gEngfuncs.COM_RandomFloat( -0.125f, 0.125f );
|
||||
|
@ -62,9 +63,9 @@ static void FracNoise( float *noise, int divs )
|
|||
|
||||
static void SineNoise( float *noise, int divs )
|
||||
{
|
||||
float freq = 0;
|
||||
float step = M_PI_F / (float)divs;
|
||||
int i;
|
||||
float freq = 0;
|
||||
float step = M_PI_F / (float)divs;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < divs; i++ )
|
||||
{
|
||||
|
@ -84,7 +85,7 @@ BEAM MATHLIB
|
|||
static void R_BeamComputePerpendicular( const vec3_t vecBeamDelta, vec3_t pPerp )
|
||||
{
|
||||
// direction in worldspace of the center of the beam
|
||||
vec3_t vecBeamCenter;
|
||||
vec3_t vecBeamCenter;
|
||||
|
||||
VectorNormalize2( vecBeamDelta, vecBeamCenter );
|
||||
CrossProduct( RI.vforward, vecBeamCenter, pPerp );
|
||||
|
@ -94,7 +95,7 @@ static void R_BeamComputePerpendicular( const vec3_t vecBeamDelta, vec3_t pPerp
|
|||
static void R_BeamComputeNormal( const vec3_t vStartPos, const vec3_t vNextPos, vec3_t pNormal )
|
||||
{
|
||||
// vTangentY = line vector for beam
|
||||
vec3_t vTangentY, vDirToBeam;
|
||||
vec3_t vTangentY, vDirToBeam;
|
||||
|
||||
VectorSubtract( vStartPos, vNextPos, vTangentY );
|
||||
|
||||
|
@ -117,8 +118,8 @@ Cull the beam by bbox
|
|||
*/
|
||||
qboolean GAME_EXPORT R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly )
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
int i;
|
||||
vec3_t mins, maxs;
|
||||
int i;
|
||||
return false;
|
||||
/*
|
||||
for( i = 0; i < 3; i++ )
|
||||
|
@ -193,14 +194,15 @@ general code for drawing beams
|
|||
*/
|
||||
static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments, int flags )
|
||||
{
|
||||
int noiseIndex, noiseStep;
|
||||
int i, total_segs, segs_drawn;
|
||||
float div, length, fraction, factor;
|
||||
float flMaxWidth, vLast, vStep, brightness;
|
||||
vec3_t perp1, vLastNormal = { 0.0f };
|
||||
beamseg_t curSeg;
|
||||
int noiseIndex, noiseStep;
|
||||
int i, total_segs, segs_drawn;
|
||||
float div, length, fraction, factor;
|
||||
float flMaxWidth, vLast, vStep, brightness;
|
||||
vec3_t perp1, vLastNormal = { 0.0f };
|
||||
beamseg_t curSeg;
|
||||
|
||||
if( segments < 2 ) return;
|
||||
if( segments < 2 )
|
||||
return;
|
||||
|
||||
length = VectorLength( delta );
|
||||
flMaxWidth = width * 0.5f;
|
||||
|
@ -210,15 +212,16 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
|||
{
|
||||
// here, we have too many segments; we could get overlap... so lets have less segments
|
||||
segments = (int)( length / ( flMaxWidth * 1.414f )) + 1.0f;
|
||||
if( segments < 2 ) segments = 2;
|
||||
if( segments < 2 )
|
||||
segments = 2;
|
||||
}
|
||||
|
||||
if( segments > NOISE_DIVISIONS )
|
||||
segments = NOISE_DIVISIONS;
|
||||
|
||||
div = 1.0f / (segments - 1);
|
||||
div = 1.0f / ( segments - 1 );
|
||||
length *= 0.01f;
|
||||
vStep = length * div; // Texture length texels per space pixel
|
||||
vStep = length * div; // Texture length texels per space pixel
|
||||
|
||||
// Scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
|
||||
vLast = fmod( freq * speed, 1 );
|
||||
|
@ -255,8 +258,8 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
|||
// specify all the segments.
|
||||
for( i = 0; i < segments; i++ )
|
||||
{
|
||||
beamseg_t nextSeg;
|
||||
vec3_t vPoint1, vPoint2;
|
||||
beamseg_t nextSeg;
|
||||
vec3_t vPoint1, vPoint2;
|
||||
|
||||
Assert( noiseIndex < ( NOISE_DIVISIONS << 16 ));
|
||||
|
||||
|
@ -267,17 +270,17 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
|||
// distort using noise
|
||||
if( scale != 0 )
|
||||
{
|
||||
factor = rgNoise[noiseIndex>>16] * scale;
|
||||
factor = rgNoise[noiseIndex >> 16] * scale;
|
||||
|
||||
if( FBitSet( flags, FBEAM_SINENOISE ))
|
||||
{
|
||||
float s, c;
|
||||
float s, c;
|
||||
|
||||
SinCos( fraction * M_PI_F * length + freq, &s, &c );
|
||||
VectorMA( nextSeg.pos, (factor * s), RI.vup, nextSeg.pos );
|
||||
VectorMA( nextSeg.pos, ( factor * s ), RI.vup, nextSeg.pos );
|
||||
|
||||
// rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
|
||||
VectorMA( nextSeg.pos, (factor * c), RI.vright, nextSeg.pos );
|
||||
VectorMA( nextSeg.pos, ( factor * c ), RI.vright, nextSeg.pos );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -289,11 +292,11 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
|||
nextSeg.width = width * 2.0f;
|
||||
nextSeg.texcoord = vLast;
|
||||
|
||||
if( segs_drawn > 0 )
|
||||
if( segs_drawn > 0 )
|
||||
{
|
||||
// Get a vector that is perpendicular to us and perpendicular to the beam.
|
||||
// This is used to fatten the beam.
|
||||
vec3_t vNormal, vAveNormal;
|
||||
vec3_t vNormal, vAveNormal;
|
||||
|
||||
R_BeamComputeNormal( curSeg.pos, nextSeg.pos, vNormal );
|
||||
|
||||
|
@ -313,16 +316,16 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
|||
|
||||
// draw regular segment
|
||||
VectorMA( curSeg.pos, ( curSeg.width * 0.5f ), vAveNormal, vPoint1 );
|
||||
VectorMA( curSeg.pos, (-curSeg.width * 0.5f ), vAveNormal, vPoint2 );
|
||||
VectorMA( curSeg.pos, ( -curSeg.width * 0.5f ), vAveNormal, vPoint2 );
|
||||
|
||||
TriTexCoord2f( 0.0f, curSeg.texcoord );
|
||||
TriBrightness( brightness );
|
||||
//pglNormal3fv( vAveNormal );
|
||||
// pglNormal3fv( vAveNormal );
|
||||
TriVertex3fv( vPoint1 );
|
||||
|
||||
TriTexCoord2f( 1.0f, curSeg.texcoord );
|
||||
TriBrightness( brightness );
|
||||
//pflNormal3fv( vAveNormal );
|
||||
// pflNormal3fv( vAveNormal );
|
||||
TriVertex3fv( vPoint2 );
|
||||
}
|
||||
|
||||
|
@ -331,8 +334,10 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
|||
|
||||
if( FBitSet( flags, FBEAM_SHADEIN ) && FBitSet( flags, FBEAM_SHADEOUT ))
|
||||
{
|
||||
if( fraction < 0.5f ) brightness = fraction;
|
||||
else brightness = ( 1.0f - fraction );
|
||||
if( fraction < 0.5f )
|
||||
brightness = fraction;
|
||||
else
|
||||
brightness = ( 1.0f - fraction );
|
||||
}
|
||||
else if( FBitSet( flags, FBEAM_SHADEIN ))
|
||||
{
|
||||
|
@ -343,21 +348,21 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
|||
brightness = 1.0f - fraction;
|
||||
}
|
||||
|
||||
if( segs_drawn == total_segs )
|
||||
if( segs_drawn == total_segs )
|
||||
{
|
||||
// draw the last segment
|
||||
VectorMA( curSeg.pos, ( curSeg.width * 0.5f ), vLastNormal, vPoint1 );
|
||||
VectorMA( curSeg.pos, (-curSeg.width * 0.5f ), vLastNormal, vPoint2 );
|
||||
VectorMA( curSeg.pos, ( -curSeg.width * 0.5f ), vLastNormal, vPoint2 );
|
||||
|
||||
// specify the points.
|
||||
TriTexCoord2f( 0.0f, curSeg.texcoord );
|
||||
TriBrightness( brightness );
|
||||
//pglNormal3fv( vLastNormal );
|
||||
// pglNormal3fv( vLastNormal );
|
||||
TriVertex3fv( vPoint1 );
|
||||
|
||||
TriTexCoord2f( 1.0f, curSeg.texcoord );
|
||||
TriBrightness( brightness );
|
||||
//pglNormal3fv( vLastNormal );
|
||||
// pglNormal3fv( vLastNormal );
|
||||
TriVertex3fv( vPoint2 );
|
||||
}
|
||||
|
||||
|
@ -375,9 +380,9 @@ Draw beamtours
|
|||
*/
|
||||
static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
|
||||
{
|
||||
int i, noiseIndex, noiseStep;
|
||||
float div, length, fraction, factor, vLast, vStep;
|
||||
vec3_t last1, last2, point, screen, screenLast, tmp, normal;
|
||||
int i, noiseIndex, noiseStep;
|
||||
float div, length, fraction, factor, vLast, vStep;
|
||||
vec3_t last1, last2, point, screen, screenLast, tmp, normal;
|
||||
|
||||
if( segments < 2 )
|
||||
return;
|
||||
|
@ -386,9 +391,10 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
|
|||
segments = NOISE_DIVISIONS;
|
||||
|
||||
length = VectorLength( delta ) * 0.01f;
|
||||
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
|
||||
if( length < 0.5f )
|
||||
length = 0.5f; // don't lose all of the noise/texture on short beams
|
||||
|
||||
div = 1.0f / (segments - 1);
|
||||
div = 1.0f / ( segments - 1 );
|
||||
|
||||
vStep = length * div; // Texture length texels per space pixel
|
||||
|
||||
|
@ -402,7 +408,7 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
|
|||
|
||||
for( i = 0; i < segments; i++ )
|
||||
{
|
||||
float s, c;
|
||||
float s, c;
|
||||
|
||||
fraction = i * div;
|
||||
SinCos( fraction * M_PI2, &s, &c );
|
||||
|
@ -416,11 +422,11 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
|
|||
{
|
||||
if(( noiseIndex >> 16 ) < NOISE_DIVISIONS )
|
||||
{
|
||||
factor = rgNoise[noiseIndex>>16] * scale;
|
||||
factor = rgNoise[noiseIndex >> 16] * scale;
|
||||
VectorMA( point, factor, RI.vup, point );
|
||||
|
||||
// rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
|
||||
factor = rgNoise[noiseIndex>>16] * scale * cos( fraction * M_PI_F * 3 + freq );
|
||||
factor = rgNoise[noiseIndex >> 16] * scale * cos( fraction *M_PI_F * 3 + freq );
|
||||
VectorMA( point, factor, RI.vright, point );
|
||||
}
|
||||
}
|
||||
|
@ -436,7 +442,7 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
|
|||
// we don't need Z, we're in screen space
|
||||
tmp[2] = 0;
|
||||
VectorNormalize( tmp );
|
||||
VectorScale( RI.vup, -tmp[0], normal ); // Build point along noraml line (normal is -y, x)
|
||||
VectorScale( RI.vup, -tmp[0], normal ); // Build point along noraml line (normal is -y, x)
|
||||
VectorMA( normal, tmp[1], RI.vright, normal );
|
||||
|
||||
// Make a wide line
|
||||
|
@ -464,22 +470,23 @@ Draw beamdisk
|
|||
*/
|
||||
static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
|
||||
{
|
||||
float div, length, fraction;
|
||||
float w, vLast, vStep;
|
||||
vec3_t point;
|
||||
int i;
|
||||
float div, length, fraction;
|
||||
float w, vLast, vStep;
|
||||
vec3_t point;
|
||||
int i;
|
||||
|
||||
if( segments < 2 )
|
||||
return;
|
||||
|
||||
if( segments > NOISE_DIVISIONS ) // UNDONE: Allow more segments?
|
||||
if( segments > NOISE_DIVISIONS ) // UNDONE: Allow more segments?
|
||||
segments = NOISE_DIVISIONS;
|
||||
|
||||
length = VectorLength( delta ) * 0.01f;
|
||||
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
|
||||
if( length < 0.5f )
|
||||
length = 0.5f; // don't lose all of the noise/texture on short beams
|
||||
|
||||
div = 1.0f / (segments - 1);
|
||||
vStep = length * div; // Texture length texels per space pixel
|
||||
div = 1.0f / ( segments - 1 );
|
||||
vStep = length * div; // Texture length texels per space pixel
|
||||
|
||||
// scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
|
||||
vLast = fmod( freq * speed, 1 );
|
||||
|
@ -491,7 +498,7 @@ static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, f
|
|||
// NOTE: we must force the degenerate triangles to be on the edge
|
||||
for( i = 0; i < segments; i++ )
|
||||
{
|
||||
float s, c;
|
||||
float s, c;
|
||||
|
||||
fraction = i * div;
|
||||
VectorCopy( source, point );
|
||||
|
@ -509,7 +516,7 @@ static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, f
|
|||
TriTexCoord2f( 0.0f, vLast );
|
||||
TriVertex3fv( point );
|
||||
|
||||
vLast += vStep; // advance texture scroll (v axis only)
|
||||
vLast += vStep; // advance texture scroll (v axis only)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -522,10 +529,10 @@ Draw beam cylinder
|
|||
*/
|
||||
static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
|
||||
{
|
||||
float div, length, fraction;
|
||||
float vLast, vStep;
|
||||
vec3_t point;
|
||||
int i;
|
||||
float div, length, fraction;
|
||||
float vLast, vStep;
|
||||
vec3_t point;
|
||||
int i;
|
||||
|
||||
if( segments < 2 )
|
||||
return;
|
||||
|
@ -534,18 +541,19 @@ static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scal
|
|||
segments = NOISE_DIVISIONS;
|
||||
|
||||
length = VectorLength( delta ) * 0.01f;
|
||||
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
|
||||
if( length < 0.5f )
|
||||
length = 0.5f; // don't lose all of the noise/texture on short beams
|
||||
|
||||
div = 1.0f / (segments - 1);
|
||||
vStep = length * div; // texture length texels per space pixel
|
||||
div = 1.0f / ( segments - 1 );
|
||||
vStep = length * div; // texture length texels per space pixel
|
||||
|
||||
// Scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
|
||||
vLast = fmod( freq * speed, 1 );
|
||||
scale = scale * length;
|
||||
|
||||
for ( i = 0; i < segments; i++ )
|
||||
for( i = 0; i < segments; i++ )
|
||||
{
|
||||
float s, c;
|
||||
float s, c;
|
||||
|
||||
fraction = i * div;
|
||||
SinCos( fraction * M_PI2, &s, &c );
|
||||
|
@ -566,7 +574,7 @@ static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scal
|
|||
TriTexCoord2f( 0, vLast );
|
||||
TriVertex3fv( point );
|
||||
|
||||
vLast += vStep; // Advance texture scroll (v axis only)
|
||||
vLast += vStep; // Advance texture scroll (v axis only)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -579,10 +587,10 @@ drawi followed beam
|
|||
*/
|
||||
static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
|
||||
{
|
||||
particle_t *pnew, *particles;
|
||||
float fraction, div, vLast, vStep, saved_fraction;
|
||||
vec3_t last1, last2, tmp, screen, saved_last2;
|
||||
vec3_t delta, screenLast, normal;
|
||||
particle_t *pnew, *particles;
|
||||
float fraction, div, vLast, vStep, saved_fraction;
|
||||
vec3_t last1, last2, tmp, screen, saved_last2;
|
||||
vec3_t delta, screenLast, normal;
|
||||
|
||||
gEngfuncs.R_FreeDeadParticles( &pbeam->particles );
|
||||
|
||||
|
@ -620,7 +628,8 @@ static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
|
|||
}
|
||||
|
||||
// nothing to draw
|
||||
if( !particles ) return;
|
||||
if( !particles )
|
||||
return;
|
||||
|
||||
if( !pnew && div != 0 )
|
||||
{
|
||||
|
@ -650,7 +659,7 @@ static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
|
|||
VectorNormalize( tmp );
|
||||
|
||||
// Build point along noraml line (normal is -y, x)
|
||||
VectorScale( RI.vup, tmp[0], normal ); // Build point along normal line (normal is -y, x)
|
||||
VectorScale( RI.vup, tmp[0], normal ); // Build point along normal line (normal is -y, x)
|
||||
VectorMA( normal, tmp[1], RI.vright, normal );
|
||||
|
||||
// Make a wide line
|
||||
|
@ -683,18 +692,18 @@ static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
|
|||
// we don't need Z, we're in screen space
|
||||
tmp[2] = 0;
|
||||
VectorNormalize( tmp );
|
||||
VectorScale( RI.vup, tmp[0], normal ); // Build point along noraml line (normal is -y, x)
|
||||
VectorScale( RI.vup, tmp[0], normal ); // Build point along noraml line (normal is -y, x)
|
||||
VectorMA( normal, tmp[1], RI.vright, normal );
|
||||
|
||||
// Make a wide line
|
||||
VectorMA( particles->org, pbeam->width, normal, last1 );
|
||||
VectorMA( particles->org, -pbeam->width, normal, last2 );
|
||||
|
||||
vLast += vStep; // Advance texture scroll (v axis only)
|
||||
vLast += vStep; // Advance texture scroll (v axis only)
|
||||
|
||||
if( particles->next != NULL )
|
||||
{
|
||||
fraction = (particles->die - gp_cl->time) * div;
|
||||
fraction = ( particles->die - gp_cl->time ) * div;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -739,11 +748,11 @@ Draw beamring
|
|||
*/
|
||||
static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, float freq, float speed, int segments )
|
||||
{
|
||||
int i, j, noiseIndex, noiseStep;
|
||||
float div, length, fraction, factor, vLast, vStep;
|
||||
vec3_t last1, last2, point, screen, screenLast;
|
||||
vec3_t tmp, normal, center, xaxis, yaxis;
|
||||
float radius, x, y, scale;
|
||||
int i, j, noiseIndex, noiseStep;
|
||||
float div, length, fraction, factor, vLast, vStep;
|
||||
vec3_t last1, last2, point, screen, screenLast;
|
||||
vec3_t tmp, normal, center, xaxis, yaxis;
|
||||
float radius, x, y, scale;
|
||||
|
||||
if( segments < 2 )
|
||||
return;
|
||||
|
@ -755,11 +764,12 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
|
|||
segments = NOISE_DIVISIONS * 8;
|
||||
|
||||
length = VectorLength( delta ) * 0.01f * M_PI_F;
|
||||
if( length < 0.5f ) length = 0.5f; // Don't lose all of the noise/texture on short beams
|
||||
if( length < 0.5f )
|
||||
length = 0.5f; // Don't lose all of the noise/texture on short beams
|
||||
|
||||
div = 1.0f / ( segments - 1 );
|
||||
|
||||
vStep = length * div / 8.0f; // texture length texels per space pixel
|
||||
vStep = length * div / 8.0f; // texture length texels per space pixel
|
||||
|
||||
// Scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
|
||||
vLast = fmod( freq * speed, 1.0f );
|
||||
|
@ -779,14 +789,14 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
|
|||
// --------------------------------
|
||||
// Compute box center +/- radius
|
||||
VectorSet( last1, radius, radius, scale );
|
||||
VectorAdd( center, last1, tmp ); // maxs
|
||||
VectorSubtract( center, last1, screen ); // mins
|
||||
VectorAdd( center, last1, tmp ); // maxs
|
||||
VectorSubtract( center, last1, screen ); // mins
|
||||
|
||||
if( !WORLDMODEL )
|
||||
return;
|
||||
|
||||
// is that box in PVS && frustum?
|
||||
if( !gEngfuncs.Mod_BoxVisible( screen, tmp, Mod_GetCurrentVis( )) ) //|| R_CullBox( screen, tmp ))
|
||||
if( !gEngfuncs.Mod_BoxVisible( screen, tmp, Mod_GetCurrentVis( ))) // || R_CullBox( screen, tmp ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -805,11 +815,11 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
|
|||
VectorMAMAM( x, xaxis, y, yaxis, 1.0f, center, point );
|
||||
|
||||
// distort using noise
|
||||
factor = rgNoise[(noiseIndex >> 16) & (NOISE_DIVISIONS - 1)] * scale;
|
||||
factor = rgNoise[( noiseIndex >> 16 ) & ( NOISE_DIVISIONS - 1 )] * scale;
|
||||
VectorMA( point, factor, RI.vup, point );
|
||||
|
||||
// Rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
|
||||
factor = rgNoise[(noiseIndex >> 16) & (NOISE_DIVISIONS - 1)] * scale;
|
||||
factor = rgNoise[( noiseIndex >> 16 ) & ( NOISE_DIVISIONS - 1 )] * scale;
|
||||
factor *= cos( fraction * M_PI_F * 24 + freq );
|
||||
VectorMA( point, factor, RI.vright, point );
|
||||
|
||||
|
@ -833,7 +843,7 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
|
|||
VectorMA( point, width, normal, last1 );
|
||||
VectorMA( point, -width, normal, last2 );
|
||||
|
||||
vLast += vStep; // Advance texture scroll (v axis only)
|
||||
vLast += vStep; // Advance texture scroll (v axis only)
|
||||
TriTexCoord2f( 1.0f, vLast );
|
||||
TriVertex3fv( last2 );
|
||||
TriTexCoord2f( 0.0f, vLast );
|
||||
|
@ -861,14 +871,15 @@ compute attachment point for beam
|
|||
*/
|
||||
static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
|
||||
{
|
||||
cl_entity_t *ent;
|
||||
int attach;
|
||||
cl_entity_t *ent;
|
||||
int attach;
|
||||
|
||||
ent = gEngfuncs.R_BeamGetEntity( beamEnt );
|
||||
|
||||
if( beamEnt < 0 )
|
||||
attach = BEAMENT_ATTACHMENT( -beamEnt );
|
||||
else attach = BEAMENT_ATTACHMENT( beamEnt );
|
||||
else
|
||||
attach = BEAMENT_ATTACHMENT( beamEnt );
|
||||
|
||||
if( !ent )
|
||||
{
|
||||
|
@ -882,7 +893,8 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
|
|||
VectorCopy( ent->attachment[attach - 1], pt );
|
||||
else if( ent->index == ( gp_cl->playernum + 1 ))
|
||||
VectorCopy( gp_cl->simorg, pt );
|
||||
else VectorCopy( ent->origin, pt );
|
||||
else
|
||||
VectorCopy( ent->origin, pt );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -949,8 +961,8 @@ Update beam vars and draw it
|
|||
*/
|
||||
static void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||
{
|
||||
model_t *model;
|
||||
vec3_t delta;
|
||||
model_t *model;
|
||||
vec3_t delta;
|
||||
|
||||
model = CL_ModelHandle( pbeam->modelIndex );
|
||||
SetBits( pbeam->flags, FBEAM_ISACTIVE );
|
||||
|
@ -976,11 +988,12 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||
{
|
||||
if( FBitSet( pbeam->flags, FBEAM_SINENOISE ))
|
||||
SineNoise( rgNoise, NOISE_DIVISIONS );
|
||||
else FracNoise( rgNoise, NOISE_DIVISIONS );
|
||||
else
|
||||
FracNoise( rgNoise, NOISE_DIVISIONS );
|
||||
}
|
||||
|
||||
// update end points
|
||||
if( FBitSet( pbeam->flags, FBEAM_STARTENTITY|FBEAM_ENDENTITY ))
|
||||
if( FBitSet( pbeam->flags, FBEAM_STARTENTITY | FBEAM_ENDENTITY ))
|
||||
{
|
||||
// makes sure attachment[0] + attachment[1] are valid
|
||||
if( !R_BeamRecomputeEndpoints( pbeam ))
|
||||
|
@ -998,7 +1011,8 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||
|
||||
if( pbeam->amplitude >= 0.50f )
|
||||
pbeam->segments = VectorLength( pbeam->delta ) * 0.25f + 3.0f; // one per 4 pixels
|
||||
else pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
|
||||
else
|
||||
pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
|
||||
}
|
||||
|
||||
if( pbeam->type == TE_BEAMPOINTS && R_BeamCull( pbeam->source, pbeam->target, 0 ))
|
||||
|
@ -1013,16 +1027,17 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||
return;
|
||||
}
|
||||
|
||||
if( pbeam->flags & ( FBEAM_FADEIN|FBEAM_FADEOUT ))
|
||||
if( pbeam->flags & ( FBEAM_FADEIN | FBEAM_FADEOUT ))
|
||||
{
|
||||
// update life cycle
|
||||
pbeam->t = pbeam->freq + ( pbeam->die - gp_cl->time );
|
||||
if( pbeam->t != 0.0f ) pbeam->t = 1.0f - pbeam->freq / pbeam->t;
|
||||
if( pbeam->t != 0.0f )
|
||||
pbeam->t = 1.0f - pbeam->freq / pbeam->t;
|
||||
}
|
||||
|
||||
if( pbeam->type == TE_BEAMHOSE )
|
||||
{
|
||||
float flDot;
|
||||
float flDot;
|
||||
|
||||
VectorSubtract( pbeam->target, pbeam->source, delta );
|
||||
VectorNormalize( delta );
|
||||
|
@ -1036,9 +1051,9 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||
}
|
||||
else
|
||||
{
|
||||
float flFade = pow( flDot, 10 );
|
||||
vec3_t localDir, vecProjection, tmp;
|
||||
float flDistance;
|
||||
float flFade = pow( flDot, 10 );
|
||||
vec3_t localDir, vecProjection, tmp;
|
||||
float flDistance;
|
||||
|
||||
// fade the beam if the player's not looking at the source
|
||||
VectorSubtract( RI.vieworg, pbeam->source, localDir );
|
||||
|
@ -1050,8 +1065,10 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||
if( flDistance > 30 )
|
||||
{
|
||||
flDistance = 1.0f - (( flDistance - 30.0f ) / 64.0f );
|
||||
if( flDistance <= 0 ) flFade = 0;
|
||||
else flFade *= pow( flDistance, 3 );
|
||||
if( flDistance <= 0 )
|
||||
flFade = 0;
|
||||
else
|
||||
flFade *= pow( flDistance, 3 );
|
||||
}
|
||||
|
||||
if( flFade < ( 1.0f / 255.0f ))
|
||||
|
@ -1064,7 +1081,7 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||
|
||||
TriRenderMode( FBitSet( pbeam->flags, FBEAM_SOLID ) ? kRenderNormal : kRenderTransAdd );
|
||||
|
||||
if( !TriSpriteTexture( model, (int)(pbeam->frame + pbeam->frameRate * gp_cl->time) % pbeam->frameCount ))
|
||||
if( !TriSpriteTexture( model, (int)( pbeam->frame + pbeam->frameRate * gp_cl->time ) % pbeam->frameCount ))
|
||||
{
|
||||
ClearBits( pbeam->flags, FBEAM_ISACTIVE );
|
||||
return;
|
||||
|
@ -1072,7 +1089,7 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||
|
||||
if( pbeam->type == TE_BEAMFOLLOW )
|
||||
{
|
||||
cl_entity_t *pStart;
|
||||
cl_entity_t *pStart;
|
||||
|
||||
// XASH SPECIFIC: get brightness from head entity
|
||||
pStart = gEngfuncs.R_BeamGetEntity( pbeam->startEntity );
|
||||
|
@ -1084,24 +1101,25 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||
TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->t * pbeam->brightness );
|
||||
else if( FBitSet( pbeam->flags, FBEAM_FADEOUT ))
|
||||
TriColor4f( pbeam->r, pbeam->g, pbeam->b, ( 1.0f - pbeam->t ) * pbeam->brightness );
|
||||
else TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->brightness );
|
||||
else
|
||||
TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->brightness );
|
||||
|
||||
switch( pbeam->type )
|
||||
{
|
||||
case TE_BEAMTORUS:
|
||||
//GL_Cull( GL_NONE );
|
||||
// GL_Cull( GL_NONE );
|
||||
TriBegin( TRI_TRIANGLE_STRIP );
|
||||
R_DrawTorus( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
||||
TriEnd();
|
||||
break;
|
||||
case TE_BEAMDISK:
|
||||
//GL_Cull( GL_NONE );
|
||||
// GL_Cull( GL_NONE );
|
||||
TriBegin( TRI_TRIANGLE_STRIP );
|
||||
R_DrawDisk( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
||||
TriEnd();
|
||||
break;
|
||||
case TE_BEAMCYLINDER:
|
||||
//GL_Cull( GL_NONE );
|
||||
// GL_Cull( GL_NONE );
|
||||
TriBegin( TRI_TRIANGLE_STRIP );
|
||||
R_DrawCylinder( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
||||
TriEnd();
|
||||
|
@ -1118,14 +1136,14 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||
TriEnd();
|
||||
break;
|
||||
case TE_BEAMRING:
|
||||
//GL_Cull( GL_NONE );
|
||||
// GL_Cull( GL_NONE );
|
||||
TriBegin( TRI_TRIANGLE_STRIP );
|
||||
R_DrawRing( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
||||
TriEnd();
|
||||
break;
|
||||
}
|
||||
|
||||
//GL_Cull( GL_FRONT );
|
||||
// GL_Cull( GL_FRONT );
|
||||
r_stats.c_view_beams_count++;
|
||||
}
|
||||
|
||||
|
@ -1155,9 +1173,10 @@ passed through this
|
|||
*/
|
||||
static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed )
|
||||
{
|
||||
model_t *sprite = CL_ModelHandle( modelIndex );
|
||||
model_t *sprite = CL_ModelHandle( modelIndex );
|
||||
|
||||
if( !sprite ) return;
|
||||
if( !sprite )
|
||||
return;
|
||||
|
||||
pbeam->type = BEAM_POINTS;
|
||||
pbeam->modelIndex = modelIndex;
|
||||
|
@ -1177,8 +1196,9 @@ static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex,
|
|||
pbeam->speed = speed;
|
||||
|
||||
if( amplitude >= 0.50f )
|
||||
pbeam->segments = VectorLength( pbeam->delta ) * 0.25f + 3.0f; // one per 4 pixels
|
||||
else pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
|
||||
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
|
||||
|
||||
pbeam->pFollowModel = NULL;
|
||||
pbeam->flags = 0;
|
||||
|
@ -1195,11 +1215,11 @@ initialize beam from server entity
|
|||
*/
|
||||
static void R_BeamDrawCustomEntity( cl_entity_t *ent )
|
||||
{
|
||||
BEAM beam;
|
||||
float amp = ent->curstate.body / 100.0f;
|
||||
float blend = CL_FxBlend( ent ) / 255.0f;
|
||||
float r, g, b;
|
||||
int beamFlags;
|
||||
BEAM beam;
|
||||
float amp = ent->curstate.body / 100.0f;
|
||||
float blend = CL_FxBlend( ent ) / 255.0f;
|
||||
float r, g, b;
|
||||
int beamFlags;
|
||||
|
||||
r = ent->curstate.rendercolor.r / 255.0f;
|
||||
g = ent->curstate.rendercolor.g / 255.0f;
|
||||
|
@ -1212,7 +1232,7 @@ static void R_BeamDrawCustomEntity( cl_entity_t *ent )
|
|||
switch( ent->curstate.rendermode & 0x0F )
|
||||
{
|
||||
case BEAM_ENTPOINT:
|
||||
beam.type = TE_BEAMPOINTS;
|
||||
beam.type = TE_BEAMPOINTS;
|
||||
if( ent->curstate.sequence )
|
||||
{
|
||||
SetBits( beam.flags, FBEAM_STARTENTITY );
|
||||
|
@ -1225,13 +1245,13 @@ static void R_BeamDrawCustomEntity( cl_entity_t *ent )
|
|||
}
|
||||
break;
|
||||
case BEAM_ENTS:
|
||||
beam.type = TE_BEAMPOINTS;
|
||||
beam.type = TE_BEAMPOINTS;
|
||||
SetBits( beam.flags, FBEAM_STARTENTITY | FBEAM_ENDENTITY );
|
||||
beam.startEntity = ent->curstate.sequence;
|
||||
beam.endEntity = ent->curstate.skin;
|
||||
break;
|
||||
case BEAM_HOSE:
|
||||
beam.type = TE_BEAMHOSE;
|
||||
beam.type = TE_BEAMHOSE;
|
||||
break;
|
||||
case BEAM_POINTS:
|
||||
// already set up
|
||||
|
@ -1266,11 +1286,11 @@ draw beam loop
|
|||
*/
|
||||
void GAME_EXPORT CL_DrawBeams( int fTrans, BEAM *active_beams )
|
||||
{
|
||||
BEAM *pBeam;
|
||||
int i, flags;
|
||||
BEAM *pBeam;
|
||||
int i, flags;
|
||||
|
||||
//pglShadeModel( GL_SMOOTH );
|
||||
//pglDepthMask( fTrans ? GL_FALSE : GL_TRUE );
|
||||
// pglShadeModel( GL_SMOOTH );
|
||||
// pglDepthMask( fTrans ? GL_FALSE : GL_TRUE );
|
||||
|
||||
// server beams don't allocate beam chains
|
||||
// all params are stored in cl_entity_t
|
||||
|
@ -1300,9 +1320,9 @@ void GAME_EXPORT CL_DrawBeams( int fTrans, BEAM *active_beams )
|
|||
if( !fTrans && !FBitSet( pBeam->flags, FBEAM_SOLID ))
|
||||
continue;
|
||||
|
||||
R_BeamDraw( pBeam, gp_cl->time - gp_cl->oldtime );
|
||||
R_BeamDraw( pBeam, gp_cl->time - gp_cl->oldtime );
|
||||
}
|
||||
|
||||
//pglShadeModel( GL_FLAT );
|
||||
//pglDepthMask( GL_TRUE );
|
||||
// pglShadeModel( GL_FLAT );
|
||||
// pglDepthMask( GL_TRUE );
|
||||
}
|
||||
|
|
437
ref/soft/r_bsp.c
437
ref/soft/r_bsp.c
|
@ -24,25 +24,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
//
|
||||
// current entity info
|
||||
//
|
||||
vec3_t r_entorigin; // the currently rendering entity in world
|
||||
// coordinates
|
||||
vec3_t r_entorigin; // the currently rendering entity in world
|
||||
// coordinates
|
||||
|
||||
float entity_rotation[3][3];
|
||||
float entity_rotation[3][3];
|
||||
|
||||
int r_currentbkey;
|
||||
int r_currentbkey;
|
||||
|
||||
typedef enum {touchessolid, drawnode, nodrawnode} solidstate_t;
|
||||
|
||||
#define MAX_BMODEL_VERTS 1000 // 12K
|
||||
#define MAX_BMODEL_EDGES 2000 // 24K
|
||||
#define MAX_BMODEL_VERTS 1000 // 12K
|
||||
#define MAX_BMODEL_EDGES 2000 // 24K
|
||||
|
||||
static mvertex_t *pbverts;
|
||||
static bedge_t *pbedges;
|
||||
static int numbverts, numbedges;
|
||||
static mvertex_t *pbverts;
|
||||
static bedge_t *pbedges;
|
||||
static int numbverts, numbedges;
|
||||
|
||||
static mvertex_t *pfrontenter, *pfrontexit;
|
||||
static mvertex_t *pfrontenter, *pfrontexit;
|
||||
|
||||
static qboolean makeclippededge;
|
||||
static qboolean makeclippededge;
|
||||
|
||||
|
||||
|
||||
|
@ -51,44 +51,44 @@ static qboolean makeclippededge;
|
|||
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] +
|
||||
in1[0][2] * in2[2][0];
|
||||
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
|
||||
in1[0][2] * in2[2][1];
|
||||
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
|
||||
in1[0][2] * in2[2][2];
|
||||
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
|
||||
in1[1][2] * in2[2][0];
|
||||
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
|
||||
in1[1][2] * in2[2][1];
|
||||
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
|
||||
in1[1][2] * in2[2][2];
|
||||
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
|
||||
in1[2][2] * in2[2][0];
|
||||
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
|
||||
in1[2][2] * in2[2][1];
|
||||
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
|
||||
in1[2][2] * in2[2][2];
|
||||
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0]
|
||||
+ in1[0][2] * in2[2][0];
|
||||
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1]
|
||||
+ in1[0][2] * in2[2][1];
|
||||
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2]
|
||||
+ in1[0][2] * in2[2][2];
|
||||
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0]
|
||||
+ in1[1][2] * in2[2][0];
|
||||
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1]
|
||||
+ in1[1][2] * in2[2][1];
|
||||
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2]
|
||||
+ in1[1][2] * in2[2][2];
|
||||
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0]
|
||||
+ in1[2][2] * in2[2][0];
|
||||
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1]
|
||||
+ in1[2][2] * in2[2][1];
|
||||
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2]
|
||||
+ in1[2][2] * in2[2][2];
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// ===========================================================================
|
||||
|
||||
/*
|
||||
================
|
||||
R_EntityRotate
|
||||
================
|
||||
*/
|
||||
static void R_EntityRotate (vec3_t vec)
|
||||
static void R_EntityRotate( vec3_t vec )
|
||||
{
|
||||
vec3_t tvec;
|
||||
vec3_t tvec;
|
||||
|
||||
VectorCopy (vec, tvec);
|
||||
vec[0] = DotProduct (entity_rotation[0], tvec);
|
||||
vec[1] = DotProduct (entity_rotation[1], tvec);
|
||||
vec[2] = DotProduct (entity_rotation[2], tvec);
|
||||
VectorCopy( vec, tvec );
|
||||
vec[0] = DotProduct( entity_rotation[0], tvec );
|
||||
vec[1] = DotProduct( entity_rotation[1], tvec );
|
||||
vec[2] = DotProduct( entity_rotation[2], tvec );
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,9 +97,9 @@ static void R_EntityRotate (vec3_t vec)
|
|||
R_RotateBmodel
|
||||
================
|
||||
*/
|
||||
void R_RotateBmodel (void)
|
||||
void R_RotateBmodel( void )
|
||||
{
|
||||
float angle, s, c, temp1[3][3], temp2[3][3], temp3[3][3];
|
||||
float angle, s, c, temp1[3][3], temp2[3][3], temp3[3][3];
|
||||
|
||||
// TODO: should use a look-up table
|
||||
// TODO: should really be stored with the entity instead of being reconstructed
|
||||
|
@ -109,8 +109,8 @@ void R_RotateBmodel (void)
|
|||
// yaw
|
||||
angle = RI.currententity->angles[YAW];
|
||||
angle = angle * M_PI_F * 2 / 360.0f;
|
||||
s = sin(angle);
|
||||
c = cos(angle);
|
||||
s = sin( angle );
|
||||
c = cos( angle );
|
||||
|
||||
temp1[0][0] = c;
|
||||
temp1[0][1] = s;
|
||||
|
@ -126,8 +126,8 @@ void R_RotateBmodel (void)
|
|||
// pitch
|
||||
angle = RI.currententity->angles[PITCH];
|
||||
angle = angle * M_PI_F * 2 / 360.0f;
|
||||
s = sin(angle);
|
||||
c = cos(angle);
|
||||
s = sin( angle );
|
||||
c = cos( angle );
|
||||
|
||||
temp2[0][0] = c;
|
||||
temp2[0][1] = 0;
|
||||
|
@ -139,13 +139,13 @@ void R_RotateBmodel (void)
|
|||
temp2[2][1] = 0;
|
||||
temp2[2][2] = c;
|
||||
|
||||
R_ConcatRotations (temp2, temp1, temp3);
|
||||
R_ConcatRotations( temp2, temp1, temp3 );
|
||||
|
||||
// roll
|
||||
angle = RI.currententity->angles[ROLL];
|
||||
angle = angle * M_PI_F*2 / 360.0f;
|
||||
s = sin(angle);
|
||||
c = cos(angle);
|
||||
angle = angle * M_PI_F * 2 / 360.0f;
|
||||
s = sin( angle );
|
||||
c = cos( angle );
|
||||
|
||||
temp1[0][0] = 1;
|
||||
temp1[0][1] = 0;
|
||||
|
@ -157,17 +157,17 @@ void R_RotateBmodel (void)
|
|||
temp1[2][1] = -s;
|
||||
temp1[2][2] = c;
|
||||
|
||||
R_ConcatRotations (temp1, temp3, entity_rotation);
|
||||
R_ConcatRotations( temp1, temp3, entity_rotation );
|
||||
|
||||
//
|
||||
// rotate modelorg and the transformation matrix
|
||||
//
|
||||
R_EntityRotate (tr.modelorg);
|
||||
R_EntityRotate (RI.vforward);
|
||||
R_EntityRotate (RI.vright);
|
||||
R_EntityRotate (RI.vup);
|
||||
R_EntityRotate( tr.modelorg );
|
||||
R_EntityRotate( RI.vforward );
|
||||
R_EntityRotate( RI.vright );
|
||||
R_EntityRotate( RI.vup );
|
||||
|
||||
R_TransformFrustum ();
|
||||
R_TransformFrustum();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -175,14 +175,14 @@ void R_RotateBmodel (void)
|
|||
R_RecursiveClipBPoly
|
||||
================
|
||||
*/
|
||||
static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
|
||||
static void R_RecursiveClipBPoly( bedge_t *pedges, mnode_t *pnode, msurface_t *psurf )
|
||||
{
|
||||
bedge_t *psideedges[2], *pnextedge, *ptedge;
|
||||
int i, side, lastside;
|
||||
float dist, frac, lastdist;
|
||||
mplane_t *splitplane, tplane;
|
||||
mvertex_t *pvert, *plastvert, *ptvert;
|
||||
mnode_t *pn;
|
||||
bedge_t *psideedges[2], *pnextedge, *ptedge;
|
||||
int i, side, lastside;
|
||||
float dist, frac, lastdist;
|
||||
mplane_t *splitplane, tplane;
|
||||
mvertex_t *pvert, *plastvert, *ptvert;
|
||||
mnode_t *pn;
|
||||
|
||||
psideedges[0] = psideedges[1] = NULL;
|
||||
|
||||
|
@ -191,62 +191,62 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
|
|||
// transform the BSP plane into model space
|
||||
// FIXME: cache these?
|
||||
splitplane = pnode->plane;
|
||||
tplane.dist = splitplane->dist -
|
||||
DotProduct(r_entorigin, splitplane->normal);
|
||||
tplane.normal[0] = DotProduct (entity_rotation[0], splitplane->normal);
|
||||
tplane.normal[1] = DotProduct (entity_rotation[1], splitplane->normal);
|
||||
tplane.normal[2] = DotProduct (entity_rotation[2], splitplane->normal);
|
||||
tplane.dist = splitplane->dist
|
||||
- DotProduct( r_entorigin, splitplane->normal );
|
||||
tplane.normal[0] = DotProduct( entity_rotation[0], splitplane->normal );
|
||||
tplane.normal[1] = DotProduct( entity_rotation[1], splitplane->normal );
|
||||
tplane.normal[2] = DotProduct( entity_rotation[2], splitplane->normal );
|
||||
|
||||
// clip edges to BSP plane
|
||||
for ( ; pedges ; pedges = pnextedge)
|
||||
for( ; pedges; pedges = pnextedge )
|
||||
{
|
||||
pnextedge = pedges->pnext;
|
||||
|
||||
// set the status for the last point as the previous point
|
||||
// FIXME: cache this stuff somehow?
|
||||
// set the status for the last point as the previous point
|
||||
// FIXME: cache this stuff somehow?
|
||||
plastvert = pedges->v[0];
|
||||
lastdist = DotProduct (plastvert->position, tplane.normal) -
|
||||
tplane.dist;
|
||||
lastdist = DotProduct( plastvert->position, tplane.normal )
|
||||
- tplane.dist;
|
||||
|
||||
if (lastdist > 0)
|
||||
if( lastdist > 0 )
|
||||
lastside = 0;
|
||||
else
|
||||
lastside = 1;
|
||||
|
||||
pvert = pedges->v[1];
|
||||
|
||||
dist = DotProduct (pvert->position, tplane.normal) - tplane.dist;
|
||||
dist = DotProduct( pvert->position, tplane.normal ) - tplane.dist;
|
||||
|
||||
if (dist > 0)
|
||||
if( dist > 0 )
|
||||
side = 0;
|
||||
else
|
||||
side = 1;
|
||||
|
||||
if (side != lastside)
|
||||
if( side != lastside )
|
||||
{
|
||||
// clipped
|
||||
if (numbverts >= MAX_BMODEL_VERTS)
|
||||
// clipped
|
||||
if( numbverts >= MAX_BMODEL_VERTS )
|
||||
return;
|
||||
|
||||
// generate the clipped vertex
|
||||
frac = lastdist / (lastdist - dist);
|
||||
// generate the clipped vertex
|
||||
frac = lastdist / ( lastdist - dist );
|
||||
ptvert = &pbverts[numbverts++];
|
||||
ptvert->position[0] = plastvert->position[0] +
|
||||
frac * (pvert->position[0] -
|
||||
plastvert->position[0]);
|
||||
ptvert->position[1] = plastvert->position[1] +
|
||||
frac * (pvert->position[1] -
|
||||
plastvert->position[1]);
|
||||
ptvert->position[2] = plastvert->position[2] +
|
||||
frac * (pvert->position[2] -
|
||||
plastvert->position[2]);
|
||||
ptvert->position[0] = plastvert->position[0]
|
||||
+ frac * ( pvert->position[0]
|
||||
- plastvert->position[0] );
|
||||
ptvert->position[1] = plastvert->position[1]
|
||||
+ frac * ( pvert->position[1]
|
||||
- plastvert->position[1] );
|
||||
ptvert->position[2] = plastvert->position[2]
|
||||
+ frac * ( pvert->position[2]
|
||||
- plastvert->position[2] );
|
||||
|
||||
// split into two edges, one on each side, and remember entering
|
||||
// and exiting points
|
||||
// FIXME: share the clip edge by having a winding direction flag?
|
||||
if (numbedges >= (MAX_BMODEL_EDGES - 1))
|
||||
// split into two edges, one on each side, and remember entering
|
||||
// and exiting points
|
||||
// FIXME: share the clip edge by having a winding direction flag?
|
||||
if( numbedges >= ( MAX_BMODEL_EDGES - 1 ))
|
||||
{
|
||||
//gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
|
||||
// gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -264,9 +264,9 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
|
|||
|
||||
numbedges += 2;
|
||||
|
||||
if (side == 0)
|
||||
if( side == 0 )
|
||||
{
|
||||
// entering for front, exiting for back
|
||||
// entering for front, exiting for back
|
||||
pfrontenter = ptvert;
|
||||
makeclippededge = true;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
|
|||
}
|
||||
else
|
||||
{
|
||||
// add the edge to the appropriate side
|
||||
// add the edge to the appropriate side
|
||||
pedges->pnext = psideedges[side];
|
||||
psideedges[side] = pedges;
|
||||
}
|
||||
|
@ -286,11 +286,11 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
|
|||
|
||||
// if anything was clipped, reconstitute and add the edges along the clip
|
||||
// plane to both sides (but in opposite directions)
|
||||
if (makeclippededge)
|
||||
if( makeclippededge )
|
||||
{
|
||||
if (numbedges >= (MAX_BMODEL_EDGES - 2))
|
||||
if( numbedges >= ( MAX_BMODEL_EDGES - 2 ))
|
||||
{
|
||||
//gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
|
||||
// gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -310,30 +310,30 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
|
|||
}
|
||||
|
||||
// draw or recurse further
|
||||
for (i=0 ; i<2 ; i++)
|
||||
for( i = 0; i < 2; i++ )
|
||||
{
|
||||
if (psideedges[i])
|
||||
if( psideedges[i] )
|
||||
{
|
||||
// draw if we've reached a non-solid leaf, done if all that's left is a
|
||||
// solid leaf, and continue down the tree if it's not a leaf
|
||||
// draw if we've reached a non-solid leaf, done if all that's left is a
|
||||
// solid leaf, and continue down the tree if it's not a leaf
|
||||
pn = pnode->children[i];
|
||||
|
||||
// we're done with this branch if the node or leaf isn't in the PVS
|
||||
if (pn->visframe == tr.visframecount)
|
||||
// we're done with this branch if the node or leaf isn't in the PVS
|
||||
if( pn->visframe == tr.visframecount )
|
||||
{
|
||||
if (pn->contents < 0)
|
||||
if( pn->contents < 0 )
|
||||
{
|
||||
if (pn->contents != CONTENTS_SOLID)
|
||||
if( pn->contents != CONTENTS_SOLID )
|
||||
{
|
||||
//r_currentbkey = ((mleaf_t *)pn)->cluster;
|
||||
r_currentbkey = LEAF_KEY (((mleaf_t *)pn));
|
||||
R_RenderBmodelFace (psideedges[i], psurf);
|
||||
// r_currentbkey = ((mleaf_t *)pn)->cluster;
|
||||
r_currentbkey = LEAF_KEY(((mleaf_t *)pn ));
|
||||
R_RenderBmodelFace( psideedges[i], psurf );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
R_RecursiveClipBPoly (psideedges[i], pnode->children[i],
|
||||
psurf);
|
||||
R_RecursiveClipBPoly( psideedges[i], pnode->children[i],
|
||||
psurf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -347,16 +347,16 @@ R_DrawSolidClippedSubmodelPolygons
|
|||
Bmodel crosses multiple leafs
|
||||
================
|
||||
*/
|
||||
void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
|
||||
void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode )
|
||||
{
|
||||
int i, j, lindex;
|
||||
vec_t dot;
|
||||
msurface_t *psurf;
|
||||
int numsurfaces;
|
||||
mplane_t *pplane;
|
||||
mvertex_t bverts[MAX_BMODEL_VERTS];
|
||||
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
|
||||
medge_t *pedge, *pedges;
|
||||
int i, j, lindex;
|
||||
vec_t dot;
|
||||
msurface_t *psurf;
|
||||
int numsurfaces;
|
||||
mplane_t *pplane;
|
||||
mvertex_t bverts[MAX_BMODEL_VERTS];
|
||||
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
|
||||
medge_t *pedge, *pedges;
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
|
@ -364,7 +364,7 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
|
|||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
pedges = pmodel->edges;
|
||||
|
||||
for (i=0 ; i<numsurfaces ; i++, psurf++)
|
||||
for( i = 0; i < numsurfaces; i++, psurf++ )
|
||||
{
|
||||
if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
|
||||
{
|
||||
|
@ -373,33 +373,33 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
|
|||
if( r_entorigin[2] + pmodel->mins[2] + 1.0f >= psurf->plane->dist )
|
||||
continue;
|
||||
}
|
||||
// find which side of the node we are on
|
||||
// find which side of the node we are on
|
||||
pplane = psurf->plane;
|
||||
|
||||
dot = DotProduct (tr.modelorg, pplane->normal) - pplane->dist;
|
||||
dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
|
||||
|
||||
// draw the polygon
|
||||
if (( !(psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
|
||||
((psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
|
||||
// draw the polygon
|
||||
if(( !( psurf->flags & SURF_PLANEBACK ) && ( dot < -BACKFACE_EPSILON ))
|
||||
|| (( psurf->flags & SURF_PLANEBACK ) && ( dot > BACKFACE_EPSILON )))
|
||||
continue;
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
// copy the edges to bedges, flipping if necessary so always
|
||||
// clockwise winding
|
||||
// FIXME: if edges and vertices get caches, these assignments must move
|
||||
// outside the loop, and overflow checking must be done here
|
||||
// copy the edges to bedges, flipping if necessary so always
|
||||
// clockwise winding
|
||||
// FIXME: if edges and vertices get caches, these assignments must move
|
||||
// outside the loop, and overflow checking must be done here
|
||||
pbverts = bverts;
|
||||
pbedges = bedges;
|
||||
numbverts = numbedges = 0;
|
||||
pbedge = &bedges[numbedges];
|
||||
numbedges += psurf->numedges;
|
||||
|
||||
for (j=0 ; j<psurf->numedges ; j++)
|
||||
for( j = 0; j < psurf->numedges; j++ )
|
||||
{
|
||||
lindex = pmodel->surfedges[psurf->firstedge+j];
|
||||
lindex = pmodel->surfedges[psurf->firstedge + j];
|
||||
|
||||
if (lindex > 0)
|
||||
if( lindex > 0 )
|
||||
{
|
||||
pedge = &pedges[lindex];
|
||||
pbedge[j].v[0] = &r_pcurrentvertbase[pedge->v[0]];
|
||||
|
@ -413,14 +413,14 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
|
|||
pbedge[j].v[1] = &r_pcurrentvertbase[pedge->v[0]];
|
||||
}
|
||||
|
||||
pbedge[j].pnext = &pbedge[j+1];
|
||||
pbedge[j].pnext = &pbedge[j + 1];
|
||||
}
|
||||
|
||||
pbedge[j-1].pnext = NULL; // mark end of edges
|
||||
pbedge[j - 1].pnext = NULL; // mark end of edges
|
||||
|
||||
//if ( !( psurf->texinfo->flags & ( SURF_TRANS66 | SURF_TRANS33 ) ) )
|
||||
R_RecursiveClipBPoly (pbedge, topnode, psurf);
|
||||
//else
|
||||
// if ( !( psurf->texinfo->flags & ( SURF_TRANS66 | SURF_TRANS33 ) ) )
|
||||
R_RecursiveClipBPoly( pbedge, topnode, psurf );
|
||||
// else
|
||||
// R_RenderBmodelFace( pbedge, psurf );
|
||||
}
|
||||
}
|
||||
|
@ -433,20 +433,20 @@ R_DrawSubmodelPolygons
|
|||
All in one leaf
|
||||
================
|
||||
*/
|
||||
void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags, mnode_t *topnode)
|
||||
void R_DrawSubmodelPolygons( model_t *pmodel, int clipflags, mnode_t *topnode )
|
||||
{
|
||||
int i;
|
||||
vec_t dot;
|
||||
msurface_t *psurf;
|
||||
int numsurfaces;
|
||||
mplane_t *pplane;
|
||||
int i;
|
||||
vec_t dot;
|
||||
msurface_t *psurf;
|
||||
int numsurfaces;
|
||||
mplane_t *pplane;
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
|
||||
for (i=0 ; i<numsurfaces ; i++, psurf++)
|
||||
for( i = 0; i < numsurfaces; i++, psurf++ )
|
||||
{
|
||||
if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
|
||||
{
|
||||
|
@ -455,19 +455,19 @@ void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags, mnode_t *topnode)
|
|||
if( r_entorigin[2] + pmodel->mins[2] + 1.0f >= psurf->plane->dist )
|
||||
continue;
|
||||
}
|
||||
// find which side of the node we are on
|
||||
// find which side of the node we are on
|
||||
pplane = psurf->plane;
|
||||
|
||||
dot = DotProduct (tr.modelorg, pplane->normal) - pplane->dist;
|
||||
dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
|
||||
|
||||
// draw the polygon
|
||||
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
|
||||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
|
||||
// draw the polygon
|
||||
if((( 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 ));
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
R_RenderFace (psurf, clipflags);
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
R_RenderFace( psurf, clipflags );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -482,34 +482,34 @@ int r_leafkeys[MAX_MAP_LEAFS];
|
|||
R_RecursiveWorldNode
|
||||
================
|
||||
*/
|
||||
static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
|
||||
static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
|
||||
{
|
||||
int i, c, side, *pindex;
|
||||
vec3_t acceptpt, rejectpt;
|
||||
mplane_t *plane;
|
||||
msurface_t *surf, **mark;
|
||||
mleaf_t *pleaf;
|
||||
double d, dot;
|
||||
int i, c, side, *pindex;
|
||||
vec3_t acceptpt, rejectpt;
|
||||
mplane_t *plane;
|
||||
msurface_t *surf, **mark;
|
||||
mleaf_t *pleaf;
|
||||
double d, dot;
|
||||
|
||||
if (node->contents == CONTENTS_SOLID)
|
||||
return; // solid
|
||||
if( node->contents == CONTENTS_SOLID )
|
||||
return; // solid
|
||||
|
||||
if (node->visframe != tr.visframecount)
|
||||
if( node->visframe != tr.visframecount )
|
||||
return;
|
||||
|
||||
// cull the clipping planes if not trivial accept
|
||||
// FIXME: the compiler is doing a lousy job of optimizing here; it could be
|
||||
// twice as fast in ASM
|
||||
if (clipflags)
|
||||
if( clipflags )
|
||||
{
|
||||
for (i=0 ; i<4 ; i++)
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
if (! (clipflags & (1<<i)) )
|
||||
continue; // don't need to clip against it
|
||||
if( !( clipflags & ( 1 << i )))
|
||||
continue; // don't need to clip against it
|
||||
|
||||
// generate accept and reject points
|
||||
// FIXME: do with fast look-ups or integer tests based on the sign bit
|
||||
// of the floating point values
|
||||
// generate accept and reject points
|
||||
// FIXME: do with fast look-ups or integer tests based on the sign bit
|
||||
// of the floating point values
|
||||
|
||||
pindex = qfrustum.pfrustum_indexes[i];
|
||||
|
||||
|
@ -517,60 +517,61 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
|
|||
rejectpt[1] = (float)node->minmaxs[pindex[1]];
|
||||
rejectpt[2] = (float)node->minmaxs[pindex[2]];
|
||||
|
||||
d = DotProduct (rejectpt, qfrustum.view_clipplanes[i].normal);
|
||||
d = DotProduct( rejectpt, qfrustum.view_clipplanes[i].normal );
|
||||
d -= qfrustum.view_clipplanes[i].dist;
|
||||
|
||||
if (d <= 0)
|
||||
if( d <= 0 )
|
||||
return;
|
||||
|
||||
acceptpt[0] = (float)node->minmaxs[pindex[3+0]];
|
||||
acceptpt[1] = (float)node->minmaxs[pindex[3+1]];
|
||||
acceptpt[2] = (float)node->minmaxs[pindex[3+2]];
|
||||
acceptpt[0] = (float)node->minmaxs[pindex[3 + 0]];
|
||||
acceptpt[1] = (float)node->minmaxs[pindex[3 + 1]];
|
||||
acceptpt[2] = (float)node->minmaxs[pindex[3 + 2]];
|
||||
|
||||
d = DotProduct (acceptpt, qfrustum.view_clipplanes[i].normal);
|
||||
d = DotProduct( acceptpt, qfrustum.view_clipplanes[i].normal );
|
||||
d -= qfrustum.view_clipplanes[i].dist;
|
||||
|
||||
if (d >= 0)
|
||||
clipflags &= ~(1<<i); // node is entirely on screen
|
||||
if( d >= 0 )
|
||||
clipflags &= ~( 1 << i ); // node is entirely on screen
|
||||
}
|
||||
}
|
||||
|
||||
// if a leaf node, draw stuff
|
||||
if (node->contents < 0)
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
pleaf = (mleaf_t *)node;
|
||||
|
||||
mark = pleaf->firstmarksurface;
|
||||
c = pleaf->nummarksurfaces;
|
||||
|
||||
if (c)
|
||||
if( c )
|
||||
{
|
||||
do
|
||||
{
|
||||
(*mark)->visframe = tr.framecount;
|
||||
( *mark )->visframe = tr.framecount;
|
||||
mark++;
|
||||
} while (--c);
|
||||
}
|
||||
while( --c );
|
||||
}
|
||||
|
||||
// deal with model fragments in this leaf
|
||||
if (pleaf->efrags)
|
||||
// deal with model fragments in this leaf
|
||||
if( pleaf->efrags )
|
||||
{
|
||||
gEngfuncs.R_StoreEfrags(&pleaf->efrags,tr.realframecount);
|
||||
gEngfuncs.R_StoreEfrags( &pleaf->efrags, tr.realframecount );
|
||||
}
|
||||
|
||||
|
||||
// pleaf->cluster
|
||||
LEAF_KEY(pleaf) = r_currentkey;
|
||||
r_currentkey++; // all bmodels in a leaf share the same key
|
||||
// pleaf->cluster
|
||||
LEAF_KEY( pleaf ) = r_currentkey;
|
||||
r_currentkey++; // all bmodels in a leaf share the same key
|
||||
}
|
||||
else
|
||||
{
|
||||
// node is just a decision point, so go down the apropriate sides
|
||||
// node is just a decision point, so go down the apropriate sides
|
||||
|
||||
// find which side of the node we are on
|
||||
// find which side of the node we are on
|
||||
plane = node->plane;
|
||||
|
||||
switch (plane->type)
|
||||
switch( plane->type )
|
||||
{
|
||||
case PLANE_X:
|
||||
dot = tr.modelorg[0] - plane->dist;
|
||||
|
@ -582,58 +583,60 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
|
|||
dot = tr.modelorg[2] - plane->dist;
|
||||
break;
|
||||
default:
|
||||
dot = DotProduct (tr.modelorg, plane->normal) - plane->dist;
|
||||
dot = DotProduct( tr.modelorg, plane->normal ) - plane->dist;
|
||||
break;
|
||||
}
|
||||
|
||||
if (dot >= 0)
|
||||
if( dot >= 0 )
|
||||
side = 0;
|
||||
else
|
||||
side = 1;
|
||||
|
||||
// recurse down the children, front side first
|
||||
R_RecursiveWorldNode (node->children[side], clipflags);
|
||||
// recurse down the children, front side first
|
||||
R_RecursiveWorldNode( node->children[side], clipflags );
|
||||
|
||||
// draw stuff
|
||||
// draw stuff
|
||||
c = node->numsurfaces;
|
||||
|
||||
if (c)
|
||||
if( c )
|
||||
{
|
||||
surf = WORLDMODEL->surfaces + node->firstsurface;
|
||||
|
||||
if (dot < -BACKFACE_EPSILON)
|
||||
if( dot < -BACKFACE_EPSILON )
|
||||
{
|
||||
do
|
||||
{
|
||||
if ((surf->flags & SURF_PLANEBACK) &&
|
||||
(surf->visframe == tr.framecount))
|
||||
if(( surf->flags & SURF_PLANEBACK )
|
||||
&& ( surf->visframe == tr.framecount ))
|
||||
{
|
||||
R_RenderFace (surf, clipflags);
|
||||
R_RenderFace( surf, clipflags );
|
||||
}
|
||||
|
||||
surf++;
|
||||
} while (--c);
|
||||
}
|
||||
while( --c );
|
||||
}
|
||||
else if (dot > BACKFACE_EPSILON)
|
||||
else if( dot > BACKFACE_EPSILON )
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!(surf->flags & SURF_PLANEBACK) &&
|
||||
(surf->visframe == tr.framecount))
|
||||
if( !( surf->flags & SURF_PLANEBACK )
|
||||
&& ( surf->visframe == tr.framecount ))
|
||||
{
|
||||
R_RenderFace (surf, clipflags);
|
||||
R_RenderFace( surf, clipflags );
|
||||
}
|
||||
|
||||
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
|
||||
r_currentkey++;
|
||||
}
|
||||
|
||||
// recurse down the back side
|
||||
R_RecursiveWorldNode (node->children[!side], clipflags);
|
||||
// recurse down the back side
|
||||
R_RecursiveWorldNode( node->children[!side], clipflags );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,18 +645,18 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
|
|||
R_RenderWorld
|
||||
================
|
||||
*/
|
||||
void R_RenderWorld (void)
|
||||
void R_RenderWorld( void )
|
||||
{
|
||||
if ( !RI.drawWorld )
|
||||
if( !RI.drawWorld )
|
||||
return;
|
||||
|
||||
// auto cycle the world frame for texture animation
|
||||
RI.currententity = CL_GetEntityByIndex(0);
|
||||
//RI.currententity->frame = (int)(gp_cl->time*2);
|
||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||
// RI.currententity->frame = (int)(gp_cl->time*2);
|
||||
|
||||
VectorCopy (RI.vieworg, tr.modelorg);
|
||||
VectorCopy( RI.vieworg, tr.modelorg );
|
||||
RI.currentmodel = WORLDMODEL;
|
||||
r_pcurrentvertbase = RI.currentmodel->vertexes;
|
||||
|
||||
R_RecursiveWorldNode (RI.currentmodel->nodes, 15);
|
||||
R_RecursiveWorldNode( RI.currentmodel->nodes, 15 );
|
||||
}
|
||||
|
|
|
@ -15,14 +15,14 @@ GNU General Public License for more details.
|
|||
|
||||
#include "r_local.h"
|
||||
|
||||
ref_api_t gEngfuncs;
|
||||
ref_api_t gEngfuncs;
|
||||
ref_globals_t *gpGlobals;
|
||||
ref_client_t *gp_cl;
|
||||
ref_host_t *gp_host;
|
||||
gl_globals_t tr;
|
||||
ref_speeds_t r_stats;
|
||||
poolhandle_t r_temppool;
|
||||
viddef_t vid;
|
||||
gl_globals_t tr;
|
||||
ref_speeds_t r_stats;
|
||||
poolhandle_t r_temppool;
|
||||
viddef_t vid;
|
||||
|
||||
void _Mem_Free( void *data, const char *filename, int fileline )
|
||||
{
|
||||
|
@ -58,8 +58,8 @@ CL_FillRGBA
|
|||
static void GAME_EXPORT CL_FillRGBA( int rendermode, float _x, float _y, float _w, float _h, byte r, byte g, byte b, byte a )
|
||||
{
|
||||
vid.rendermode = rendermode;
|
||||
_TriColor4ub(r,g,b,a);
|
||||
Draw_Fill(_x,_y,_w,_h);
|
||||
_TriColor4ub( r, g, b, a );
|
||||
Draw_Fill( _x, _y, _w, _h );
|
||||
}
|
||||
|
||||
void Mod_UnloadTextures( model_t *mod );
|
||||
|
@ -72,20 +72,20 @@ static qboolean GAME_EXPORT Mod_ProcessRenderData( model_t *mod, qboolean create
|
|||
{
|
||||
switch( mod->type )
|
||||
{
|
||||
case mod_studio:
|
||||
//Mod_LoadStudioModel( mod, buf, loaded );
|
||||
break;
|
||||
case mod_sprite:
|
||||
Mod_LoadSpriteModel( mod, buf, &loaded, mod->numtexinfo );
|
||||
break;
|
||||
case mod_alias:
|
||||
//Mod_LoadAliasModel( mod, buf, &loaded );
|
||||
break;
|
||||
case mod_brush:
|
||||
// Mod_LoadBrushModel( mod, buf, loaded );
|
||||
break;
|
||||
case mod_studio:
|
||||
// Mod_LoadStudioModel( mod, buf, loaded );
|
||||
break;
|
||||
case mod_sprite:
|
||||
Mod_LoadSpriteModel( mod, buf, &loaded, mod->numtexinfo );
|
||||
break;
|
||||
case mod_alias:
|
||||
// Mod_LoadAliasModel( mod, buf, &loaded );
|
||||
break;
|
||||
case mod_brush:
|
||||
// Mod_LoadBrushModel( mod, buf, loaded );
|
||||
break;
|
||||
|
||||
default: gEngfuncs.Host_Error( "%s: unsupported type %d\n", __func__, mod->type );
|
||||
default: gEngfuncs.Host_Error( "%s: unsupported type %d\n", __func__, mod->type );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,10 +118,10 @@ static int GL_RefGetParm( int parm, int arg )
|
|||
return glt->srcHeight;
|
||||
case PARM_TEX_GLFORMAT:
|
||||
glt = R_GetTexture( arg );
|
||||
return 0; //glt->format;
|
||||
return 0; // glt->format;
|
||||
case PARM_TEX_ENCODE:
|
||||
glt = R_GetTexture( arg );
|
||||
return 0; //glt->encode;
|
||||
return 0; // glt->encode;
|
||||
case PARM_TEX_MIPCOUNT:
|
||||
glt = R_GetTexture( arg );
|
||||
return glt->numMips;
|
||||
|
@ -132,36 +132,36 @@ static int GL_RefGetParm( int parm, int arg )
|
|||
Assert( arg >= 0 && arg < 6 );
|
||||
return tr.skyboxTextures[arg];
|
||||
case PARM_TEX_SKYTEXNUM:
|
||||
return 0; //tr.skytexturenum;
|
||||
return 0; // tr.skytexturenum;
|
||||
case PARM_TEX_LIGHTMAP:
|
||||
arg = bound( 0, arg, MAX_LIGHTMAPS - 1 );
|
||||
return tr.lightmapTextures[arg];
|
||||
case PARM_TEX_TARGET:
|
||||
glt = R_GetTexture( arg );
|
||||
return 0; //glt->target;
|
||||
return 0; // glt->target;
|
||||
case PARM_TEX_TEXNUM:
|
||||
glt = R_GetTexture( arg );
|
||||
return 0; //glt->texnum;
|
||||
return 0; // glt->texnum;
|
||||
case PARM_TEX_FLAGS:
|
||||
glt = R_GetTexture( arg );
|
||||
return glt->flags;
|
||||
case PARM_TEX_MEMORY:
|
||||
return R_TexMemory();
|
||||
case PARM_ACTIVE_TMU:
|
||||
return 0; //glState.activeTMU;
|
||||
return 0; // glState.activeTMU;
|
||||
case PARM_LIGHTSTYLEVALUE:
|
||||
arg = bound( 0, arg, MAX_LIGHTSTYLES - 1 );
|
||||
return tr.lightstylevalue[arg];
|
||||
case PARM_MAX_IMAGE_UNITS:
|
||||
return 0; //GL_MaxTextureUnits();
|
||||
return 0; // GL_MaxTextureUnits();
|
||||
case PARM_REBUILD_GAMMA:
|
||||
return 0;
|
||||
case PARM_GL_CONTEXT_TYPE:
|
||||
return 0; //glConfig.context;
|
||||
return 0; // glConfig.context;
|
||||
case PARM_GLES_WRAPPER:
|
||||
return 0; //glConfig.wrapper;
|
||||
return 0; // glConfig.wrapper;
|
||||
case PARM_STENCIL_ACTIVE:
|
||||
return 0; //glState.stencilEnabled;
|
||||
return 0; // glState.stencilEnabled;
|
||||
case PARM_SKY_SPHERE:
|
||||
return 0; // ref_soft doesn't support sky sphere
|
||||
case PARM_TEX_FILTERING:
|
||||
|
@ -176,18 +176,24 @@ static void GAME_EXPORT R_GetDetailScaleForTexture( int texture, float *xScale,
|
|||
{
|
||||
image_t *glt = R_GetTexture( texture );
|
||||
|
||||
if( xScale ) *xScale = glt->xscale;
|
||||
if( yScale ) *yScale = glt->yscale;
|
||||
if( xScale )
|
||||
*xScale = glt->xscale;
|
||||
if( yScale )
|
||||
*yScale = glt->yscale;
|
||||
}
|
||||
|
||||
static void GAME_EXPORT R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
|
||||
{
|
||||
image_t *glt = R_GetTexture( texture );
|
||||
|
||||
if( red ) *red = glt->fogParams[0];
|
||||
if( green ) *green = glt->fogParams[1];
|
||||
if( blue ) *blue = glt->fogParams[2];
|
||||
if( density ) *density = glt->fogParams[3];
|
||||
if( red )
|
||||
*red = glt->fogParams[0];
|
||||
if( green )
|
||||
*green = glt->fogParams[1];
|
||||
if( blue )
|
||||
*blue = glt->fogParams[2];
|
||||
if( density )
|
||||
*density = glt->fogParams[3];
|
||||
}
|
||||
|
||||
|
||||
|
@ -231,33 +237,33 @@ static void Mod_BrushUnloadTextures( model_t *mod )
|
|||
int i;
|
||||
|
||||
|
||||
gEngfuncs.Con_Printf("Unloading world\n");
|
||||
gEngfuncs.Con_Printf( "Unloading world\n" );
|
||||
tr.map_unload = true;
|
||||
|
||||
for( i = 0; i < mod->numtextures; i++ )
|
||||
{
|
||||
texture_t *tx = mod->textures[i];
|
||||
if( !tx || tx->gl_texturenum == tr.defaultTexture )
|
||||
continue; // free slot
|
||||
continue; // free slot
|
||||
|
||||
GL_FreeTexture( tx->gl_texturenum ); // main texture
|
||||
GL_FreeTexture( tx->fb_texturenum ); // luma texture
|
||||
GL_FreeTexture( tx->gl_texturenum ); // main texture
|
||||
GL_FreeTexture( tx->fb_texturenum ); // luma texture
|
||||
}
|
||||
}
|
||||
|
||||
void Mod_UnloadTextures( model_t *mod )
|
||||
{
|
||||
int i, j;
|
||||
int i, j;
|
||||
|
||||
Assert( mod != NULL );
|
||||
|
||||
switch( mod->type )
|
||||
{
|
||||
case mod_studio:
|
||||
//Mod_StudioUnloadTextures( mod->cache.data );
|
||||
// Mod_StudioUnloadTextures( mod->cache.data );
|
||||
break;
|
||||
case mod_alias:
|
||||
//Mod_AliasUnloadTextures( mod->cache.data );
|
||||
// Mod_AliasUnloadTextures( mod->cache.data );
|
||||
break;
|
||||
case mod_brush:
|
||||
Mod_BrushUnloadTextures( mod );
|
||||
|
@ -298,7 +304,7 @@ static void GAME_EXPORT GL_BackendEndFrame( void )
|
|||
}
|
||||
|
||||
|
||||
void GAME_EXPORT GL_SetRenderMode(int mode)
|
||||
void GAME_EXPORT GL_SetRenderMode( int mode )
|
||||
{
|
||||
vid.rendermode = mode;
|
||||
/// TODO: table shading/blending???
|
||||
|
@ -322,7 +328,7 @@ static void GAME_EXPORT R_SetupSky( int *skyboxTextures )
|
|||
tr.skyboxTextures[i] = skyboxTextures[i];
|
||||
}
|
||||
|
||||
qboolean GAME_EXPORT VID_CubemapShot(const char *base, uint size, const float *vieworg, qboolean skyshot)
|
||||
qboolean GAME_EXPORT VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot )
|
||||
{
|
||||
// cubemaps? in my softrender???
|
||||
return false;
|
||||
|
@ -339,17 +345,17 @@ static void GAME_EXPORT GL_SubdivideSurface( model_t *mod, msurface_t *fa )
|
|||
|
||||
}
|
||||
|
||||
static void GAME_EXPORT DrawSingleDecal(decal_t *pDecal, msurface_t *fa)
|
||||
static void GAME_EXPORT DrawSingleDecal( decal_t *pDecal, msurface_t *fa )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void GAME_EXPORT GL_SelectTexture(int texture)
|
||||
static void GAME_EXPORT GL_SelectTexture( int texture )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void GAME_EXPORT GL_LoadTexMatrixExt(const float *glmatrix)
|
||||
static void GAME_EXPORT GL_LoadTexMatrixExt( const float *glmatrix )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -359,27 +365,27 @@ static void GAME_EXPORT GL_LoadIdentityTexMatrix( void )
|
|||
|
||||
}
|
||||
|
||||
static void GAME_EXPORT GL_CleanUpTextureUnits(int last)
|
||||
static void GAME_EXPORT GL_CleanUpTextureUnits( int last )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void GAME_EXPORT GL_TexGen(unsigned int coord, unsigned int mode)
|
||||
static void GAME_EXPORT GL_TexGen( unsigned int coord, unsigned int mode )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void GAME_EXPORT GL_TextureTarget(uint target)
|
||||
static void GAME_EXPORT GL_TextureTarget( uint target )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GAME_EXPORT Mod_SetOrthoBounds(const float *mins, const float *maxs)
|
||||
void GAME_EXPORT Mod_SetOrthoBounds( const float *mins, const float *maxs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
qboolean GAME_EXPORT R_SpeedsMessage(char *out, size_t size)
|
||||
qboolean GAME_EXPORT R_SpeedsMessage( char *out, size_t size )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -410,7 +416,7 @@ static const char *R_GetConfigName( void )
|
|||
return "ref_soft"; // software specific cvars will go to ref_soft.cfg
|
||||
}
|
||||
|
||||
static void* GAME_EXPORT R_GetProcAddress( const char *name )
|
||||
static void * GAME_EXPORT R_GetProcAddress( const char *name )
|
||||
{
|
||||
return gEngfuncs.GL_GetProcAddress( name );
|
||||
}
|
||||
|
|
|
@ -15,44 +15,44 @@ GNU General Public License for more details.
|
|||
|
||||
#include "r_local.h"
|
||||
|
||||
#define DECAL_OVERLAP_DISTANCE 2
|
||||
#define DECAL_DISTANCE 4 // too big values produce more clipped polygons
|
||||
#define MAX_DECALCLIPVERT 32 // produced vertexes of fragmented decal
|
||||
#define DECAL_CACHEENTRY 256 // MUST BE POWER OF 2 or code below needs to change!
|
||||
#define DECAL_TRANSPARENT_THRESHOLD 230 // transparent decals draw with GL_MODULATE
|
||||
#define DECAL_OVERLAP_DISTANCE 2
|
||||
#define DECAL_DISTANCE 4 // too big values produce more clipped polygons
|
||||
#define MAX_DECALCLIPVERT 32 // produced vertexes of fragmented decal
|
||||
#define DECAL_CACHEENTRY 256 // MUST BE POWER OF 2 or code below needs to change!
|
||||
#define DECAL_TRANSPARENT_THRESHOLD 230 // transparent decals draw with GL_MODULATE
|
||||
|
||||
// empirically determined constants for minimizing overalpping decals
|
||||
#define MAX_OVERLAP_DECALS 6
|
||||
#define DECAL_OVERLAP_DIST 8
|
||||
#define MIN_DECAL_SCALE 0.01f
|
||||
#define MAX_DECAL_SCALE 16.0f
|
||||
#define MAX_OVERLAP_DECALS 6
|
||||
#define DECAL_OVERLAP_DIST 8
|
||||
#define MIN_DECAL_SCALE 0.01f
|
||||
#define MAX_DECAL_SCALE 16.0f
|
||||
|
||||
// clip edges
|
||||
#define LEFT_EDGE 0
|
||||
#define RIGHT_EDGE 1
|
||||
#define TOP_EDGE 2
|
||||
#define BOTTOM_EDGE 3
|
||||
#define LEFT_EDGE 0
|
||||
#define RIGHT_EDGE 1
|
||||
#define TOP_EDGE 2
|
||||
#define BOTTOM_EDGE 3
|
||||
|
||||
// This structure contains the information used to create new decals
|
||||
typedef struct
|
||||
{
|
||||
vec3_t m_Position; // world coordinates of the decal center
|
||||
model_t *m_pModel; // the model the decal is going to be applied in
|
||||
int m_iTexture; // The decal material
|
||||
int m_Size; // Size of the decal (in world coords)
|
||||
int m_Flags;
|
||||
int m_Entity; // Entity the decal is applied to.
|
||||
float m_scale;
|
||||
int m_decalWidth;
|
||||
int m_decalHeight;
|
||||
vec3_t m_Basis[3];
|
||||
vec3_t m_Position; // world coordinates of the decal center
|
||||
model_t *m_pModel; // the model the decal is going to be applied in
|
||||
int m_iTexture; // The decal material
|
||||
int m_Size; // Size of the decal (in world coords)
|
||||
int m_Flags;
|
||||
int m_Entity; // Entity the decal is applied to.
|
||||
float m_scale;
|
||||
int m_decalWidth;
|
||||
int m_decalHeight;
|
||||
vec3_t m_Basis[3];
|
||||
} decalinfo_t;
|
||||
|
||||
static float g_DecalClipVerts[MAX_DECALCLIPVERT][VERTEXSIZE];
|
||||
static float g_DecalClipVerts2[MAX_DECALCLIPVERT][VERTEXSIZE];
|
||||
static float g_DecalClipVerts[MAX_DECALCLIPVERT][VERTEXSIZE];
|
||||
static float g_DecalClipVerts2[MAX_DECALCLIPVERT][VERTEXSIZE];
|
||||
|
||||
decal_t gDecalPool[MAX_RENDER_DECALS];
|
||||
static int gDecalCount;
|
||||
decal_t gDecalPool[MAX_RENDER_DECALS];
|
||||
static int gDecalCount;
|
||||
|
||||
void R_ClearDecals( void )
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ void R_ClearDecals( void )
|
|||
// unlink pdecal from any surface it's attached to
|
||||
static void R_DecalUnlink( decal_t *pdecal )
|
||||
{
|
||||
decal_t *tmp;
|
||||
decal_t *tmp;
|
||||
|
||||
if( pdecal->psurface )
|
||||
{
|
||||
|
@ -74,7 +74,8 @@ static void R_DecalUnlink( decal_t *pdecal )
|
|||
else
|
||||
{
|
||||
tmp = pdecal->psurface->pdecals;
|
||||
if( !tmp ) gEngfuncs.Host_Error( "%s: bad decal list\n", __func__ );
|
||||
if( !tmp )
|
||||
gEngfuncs.Host_Error( "%s: bad decal list\n", __func__ );
|
||||
|
||||
while( tmp->pnext )
|
||||
{
|
||||
|
@ -100,16 +101,17 @@ static void R_DecalUnlink( decal_t *pdecal )
|
|||
// as each surface needs it's own.
|
||||
static decal_t *R_DecalAlloc( decal_t *pdecal )
|
||||
{
|
||||
int limit = MAX_RENDER_DECALS;
|
||||
int limit = MAX_RENDER_DECALS;
|
||||
|
||||
if( r_decals->value < limit )
|
||||
limit = r_decals->value;
|
||||
|
||||
if( !limit ) return NULL;
|
||||
if( !limit )
|
||||
return NULL;
|
||||
|
||||
if( !pdecal )
|
||||
{
|
||||
int count = 0;
|
||||
int count = 0;
|
||||
|
||||
// check for the odd possiblity of infinte loop
|
||||
do
|
||||
|
@ -120,7 +122,8 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
|
|||
pdecal = &gDecalPool[gDecalCount]; // reuse next decal
|
||||
gDecalCount++;
|
||||
count++;
|
||||
} while( FBitSet( pdecal->flags, FDECAL_PERMANENT ) && count < limit );
|
||||
}
|
||||
while( FBitSet( pdecal->flags, FDECAL_PERMANENT ) && count < limit );
|
||||
}
|
||||
|
||||
// if decal is already linked to a surface, unlink it.
|
||||
|
@ -129,28 +132,31 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
|
|||
return pdecal;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// find decal image and grab size from it
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
static void R_GetDecalDimensions( int texture, int *width, int *height )
|
||||
{
|
||||
if( width ) *width = 1; // to avoid divide by zero
|
||||
if( height ) *height = 1;
|
||||
if( width )
|
||||
*width = 1; // to avoid divide by zero
|
||||
if( height )
|
||||
*height = 1;
|
||||
|
||||
R_GetTextureParms( width, height, texture );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// compute the decal basis based on surface normal
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
void R_DecalComputeBasis( msurface_t *surf, int flags, vec3_t textureSpaceBasis[3] )
|
||||
{
|
||||
vec3_t surfaceNormal;
|
||||
vec3_t surfaceNormal;
|
||||
|
||||
// setup normal
|
||||
if( surf->flags & SURF_PLANEBACK )
|
||||
VectorNegate( surf->plane->normal, surfaceNormal );
|
||||
else VectorCopy( surf->plane->normal, surfaceNormal );
|
||||
else
|
||||
VectorCopy( surf->plane->normal, surfaceNormal );
|
||||
|
||||
VectorNormalize2( surfaceNormal, textureSpaceBasis[2] );
|
||||
VectorNormalize2( surf->texinfo->vecs[0], textureSpaceBasis[0] );
|
||||
|
@ -159,7 +165,7 @@ void R_DecalComputeBasis( msurface_t *surf, int flags, vec3_t textureSpaceBasis[
|
|||
|
||||
static void R_SetupDecalTextureSpaceBasis( decal_t *pDecal, msurface_t *surf, int texture, vec3_t textureSpaceBasis[3], float decalWorldScale[2] )
|
||||
{
|
||||
int width, height;
|
||||
int width, height;
|
||||
|
||||
// Compute the non-scaled decal basis
|
||||
R_DecalComputeBasis( surf, pDecal->flags, textureSpaceBasis );
|
||||
|
@ -177,10 +183,10 @@ static void R_SetupDecalTextureSpaceBasis( decal_t *pDecal, msurface_t *surf, in
|
|||
}
|
||||
|
||||
// Build the initial list of vertices from the surface verts into the global array, 'verts'.
|
||||
static void R_SetupDecalVertsForMSurface( decal_t *pDecal, msurface_t *surf, vec3_t textureSpaceBasis[3], float *verts )
|
||||
static void R_SetupDecalVertsForMSurface( decal_t *pDecal, msurface_t *surf, vec3_t textureSpaceBasis[3], float *verts )
|
||||
{
|
||||
float *v;
|
||||
int i;
|
||||
float *v;
|
||||
int i;
|
||||
|
||||
if( !surf->polys )
|
||||
return;
|
||||
|
@ -235,7 +241,7 @@ static int R_ClipInside( float *vert, int edge )
|
|||
|
||||
static void R_ClipIntersect( float *one, float *two, float *out, int edge )
|
||||
{
|
||||
float t;
|
||||
float t;
|
||||
|
||||
// t is the parameter of the line between one and two clipped to the edge
|
||||
// or the fraction of the clipped point between one & two
|
||||
|
@ -250,36 +256,36 @@ static void R_ClipIntersect( float *one, float *two, float *out, int edge )
|
|||
if( edge == LEFT_EDGE )
|
||||
{
|
||||
// left
|
||||
t = ((one[3] - 0.0f) / (one[3] - two[3]));
|
||||
t = (( one[3] - 0.0f ) / ( one[3] - two[3] ));
|
||||
out[3] = out[5] = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// right
|
||||
t = ((one[3] - 1.0f) / (one[3] - two[3]));
|
||||
t = (( one[3] - 1.0f ) / ( one[3] - two[3] ));
|
||||
out[3] = out[5] = 1.0f;
|
||||
}
|
||||
|
||||
out[4] = one[4] + (two[4] - one[4]) * t;
|
||||
out[6] = one[6] + (two[6] - one[6]) * t;
|
||||
out[4] = one[4] + ( two[4] - one[4] ) * t;
|
||||
out[6] = one[6] + ( two[6] - one[6] ) * t;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( edge == TOP_EDGE )
|
||||
{
|
||||
// top
|
||||
t = ((one[4] - 0.0f) / (one[4] - two[4]));
|
||||
t = (( one[4] - 0.0f ) / ( one[4] - two[4] ));
|
||||
out[4] = out[6] = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// bottom
|
||||
t = ((one[4] - 1.0f) / (one[4] - two[4]));
|
||||
t = (( one[4] - 1.0f ) / ( one[4] - two[4] ));
|
||||
out[4] = out[6] = 1.0f;
|
||||
}
|
||||
|
||||
out[3] = one[3] + (two[3] - one[3]) * t;
|
||||
out[5] = one[5] + (two[4] - one[5]) * t;
|
||||
out[3] = one[3] + ( two[3] - one[3] ) * t;
|
||||
out[5] = one[5] + ( two[4] - one[5] ) * t;
|
||||
}
|
||||
|
||||
VectorLerp( one, t, two, out );
|
||||
|
@ -287,12 +293,12 @@ static void R_ClipIntersect( float *one, float *two, float *out, int edge )
|
|||
|
||||
static int SHClip( float *vert, int vertCount, float *out, int edge )
|
||||
{
|
||||
int j, outCount;
|
||||
float *s, *p;
|
||||
int j, outCount;
|
||||
float *s, *p;
|
||||
|
||||
outCount = 0;
|
||||
|
||||
s = &vert[(vertCount - 1) * VERTEXSIZE];
|
||||
s = &vert[( vertCount - 1 ) * VERTEXSIZE];
|
||||
|
||||
for( j = 0; j < vertCount; j++ )
|
||||
{
|
||||
|
@ -336,8 +342,8 @@ static int SHClip( float *vert, int vertCount, float *out, int edge )
|
|||
|
||||
static float *R_DoDecalSHClip( float *pInVerts, decal_t *pDecal, int nStartVerts, int *pVertCount )
|
||||
{
|
||||
float *pOutVerts = g_DecalClipVerts[0];
|
||||
int outCount;
|
||||
float *pOutVerts = g_DecalClipVerts[0];
|
||||
int outCount;
|
||||
|
||||
// clip the polygon to the decal texture space
|
||||
outCount = SHClip( pInVerts, nStartVerts, g_DecalClipVerts2[0], LEFT_EDGE );
|
||||
|
@ -351,13 +357,13 @@ static float *R_DoDecalSHClip( float *pInVerts, decal_t *pDecal, int nStartVerts
|
|||
return pOutVerts;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Generate clipped vertex list for decal pdecal projected onto polygon psurf
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
static float *R_DecalVertsClip( decal_t *pDecal, msurface_t *surf, int texture, int *pVertCount )
|
||||
{
|
||||
float decalWorldScale[2];
|
||||
vec3_t textureSpaceBasis[3];
|
||||
float decalWorldScale[2];
|
||||
vec3_t textureSpaceBasis[3];
|
||||
|
||||
// figure out where the decal maps onto the surface.
|
||||
R_SetupDecalClip( pDecal, surf, texture, textureSpaceBasis, decalWorldScale );
|
||||
|
@ -373,11 +379,11 @@ static float *R_DecalVertsClip( decal_t *pDecal, msurface_t *surf, int texture,
|
|||
// Generate lighting coordinates at each vertex for decal vertices v[] on surface psurf
|
||||
static void R_DecalVertsLight( float *v, msurface_t *surf, int vertCount )
|
||||
{
|
||||
float s, t;
|
||||
mtexinfo_t *tex;
|
||||
mextrasurf_t *info = surf->info;
|
||||
float sample_size;
|
||||
int j;
|
||||
float s, t;
|
||||
mtexinfo_t *tex;
|
||||
mextrasurf_t *info = surf->info;
|
||||
float sample_size;
|
||||
int j;
|
||||
|
||||
sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
|
||||
tex = surf->texinfo;
|
||||
|
@ -388,12 +394,12 @@ static void R_DecalVertsLight( float *v, msurface_t *surf, int vertCount )
|
|||
s = DotProduct( v, info->lmvecs[0] ) + info->lmvecs[0][3] - info->lightmapmins[0];
|
||||
s += surf->light_s * sample_size;
|
||||
s += sample_size * 0.5f;
|
||||
s /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
|
||||
s /= BLOCK_SIZE * sample_size; // fa->texinfo->texture->width;
|
||||
|
||||
t = DotProduct( v, info->lmvecs[1] ) + info->lmvecs[1][3] - info->lightmapmins[1];
|
||||
t += surf->light_t * sample_size;
|
||||
t += sample_size * 0.5f;
|
||||
t /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->height;
|
||||
t /= BLOCK_SIZE * sample_size; // fa->texinfo->texture->height;
|
||||
|
||||
v[5] = s;
|
||||
v[6] = t;
|
||||
|
@ -403,11 +409,11 @@ static void R_DecalVertsLight( float *v, msurface_t *surf, int vertCount )
|
|||
// Check for intersecting decals on this surface
|
||||
static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int *pcount )
|
||||
{
|
||||
int texture;
|
||||
decal_t *plast, *pDecal;
|
||||
vec3_t decalExtents[2];
|
||||
float lastArea = 2;
|
||||
int mapSize[2];
|
||||
int texture;
|
||||
decal_t *plast, *pDecal;
|
||||
vec3_t decalExtents[2];
|
||||
float lastArea = 2;
|
||||
int mapSize[2];
|
||||
|
||||
plast = NULL;
|
||||
*pcount = 0;
|
||||
|
@ -417,8 +423,8 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
|
|||
|
||||
// precalculate the extents of decalinfo's decal in world space.
|
||||
R_GetDecalDimensions( texture, &mapSize[0], &mapSize[1] );
|
||||
VectorScale( decalinfo->m_Basis[0], ((mapSize[0] / decalinfo->m_scale) * 0.5f), decalExtents[0] );
|
||||
VectorScale( decalinfo->m_Basis[1], ((mapSize[1] / decalinfo->m_scale) * 0.5f), decalExtents[1] );
|
||||
VectorScale( decalinfo->m_Basis[0], (( mapSize[0] / decalinfo->m_scale ) * 0.5f ), decalExtents[0] );
|
||||
VectorScale( decalinfo->m_Basis[1], (( mapSize[1] / decalinfo->m_scale ) * 0.5f ), decalExtents[1] );
|
||||
|
||||
pDecal = surf->pdecals;
|
||||
|
||||
|
@ -430,11 +436,11 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
|
|||
// Don't steal permanent decals
|
||||
if( !FBitSet( pDecal->flags, FDECAL_PERMANENT ))
|
||||
{
|
||||
vec3_t testBasis[3];
|
||||
vec3_t testPosition[2];
|
||||
float testWorldScale[2];
|
||||
vec2_t vDecalMin, vDecalMax;
|
||||
vec2_t vUnionMin, vUnionMax;
|
||||
vec3_t testBasis[3];
|
||||
vec3_t testPosition[2];
|
||||
float testWorldScale[2];
|
||||
vec2_t vDecalMin, vDecalMax;
|
||||
vec2_t vUnionMin, vUnionMax;
|
||||
|
||||
R_SetupDecalTextureSpaceBasis( pDecal, surf, texture, testBasis, testWorldScale );
|
||||
|
||||
|
@ -445,15 +451,15 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
|
|||
// this decal's (pDecal's) [0,0,1,1] clip space, just like we would if we were
|
||||
// clipping a triangle into pDecal's clip space.
|
||||
Vector2Set( vDecalMin,
|
||||
DotProduct( testPosition[0], testBasis[0] ) - pDecal->dx + 0.5f,
|
||||
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f );
|
||||
DotProduct( testPosition[0], testBasis[0] ) - pDecal->dx + 0.5f,
|
||||
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f );
|
||||
|
||||
VectorAdd( decalinfo->m_Position, decalExtents[0], testPosition[0] );
|
||||
VectorAdd( decalinfo->m_Position, decalExtents[1], testPosition[1] );
|
||||
|
||||
Vector2Set( vDecalMax,
|
||||
DotProduct( testPosition[0], testBasis[0] ) - pDecal->dx + 0.5f,
|
||||
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f );
|
||||
DotProduct( testPosition[0], testBasis[0] ) - pDecal->dx + 0.5f,
|
||||
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f );
|
||||
|
||||
// Now figure out the part of the projection that intersects pDecal's
|
||||
// clip box [0,0,1,1].
|
||||
|
@ -463,7 +469,7 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
|
|||
if( vUnionMin[0] < 1 && vUnionMin[1] < 1 && vUnionMax[0] > 0 && vUnionMax[1] > 0 )
|
||||
{
|
||||
// Figure out how much of this intersects the (0,0) - (1,1) bbox.
|
||||
float flArea = (vUnionMax[0] - vUnionMin[1]) * (vUnionMax[1] - vUnionMin[1]);
|
||||
float flArea = ( vUnionMax[0] - vUnionMin[1] ) * ( vUnionMax[1] - vUnionMin[1] );
|
||||
|
||||
if( flArea > 0.6f )
|
||||
{
|
||||
|
@ -472,7 +478,7 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
|
|||
if( !plast || flArea <= lastArea )
|
||||
{
|
||||
plast = pDecal;
|
||||
lastArea = flArea;
|
||||
lastArea = flArea;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -491,17 +497,18 @@ creates mesh for decal on first rendering
|
|||
*/
|
||||
static glpoly2_t *R_DecalCreatePoly( decalinfo_t *decalinfo, decal_t *pdecal, msurface_t *surf )
|
||||
{
|
||||
int lnumverts;
|
||||
glpoly2_t *poly;
|
||||
float *v;
|
||||
int i;
|
||||
int lnumverts;
|
||||
glpoly2_t *poly;
|
||||
float *v;
|
||||
int i;
|
||||
|
||||
return NULL;
|
||||
if( pdecal->polys ) // already created?
|
||||
if( pdecal->polys ) // already created?
|
||||
return pdecal->polys;
|
||||
|
||||
v = R_DecalSetupVerts( pdecal, surf, pdecal->texture, &lnumverts );
|
||||
if( !lnumverts ) return NULL; // probably this never happens
|
||||
if( !lnumverts )
|
||||
return NULL; // probably this never happens
|
||||
|
||||
// allocate glpoly
|
||||
// REFTODO: com_studiocache pool!
|
||||
|
@ -526,7 +533,7 @@ static glpoly2_t *R_DecalCreatePoly( decalinfo_t *decalinfo, decal_t *pdecal, ms
|
|||
// Add the decal to the surface's list of decals.
|
||||
static void R_AddDecalToSurface( decal_t *pdecal, msurface_t *surf, decalinfo_t *decalinfo )
|
||||
{
|
||||
decal_t *pold;
|
||||
decal_t *pold;
|
||||
|
||||
pdecal->pnext = NULL;
|
||||
pold = surf->pdecals;
|
||||
|
@ -554,21 +561,24 @@ static void R_AddDecalToSurface( decal_t *pdecal, msurface_t *surf, decalinfo_t
|
|||
|
||||
// alloc clipped poly for decal
|
||||
R_DecalCreatePoly( decalinfo, pdecal, surf );
|
||||
//R_AddDecalVBO( pdecal, surf );
|
||||
// R_AddDecalVBO( pdecal, surf );
|
||||
}
|
||||
|
||||
static void R_DecalCreate( decalinfo_t *decalinfo, msurface_t *surf, float x, float y )
|
||||
{
|
||||
decal_t *pdecal, *pold;
|
||||
int count, vertCount;
|
||||
decal_t *pdecal, *pold;
|
||||
int count, vertCount;
|
||||
|
||||
if( !surf ) return; // ???
|
||||
if( !surf )
|
||||
return; // ???
|
||||
|
||||
pold = R_DecalIntersect( decalinfo, surf, &count );
|
||||
if( count < MAX_OVERLAP_DECALS ) pold = NULL;
|
||||
if( count < MAX_OVERLAP_DECALS )
|
||||
pold = NULL;
|
||||
|
||||
pdecal = R_DecalAlloc( pold );
|
||||
if( !pdecal ) return; // r_decals == 0 ???
|
||||
if( !pdecal )
|
||||
return; // r_decals == 0 ???
|
||||
|
||||
pdecal->flags = decalinfo->m_Flags;
|
||||
|
||||
|
@ -599,10 +609,10 @@ static void R_DecalCreate( decalinfo_t *decalinfo, msurface_t *surf, float x, fl
|
|||
static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
|
||||
{
|
||||
// get the texture associated with this surface
|
||||
mtexinfo_t *tex = surf->texinfo;
|
||||
decal_t *decal = surf->pdecals;
|
||||
vec4_t textureU, textureV;
|
||||
float s, t, w, h;
|
||||
mtexinfo_t *tex = surf->texinfo;
|
||||
decal_t *decal = surf->pdecals;
|
||||
vec4_t textureU, textureV;
|
||||
float s, t, w, h;
|
||||
connstate_t state = ENGINE_GET_PARM( PARM_CONNSTATE );
|
||||
|
||||
// we in restore mode
|
||||
|
@ -643,18 +653,18 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
|
|||
// (decalWidth * decalBasis[0], decalHeight * decalBasis[1])
|
||||
// in texture coordinates:
|
||||
|
||||
w = fabs( decalinfo->m_decalWidth * DotProduct( textureU, decalinfo->m_Basis[0] )) +
|
||||
fabs( decalinfo->m_decalHeight * DotProduct( textureU, decalinfo->m_Basis[1] ));
|
||||
w = fabs( decalinfo->m_decalWidth * DotProduct( textureU, decalinfo->m_Basis[0] ))
|
||||
+ fabs( decalinfo->m_decalHeight * DotProduct( textureU, decalinfo->m_Basis[1] ));
|
||||
|
||||
h = fabs( decalinfo->m_decalWidth * DotProduct( textureV, decalinfo->m_Basis[0] )) +
|
||||
fabs( decalinfo->m_decalHeight * DotProduct( textureV, decalinfo->m_Basis[1] ));
|
||||
h = fabs( decalinfo->m_decalWidth * DotProduct( textureV, decalinfo->m_Basis[0] ))
|
||||
+ fabs( decalinfo->m_decalHeight * DotProduct( textureV, decalinfo->m_Basis[1] ));
|
||||
|
||||
// move s,t to upper left corner
|
||||
s -= ( w * 0.5f );
|
||||
t -= ( h * 0.5f );
|
||||
|
||||
// Is this rect within the surface? -- tex width & height are unsigned
|
||||
if( s <= -w || t <= -h || s > (surf->extents[0] + w) || t > (surf->extents[1] + h))
|
||||
if( s <= -w || t <= -h || s > ( surf->extents[0] + w ) || t > ( surf->extents[1] + h ))
|
||||
{
|
||||
return; // nope
|
||||
}
|
||||
|
@ -663,40 +673,40 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
|
|||
R_DecalCreate( decalinfo, surf, s, t );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// iterate over all surfaces on a node, looking for surfaces to decal
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
static void R_DecalNodeSurfaces( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
{
|
||||
// iterate over all surfaces in the node
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
|
||||
surf = model->surfaces + node->firstsurface;
|
||||
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
// never apply decals on the water or sky surfaces
|
||||
if( surf->flags & (SURF_DRAWTURB|SURF_DRAWSKY|SURF_CONVEYOR))
|
||||
if( surf->flags & ( SURF_DRAWTURB | SURF_DRAWSKY | SURF_CONVEYOR ))
|
||||
continue;
|
||||
|
||||
// we can implement alpha testing without stencil
|
||||
//if( surf->flags & SURF_TRANSPARENT && !glState.stencilEnabled )
|
||||
//continue;
|
||||
// if( surf->flags & SURF_TRANSPARENT && !glState.stencilEnabled )
|
||||
// continue;
|
||||
|
||||
R_DecalSurface( surf, decalinfo );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Recursive routine to find surface to apply a decal to. World coordinates of
|
||||
// the decal are passed in r_recalpos like the rest of the engine. This should
|
||||
// be called through R_DecalShoot()
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
float dist;
|
||||
mplane_t *splitplane;
|
||||
float dist;
|
||||
|
||||
Assert( node != NULL );
|
||||
|
||||
|
@ -738,11 +748,11 @@ static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
|
|||
// Shoots a decal onto the surface of the BSP. position is the center of the decal in world coords
|
||||
void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos, int flags, float scale )
|
||||
{
|
||||
decalinfo_t decalInfo;
|
||||
cl_entity_t *ent = NULL;
|
||||
model_t *model = NULL;
|
||||
int width, height;
|
||||
hull_t *hull;
|
||||
decalinfo_t decalInfo;
|
||||
cl_entity_t *ent = NULL;
|
||||
model_t *model = NULL;
|
||||
int width, height;
|
||||
hull_t *hull;
|
||||
|
||||
if( textureIndex <= 0 || textureIndex >= MAX_TEXTURES )
|
||||
{
|
||||
|
@ -754,15 +764,20 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
|
|||
{
|
||||
ent = CL_GetEntityByIndex( entityIndex );
|
||||
|
||||
if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
|
||||
else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
|
||||
else return;
|
||||
if( modelIndex > 0 )
|
||||
model = CL_ModelHandle( modelIndex );
|
||||
else if( ent != NULL )
|
||||
model = CL_ModelHandle( ent->curstate.modelindex );
|
||||
else
|
||||
return;
|
||||
}
|
||||
else if( modelIndex > 0 )
|
||||
model = CL_ModelHandle( modelIndex );
|
||||
else model = WORLDMODEL;
|
||||
else
|
||||
model = WORLDMODEL;
|
||||
|
||||
if( !model ) return;
|
||||
if( !model )
|
||||
return;
|
||||
|
||||
if( model->type != mod_brush )
|
||||
{
|
||||
|
@ -771,18 +786,18 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
|
|||
}
|
||||
|
||||
decalInfo.m_pModel = model;
|
||||
hull = &model->hulls[0]; // always use #0 hull
|
||||
hull = &model->hulls[0]; // always use #0 hull
|
||||
|
||||
// NOTE: all the decals at 'first shoot' placed into local space of parent entity
|
||||
// and won't transform again on a next restore, levelchange etc
|
||||
if( ent && !FBitSet( flags, FDECAL_LOCAL_SPACE ))
|
||||
{
|
||||
vec3_t pos_l;
|
||||
vec3_t pos_l;
|
||||
|
||||
// transform decal position in local bmodel space
|
||||
if( !VectorIsNull( ent->angles ))
|
||||
{
|
||||
matrix4x4 matrix;
|
||||
matrix4x4 matrix;
|
||||
|
||||
Matrix4x4_CreateFromEntity( matrix, ent->angles, ent->origin, 1.0f );
|
||||
Matrix4x4_VectorITransform( matrix, pos, pos_l );
|
||||
|
@ -831,9 +846,9 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
|
|||
// triangles the same way.
|
||||
float * GAME_EXPORT R_DecalSetupVerts( decal_t *pDecal, msurface_t *surf, int texture, int *outCount )
|
||||
{
|
||||
glpoly2_t *p = pDecal->polys;
|
||||
int i, count;
|
||||
float *v, *v2;
|
||||
glpoly2_t *p = pDecal->polys;
|
||||
int i, count;
|
||||
float *v, *v2;
|
||||
|
||||
if( p )
|
||||
{
|
||||
|
@ -884,30 +899,31 @@ static qboolean R_DecalUnProject( decal_t *pdecal, decallist_t *entry )
|
|||
// Grab surface plane equation
|
||||
if( pdecal->psurface->flags & SURF_PLANEBACK )
|
||||
VectorNegate( pdecal->psurface->plane->normal, entry->impactPlaneNormal );
|
||||
else VectorCopy( pdecal->psurface->plane->normal, entry->impactPlaneNormal );
|
||||
else
|
||||
VectorCopy( pdecal->psurface->plane->normal, entry->impactPlaneNormal );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *pList -
|
||||
// count -
|
||||
// Output : static int
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
static int DecalListAdd( decallist_t *pList, int count )
|
||||
{
|
||||
vec3_t tmp;
|
||||
decallist_t *pdecal;
|
||||
int i;
|
||||
vec3_t tmp;
|
||||
decallist_t *pdecal;
|
||||
int i;
|
||||
|
||||
pdecal = pList + count;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
if( !Q_strcmp( pdecal->name, pList[i].name ) && pdecal->entityIndex == pList[i].entityIndex )
|
||||
if( !Q_strcmp( pdecal->name, pList[i].name ) && pdecal->entityIndex == pList[i].entityIndex )
|
||||
{
|
||||
VectorSubtract( pdecal->position, pList[i].position, tmp ); // Merge
|
||||
VectorSubtract( pdecal->position, pList[i].position, tmp ); // Merge
|
||||
|
||||
if( VectorLength( tmp ) < DECAL_OVERLAP_DISTANCE )
|
||||
return count;
|
||||
|
@ -920,7 +936,7 @@ static int DecalListAdd( decallist_t *pList, int count )
|
|||
|
||||
static int DecalDepthCompare( const void *a, const void *b )
|
||||
{
|
||||
const decallist_t *elem1, *elem2;
|
||||
const decallist_t *elem1, *elem2;
|
||||
|
||||
elem1 = (const decallist_t *)a;
|
||||
elem2 = (const decallist_t *)b;
|
||||
|
@ -933,15 +949,15 @@ static int DecalDepthCompare( const void *a, const void *b )
|
|||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Purpose: Called by CSaveRestore::SaveClientState
|
||||
// Input : *pList -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
int GAME_EXPORT R_CreateDecalList( decallist_t *pList )
|
||||
{
|
||||
int total = 0;
|
||||
int i, depth;
|
||||
int total = 0;
|
||||
int i, depth;
|
||||
|
||||
// return 0; // crash on changelevel. API bug?
|
||||
|
||||
|
@ -949,12 +965,12 @@ int GAME_EXPORT R_CreateDecalList( decallist_t *pList )
|
|||
{
|
||||
for( i = 0; i < MAX_RENDER_DECALS; i++ )
|
||||
{
|
||||
decal_t *decal = &gDecalPool[i];
|
||||
decal_t *pdecals;
|
||||
decal_t *decal = &gDecalPool[i];
|
||||
decal_t *pdecals;
|
||||
|
||||
// decal is in use and is not a custom decal
|
||||
if( decal->psurface == NULL || FBitSet( decal->flags, FDECAL_DONTSAVE ))
|
||||
continue;
|
||||
continue;
|
||||
|
||||
// compute depth
|
||||
depth = 0;
|
||||
|
@ -998,8 +1014,8 @@ remove all decals with specified texture
|
|||
*/
|
||||
void GAME_EXPORT R_DecalRemoveAll( int textureIndex )
|
||||
{
|
||||
decal_t *pdecal;
|
||||
int i;
|
||||
decal_t *pdecal;
|
||||
int i;
|
||||
|
||||
if( textureIndex < 0 || textureIndex >= MAX_TEXTURES )
|
||||
return; // out of bounds
|
||||
|
@ -1026,9 +1042,9 @@ remove all decals from specified entity
|
|||
*/
|
||||
void GAME_EXPORT R_EntityRemoveDecals( model_t *mod )
|
||||
{
|
||||
msurface_t *psurf;
|
||||
decal_t *p;
|
||||
int i;
|
||||
msurface_t *psurf;
|
||||
decal_t *p;
|
||||
int i;
|
||||
|
||||
if( !mod || mod->type != mod_brush )
|
||||
return;
|
||||
|
@ -1051,8 +1067,8 @@ used for full decals restart
|
|||
*/
|
||||
void GAME_EXPORT R_ClearAllDecals( void )
|
||||
{
|
||||
decal_t *pdecal;
|
||||
int i;
|
||||
decal_t *pdecal;
|
||||
int i;
|
||||
|
||||
// because gDecalCount may be zeroed after recach the decal limit
|
||||
for( i = 0; i < MAX_RENDER_DECALS; i++ )
|
||||
|
|
|
@ -22,11 +22,13 @@ R_GetImageParms
|
|||
*/
|
||||
void R_GetTextureParms( int *w, int *h, int texnum )
|
||||
{
|
||||
image_t *glt;
|
||||
image_t *glt;
|
||||
|
||||
glt = R_GetTexture( texnum );
|
||||
if( w ) *w = glt->srcWidth;
|
||||
if( h ) *h = glt->srcHeight;
|
||||
if( w )
|
||||
*w = glt->srcWidth;
|
||||
if( h )
|
||||
*h = glt->srcHeight;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -39,14 +41,18 @@ for sprite models
|
|||
*/
|
||||
void GAME_EXPORT R_GetSpriteParms( int *frameWidth, int *frameHeight, int *numFrames, int currentFrame, const model_t *pSprite )
|
||||
{
|
||||
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 );
|
||||
|
||||
if( frameWidth ) *frameWidth = pFrame->width;
|
||||
if( frameHeight ) *frameHeight = pFrame->height;
|
||||
if( numFrames ) *numFrames = pSprite->numframes;
|
||||
if( frameWidth )
|
||||
*frameWidth = pFrame->width;
|
||||
if( frameHeight )
|
||||
*frameHeight = pFrame->height;
|
||||
if( numFrames )
|
||||
*numFrames = pSprite->numframes;
|
||||
}
|
||||
|
||||
int GAME_EXPORT R_GetSpriteTexture( const model_t *m_pSpriteModel, int frame )
|
||||
|
@ -63,33 +69,33 @@ int GAME_EXPORT R_GetSpriteTexture( const model_t *m_pSpriteModel, int frame )
|
|||
Draw_StretchPicImplementation
|
||||
=============
|
||||
*/
|
||||
static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1, int t1, int s2, int t2, image_t *pic )
|
||||
static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1, int t1, int s2, int t2, image_t *pic )
|
||||
{
|
||||
unsigned int height;
|
||||
int skip, v;
|
||||
qboolean transparent = false;
|
||||
pixel_t *buffer;
|
||||
unsigned int height;
|
||||
int skip, v;
|
||||
qboolean transparent = false;
|
||||
pixel_t *buffer;
|
||||
|
||||
if( x < 0 )
|
||||
{
|
||||
s1 += (-x)*(s2-s1) / w;
|
||||
s1 += ( -x ) * ( s2 - s1 ) / w;
|
||||
x = 0;
|
||||
}
|
||||
if( x + w > vid.width )
|
||||
{
|
||||
s2 -= (x + w - vid.width) * (s2 - s1)/ w ;
|
||||
s2 -= ( x + w - vid.width ) * ( s2 - s1 ) / w;
|
||||
w = vid.width - x;
|
||||
}
|
||||
if( y + h > vid.height )
|
||||
{
|
||||
t2 -= (y + h - vid.height) * (t2 - t1) / h;
|
||||
t2 -= ( y + h - vid.height ) * ( t2 - t1 ) / h;
|
||||
h = vid.height - y;
|
||||
}
|
||||
|
||||
if( !pic->pixels[0] || s1 >= s2 || t1 >= t2 )
|
||||
return;
|
||||
|
||||
//gEngfuncs.Con_Printf ("pixels is %p\n", pic->pixels[0] );
|
||||
// gEngfuncs.Con_Printf ("pixels is %p\n", pic->pixels[0] );
|
||||
|
||||
height = h;
|
||||
|
||||
|
@ -115,21 +121,21 @@ static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1,
|
|||
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (v=0 ; v<height ; v++)
|
||||
for( v = 0; v < height; v++ )
|
||||
{
|
||||
int alpha1 = vid.alpha;
|
||||
pixel_t *dest = vid.buffer + (y + v) * vid.rowbytes + x;
|
||||
uint sv = (skip + v)*(t2-t1)/h + t1;
|
||||
uint u, f, fstep;
|
||||
pixel_t *source = buffer + sv*pic->width + s1;
|
||||
int alpha1 = vid.alpha;
|
||||
pixel_t *dest = vid.buffer + ( y + v ) * vid.rowbytes + x;
|
||||
uint sv = ( skip + v ) * ( t2 - t1 ) / h + t1;
|
||||
uint u, f, fstep;
|
||||
pixel_t *source = buffer + sv * pic->width + s1;
|
||||
|
||||
f = 0;
|
||||
fstep = ((s2-s1) << 16)/w;
|
||||
fstep = (( s2 - s1 ) << 16 ) / w;
|
||||
|
||||
for (u=0 ; u<w ; u++)
|
||||
for( u = 0; u < w; u++ )
|
||||
{
|
||||
pixel_t src = source[f>>16];
|
||||
int alpha = alpha1;
|
||||
pixel_t src = source[f >> 16];
|
||||
int alpha = alpha1;
|
||||
f += fstep;
|
||||
|
||||
if( transparent )
|
||||
|
@ -142,22 +148,22 @@ static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1,
|
|||
continue;
|
||||
|
||||
if( vid.color != COLOR_WHITE )
|
||||
src = vid.modmap[(src & 0xff00)|(vid.color>>8)] << 8 | (src & vid.color & 0xff) | ((src & 0xff) >> 3);
|
||||
src = vid.modmap[( src & 0xff00 ) | ( vid.color >> 8 )] << 8 | ( src & vid.color & 0xff ) | (( src & 0xff ) >> 3 );
|
||||
|
||||
if( vid.rendermode == kRenderTransAdd)
|
||||
if( vid.rendermode == kRenderTransAdd )
|
||||
{
|
||||
pixel_t screen = dest[u];
|
||||
dest[u] = vid.addmap[(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) | ((src & 0xff) >> 0);
|
||||
dest[u] = vid.addmap[( src & 0xff00 ) | ( screen >> 8 )] << 8 | ( screen & 0xff ) | (( src & 0xff ) >> 0 );
|
||||
}
|
||||
else if( vid.rendermode == kRenderScreenFadeModulate )
|
||||
{
|
||||
pixel_t screen = dest[u];
|
||||
dest[u] = BLEND_COLOR( screen, vid.color );
|
||||
}
|
||||
else if( alpha < 7) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
|
||||
else if( alpha < 7 ) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
|
||||
{
|
||||
pixel_t screen = dest[u]; // | 0xff & screen & src ;
|
||||
dest[u] = BLEND_ALPHA( alpha, src, screen );//vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
|
||||
pixel_t screen = dest[u]; // | 0xff & screen & src ;
|
||||
dest[u] = BLEND_ALPHA( alpha, src, screen ); // vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
|
||||
}
|
||||
else
|
||||
dest[u] = src;
|
||||
|
@ -174,8 +180,8 @@ R_DrawStretchPic
|
|||
*/
|
||||
void GAME_EXPORT R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum )
|
||||
{
|
||||
image_t *pic = R_GetTexture(texnum);
|
||||
int width = pic->width, height = pic->height;
|
||||
image_t *pic = R_GetTexture( texnum );
|
||||
int width = pic->width, height = pic->height;
|
||||
// GL_Bind( XASH_TEXTURE0, texnum );
|
||||
if( s2 > 1.0f || t2 > 1.0f )
|
||||
return;
|
||||
|
@ -183,15 +189,15 @@ void GAME_EXPORT R_DrawStretchPic( float x, float y, float w, float h, float s1,
|
|||
return;
|
||||
if( w < 1.0f || h < 1.0f )
|
||||
return;
|
||||
R_DrawStretchPicImplementation(x,y,w,h, width * s1, height * t1, width * s2, height * t2, pic);
|
||||
R_DrawStretchPicImplementation( x, y, w, h, width * s1, height * t1, width * s2, height * t2, pic );
|
||||
}
|
||||
|
||||
void Draw_Fill (int x, int y, int w, int h)
|
||||
void Draw_Fill( int x, int y, int w, int h )
|
||||
{
|
||||
unsigned int height;
|
||||
int v;
|
||||
pixel_t src = vid.color;
|
||||
int alpha = vid.alpha;
|
||||
int v;
|
||||
pixel_t src = vid.color;
|
||||
int alpha = vid.alpha;
|
||||
|
||||
if( x < 0 )
|
||||
x = 0;
|
||||
|
@ -218,25 +224,25 @@ void Draw_Fill (int x, int y, int w, int h)
|
|||
}
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (v=0 ; v<height ; v++)
|
||||
for( v = 0; v < height; v++ )
|
||||
{
|
||||
pixel_t *dest = vid.buffer + (y + v) * vid.rowbytes + x;
|
||||
uint u;
|
||||
pixel_t *dest = vid.buffer + ( y + v ) * vid.rowbytes + x;
|
||||
uint u;
|
||||
|
||||
for (u=0 ; u<w ; u++)
|
||||
for( u = 0; u < w; u++ )
|
||||
{
|
||||
if( alpha == 0 )
|
||||
continue;
|
||||
|
||||
if( vid.rendermode == kRenderTransAdd)
|
||||
if( vid.rendermode == kRenderTransAdd )
|
||||
{
|
||||
pixel_t screen = dest[u];
|
||||
dest[u] = vid.addmap[(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) | ((src & 0xff) >> 0);
|
||||
dest[u] = vid.addmap[( src & 0xff00 ) | ( screen >> 8 )] << 8 | ( screen & 0xff ) | (( src & 0xff ) >> 0 );
|
||||
}
|
||||
else if( alpha < 7) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
|
||||
else if( alpha < 7 ) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
|
||||
{
|
||||
pixel_t screen = dest[u]; // | 0xff & screen & src ;
|
||||
dest[u] = BLEND_ALPHA( alpha, src, screen);//vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
|
||||
pixel_t screen = dest[u]; // | 0xff & screen & src ;
|
||||
dest[u] = BLEND_ALPHA( alpha, src, screen ); // vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
|
||||
}
|
||||
else
|
||||
dest[u] = src;
|
||||
|
@ -251,14 +257,14 @@ R_DrawStretchRaw
|
|||
*/
|
||||
void GAME_EXPORT R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty )
|
||||
{
|
||||
byte *raw = NULL;
|
||||
image_t *tex;
|
||||
byte *raw = NULL;
|
||||
image_t *tex;
|
||||
|
||||
raw = (byte *)data;
|
||||
|
||||
//pglDisable( GL_BLEND );
|
||||
//pglDisable( GL_ALPHA_TEST );
|
||||
//pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
|
||||
// pglDisable( GL_BLEND );
|
||||
// pglDisable( GL_ALPHA_TEST );
|
||||
// pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
|
||||
|
||||
tex = R_GetTexture( tr.cinTexture );
|
||||
GL_Bind( XASH_TEXTURE0, tr.cinTexture );
|
||||
|
@ -271,8 +277,8 @@ R_UploadStretchRaw
|
|||
*/
|
||||
void GAME_EXPORT R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data )
|
||||
{
|
||||
byte *raw = NULL;
|
||||
image_t *tex;
|
||||
byte *raw = NULL;
|
||||
image_t *tex;
|
||||
raw = (byte *)data;
|
||||
|
||||
tex = R_GetTexture( texture );
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,13 +4,13 @@
|
|||
|
||||
struct swblit_s
|
||||
{
|
||||
uint stride;
|
||||
uint bpp;
|
||||
uint rmask, gmask, bmask;
|
||||
void *(*pLockBuffer)( void );
|
||||
void (*pUnlockBuffer)( void );
|
||||
qboolean(*pCreateBuffer)( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b );
|
||||
uint rotate;
|
||||
uint stride;
|
||||
uint bpp;
|
||||
uint rmask, gmask, bmask;
|
||||
void *(*pLockBuffer)( void );
|
||||
void (*pUnlockBuffer)( void );
|
||||
qboolean (*pCreateBuffer)( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b );
|
||||
uint rotate;
|
||||
qboolean gl1;
|
||||
} swblit;
|
||||
|
||||
|
@ -20,7 +20,7 @@ qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int
|
|||
qboolean ret = true;
|
||||
if( rotate > 1 )
|
||||
{
|
||||
gEngfuncs.Con_Printf("only 0-1 rotation supported\n");
|
||||
gEngfuncs.Con_Printf( "only 0-1 rotation supported\n" );
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
|
@ -29,14 +29,14 @@ qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int
|
|||
if( offset_x || offset_y )
|
||||
{
|
||||
// it is possible implement for offset > 0
|
||||
gEngfuncs.Con_Printf("offset transform not supported\n");
|
||||
gEngfuncs.Con_Printf( "offset transform not supported\n" );
|
||||
ret = false;
|
||||
}
|
||||
|
||||
if( scale_x != 1.0f || scale_y != 1.0f )
|
||||
{
|
||||
// maybe implement 2x2?
|
||||
gEngfuncs.Con_Printf("scale transform not supported\n");
|
||||
gEngfuncs.Con_Printf( "scale transform not supported\n" );
|
||||
ret = false;
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,8 @@ static void APIENTRY GL_DebugOutput( GLuint source, GLuint type, GLuint id, GLui
|
|||
static unsigned short *glbuf;
|
||||
static int tex;
|
||||
|
||||
#define LOAD(x) p##x = gEngfuncs.GL_GetProcAddress(#x); \
|
||||
gEngfuncs.Con_Printf(#x " : %p\n",p##x)
|
||||
#define LOAD( x ) p ## x = gEngfuncs.GL_GetProcAddress(#x ); \
|
||||
gEngfuncs.Con_Printf(#x " : %p\n", p ## x )
|
||||
|
||||
|
||||
void GAME_EXPORT GL_SetupAttributes( int safegl )
|
||||
|
@ -108,69 +108,69 @@ void GAME_EXPORT GL_SetupAttributes( int safegl )
|
|||
gEngfuncs.GL_SetAttribute( REF_GL_BLUE_SIZE, 5 );
|
||||
}
|
||||
|
||||
void (*pglOrthof)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
|
||||
void GL_FUNCTION( glBindBuffer)(GLenum target, GLuint buffer);
|
||||
void (*pglOrthof)( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar );
|
||||
void GL_FUNCTION( glBindBuffer )( GLenum target, GLuint buffer );
|
||||
|
||||
void GL_FUNCTION( glBufferData )(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
|
||||
void GL_FUNCTION( glGenBuffers )(GLsizei n, GLuint *buffers);
|
||||
void GL_FUNCTION( glDeleteBuffers )(GLsizei n, const GLuint *buffers);
|
||||
GLvoid* GL_FUNCTION( glMapBufferOES )(GLenum target, GLenum access);
|
||||
GLboolean GL_FUNCTION( glUnmapBufferOES )(GLenum target);
|
||||
void GL_FUNCTION( glBufferData )( GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage );
|
||||
void GL_FUNCTION( glGenBuffers )( GLsizei n, GLuint *buffers );
|
||||
void GL_FUNCTION( glDeleteBuffers )( GLsizei n, const GLuint *buffers );
|
||||
GLvoid * GL_FUNCTION( glMapBufferOES )( GLenum target, GLenum access );
|
||||
GLboolean GL_FUNCTION( glUnmapBufferOES )( GLenum target );
|
||||
#define GL_PIXEL_UNPACK_BUFFER 0x88EC
|
||||
#define GL_FRAMEBUFFER 0x8D40
|
||||
#define GL_COLOR_ATTACHMENT0 0x8CE0
|
||||
#define GL_READ_FRAMEBUFFER 0x8CA8
|
||||
#define GL_DRAW_FRAMEBUFFER 0x8CA9
|
||||
#define GL_FRAMEBUFFER 0x8D40
|
||||
#define GL_COLOR_ATTACHMENT0 0x8CE0
|
||||
#define GL_READ_FRAMEBUFFER 0x8CA8
|
||||
#define GL_DRAW_FRAMEBUFFER 0x8CA9
|
||||
void GAME_EXPORT GL_InitExtensions( void )
|
||||
{
|
||||
LOAD(glBegin);
|
||||
LOAD(glEnd);
|
||||
LOAD(glTexCoord2f);
|
||||
LOAD(glVertex2f);
|
||||
LOAD(glEnable);
|
||||
LOAD(glDisable);
|
||||
LOAD(glTexImage2D);
|
||||
LOAD(glOrtho);
|
||||
LOAD(glOrthof);
|
||||
LOAD(glMatrixMode);
|
||||
LOAD(glLoadIdentity);
|
||||
LOAD(glViewport);
|
||||
LOAD(glBindTexture);
|
||||
LOAD(glDebugMessageCallbackARB);
|
||||
LOAD(glDebugMessageControlARB);
|
||||
LOAD(glGetError);
|
||||
LOAD(glGenTextures);
|
||||
LOAD(glTexParameteri);
|
||||
LOAD(glEnableClientState);
|
||||
LOAD(glDisableClientState);
|
||||
LOAD(glVertexPointer);
|
||||
LOAD(glTexCoordPointer);
|
||||
LOAD(glDrawElements);
|
||||
LOAD(glClear);
|
||||
LOAD(glClearColor);
|
||||
LOAD(glGetString);
|
||||
LOAD(glColor4f);
|
||||
LOAD(glDrawArrays);
|
||||
LOAD(glBindBuffer);
|
||||
LOAD(glBufferData);
|
||||
LOAD(glGenBuffers);
|
||||
LOAD(glDeleteBuffers);
|
||||
LOAD(glMapBufferOES);
|
||||
LOAD( glBegin );
|
||||
LOAD( glEnd );
|
||||
LOAD( glTexCoord2f );
|
||||
LOAD( glVertex2f );
|
||||
LOAD( glEnable );
|
||||
LOAD( glDisable );
|
||||
LOAD( glTexImage2D );
|
||||
LOAD( glOrtho );
|
||||
LOAD( glOrthof );
|
||||
LOAD( glMatrixMode );
|
||||
LOAD( glLoadIdentity );
|
||||
LOAD( glViewport );
|
||||
LOAD( glBindTexture );
|
||||
LOAD( glDebugMessageCallbackARB );
|
||||
LOAD( glDebugMessageControlARB );
|
||||
LOAD( glGetError );
|
||||
LOAD( glGenTextures );
|
||||
LOAD( glTexParameteri );
|
||||
LOAD( glEnableClientState );
|
||||
LOAD( glDisableClientState );
|
||||
LOAD( glVertexPointer );
|
||||
LOAD( glTexCoordPointer );
|
||||
LOAD( glDrawElements );
|
||||
LOAD( glClear );
|
||||
LOAD( glClearColor );
|
||||
LOAD( glGetString );
|
||||
LOAD( glColor4f );
|
||||
LOAD( glDrawArrays );
|
||||
LOAD( glBindBuffer );
|
||||
LOAD( glBufferData );
|
||||
LOAD( glGenBuffers );
|
||||
LOAD( glDeleteBuffers );
|
||||
LOAD( glMapBufferOES );
|
||||
if( !pglMapBufferOES )
|
||||
pglMapBufferOES = gEngfuncs.GL_GetProcAddress("glMapBuffer");
|
||||
LOAD(glUnmapBufferOES);
|
||||
pglMapBufferOES = gEngfuncs.GL_GetProcAddress( "glMapBuffer" );
|
||||
LOAD( glUnmapBufferOES );
|
||||
if( !pglUnmapBufferOES )
|
||||
pglUnmapBufferOES = gEngfuncs.GL_GetProcAddress("glUnmapBuffer");
|
||||
LOAD(glGenFramebuffers);
|
||||
LOAD(glBindFramebuffer);
|
||||
LOAD(glFramebufferTexture2D);
|
||||
LOAD(glBlitFramebuffer);
|
||||
LOAD(glGenTextures);
|
||||
gEngfuncs.Con_Printf("version:%s\n",pglGetString(GL_VERSION));
|
||||
pglUnmapBufferOES = gEngfuncs.GL_GetProcAddress( "glUnmapBuffer" );
|
||||
LOAD( glGenFramebuffers );
|
||||
LOAD( glBindFramebuffer );
|
||||
LOAD( glFramebufferTexture2D );
|
||||
LOAD( glBlitFramebuffer );
|
||||
LOAD( glGenTextures );
|
||||
gEngfuncs.Con_Printf( "version:%s\n", pglGetString( GL_VERSION ));
|
||||
#if GLDEBUG
|
||||
if( gpGlobals->developer )
|
||||
{
|
||||
gEngfuncs.Con_Reportf( "Installing GL_DebugOutput...\n");
|
||||
gEngfuncs.Con_Reportf( "Installing GL_DebugOutput...\n" );
|
||||
pglDebugMessageCallbackARB( GL_DebugOutput, NULL );
|
||||
|
||||
// force everything to happen in the main thread instead of in a separate driver thread
|
||||
|
@ -196,19 +196,19 @@ static void R_Unlock_GL1( void )
|
|||
{
|
||||
|
||||
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, glbuf );
|
||||
//gEngfuncs.Con_Printf("%d\n",pglGetError());
|
||||
// gEngfuncs.Con_Printf("%d\n",pglGetError());
|
||||
pglBegin( GL_QUADS );
|
||||
pglTexCoord2f( 0, 0 );
|
||||
pglVertex2f( 0, 0 );
|
||||
pglTexCoord2f( 0, 0 );
|
||||
pglVertex2f( 0, 0 );
|
||||
|
||||
pglTexCoord2f( 1, 0 );
|
||||
pglVertex2f( 1, 0 );
|
||||
pglTexCoord2f( 1, 0 );
|
||||
pglVertex2f( 1, 0 );
|
||||
|
||||
pglTexCoord2f( 1, 1 );
|
||||
pglVertex2f( 1, 1 );
|
||||
pglTexCoord2f( 1, 1 );
|
||||
pglVertex2f( 1, 1 );
|
||||
|
||||
pglTexCoord2f( 0, 1 );
|
||||
pglVertex2f( 0, 1 );
|
||||
pglTexCoord2f( 0, 1 );
|
||||
pglVertex2f( 0, 1 );
|
||||
pglEnd();
|
||||
gEngfuncs.GL_SwapBuffers();
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ static void R_Unlock_GL1( void )
|
|||
static void R_Unlock_GLES1( void )
|
||||
{
|
||||
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, glbuf );
|
||||
pglDrawArrays( GL_TRIANGLE_FAN, 0,4 );
|
||||
pglDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
||||
|
||||
gEngfuncs.GL_SwapBuffers();
|
||||
}
|
||||
|
@ -232,19 +232,19 @@ static qboolean R_CreateBuffer_GL1( int width, int height, uint *stride, uint *b
|
|||
pglLoadIdentity();
|
||||
|
||||
pglEnable( GL_TEXTURE_2D );
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
pglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
pglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
|
||||
if( glbuf )
|
||||
Mem_Free(glbuf);
|
||||
Mem_Free( glbuf );
|
||||
|
||||
glbuf = Mem_Malloc( r_temppool, width*height*2 );
|
||||
glbuf = Mem_Malloc( r_temppool, width * height * 2 );
|
||||
|
||||
*stride = width;
|
||||
*bpp = 2;
|
||||
*r = MASK(5) << (6 + 5);
|
||||
*g = MASK(6) << 5;
|
||||
*b = MASK(5);
|
||||
*r = MASK( 5 ) << ( 6 + 5 );
|
||||
*g = MASK( 6 ) << 5;
|
||||
*b = MASK( 5 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ static qboolean R_CreateBuffer_GLES1( int width, int height, uint *stride, uint
|
|||
1, 1,
|
||||
0, 1,
|
||||
};
|
||||
int vbo;
|
||||
int vbo;
|
||||
|
||||
pglViewport( 0, 0, width, height );
|
||||
pglMatrixMode( GL_PROJECTION );
|
||||
|
@ -272,32 +272,32 @@ static qboolean R_CreateBuffer_GLES1( int width, int height, uint *stride, uint
|
|||
pglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
pglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
|
||||
//if( vbo )
|
||||
// if( vbo )
|
||||
// pglDeleteBuffers( 1,&vbo );
|
||||
|
||||
pglGenBuffers( 1,&vbo );
|
||||
pglGenBuffers( 1, &vbo );
|
||||
pglBindBuffer( GL_ARRAY_BUFFER_ARB, vbo );
|
||||
pglBufferData( GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB );
|
||||
pglBufferData( GL_ARRAY_BUFFER_ARB, sizeof( data ), data, GL_STATIC_DRAW_ARB );
|
||||
|
||||
pglEnableClientState( GL_VERTEX_ARRAY );
|
||||
pglEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
pglVertexPointer( 2, GL_FLOAT, 8, 0 );
|
||||
pglTexCoordPointer( 2, GL_FLOAT, 8, 0 );
|
||||
pglBindBuffer( GL_ARRAY_BUFFER_ARB, 0 ) ;
|
||||
pglBindBuffer( GL_ARRAY_BUFFER_ARB, 0 );
|
||||
pglColor4f( 1, 1, 1, 1 );
|
||||
|
||||
|
||||
if( glbuf )
|
||||
Mem_Free( glbuf );
|
||||
|
||||
glbuf = Mem_Malloc( r_temppool, width*height*2 );
|
||||
glbuf = Mem_Malloc( r_temppool, width * height * 2 );
|
||||
|
||||
*stride = width;
|
||||
*bpp = 2;
|
||||
*r = MASK(5) << (6 + 5);
|
||||
*g = MASK(6) << 5;
|
||||
*b = MASK(5);
|
||||
*r = MASK( 5 ) << ( 6 + 5 );
|
||||
*g = MASK( 6 ) << 5;
|
||||
*b = MASK( 5 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ static void *R_Lock_GLES3( void )
|
|||
if( pglUnmapBufferOES )
|
||||
pglUnmapBufferOES( GL_PIXEL_UNPACK_BUFFER );
|
||||
pglBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 );
|
||||
glbuf = Mem_Malloc( r_temppool, vid.width*vid.height*2 );
|
||||
glbuf = Mem_Malloc( r_temppool, vid.width * vid.height * 2 );
|
||||
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, glbuf );
|
||||
return glbuf;
|
||||
}
|
||||
|
@ -340,13 +340,13 @@ static void R_Unlock_GLES3( void )
|
|||
pglUnmapBufferOES( GL_PIXEL_UNPACK_BUFFER );
|
||||
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0 );
|
||||
}
|
||||
//pglDrawArrays( GL_TRIANGLE_FAN, 0,4 );
|
||||
// pglDrawArrays( GL_TRIANGLE_FAN, 0,4 );
|
||||
pglBlitFramebuffer( 0, vid.height, vid.width, 0, 0, 0, vid.width, vid.height, GL_COLOR_BUFFER_BIT, GL_NEAREST );
|
||||
}
|
||||
|
||||
static qboolean R_CreateBuffer_GLES3( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b )
|
||||
{
|
||||
float data[] = {
|
||||
float data[] = {
|
||||
// quad verts match texcoords
|
||||
0, 0,
|
||||
1, 0,
|
||||
|
@ -378,35 +378,35 @@ static qboolean R_CreateBuffer_GLES3( int width, int height, uint *stride, uint
|
|||
pglDeleteBuffers( 1,&pbo );
|
||||
*/
|
||||
|
||||
//pglGenBuffers( 1,&vbo );
|
||||
// pglGenBuffers( 1,&vbo );
|
||||
pglGenBuffers( 1, &pbo );
|
||||
//pglBindBuffer( GL_ARRAY_BUFFER_ARB, vbo );
|
||||
//pglBufferData( GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB );
|
||||
// pglBindBuffer( GL_ARRAY_BUFFER_ARB, vbo );
|
||||
// pglBufferData( GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB );
|
||||
|
||||
//pglEnableClientState( GL_VERTEX_ARRAY );
|
||||
//pglEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
// pglEnableClientState( GL_VERTEX_ARRAY );
|
||||
// pglEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
//pglVertexPointer( 2, GL_FLOAT, 8, 0 );
|
||||
//pglTexCoordPointer( 2, GL_FLOAT, 8, 0 );
|
||||
//pglBindBuffer( GL_ARRAY_BUFFER_ARB, 0 );
|
||||
// pglVertexPointer( 2, GL_FLOAT, 8, 0 );
|
||||
// pglTexCoordPointer( 2, GL_FLOAT, 8, 0 );
|
||||
// pglBindBuffer( GL_ARRAY_BUFFER_ARB, 0 );
|
||||
|
||||
pglBindBuffer( GL_PIXEL_UNPACK_BUFFER, pbo );
|
||||
pglBufferData( GL_PIXEL_UNPACK_BUFFER, width * height * 2, 0, GL_STREAM_DRAW_ARB );
|
||||
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0 );
|
||||
|
||||
pglGenFramebuffers(1, &fbo);
|
||||
pglBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
|
||||
pglFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, to, 0);
|
||||
pglBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
pglGenFramebuffers( 1, &fbo );
|
||||
pglBindFramebuffer( GL_READ_FRAMEBUFFER, fbo );
|
||||
pglFramebufferTexture2D( GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, to, 0 );
|
||||
pglBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
|
||||
|
||||
//pglColor4f( 1, 1, 1, 1 );
|
||||
// pglColor4f( 1, 1, 1, 1 );
|
||||
|
||||
|
||||
*stride = width;
|
||||
*bpp = 2;
|
||||
*r = MASK(5) << (6 + 5);
|
||||
*g = MASK(6) << 5;
|
||||
*b = MASK(5);
|
||||
*r = MASK( 5 ) << ( 6 + 5 );
|
||||
*g = MASK( 6 ) << 5;
|
||||
*b = MASK( 5 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -417,7 +417,8 @@ static int FIRST_BIT( uint mask )
|
|||
{
|
||||
uint i;
|
||||
|
||||
for( i = 0; !(BIT(i) & mask); i++ );
|
||||
for( i = 0; !( BIT( i ) & mask ); i++ )
|
||||
;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -434,60 +435,60 @@ static int COUNT_BITS( uint mask )
|
|||
|
||||
static void R_BuildScreenMap( void )
|
||||
{
|
||||
int i;
|
||||
uint rshift = FIRST_BIT(swblit.rmask), gshift = FIRST_BIT(swblit.gmask), bshift = FIRST_BIT(swblit.bmask);
|
||||
uint rbits = COUNT_BITS(swblit.rmask), gbits = COUNT_BITS(swblit.gmask), bbits = COUNT_BITS(swblit.bmask);
|
||||
uint rmult = BIT(rbits), gmult = BIT(gbits), bmult = BIT(bbits);
|
||||
uint rdiv = MASK(5), gdiv = MASK(6), bdiv = MASK(5);
|
||||
int i;
|
||||
uint rshift = FIRST_BIT( swblit.rmask ), gshift = FIRST_BIT( swblit.gmask ), bshift = FIRST_BIT( swblit.bmask );
|
||||
uint rbits = COUNT_BITS( swblit.rmask ), gbits = COUNT_BITS( swblit.gmask ), bbits = COUNT_BITS( swblit.bmask );
|
||||
uint rmult = BIT( rbits ), gmult = BIT( gbits ), bmult = BIT( bbits );
|
||||
uint rdiv = MASK( 5 ), gdiv = MASK( 6 ), bdiv = MASK( 5 );
|
||||
|
||||
gEngfuncs.Con_Printf("Blit table: %d %d %d %d %d %d\n", rmult, gmult, bmult, rdiv, gdiv, bdiv );
|
||||
gEngfuncs.Con_Printf( "Blit table: %d %d %d %d %d %d\n", rmult, gmult, bmult, rdiv, gdiv, bdiv );
|
||||
|
||||
#ifdef SEPARATE_BLIT
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
unsigned int r,g,b;
|
||||
unsigned int r, g, b;
|
||||
|
||||
// 332 to 565
|
||||
r = ((i >> (8 - 3) )<< 2 ) & MASK(5);
|
||||
g = ((i >> (8 - 3 - 3)) << 3) & MASK(6);
|
||||
b = ((i >> (8 - 3 - 3 - 2)) << 3) & MASK(5);
|
||||
vid.screen_major[i] = r << (6 + 5) | (g << 5) | b;
|
||||
r = (( i >> ( 8 - 3 )) << 2 ) & MASK( 5 );
|
||||
g = (( i >> ( 8 - 3 - 3 )) << 3 ) & MASK( 6 );
|
||||
b = (( i >> ( 8 - 3 - 3 - 2 )) << 3 ) & MASK( 5 );
|
||||
vid.screen_major[i] = r << ( 6 + 5 ) | ( g << 5 ) | b;
|
||||
|
||||
|
||||
// restore minor GBRGBRGB
|
||||
r = MOVE_BIT(i, 5, 1) | MOVE_BIT(i, 2, 0);
|
||||
g = MOVE_BIT(i, 7, 2) | MOVE_BIT(i, 4, 1) | MOVE_BIT(i, 1, 0);
|
||||
b = MOVE_BIT(i, 6, 2) | MOVE_BIT(i, 3, 1) | MOVE_BIT(i, 0, 0);
|
||||
vid.screen_minor[i] = r << (6 + 5) | (g << 5) | b;
|
||||
r = MOVE_BIT( i, 5, 1 ) | MOVE_BIT( i, 2, 0 );
|
||||
g = MOVE_BIT( i, 7, 2 ) | MOVE_BIT( i, 4, 1 ) | MOVE_BIT( i, 1, 0 );
|
||||
b = MOVE_BIT( i, 6, 2 ) | MOVE_BIT( i, 3, 1 ) | MOVE_BIT( i, 0, 0 );
|
||||
vid.screen_minor[i] = r << ( 6 + 5 ) | ( g << 5 ) | b;
|
||||
|
||||
}
|
||||
#else
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
unsigned int r,g,b , major, j;
|
||||
unsigned int r, g, b, major, j;
|
||||
|
||||
// 332 to 565
|
||||
r = ((i >> (8 - 3) )<< 2 ) & MASK(5);
|
||||
g = ((i >> (8 - 3 - 3)) << 3) & MASK(6);
|
||||
b = ((i >> (8 - 3 - 3 - 2)) << 3) & MASK(5);
|
||||
//major = r << (6 + 5) | (g << 5) | b;
|
||||
major = (r * rmult / rdiv) << rshift | (g * gmult / gdiv) << gshift | (b * bmult / bdiv) << bshift;
|
||||
r = (( i >> ( 8 - 3 )) << 2 ) & MASK( 5 );
|
||||
g = (( i >> ( 8 - 3 - 3 )) << 3 ) & MASK( 6 );
|
||||
b = (( i >> ( 8 - 3 - 3 - 2 )) << 3 ) & MASK( 5 );
|
||||
// major = r << (6 + 5) | (g << 5) | b;
|
||||
major = ( r * rmult / rdiv ) << rshift | ( g * gmult / gdiv ) << gshift | ( b * bmult / bdiv ) << bshift;
|
||||
|
||||
|
||||
for( j = 0; j < 256; j++ )
|
||||
{
|
||||
uint minor;
|
||||
// restore minor GBRGBRGB
|
||||
r = MOVE_BIT(j, 5, 1) | MOVE_BIT(j, 2, 0);
|
||||
g = MOVE_BIT(j, 7, 2) | MOVE_BIT(j, 4, 1) | MOVE_BIT(j, 1, 0);
|
||||
b = MOVE_BIT(j, 6, 2) | MOVE_BIT(j, 3, 1) | MOVE_BIT(j, 0, 0);
|
||||
//vid.screen[(i<<8)|j] = r << (6 + 5) | (g << 5) | b | major;
|
||||
minor = (r * rmult / rdiv) << rshift | (g * gmult / gdiv) << gshift | (b * bmult / bdiv) << bshift;
|
||||
r = MOVE_BIT( j, 5, 1 ) | MOVE_BIT( j, 2, 0 );
|
||||
g = MOVE_BIT( j, 7, 2 ) | MOVE_BIT( j, 4, 1 ) | MOVE_BIT( j, 1, 0 );
|
||||
b = MOVE_BIT( j, 6, 2 ) | MOVE_BIT( j, 3, 1 ) | MOVE_BIT( j, 0, 0 );
|
||||
// vid.screen[(i<<8)|j] = r << (6 + 5) | (g << 5) | b | major;
|
||||
minor = ( r * rmult / rdiv ) << rshift | ( g * gmult / gdiv ) << gshift | ( b * bmult / bdiv ) << bshift;
|
||||
|
||||
if( swblit.bpp == 2 )
|
||||
vid.screen[(i<<8)|j] = major | minor;
|
||||
vid.screen[( i << 8 ) | j] = major | minor;
|
||||
else
|
||||
vid.screen32[(i<<8)|j] = major | minor;
|
||||
vid.screen32[( i << 8 ) | j] = major | minor;
|
||||
|
||||
}
|
||||
|
||||
|
@ -495,7 +496,7 @@ static void R_BuildScreenMap( void )
|
|||
#endif
|
||||
}
|
||||
|
||||
#define FOR_EACH_COLOR(x) for( r##x = 0; r##x < BIT(3); r##x++ ) for( g##x = 0; g##x < BIT(3); g##x++ ) for( b##x = 0; b##x < BIT(2); b##x++ )
|
||||
#define FOR_EACH_COLOR( x ) for( r ## x = 0; r ## x < BIT( 3 ); r ## x++ ) for( g ## x = 0; g ## x < BIT( 3 ); g ## x++ ) for( b ## x = 0; b ## x < BIT( 2 ); b ## x++ )
|
||||
|
||||
static void R_BuildBlendMaps( void )
|
||||
{
|
||||
|
@ -503,82 +504,82 @@ static void R_BuildBlendMaps( void )
|
|||
unsigned int r2, g2, b2;
|
||||
unsigned int i, j;
|
||||
|
||||
FOR_EACH_COLOR(1)FOR_EACH_COLOR(2)
|
||||
FOR_EACH_COLOR( 1 ) FOR_EACH_COLOR( 2 )
|
||||
{
|
||||
unsigned int r, g, b;
|
||||
unsigned short index1 = r1 << (2 + 3) | g1 << 2 | b1;
|
||||
unsigned short index2 = (r2 << (2 + 3) | g2 << 2 | b2) << 8;
|
||||
unsigned int a;
|
||||
unsigned int r, g, b;
|
||||
unsigned short index1 = r1 << ( 2 + 3 ) | g1 << 2 | b1;
|
||||
unsigned short index2 = ( r2 << ( 2 + 3 ) | g2 << 2 | b2 ) << 8;
|
||||
unsigned int a;
|
||||
|
||||
r = r1 + r2;
|
||||
g = g1 + g2;
|
||||
b = b1 + b2;
|
||||
if( r > MASK(3) )
|
||||
r = MASK(3);
|
||||
if( g > MASK(3) )
|
||||
g = MASK(3);
|
||||
if( b > MASK(2) )
|
||||
b = MASK(2);
|
||||
ASSERT(!vid.addmap[index2|index1]);
|
||||
if( r > MASK( 3 ))
|
||||
r = MASK( 3 );
|
||||
if( g > MASK( 3 ))
|
||||
g = MASK( 3 );
|
||||
if( b > MASK( 2 ))
|
||||
b = MASK( 2 );
|
||||
ASSERT( !vid.addmap[index2 | index1] );
|
||||
|
||||
vid.addmap[index2|index1] = r << (2 + 3) | g << 2 | b;
|
||||
r = r1 * r2 / MASK(3);
|
||||
g = g1 * g2 / MASK(3);
|
||||
b = b1 * b2 / MASK(2);
|
||||
vid.addmap[index2 | index1] = r << ( 2 + 3 ) | g << 2 | b;
|
||||
r = r1 * r2 / MASK( 3 );
|
||||
g = g1 * g2 / MASK( 3 );
|
||||
b = b1 * b2 / MASK( 2 );
|
||||
|
||||
vid.modmap[index2|index1] = r << (2 + 3) | g << 2 | b;
|
||||
vid.modmap[index2 | index1] = r << ( 2 + 3 ) | g << 2 | b;
|
||||
}
|
||||
for( i = 0; i < 8192; i++ )
|
||||
{
|
||||
unsigned int r, g, b;
|
||||
uint color = i << 3;
|
||||
uint m = color >> 8;
|
||||
uint j = color & 0xff;
|
||||
unsigned int r, g, b;
|
||||
uint color = i << 3;
|
||||
uint m = color >> 8;
|
||||
uint j = color & 0xff;
|
||||
unsigned short index1 = i;
|
||||
|
||||
r1 = ((m >> (8 - 3) )<< 2 ) & MASK(5);
|
||||
g1 = ((m >> (8 - 3 - 3)) << 3) & MASK(6);
|
||||
b1 = ((m >> (8 - 3 - 3 - 2)) << 3) & MASK(5);
|
||||
r1 |= MOVE_BIT(j, 5, 1) | MOVE_BIT(j, 2, 0);
|
||||
g1 |= MOVE_BIT(j, 7, 2) | MOVE_BIT(j, 4, 1) | MOVE_BIT(j, 1, 0);
|
||||
b1 |= MOVE_BIT(j, 6, 2) | MOVE_BIT(j, 3, 1) | MOVE_BIT(j, 0, 0);
|
||||
r1 = (( m >> ( 8 - 3 )) << 2 ) & MASK( 5 );
|
||||
g1 = (( m >> ( 8 - 3 - 3 )) << 3 ) & MASK( 6 );
|
||||
b1 = (( m >> ( 8 - 3 - 3 - 2 )) << 3 ) & MASK( 5 );
|
||||
r1 |= MOVE_BIT( j, 5, 1 ) | MOVE_BIT( j, 2, 0 );
|
||||
g1 |= MOVE_BIT( j, 7, 2 ) | MOVE_BIT( j, 4, 1 ) | MOVE_BIT( j, 1, 0 );
|
||||
b1 |= MOVE_BIT( j, 6, 2 ) | MOVE_BIT( j, 3, 1 ) | MOVE_BIT( j, 0, 0 );
|
||||
|
||||
|
||||
for( j = 0; j < 32; j++)
|
||||
for( j = 0; j < 32; j++ )
|
||||
{
|
||||
unsigned int index2 = j << 13;
|
||||
unsigned int major, minor;
|
||||
r = r1 * j / 32;
|
||||
g = g1 * j / 32;
|
||||
b = b1 * j / 32;
|
||||
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
|
||||
major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
|
||||
|
||||
// save minor GBRGBRGB
|
||||
minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0);
|
||||
minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
|
||||
|
||||
vid.colormap[index2|index1] = major << 8 | (minor & 0xFF);
|
||||
vid.colormap[index2 | index1] = major << 8 | ( minor & 0xFF );
|
||||
}
|
||||
}
|
||||
|
||||
for( i = 0; i < 1024; i++ )
|
||||
{
|
||||
unsigned int r, g, b;
|
||||
uint color = i << 6 | BIT(5) | BIT(4) | BIT(3);
|
||||
uint m = color >> 8;
|
||||
uint j = color & 0xff;
|
||||
unsigned int r, g, b;
|
||||
uint color = i << 6 | BIT( 5 ) | BIT( 4 ) | BIT( 3 );
|
||||
uint m = color >> 8;
|
||||
uint j = color & 0xff;
|
||||
unsigned short index1 = i;
|
||||
|
||||
r1 = ((m >> (8 - 3) )<< 2 ) & MASK(5);
|
||||
g1 = ((m >> (8 - 3 - 3)) << 3) & MASK(6);
|
||||
b1 = ((m >> (8 - 3 - 3 - 2)) << 3) & MASK(5);
|
||||
r1 |= MOVE_BIT(j, 5, 1) | MOVE_BIT(j, 2, 0);
|
||||
g1 |= MOVE_BIT(j, 7, 2) | MOVE_BIT(j, 4, 1) | MOVE_BIT(j, 1, 0);
|
||||
b1 |= MOVE_BIT(j, 6, 2) | MOVE_BIT(j, 3, 1) | MOVE_BIT(j, 0, 0);
|
||||
r1 = (( m >> ( 8 - 3 )) << 2 ) & MASK( 5 );
|
||||
g1 = (( m >> ( 8 - 3 - 3 )) << 3 ) & MASK( 6 );
|
||||
b1 = (( m >> ( 8 - 3 - 3 - 2 )) << 3 ) & MASK( 5 );
|
||||
r1 |= MOVE_BIT( j, 5, 1 ) | MOVE_BIT( j, 2, 0 );
|
||||
g1 |= MOVE_BIT( j, 7, 2 ) | MOVE_BIT( j, 4, 1 ) | MOVE_BIT( j, 1, 0 );
|
||||
b1 |= MOVE_BIT( j, 6, 2 ) | MOVE_BIT( j, 3, 1 ) | MOVE_BIT( j, 0, 0 );
|
||||
|
||||
|
||||
FOR_EACH_COLOR(2)
|
||||
FOR_EACH_COLOR( 2 )
|
||||
{
|
||||
unsigned int index2 = (r2 << (2 + 3) | g2 << 2 | b2) << 10;
|
||||
unsigned int index2 = ( r2 << ( 2 + 3 ) | g2 << 2 | b2 ) << 10;
|
||||
unsigned int k;
|
||||
for( k = 0; k < 3; k++ )
|
||||
{
|
||||
|
@ -586,25 +587,25 @@ static void R_BuildBlendMaps( void )
|
|||
unsigned int a = k + 2;
|
||||
|
||||
|
||||
r = r1 * (7 - a) / 7 + (r2 << 2 | BIT(2)) * a / 7;
|
||||
g = g1 * (7 - a) / 7 + (g2 << 3 | MASK(2)) * a / 7;
|
||||
b = b1 * (7 - a) / 7 + (b2 << 3 | MASK(2)) * a / 7;
|
||||
if( r > MASK(5) )
|
||||
r = MASK(5);
|
||||
if( g > MASK(6) )
|
||||
g = MASK(6);
|
||||
if( b > MASK(5) )
|
||||
b = MASK(5);
|
||||
r = r1 * ( 7 - a ) / 7 + ( r2 << 2 | BIT( 2 )) * a / 7;
|
||||
g = g1 * ( 7 - a ) / 7 + ( g2 << 3 | MASK( 2 )) * a / 7;
|
||||
b = b1 * ( 7 - a ) / 7 + ( b2 << 3 | MASK( 2 )) * a / 7;
|
||||
if( r > MASK( 5 ))
|
||||
r = MASK( 5 );
|
||||
if( g > MASK( 6 ))
|
||||
g = MASK( 6 );
|
||||
if( b > MASK( 5 ))
|
||||
b = MASK( 5 );
|
||||
|
||||
|
||||
ASSERT( b < 32 );
|
||||
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
|
||||
major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
|
||||
|
||||
// save minor GBRGBRGB
|
||||
minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0);
|
||||
minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
|
||||
minor = minor & ~0x3f;
|
||||
|
||||
vid.alphamap[k << 18|index2|index1] = major << 8 | (minor & 0xFF);
|
||||
vid.alphamap[k << 18 | index2 | index1] = major << 8 | ( minor & 0xFF );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -661,7 +662,7 @@ static qboolean R_AllocScreen( void )
|
|||
}
|
||||
|
||||
if( !swblit.pCreateBuffer( w, h, &swblit.stride, &swblit.bpp,
|
||||
&swblit.rmask, &swblit.gmask, &swblit.bmask ))
|
||||
&swblit.rmask, &swblit.gmask, &swblit.bmask ))
|
||||
return false;
|
||||
|
||||
R_BuildScreenMap();
|
||||
|
@ -670,40 +671,40 @@ static qboolean R_AllocScreen( void )
|
|||
vid.rowbytes = gpGlobals->width; // rowpixels
|
||||
if( d_pzbuffer )
|
||||
free( d_pzbuffer );
|
||||
d_pzbuffer = malloc( vid.width*vid.height*2 + 64 );
|
||||
d_pzbuffer = malloc( vid.width * vid.height * 2 + 64 );
|
||||
|
||||
if( vid.buffer )
|
||||
free( vid.buffer );
|
||||
vid.buffer = malloc( vid.width * vid.height*sizeof( pixel_t ) );
|
||||
vid.buffer = malloc( vid.width * vid.height * sizeof( pixel_t ));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void R_BlitScreen( void )
|
||||
{
|
||||
int u, v;
|
||||
int u, v;
|
||||
void *buffer = swblit.pLockBuffer();
|
||||
// gEngfuncs.Con_Printf("blit begin\n");
|
||||
//memset( vid.buffer, 10, vid.width * vid.height );
|
||||
// memset( vid.buffer, 10, vid.width * vid.height );
|
||||
|
||||
if( !buffer || gpGlobals->width != vid.width || gpGlobals->height != vid.height )
|
||||
{
|
||||
gEngfuncs.Con_Printf("pre allocscrn\n");
|
||||
gEngfuncs.Con_Printf( "pre allocscrn\n" );
|
||||
R_AllocScreen();
|
||||
gEngfuncs.Con_Printf("post allocscrn\n");
|
||||
gEngfuncs.Con_Printf( "post allocscrn\n" );
|
||||
return;
|
||||
}
|
||||
//return;
|
||||
//byte *buf = vid.buffer;
|
||||
// return;
|
||||
// byte *buf = vid.buffer;
|
||||
|
||||
//#pragma omp parallel for schedule(static)
|
||||
//gEngfuncs.Con_Printf("swblit %d %d", swblit.bpp, vid.height );
|
||||
// #pragma omp parallel for schedule(static)
|
||||
// gEngfuncs.Con_Printf("swblit %d %d", swblit.bpp, vid.height );
|
||||
if( swblit.rotate )
|
||||
{
|
||||
if( swblit.bpp == 2 )
|
||||
{
|
||||
unsigned short *pbuf = buffer;
|
||||
for( v = 0; v < vid.height;v++)
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint d = swblit.stride - v - 1;
|
||||
|
@ -720,7 +721,7 @@ void R_BlitScreen( void )
|
|||
{
|
||||
unsigned int *pbuf = buffer;
|
||||
|
||||
for( v = 0; v < vid.height;v++)
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint d = swblit.stride - v - 1;
|
||||
|
@ -736,7 +737,7 @@ void R_BlitScreen( void )
|
|||
else if( swblit.bpp == 3 )
|
||||
{
|
||||
byte *pbuf = buffer;
|
||||
for( v = 0; v < vid.height;v++)
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint d = swblit.stride - v - 1;
|
||||
|
@ -744,11 +745,11 @@ void R_BlitScreen( void )
|
|||
for( u = 0; u < vid.width; u++ )
|
||||
{
|
||||
unsigned int s = vid.screen32[vid.buffer[start + u]];
|
||||
pbuf[(d)*3] = s;
|
||||
pbuf[( d ) * 3] = s;
|
||||
s = s >> 8;
|
||||
pbuf[(d)*3+1] = s;
|
||||
pbuf[( d ) * 3 + 1] = s;
|
||||
s = s >> 8;
|
||||
pbuf[(d)*3+2] = s;
|
||||
pbuf[( d ) * 3 + 2] = s;
|
||||
d += swblit.stride;
|
||||
}
|
||||
}
|
||||
|
@ -759,7 +760,7 @@ void R_BlitScreen( void )
|
|||
if( swblit.bpp == 2 )
|
||||
{
|
||||
unsigned short *pbuf = buffer;
|
||||
for( v = 0; v < vid.height;v++)
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint dstart = swblit.stride * v;
|
||||
|
@ -775,7 +776,7 @@ void R_BlitScreen( void )
|
|||
{
|
||||
unsigned int *pbuf = buffer;
|
||||
|
||||
for( v = 0; v < vid.height;v++)
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint dstart = swblit.stride * v;
|
||||
|
@ -790,7 +791,7 @@ void R_BlitScreen( void )
|
|||
else if( swblit.bpp == 3 )
|
||||
{
|
||||
byte *pbuf = buffer;
|
||||
for( v = 0; v < vid.height;v++)
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * v;
|
||||
uint dstart = swblit.stride * v;
|
||||
|
@ -798,11 +799,11 @@ void R_BlitScreen( void )
|
|||
for( u = 0; u < vid.width; u++ )
|
||||
{
|
||||
unsigned int s = vid.screen32[vid.buffer[start + u]];
|
||||
pbuf[(dstart+u)*3] = s;
|
||||
pbuf[( dstart + u ) * 3] = s;
|
||||
s = s >> 8;
|
||||
pbuf[(dstart+u)*3+1] = s;
|
||||
pbuf[( dstart + u ) * 3 + 1] = s;
|
||||
s = s >> 8;
|
||||
pbuf[(dstart+u)*3+2] = s;
|
||||
pbuf[( dstart + u ) * 3 + 2] = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -822,8 +823,8 @@ static uint32_t Get8888PixelAt( int u, int start )
|
|||
pixel_t color = vid.screen[vid.buffer[start + u]];
|
||||
uint8_t c[3];
|
||||
c[0] = (((( color >> 11 ) & 0x1F ) * 527 ) + 23 ) >> 6;
|
||||
c[1] = (((( color >> 5 ) & 0x3F ) * 259 ) + 33 ) >> 6;
|
||||
c[2] = (((( color ) & 0x1F ) * 527 ) + 23 ) >> 6;
|
||||
c[1] = (((( color >> 5 ) & 0x3F ) * 259 ) + 33 ) >> 6;
|
||||
c[2] = (((( color ) & 0x1F ) * 527 ) + 23 ) >> 6;
|
||||
|
||||
s = c[0] << 16 | c[1] << 8 | c[2];
|
||||
break;
|
||||
|
@ -840,13 +841,13 @@ static uint32_t Get8888PixelAt( int u, int start )
|
|||
qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
|
||||
{
|
||||
rgbdata_t *r_shot;
|
||||
uint flags = IMAGE_FLIP_Y;
|
||||
int width = 0, height = 0, u, v;
|
||||
qboolean result;
|
||||
uint flags = IMAGE_FLIP_Y;
|
||||
int width = 0, height = 0, u, v;
|
||||
qboolean result;
|
||||
|
||||
r_shot = Mem_Calloc( r_temppool, sizeof( rgbdata_t ));
|
||||
r_shot->width = (vid.width + 3) & ~3;
|
||||
r_shot->height = (vid.height + 3) & ~3;
|
||||
r_shot->width = ( vid.width + 3 ) & ~3;
|
||||
r_shot->height = ( vid.height + 3 ) & ~3;
|
||||
r_shot->flags = IMAGE_HAS_COLOR;
|
||||
r_shot->type = PF_BGRA_32; // was RGBA
|
||||
r_shot->size = r_shot->width * r_shot->height * gEngfuncs.Image_GetPFDesc( r_shot->type )->bpp;
|
||||
|
@ -874,7 +875,7 @@ qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
|
|||
{
|
||||
uint32_t *pbuf = (uint32_t *)r_shot->buffer;
|
||||
|
||||
for( v = 0; v < vid.height;v++)
|
||||
for( v = 0; v < vid.height; v++ )
|
||||
{
|
||||
uint start = vid.rowbytes * ( vid.height - v );
|
||||
uint dstart = swblit.stride * v;
|
||||
|
@ -900,7 +901,7 @@ qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
|
|||
width = Q_rint( height * ((double)r_shot->width / r_shot->height ));
|
||||
break;
|
||||
case VID_MAPSHOT:
|
||||
flags |= IMAGE_RESAMPLE|IMAGE_QUANTIZE; // GoldSrc request overviews in 8-bit format
|
||||
flags |= IMAGE_RESAMPLE | IMAGE_QUANTIZE; // GoldSrc request overviews in 8-bit format
|
||||
height = 768;
|
||||
width = 1024;
|
||||
break;
|
||||
|
@ -910,7 +911,7 @@ qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
|
|||
|
||||
// write image
|
||||
result = gEngfuncs.FS_SaveImage( filename, r_shot );
|
||||
gEngfuncs.fsapi->AllowDirectPaths( false ); // always reset after store screenshot
|
||||
gEngfuncs.fsapi->AllowDirectPaths( false ); // always reset after store screenshot
|
||||
gEngfuncs.FS_FreeImage( r_shot );
|
||||
|
||||
return result;
|
||||
|
|
|
@ -15,13 +15,13 @@ GNU General Public License for more details.
|
|||
|
||||
#include "r_local.h"
|
||||
|
||||
#define TEXTURES_HASH_SIZE (MAX_TEXTURES >> 2)
|
||||
#define TEXTURES_HASH_SIZE ( MAX_TEXTURES >> 2 )
|
||||
|
||||
static image_t r_images[MAX_TEXTURES];
|
||||
static image_t* r_imagesHashTable[TEXTURES_HASH_SIZE];
|
||||
static uint r_numImages;
|
||||
static image_t r_images[MAX_TEXTURES];
|
||||
static image_t *r_imagesHashTable[TEXTURES_HASH_SIZE];
|
||||
static uint r_numImages;
|
||||
|
||||
#define IsLightMap( tex ) ( FBitSet(( tex )->flags, TF_ATLAS_PAGE ))
|
||||
#define IsLightMap( tex ) ( FBitSet(( tex )->flags, TF_ATLAS_PAGE ))
|
||||
/*
|
||||
=================
|
||||
R_GetTexture
|
||||
|
@ -42,17 +42,17 @@ GL_Bind
|
|||
*/
|
||||
void GAME_EXPORT GL_Bind( int tmu, unsigned int texnum )
|
||||
{
|
||||
image_t *image;
|
||||
image_t *image;
|
||||
|
||||
image = &r_images[texnum];
|
||||
//vid.rendermode = kRenderNormal;
|
||||
// vid.rendermode = kRenderNormal;
|
||||
|
||||
if( vid.rendermode == kRenderNormal )
|
||||
{
|
||||
r_affinetridesc.pskin = image->pixels[0];
|
||||
d_pdrawspans = R_PolysetFillSpans8 ;
|
||||
d_pdrawspans = R_PolysetFillSpans8;
|
||||
}
|
||||
else if( vid.rendermode == kRenderTransAdd)
|
||||
else if( vid.rendermode == kRenderTransAdd )
|
||||
{
|
||||
r_affinetridesc.pskin = image->pixels[0];
|
||||
d_pdrawspans = R_PolysetDrawSpansAdditive;
|
||||
|
@ -95,11 +95,12 @@ GL_UpdateTextureParams
|
|||
*/
|
||||
static void GL_UpdateTextureParams( int iTexture )
|
||||
{
|
||||
image_t *tex = &r_images[iTexture];
|
||||
image_t *tex = &r_images[iTexture];
|
||||
|
||||
Assert( tex != NULL );
|
||||
|
||||
if( !tex->pixels) return; // free slot
|
||||
if( !tex->pixels )
|
||||
return; // free slot
|
||||
|
||||
GL_Bind( XASH_TEXTURE0, iTexture );
|
||||
}
|
||||
|
@ -111,7 +112,7 @@ R_SetTextureParameters
|
|||
*/
|
||||
void R_SetTextureParameters( void )
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
// change all the existing mipmapped texture objects
|
||||
for( i = 0; i < r_numImages; i++ )
|
||||
|
@ -126,7 +127,7 @@ GL_CalcImageSize
|
|||
*/
|
||||
static size_t GL_CalcImageSize( pixformat_t format, int width, int height, int depth )
|
||||
{
|
||||
size_t size = 0;
|
||||
size_t size = 0;
|
||||
|
||||
// check the depth error
|
||||
depth = Q_max( 1, depth );
|
||||
|
@ -142,12 +143,12 @@ static size_t GL_CalcImageSize( pixformat_t format, int width, int height, int d
|
|||
size = width * height * depth * 4;
|
||||
break;
|
||||
case PF_DXT1:
|
||||
size = (((width + 3) >> 2) * ((height + 3) >> 2) * 8) * depth;
|
||||
size = ((( width + 3 ) >> 2 ) * (( height + 3 ) >> 2 ) * 8 ) * depth;
|
||||
break;
|
||||
case PF_DXT3:
|
||||
case PF_DXT5:
|
||||
case PF_ATI2:
|
||||
size = (((width + 3) >> 2) * ((height + 3) >> 2) * 16) * depth;
|
||||
size = ((( width + 3 ) >> 2 ) * (( height + 3 ) >> 2 ) * 16 ) * depth;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -166,8 +167,8 @@ static size_t GL_CalcTextureSize( int width, int height, int depth )
|
|||
|
||||
static int GL_CalcMipmapCount( image_t *tex, qboolean haveBuffer )
|
||||
{
|
||||
int width, height;
|
||||
int mipcount;
|
||||
int width, height;
|
||||
int mipcount;
|
||||
|
||||
Assert( tex != NULL );
|
||||
|
||||
|
@ -197,8 +198,8 @@ GL_SetTextureDimensions
|
|||
*/
|
||||
static void GL_SetTextureDimensions( image_t *tex, int width, int height, int depth )
|
||||
{
|
||||
int maxTextureSize = 1024;
|
||||
int maxDepthSize = 1;
|
||||
int maxTextureSize = 1024;
|
||||
int maxDepthSize = 1;
|
||||
|
||||
Assert( tex != NULL );
|
||||
|
||||
|
@ -246,11 +247,11 @@ GL_SetTextureFormat
|
|||
*/
|
||||
static void GL_SetTextureFormat( image_t *tex, pixformat_t format, int channelMask )
|
||||
{
|
||||
qboolean haveColor = ( channelMask & IMAGE_HAS_COLOR );
|
||||
qboolean haveAlpha = ( channelMask & IMAGE_HAS_ALPHA );
|
||||
qboolean haveColor = ( channelMask & IMAGE_HAS_COLOR );
|
||||
qboolean haveAlpha = ( channelMask & IMAGE_HAS_ALPHA );
|
||||
|
||||
Assert( tex != NULL );
|
||||
//tex->transparent = !!( channelMask & IMAGE_HAS_ALPHA );
|
||||
// tex->transparent = !!( channelMask & IMAGE_HAS_ALPHA );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -262,16 +263,17 @@ Assume input buffer is RGBA
|
|||
*/
|
||||
byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int outWidth, int outHeight, qboolean isNormalMap )
|
||||
{
|
||||
uint frac, fracStep;
|
||||
uint *in = (uint *)source;
|
||||
uint p1[0x1000], p2[0x1000];
|
||||
byte *pix1, *pix2, *pix3, *pix4;
|
||||
uint *out, *inRow1, *inRow2;
|
||||
static byte *scaledImage = NULL; // pointer to a scaled image
|
||||
vec3_t normal;
|
||||
int i, x, y;
|
||||
uint frac, fracStep;
|
||||
uint *in = (uint *)source;
|
||||
uint p1[0x1000], p2[0x1000];
|
||||
byte *pix1, *pix2, *pix3, *pix4;
|
||||
uint *out, *inRow1, *inRow2;
|
||||
static byte *scaledImage = NULL; // pointer to a scaled image
|
||||
vec3_t normal;
|
||||
int i, x, y;
|
||||
|
||||
if( !source ) return NULL;
|
||||
if( !source )
|
||||
return NULL;
|
||||
|
||||
scaledImage = Mem_Realloc( r_temppool, scaledImage, outWidth * outHeight * 4 );
|
||||
fracStep = inWidth * 0x10000 / outWidth;
|
||||
|
@ -280,14 +282,14 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
|
|||
frac = fracStep >> 2;
|
||||
for( i = 0; i < outWidth; i++ )
|
||||
{
|
||||
p1[i] = 4 * (frac >> 16);
|
||||
p1[i] = 4 * ( frac >> 16 );
|
||||
frac += fracStep;
|
||||
}
|
||||
|
||||
frac = (fracStep >> 2) * 3;
|
||||
frac = ( fracStep >> 2 ) * 3;
|
||||
for( i = 0; i < outWidth; i++ )
|
||||
{
|
||||
p2[i] = 4 * (frac >> 16);
|
||||
p2[i] = 4 * ( frac >> 16 );
|
||||
frac += fracStep;
|
||||
}
|
||||
|
||||
|
@ -295,8 +297,8 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
|
|||
{
|
||||
for( y = 0; y < outHeight; y++, out += outWidth )
|
||||
{
|
||||
inRow1 = in + inWidth * (int)(((float)y + 0.25f) * inHeight / outHeight);
|
||||
inRow2 = in + inWidth * (int)(((float)y + 0.75f) * inHeight / outHeight);
|
||||
inRow1 = in + inWidth * (int)(((float)y + 0.25f ) * inHeight / outHeight );
|
||||
inRow2 = in + inWidth * (int)(((float)y + 0.75f ) * inHeight / outHeight );
|
||||
|
||||
for( x = 0; x < outWidth; x++ )
|
||||
{
|
||||
|
@ -312,10 +314,10 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
|
|||
if( !VectorNormalizeLength( normal ))
|
||||
VectorSet( normal, 0.5f, 0.5f, 1.0f );
|
||||
|
||||
((byte *)(out+x))[0] = 128 + (byte)(127.0f * normal[0]);
|
||||
((byte *)(out+x))[1] = 128 + (byte)(127.0f * normal[1]);
|
||||
((byte *)(out+x))[2] = 128 + (byte)(127.0f * normal[2]);
|
||||
((byte *)(out+x))[3] = 255;
|
||||
((byte *)( out + x ))[0] = 128 + (byte)( 127.0f * normal[0] );
|
||||
((byte *)( out + x ))[1] = 128 + (byte)( 127.0f * normal[1] );
|
||||
((byte *)( out + x ))[2] = 128 + (byte)( 127.0f * normal[2] );
|
||||
((byte *)( out + x ))[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -323,8 +325,8 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
|
|||
{
|
||||
for( y = 0; y < outHeight; y++, out += outWidth )
|
||||
{
|
||||
inRow1 = in + inWidth * (int)(((float)y + 0.25f) * inHeight / outHeight);
|
||||
inRow2 = in + inWidth * (int)(((float)y + 0.75f) * inHeight / outHeight);
|
||||
inRow1 = in + inWidth * (int)(((float)y + 0.25f ) * inHeight / outHeight );
|
||||
inRow2 = in + inWidth * (int)(((float)y + 0.75f ) * inHeight / outHeight );
|
||||
|
||||
for( x = 0; x < outWidth; x++ )
|
||||
{
|
||||
|
@ -333,10 +335,10 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
|
|||
pix3 = (byte *)inRow2 + p1[x];
|
||||
pix4 = (byte *)inRow2 + p2[x];
|
||||
|
||||
((byte *)(out+x))[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0]) >> 2;
|
||||
((byte *)(out+x))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1]) >> 2;
|
||||
((byte *)(out+x))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2]) >> 2;
|
||||
((byte *)(out+x))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3]) >> 2;
|
||||
((byte *)( out + x ))[0] = ( pix1[0] + pix2[0] + pix3[0] + pix4[0] ) >> 2;
|
||||
((byte *)( out + x ))[1] = ( pix1[1] + pix2[1] + pix3[1] + pix4[1] ) >> 2;
|
||||
((byte *)( out + x ))[2] = ( pix1[2] + pix2[2] + pix3[2] + pix4[2] ) >> 2;
|
||||
((byte *)( out + x ))[3] = ( pix1[3] + pix2[3] + pix3[3] + pix4[3] ) >> 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -353,10 +355,10 @@ box filter 3x3
|
|||
*/
|
||||
static void GL_BoxFilter3x3( byte *out, const byte *in, int w, int h, int x, int y )
|
||||
{
|
||||
int r = 0, g = 0, b = 0, a = 0;
|
||||
int count = 0, acount = 0;
|
||||
int i, j, u, v;
|
||||
const byte *pixel;
|
||||
int r = 0, g = 0, b = 0, a = 0;
|
||||
int count = 0, acount = 0;
|
||||
int i, j, u, v;
|
||||
const byte *pixel;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
|
@ -382,7 +384,7 @@ static void GL_BoxFilter3x3( byte *out, const byte *in, int w, int h, int x, int
|
|||
}
|
||||
}
|
||||
|
||||
if( acount == 0 )
|
||||
if( acount == 0 )
|
||||
acount = 1;
|
||||
|
||||
out[0] = r / acount;
|
||||
|
@ -400,11 +402,11 @@ Apply box-filter to 1-bit alpha
|
|||
*/
|
||||
static byte *GL_ApplyFilter( const byte *source, int width, int height )
|
||||
{
|
||||
byte *in = (byte *)source;
|
||||
byte *out = (byte *)source;
|
||||
int i;
|
||||
byte *in = (byte *)source;
|
||||
byte *out = (byte *)source;
|
||||
int i;
|
||||
|
||||
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) )
|
||||
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
|
||||
return in;
|
||||
|
||||
for( i = 0; source && i < width * height; i++, in += 4 )
|
||||
|
@ -425,13 +427,14 @@ Operates in place, quartering the size of the texture
|
|||
*/
|
||||
static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth, int flags )
|
||||
{
|
||||
byte *out = in;
|
||||
int instride = ALIGN( srcWidth * 4, 1 );
|
||||
int mipWidth, mipHeight, outpadding;
|
||||
int row, x, y, z;
|
||||
vec3_t normal;
|
||||
byte *out = in;
|
||||
int instride = ALIGN( srcWidth * 4, 1 );
|
||||
int mipWidth, mipHeight, outpadding;
|
||||
int row, x, y, z;
|
||||
vec3_t normal;
|
||||
|
||||
if( !in ) return;
|
||||
if( !in )
|
||||
return;
|
||||
|
||||
mipWidth = Q_max( 1, ( srcWidth >> 1 ));
|
||||
mipHeight = Q_max( 1, ( srcHeight >> 1 ));
|
||||
|
@ -456,26 +459,26 @@ static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth,
|
|||
{
|
||||
if((( x << 1 ) + 1 ) < srcWidth )
|
||||
{
|
||||
normal[0] = MAKE_SIGNED( in[row+0] ) + MAKE_SIGNED( in[row+4] )
|
||||
+ MAKE_SIGNED( next[row+0] ) + MAKE_SIGNED( next[row+4] );
|
||||
normal[1] = MAKE_SIGNED( in[row+1] ) + MAKE_SIGNED( in[row+5] )
|
||||
+ MAKE_SIGNED( next[row+1] ) + MAKE_SIGNED( next[row+5] );
|
||||
normal[2] = MAKE_SIGNED( in[row+2] ) + MAKE_SIGNED( in[row+6] )
|
||||
+ MAKE_SIGNED( next[row+2] ) + MAKE_SIGNED( next[row+6] );
|
||||
normal[0] = MAKE_SIGNED( in[row + 0] ) + MAKE_SIGNED( in[row + 4] )
|
||||
+ MAKE_SIGNED( next[row + 0] ) + MAKE_SIGNED( next[row + 4] );
|
||||
normal[1] = MAKE_SIGNED( in[row + 1] ) + MAKE_SIGNED( in[row + 5] )
|
||||
+ MAKE_SIGNED( next[row + 1] ) + MAKE_SIGNED( next[row + 5] );
|
||||
normal[2] = MAKE_SIGNED( in[row + 2] ) + MAKE_SIGNED( in[row + 6] )
|
||||
+ MAKE_SIGNED( next[row + 2] ) + MAKE_SIGNED( next[row + 6] );
|
||||
}
|
||||
else
|
||||
{
|
||||
normal[0] = MAKE_SIGNED( in[row+0] ) + MAKE_SIGNED( next[row+0] );
|
||||
normal[1] = MAKE_SIGNED( in[row+1] ) + MAKE_SIGNED( next[row+1] );
|
||||
normal[2] = MAKE_SIGNED( in[row+2] ) + MAKE_SIGNED( next[row+2] );
|
||||
normal[0] = MAKE_SIGNED( in[row + 0] ) + MAKE_SIGNED( next[row + 0] );
|
||||
normal[1] = MAKE_SIGNED( in[row + 1] ) + MAKE_SIGNED( next[row + 1] );
|
||||
normal[2] = MAKE_SIGNED( in[row + 2] ) + MAKE_SIGNED( next[row + 2] );
|
||||
}
|
||||
|
||||
if( !VectorNormalizeLength( normal ))
|
||||
VectorSet( normal, 0.5f, 0.5f, 1.0f );
|
||||
|
||||
out[0] = 128 + (byte)(127.0f * normal[0]);
|
||||
out[1] = 128 + (byte)(127.0f * normal[1]);
|
||||
out[2] = 128 + (byte)(127.0f * normal[2]);
|
||||
out[0] = 128 + (byte)( 127.0f * normal[0] );
|
||||
out[1] = 128 + (byte)( 127.0f * normal[1] );
|
||||
out[2] = 128 + (byte)( 127.0f * normal[2] );
|
||||
out[3] = 255;
|
||||
}
|
||||
}
|
||||
|
@ -489,17 +492,17 @@ static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth,
|
|||
{
|
||||
if((( x << 1 ) + 1 ) < srcWidth )
|
||||
{
|
||||
out[0] = (in[row+0] + in[row+4] + next[row+0] + next[row+4]) >> 2;
|
||||
out[1] = (in[row+1] + in[row+5] + next[row+1] + next[row+5]) >> 2;
|
||||
out[2] = (in[row+2] + in[row+6] + next[row+2] + next[row+6]) >> 2;
|
||||
out[3] = (in[row+3] + in[row+7] + next[row+3] + next[row+7]) >> 2;
|
||||
out[0] = ( in[row + 0] + in[row + 4] + next[row + 0] + next[row + 4] ) >> 2;
|
||||
out[1] = ( in[row + 1] + in[row + 5] + next[row + 1] + next[row + 5] ) >> 2;
|
||||
out[2] = ( in[row + 2] + in[row + 6] + next[row + 2] + next[row + 6] ) >> 2;
|
||||
out[3] = ( in[row + 3] + in[row + 7] + next[row + 3] + next[row + 7] ) >> 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
out[0] = (in[row+0] + next[row+0]) >> 1;
|
||||
out[1] = (in[row+1] + next[row+1]) >> 1;
|
||||
out[2] = (in[row+2] + next[row+2]) >> 1;
|
||||
out[3] = (in[row+3] + next[row+3]) >> 1;
|
||||
out[0] = ( in[row + 0] + next[row + 0] ) >> 1;
|
||||
out[1] = ( in[row + 1] + next[row + 1] ) >> 1;
|
||||
out[2] = ( in[row + 2] + next[row + 2] ) >> 1;
|
||||
out[3] = ( in[row + 3] + next[row + 3] ) >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,14 +519,14 @@ upload texture into video memory
|
|||
*/
|
||||
static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
|
||||
{
|
||||
byte *buf, *data;
|
||||
size_t texsize, size;
|
||||
uint width, height;
|
||||
uint i, j, numSides;
|
||||
uint offset = 0;
|
||||
qboolean normalMap = false;
|
||||
const byte *bufend;
|
||||
int mipCount;
|
||||
byte *buf, *data;
|
||||
size_t texsize, size;
|
||||
uint width, height;
|
||||
uint i, j, numSides;
|
||||
uint offset = 0;
|
||||
qboolean normalMap = false;
|
||||
const byte *bufend;
|
||||
int mipCount;
|
||||
|
||||
tex->fogParams[0] = pic->fogParams[0];
|
||||
tex->fogParams[1] = pic->fogParams[1];
|
||||
|
@ -532,7 +535,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
|
|||
GL_SetTextureDimensions( tex, pic->width, pic->height, pic->depth );
|
||||
GL_SetTextureFormat( tex, pic->type, pic->flags );
|
||||
|
||||
//gEngfuncs.Con_Printf("%s %d %d\n", tex->name, tex->width, tex->height );
|
||||
// gEngfuncs.Con_Printf("%s %d %d\n", tex->name, tex->width, tex->height );
|
||||
|
||||
Assert( pic != NULL );
|
||||
Assert( tex != NULL );
|
||||
|
@ -542,59 +545,60 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
|
|||
|
||||
buf = pic->buffer;
|
||||
|
||||
mipCount = 4;//GL_CalcMipmapCount( tex, ( buf != NULL ));
|
||||
mipCount = 4; // GL_CalcMipmapCount( tex, ( buf != NULL ));
|
||||
|
||||
// NOTE: only single uncompressed textures can be resamples, no mips, no layers, no sides
|
||||
if((( pic->width != tex->width ) || ( pic->height != tex->height )))
|
||||
data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap );
|
||||
else data = buf;
|
||||
else
|
||||
data = buf;
|
||||
|
||||
//if( !ImageCompressed( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
|
||||
// if( !ImageCompressed( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
|
||||
// data = GL_ApplyFilter( data, tex->width, tex->height );
|
||||
|
||||
// mips will be auto-generated if desired
|
||||
for( j = 0; j < mipCount; j++ )
|
||||
{
|
||||
int x, y;
|
||||
int x, y;
|
||||
width = Q_max( 1, ( tex->width >> j ));
|
||||
height = Q_max( 1, ( tex->height >> j ));
|
||||
texsize = GL_CalcTextureSize( width, height, tex->depth );
|
||||
size = GL_CalcImageSize( pic->type, width, height, tex->depth );
|
||||
//GL_TextureImageRAW( tex, i, j, width, height, tex->depth, pic->type, data );
|
||||
// GL_TextureImageRAW( tex, i, j, width, height, tex->depth, pic->type, data );
|
||||
// increase size to workaround triangle renderer bugs
|
||||
// it seems to assume memory readable. maybe it was pointed to WAD?
|
||||
//tex->pixels[j] = (byte*)Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) + 1024 ) + 512;
|
||||
tex->pixels[j] = (pixel_t*)Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) );
|
||||
// tex->pixels[j] = (byte*)Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) + 1024 ) + 512;
|
||||
tex->pixels[j] = (pixel_t *)Mem_Calloc( r_temppool, width * height * sizeof( pixel_t ));
|
||||
|
||||
|
||||
//memset( (byte*)tex->pixels[j] - 512, 0xFF, 512 );
|
||||
//memset( (byte*)tex->pixels[j] + width * height * sizeof(pixel_t), 0xFF, 512 );
|
||||
// memset( (byte*)tex->pixels[j] - 512, 0xFF, 512 );
|
||||
// memset( (byte*)tex->pixels[j] + width * height * sizeof(pixel_t), 0xFF, 512 );
|
||||
|
||||
if( j == 0 && tex->flags & TF_HAS_ALPHA )
|
||||
tex->alpha_pixels = (pixel_t*)Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) );
|
||||
if( j == 0 && tex->flags & TF_HAS_ALPHA )
|
||||
tex->alpha_pixels = (pixel_t *)Mem_Calloc( r_temppool, width * height * sizeof( pixel_t ));
|
||||
|
||||
for(i = 0; i < height * width; i++ )
|
||||
for( i = 0; i < height * width; i++ )
|
||||
{
|
||||
unsigned int r, g, b, major, minor;
|
||||
// seems to look better
|
||||
r = data[i * 4 + 0] * BIT(5) / 256;
|
||||
g = data[i * 4 + 1] * BIT(6) / 256;
|
||||
b = data[i * 4 + 2] * BIT(5) / 256;
|
||||
unsigned int r, g, b, major, minor;
|
||||
// seems to look better
|
||||
r = data[i * 4 + 0] * BIT( 5 ) / 256;
|
||||
g = data[i * 4 + 1] * BIT( 6 ) / 256;
|
||||
b = data[i * 4 + 2] * BIT( 5 ) / 256;
|
||||
|
||||
// 565 to 332
|
||||
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
|
||||
// 565 to 332
|
||||
major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
|
||||
|
||||
// save minor GBRGBRGB
|
||||
minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0);
|
||||
// save minor GBRGBRGB
|
||||
minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
|
||||
|
||||
tex->pixels[j][i] = major << 8 | (minor & 0xFF);
|
||||
if( j == 0 && tex->alpha_pixels )
|
||||
{
|
||||
unsigned int alpha = (data[i * 4 + 3] * 8 / 256) << (16 - 3);
|
||||
tex->alpha_pixels[i] = (tex->pixels[j][i] >> 3) | alpha;
|
||||
if( !sw_noalphabrushes.value && data[i * 4 + 3] < 128 && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ) )
|
||||
tex->pixels[j][i] = TRANSPARENT_COLOR; //0000 0011 0100 1001;
|
||||
}
|
||||
tex->pixels[j][i] = major << 8 | ( minor & 0xFF );
|
||||
if( j == 0 && tex->alpha_pixels )
|
||||
{
|
||||
unsigned int alpha = ( data[i * 4 + 3] * 8 / 256 ) << ( 16 - 3 );
|
||||
tex->alpha_pixels[i] = ( tex->pixels[j][i] >> 3 ) | alpha;
|
||||
if( !sw_noalphabrushes.value && data[i * 4 + 3] < 128 && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
|
||||
tex->pixels[j][i] = TRANSPARENT_COLOR; // 0000 0011 0100 1001;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -604,7 +608,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
|
|||
tex->size += texsize;
|
||||
tex->numMips++;
|
||||
|
||||
//GL_CheckTexImageError( tex );
|
||||
// GL_CheckTexImageError( tex );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -619,11 +623,13 @@ do specified actions on pixels
|
|||
*/
|
||||
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)
|
||||
if( tex->flags & TF_FORCE_COLOR ) pic->flags |= IMAGE_HAS_COLOR;
|
||||
if( pic->flags & IMAGE_HAS_ALPHA ) tex->flags |= TF_HAS_ALPHA;
|
||||
if( tex->flags & TF_FORCE_COLOR )
|
||||
pic->flags |= IMAGE_HAS_COLOR;
|
||||
if( pic->flags & IMAGE_HAS_ALPHA )
|
||||
tex->flags |= TF_HAS_ALPHA;
|
||||
|
||||
if( ImageCompressed( pic->type ))
|
||||
{
|
||||
|
@ -670,7 +676,7 @@ static qboolean GL_CheckTexName( const char *name )
|
|||
{
|
||||
int len;
|
||||
|
||||
if( !COM_CheckString( name ) )
|
||||
if( !COM_CheckString( name ))
|
||||
return false;
|
||||
|
||||
len = Q_strlen( name );
|
||||
|
@ -678,7 +684,7 @@ static qboolean GL_CheckTexName( const char *name )
|
|||
// because multi-layered textures can exceed name string
|
||||
if( len >= sizeof( r_images->name ))
|
||||
{
|
||||
gEngfuncs.Con_Printf( S_ERROR "%s: too long name %s (%d)\n", __func__, name, len);
|
||||
gEngfuncs.Con_Printf( S_ERROR "%s: too long name %s (%d)\n", __func__, name, len );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -692,8 +698,8 @@ GL_TextureForName
|
|||
*/
|
||||
static image_t *GL_TextureForName( const char *name )
|
||||
{
|
||||
image_t *tex;
|
||||
uint hash;
|
||||
image_t *tex;
|
||||
uint hash;
|
||||
|
||||
// find the texture in array
|
||||
hash = COM_HashKey( name, TEXTURES_HASH_SIZE );
|
||||
|
@ -714,12 +720,13 @@ GL_AllocTexture
|
|||
*/
|
||||
static image_t *GL_AllocTexture( const char *name, texFlags_t flags )
|
||||
{
|
||||
image_t *tex;
|
||||
uint i;
|
||||
image_t *tex;
|
||||
uint i;
|
||||
|
||||
// find a free texture_t slot
|
||||
for( i = 0, tex = r_images; i < r_numImages; i++, tex++ )
|
||||
if( !tex->name[0] ) break;
|
||||
if( !tex->name[0] )
|
||||
break;
|
||||
|
||||
if( i == r_numImages )
|
||||
{
|
||||
|
@ -733,7 +740,7 @@ static image_t *GL_AllocTexture( const char *name, texFlags_t flags )
|
|||
// copy initial params
|
||||
Q_strncpy( tex->name, name, sizeof( tex->name ));
|
||||
|
||||
//tex->texnum = i; // texnum is used for fast acess into gl_textures array too
|
||||
// tex->texnum = i; // texnum is used for fast acess into gl_textures array too
|
||||
tex->flags = flags;
|
||||
|
||||
// add to hash table
|
||||
|
@ -751,14 +758,15 @@ GL_DeleteTexture
|
|||
*/
|
||||
static void GL_DeleteTexture( image_t *tex )
|
||||
{
|
||||
image_t **prev;
|
||||
image_t *cur;
|
||||
int i;
|
||||
image_t **prev;
|
||||
image_t *cur;
|
||||
int i;
|
||||
|
||||
ASSERT( tex != NULL );
|
||||
|
||||
// already freed?
|
||||
if( !tex->pixels[0]) return;
|
||||
if( !tex->pixels[0] )
|
||||
return;
|
||||
|
||||
// debug
|
||||
if( !tex->name[0] )
|
||||
|
@ -773,7 +781,8 @@ static void GL_DeleteTexture( image_t *tex )
|
|||
while( 1 )
|
||||
{
|
||||
cur = *prev;
|
||||
if( !cur ) break;
|
||||
if( !cur )
|
||||
break;
|
||||
|
||||
if( cur == tex )
|
||||
{
|
||||
|
@ -788,8 +797,10 @@ static void GL_DeleteTexture( image_t *tex )
|
|||
gEngfuncs.FS_FreeImage( tex->original );
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
if( tex->pixels[i]) Mem_Free(tex->pixels[i]);
|
||||
if( tex->alpha_pixels ) Mem_Free(tex->alpha_pixels);
|
||||
if( tex->pixels[i] )
|
||||
Mem_Free( tex->pixels[i] );
|
||||
if( tex->alpha_pixels )
|
||||
Mem_Free( tex->alpha_pixels );
|
||||
|
||||
memset( tex, 0, sizeof( *tex ));
|
||||
}
|
||||
|
@ -803,9 +814,9 @@ recalc image room
|
|||
*/
|
||||
void GAME_EXPORT GL_UpdateTexSize( int texnum, int width, int height, int depth )
|
||||
{
|
||||
int i, j, texsize;
|
||||
int numSides;
|
||||
image_t *tex;
|
||||
int i, j, texsize;
|
||||
int numSides;
|
||||
image_t *tex;
|
||||
|
||||
if( texnum <= 0 || texnum >= MAX_TEXTURES )
|
||||
return;
|
||||
|
@ -834,16 +845,16 @@ GL_LoadTexture
|
|||
*/
|
||||
int GAME_EXPORT GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags )
|
||||
{
|
||||
image_t *tex;
|
||||
rgbdata_t *pic;
|
||||
uint picFlags = 0;
|
||||
image_t *tex;
|
||||
rgbdata_t *pic;
|
||||
uint picFlags = 0;
|
||||
|
||||
if( !GL_CheckTexName( name ))
|
||||
return 0;
|
||||
|
||||
// see if already loaded
|
||||
if(( tex = GL_TextureForName( name )))
|
||||
return (tex - r_images);
|
||||
return( tex - r_images );
|
||||
|
||||
if( FBitSet( flags, TF_NOFLIP_TGA ))
|
||||
SetBits( picFlags, IL_DONTFLIP_TGA );
|
||||
|
@ -855,7 +866,8 @@ int GAME_EXPORT GL_LoadTexture( const char *name, const byte *buf, size_t size,
|
|||
gEngfuncs.Image_SetForceFlags( picFlags );
|
||||
|
||||
pic = gEngfuncs.FS_LoadImage( name, buf, size );
|
||||
if( !pic ) return 0; // couldn't loading image
|
||||
if( !pic )
|
||||
return 0; // couldn't loading image
|
||||
|
||||
// allocate the new one
|
||||
tex = GL_AllocTexture( name, flags );
|
||||
|
@ -868,7 +880,7 @@ int GAME_EXPORT GL_LoadTexture( const char *name, const byte *buf, size_t size,
|
|||
return 0;
|
||||
}
|
||||
|
||||
GL_ApplyTextureParams( tex ); // update texture filter, wrap etc
|
||||
GL_ApplyTextureParams( tex ); // update texture filter, wrap etc
|
||||
gEngfuncs.FS_FreeImage( pic ); // release source texture
|
||||
|
||||
// NOTE: always return texnum as index in array or engine will stop work !!!
|
||||
|
@ -892,17 +904,18 @@ GL_LoadTextureFromBuffer
|
|||
*/
|
||||
int GAME_EXPORT GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texFlags_t flags, qboolean update )
|
||||
{
|
||||
image_t *tex;
|
||||
image_t *tex;
|
||||
|
||||
if( !GL_CheckTexName( name ))
|
||||
return 0;
|
||||
|
||||
// see if already loaded
|
||||
if(( tex = GL_TextureForName( name )) && !update )
|
||||
return (tex - r_images);
|
||||
return( tex - r_images );
|
||||
|
||||
// couldn't loading image
|
||||
if( !pic ) return 0;
|
||||
if( !pic )
|
||||
return 0;
|
||||
|
||||
if( update )
|
||||
{
|
||||
|
@ -924,7 +937,7 @@ int GAME_EXPORT GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texF
|
|||
}
|
||||
|
||||
GL_ApplyTextureParams( tex ); // update texture filter, wrap etc
|
||||
return (tex - r_images);
|
||||
return( tex - r_images );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -936,8 +949,8 @@ creates texture from buffer
|
|||
*/
|
||||
int GAME_EXPORT GL_CreateTexture( const char *name, int width, int height, const void *buffer, texFlags_t flags )
|
||||
{
|
||||
int datasize = 1;
|
||||
rgbdata_t r_empty;
|
||||
int datasize = 1;
|
||||
rgbdata_t r_empty;
|
||||
|
||||
if( FBitSet( flags, TF_ARB_16BIT ))
|
||||
datasize = 2;
|
||||
|
@ -988,14 +1001,14 @@ GL_FindTexture
|
|||
*/
|
||||
int GAME_EXPORT GL_FindTexture( const char *name )
|
||||
{
|
||||
image_t *tex;
|
||||
image_t *tex;
|
||||
|
||||
if( !GL_CheckTexName( name ))
|
||||
return 0;
|
||||
|
||||
// see if already loaded
|
||||
if(( tex = GL_TextureForName( name )))
|
||||
return (tex - r_images);
|
||||
return( tex - r_images );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1021,9 +1034,9 @@ GL_ProcessTexture
|
|||
*/
|
||||
void GAME_EXPORT GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor )
|
||||
{
|
||||
image_t *image;
|
||||
rgbdata_t *pic;
|
||||
int flags = 0;
|
||||
image_t *image;
|
||||
rgbdata_t *pic;
|
||||
int flags = 0;
|
||||
|
||||
if( texnum <= 0 || texnum >= MAX_TEXTURES )
|
||||
return; // missed image
|
||||
|
@ -1080,7 +1093,7 @@ return size of all uploaded textures
|
|||
*/
|
||||
int R_TexMemory( void )
|
||||
{
|
||||
int i, total = 0;
|
||||
int i, total = 0;
|
||||
|
||||
for( i = 0; i < r_numImages; i++ )
|
||||
total += r_images[i].size;
|
||||
|
@ -1102,8 +1115,8 @@ GL_FakeImage
|
|||
*/
|
||||
static rgbdata_t *GL_FakeImage( int width, int height, int depth, int flags )
|
||||
{
|
||||
static byte data2D[1024]; // 16x16x4
|
||||
static rgbdata_t r_image;
|
||||
static byte data2D[1024]; // 16x16x4
|
||||
static rgbdata_t r_image;
|
||||
|
||||
// also use this for bad textures, but without alpha
|
||||
r_image.width = Q_max( 1, width );
|
||||
|
@ -1112,7 +1125,7 @@ static rgbdata_t *GL_FakeImage( int width, int height, int depth, int flags )
|
|||
r_image.flags = flags;
|
||||
r_image.type = PF_RGBA_32;
|
||||
r_image.size = r_image.width * r_image.height * r_image.depth * 4;
|
||||
r_image.buffer = (r_image.size > sizeof( data2D )) ? NULL : data2D;
|
||||
r_image.buffer = ( r_image.size > sizeof( data2D )) ? NULL : data2D;
|
||||
r_image.palette = NULL;
|
||||
r_image.numMips = 1;
|
||||
r_image.encode = 0;
|
||||
|
@ -1131,7 +1144,7 @@ R_InitDlightTexture
|
|||
*/
|
||||
void R_InitDlightTexture( void )
|
||||
{
|
||||
rgbdata_t r_image;
|
||||
rgbdata_t r_image;
|
||||
|
||||
if( tr.dlightTexture != 0 )
|
||||
return; // already initialized
|
||||
|
@ -1143,7 +1156,7 @@ void R_InitDlightTexture( void )
|
|||
r_image.type = PF_RGBA_32;
|
||||
r_image.size = r_image.width * r_image.height * 4;
|
||||
|
||||
tr.dlightTexture = GL_LoadTextureInternal( "*dlight", &r_image, TF_NOMIPMAP|TF_CLAMP|TF_ATLAS_PAGE );
|
||||
tr.dlightTexture = GL_LoadTextureInternal( "*dlight", &r_image, TF_NOMIPMAP | TF_CLAMP | TF_ATLAS_PAGE );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1153,9 +1166,9 @@ GL_CreateInternalTextures
|
|||
*/
|
||||
static void GL_CreateInternalTextures( void )
|
||||
{
|
||||
int dx2, dy, d;
|
||||
int x, y;
|
||||
rgbdata_t *pic;
|
||||
int dx2, dy, d;
|
||||
int x, y;
|
||||
rgbdata_t *pic;
|
||||
|
||||
// emo-texture from quake1
|
||||
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR );
|
||||
|
@ -1165,15 +1178,16 @@ static void GL_CreateInternalTextures( void )
|
|||
for( x = 0; x < 16; x++ )
|
||||
{
|
||||
if(( y < 8 ) ^ ( x < 8 ))
|
||||
((uint *)pic->buffer)[y*16+x] = 0xFFFF00FF;
|
||||
else ((uint *)pic->buffer)[y*16+x] = 0xFF000000;
|
||||
((uint *)pic->buffer )[y * 16 + x] = 0xFFFF00FF;
|
||||
else
|
||||
((uint *)pic->buffer )[y * 16 + x] = 0xFF000000;
|
||||
}
|
||||
}
|
||||
|
||||
tr.defaultTexture = GL_LoadTextureInternal( REF_DEFAULT_TEXTURE, pic, TF_COLORMAP );
|
||||
|
||||
// particle texture from quake1
|
||||
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA );
|
||||
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR | IMAGE_HAS_ALPHA );
|
||||
|
||||
for( x = 0; x < 16; x++ )
|
||||
{
|
||||
|
@ -1193,24 +1207,24 @@ static void GL_CreateInternalTextures( void )
|
|||
// white texture
|
||||
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
|
||||
for( x = 0; x < 16; x++ )
|
||||
((uint *)pic->buffer)[x] = 0xFFFFFFFF;
|
||||
((uint *)pic->buffer )[x] = 0xFFFFFFFF;
|
||||
tr.whiteTexture = GL_LoadTextureInternal( REF_WHITE_TEXTURE, pic, TF_COLORMAP );
|
||||
|
||||
// gray texture
|
||||
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
|
||||
for( x = 0; x < 16; x++ )
|
||||
((uint *)pic->buffer)[x] = 0xFF7F7F7F;
|
||||
((uint *)pic->buffer )[x] = 0xFF7F7F7F;
|
||||
tr.grayTexture = GL_LoadTextureInternal( REF_GRAY_TEXTURE, pic, TF_COLORMAP );
|
||||
|
||||
// black texture
|
||||
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
|
||||
for( x = 0; x < 16; x++ )
|
||||
((uint *)pic->buffer)[x] = 0xFF000000;
|
||||
((uint *)pic->buffer )[x] = 0xFF000000;
|
||||
tr.blackTexture = GL_LoadTextureInternal( REF_BLACK_TEXTURE, pic, TF_COLORMAP );
|
||||
|
||||
// cinematic dummy
|
||||
pic = GL_FakeImage( 640, 100, 1, IMAGE_HAS_COLOR );
|
||||
tr.cinTexture = GL_LoadTextureInternal( "*cintexture", pic, TF_NOMIPMAP|TF_CLAMP );
|
||||
tr.cinTexture = GL_LoadTextureInternal( "*cintexture", pic, TF_NOMIPMAP | TF_CLAMP );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1220,15 +1234,16 @@ R_TextureList_f
|
|||
*/
|
||||
void R_TextureList_f( void )
|
||||
{
|
||||
image_t *image;
|
||||
int i, texCount, bytes = 0;
|
||||
image_t *image;
|
||||
int i, texCount, bytes = 0;
|
||||
|
||||
gEngfuncs.Con_Printf( "\n" );
|
||||
gEngfuncs.Con_Printf( " -id- -w- -h- -size- -fmt- -type- -data- -encode- -wrap- -depth- -name--------\n" );
|
||||
|
||||
for( i = texCount = 0, image = r_images; i < r_numImages; i++, image++ )
|
||||
{
|
||||
if( !image->pixels ) continue;
|
||||
if( !image->pixels )
|
||||
continue;
|
||||
|
||||
bytes += image->size;
|
||||
texCount++;
|
||||
|
@ -1239,13 +1254,15 @@ void R_TextureList_f( void )
|
|||
|
||||
if( image->flags & TF_NORMALMAP )
|
||||
gEngfuncs.Con_Printf( "normal " );
|
||||
else gEngfuncs.Con_Printf( "diffuse " );
|
||||
else
|
||||
gEngfuncs.Con_Printf( "diffuse " );
|
||||
|
||||
if( image->flags & TF_CLAMP )
|
||||
gEngfuncs.Con_Printf( "clamp " );
|
||||
else if( image->flags & TF_BORDER )
|
||||
gEngfuncs.Con_Printf( "border " );
|
||||
else gEngfuncs.Con_Printf( "repeat " );
|
||||
else
|
||||
gEngfuncs.Con_Printf( "repeat " );
|
||||
gEngfuncs.Con_Printf( " %d ", image->depth );
|
||||
gEngfuncs.Con_Printf( " %s\n", image->name );
|
||||
}
|
||||
|
@ -1288,8 +1305,8 @@ R_ShutdownImages
|
|||
*/
|
||||
void R_ShutdownImages( void )
|
||||
{
|
||||
image_t *tex;
|
||||
int i;
|
||||
image_t *tex;
|
||||
int i;
|
||||
|
||||
gEngfuncs.Cmd_RemoveCommand( "texturelist" );
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ GNU General Public License for more details.
|
|||
#include "xash3d_mathlib.h"
|
||||
#include "ref_params.h"
|
||||
|
||||
//unused, need refactor
|
||||
unsigned blocklights[10240];
|
||||
// unused, need refactor
|
||||
unsigned blocklights[10240];
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
@ -37,8 +37,8 @@ CL_RunLightStyles
|
|||
*/
|
||||
void CL_RunLightStyles( lightstyle_t *ls )
|
||||
{
|
||||
int i;
|
||||
float frametime = (gp_cl->time - gp_cl->oldtime);
|
||||
int i;
|
||||
float frametime = ( gp_cl->time - gp_cl->oldtime );
|
||||
|
||||
if( !WORLDMODEL )
|
||||
return;
|
||||
|
@ -54,7 +54,7 @@ void CL_RunLightStyles( lightstyle_t *ls )
|
|||
// 'm' is normal light, 'a' is no light, 'z' is double bright
|
||||
for( i = 0; i < MAX_LIGHTSTYLES; i++ )
|
||||
{
|
||||
int k, flight, clight;
|
||||
int k, flight, clight;
|
||||
float l, lerpfrac, backlerp;
|
||||
|
||||
if( !gp_cl->paused && frametime <= 0.1f )
|
||||
|
@ -76,7 +76,7 @@ void CL_RunLightStyles( lightstyle_t *ls )
|
|||
|
||||
if( !ls[i].interp || !cl_lightstyle_lerping->value )
|
||||
{
|
||||
tr.lightstylevalue[i] = ls[i].map[flight%ls[i].length] * 22;
|
||||
tr.lightstylevalue[i] = ls[i].map[flight % ls[i].length] * 22;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -104,9 +104,9 @@ R_MarkLights
|
|||
*/
|
||||
void R_MarkLights( dlight_t *light, int bit, mnode_t *node )
|
||||
{
|
||||
float dist;
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
float dist;
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
|
||||
if( !node || node->contents < 0 )
|
||||
return;
|
||||
|
@ -130,12 +130,12 @@ void R_MarkLights( dlight_t *light, int bit, mnode_t *node )
|
|||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
if( !BoundsAndSphereIntersect( surf->info->mins, surf->info->maxs, light->origin, light->radius ))
|
||||
continue; // no intersection
|
||||
continue; // no intersection
|
||||
|
||||
if( surf->dlightframe != tr.framecount )//tr.dlightframecount )
|
||||
if( surf->dlightframe != tr.framecount ) // tr.dlightframecount )
|
||||
{
|
||||
surf->dlightbits = 0;
|
||||
surf->dlightframe = tr.framecount; //tr.dlightframecount;
|
||||
surf->dlightframe = tr.framecount; // tr.dlightframecount;
|
||||
}
|
||||
surf->dlightbits |= bit;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ R_PushDlights
|
|||
*/
|
||||
void R_PushDlights( void )
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
tr.dlightframecount = tr.framecount;
|
||||
|
||||
|
@ -170,10 +170,10 @@ void R_PushDlights( void )
|
|||
if( l->die < gp_cl->time || !l->radius )
|
||||
continue;
|
||||
|
||||
//if( GL_FrustumCullSphere( &RI.frustum, l->origin, l->radius, 15 ))
|
||||
//continue;
|
||||
// if( GL_FrustumCullSphere( &RI.frustum, l->origin, l->radius, 15 ))
|
||||
// continue;
|
||||
|
||||
R_MarkLights( l, 1<<i, RI.currentmodel->nodes );
|
||||
R_MarkLights( l, 1 << i, RI.currentmodel->nodes );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,9 +184,9 @@ void R_PushDlights( void )
|
|||
|
||||
=======================================================================
|
||||
*/
|
||||
static vec3_t g_trace_lightspot;
|
||||
static vec3_t g_trace_lightvec;
|
||||
static float g_trace_fraction;
|
||||
static vec3_t g_trace_lightspot;
|
||||
static vec3_t g_trace_lightvec;
|
||||
static float g_trace_fraction;
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -195,16 +195,16 @@ R_RecursiveLightPoint
|
|||
*/
|
||||
static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f, float p2f, colorVec *cv, const vec3_t start, const vec3_t end )
|
||||
{
|
||||
float front, back, frac, midf;
|
||||
int i, map, side, size;
|
||||
float ds, dt, s, t;
|
||||
int sample_size;
|
||||
color24 *lm, *dm;
|
||||
mextrasurf_t *info;
|
||||
msurface_t *surf;
|
||||
mtexinfo_t *tex;
|
||||
matrix3x4 tbn;
|
||||
vec3_t mid;
|
||||
float front, back, frac, midf;
|
||||
int i, map, side, size;
|
||||
float ds, dt, s, t;
|
||||
int sample_size;
|
||||
color24 *lm, *dm;
|
||||
mextrasurf_t *info;
|
||||
msurface_t *surf;
|
||||
mtexinfo_t *tex;
|
||||
matrix3x4 tbn;
|
||||
vec3_t mid;
|
||||
|
||||
// didn't hit anything
|
||||
if( !node || node->contents < 0 )
|
||||
|
@ -242,13 +242,13 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
|||
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
int smax, tmax;
|
||||
int smax, tmax;
|
||||
|
||||
tex = surf->texinfo;
|
||||
info = surf->info;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_DRAWTILED ))
|
||||
continue; // no lightmaps
|
||||
continue; // no lightmaps
|
||||
|
||||
s = DotProduct( mid, info->lmvecs[0] ) + info->lmvecs[0][3];
|
||||
t = DotProduct( mid, info->lmvecs[1] ) + info->lmvecs[1][3];
|
||||
|
@ -259,7 +259,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
|||
ds = s - info->lightmapmins[0];
|
||||
dt = t - info->lightmapmins[1];
|
||||
|
||||
if ( ds > info->lightextents[0] || dt > info->lightextents[1] )
|
||||
if( ds > info->lightextents[0] || dt > info->lightextents[1] )
|
||||
continue;
|
||||
|
||||
cv->r = cv->g = cv->b = cv->a = 0;
|
||||
|
@ -268,8 +268,8 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
|||
return true;
|
||||
|
||||
sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
|
||||
smax = (info->lightextents[0] / sample_size) + 1;
|
||||
tmax = (info->lightextents[1] / sample_size) + 1;
|
||||
smax = ( info->lightextents[0] / sample_size ) + 1;
|
||||
tmax = ( info->lightextents[1] / sample_size ) + 1;
|
||||
ds /= sample_size;
|
||||
dt /= sample_size;
|
||||
|
||||
|
@ -280,11 +280,12 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
|||
|
||||
if( surf->info->deluxemap )
|
||||
{
|
||||
vec3_t faceNormal;
|
||||
vec3_t faceNormal;
|
||||
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
VectorNegate( surf->plane->normal, faceNormal );
|
||||
else VectorCopy( surf->plane->normal, faceNormal );
|
||||
else
|
||||
VectorCopy( surf->plane->normal, faceNormal );
|
||||
|
||||
// compute face TBN
|
||||
#if 1
|
||||
|
@ -304,7 +305,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
|||
|
||||
for( map = 0; map < MAXLIGHTMAPS && surf->styles[map] != 255; map++ )
|
||||
{
|
||||
uint scale = tr.lightstylevalue[surf->styles[map]];
|
||||
uint scale = tr.lightstylevalue[surf->styles[map]];
|
||||
|
||||
cv->r += lm->r * scale;
|
||||
cv->g += lm->g * scale;
|
||||
|
@ -314,12 +315,12 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
|
|||
|
||||
if( dm != NULL )
|
||||
{
|
||||
vec3_t srcNormal, lightNormal;
|
||||
float f = (1.0f / 128.0f);
|
||||
vec3_t srcNormal, lightNormal;
|
||||
float f = ( 1.0f / 128.0f );
|
||||
|
||||
VectorSet( srcNormal, ((float)dm->r - 128.0f) * f, ((float)dm->g - 128.0f) * f, ((float)dm->b - 128.0f) * f );
|
||||
Matrix3x4_VectorIRotate( tbn, srcNormal, lightNormal ); // turn to world space
|
||||
VectorScale( lightNormal, (float)scale * -1.0f, lightNormal ); // turn direction from light
|
||||
VectorSet( srcNormal, ((float)dm->r - 128.0f ) * f, ((float)dm->g - 128.0f ) * f, ((float)dm->b - 128.0f ) * f );
|
||||
Matrix3x4_VectorIRotate( tbn, srcNormal, lightNormal ); // turn to world space
|
||||
VectorScale( lightNormal, (float)scale * -1.0f, lightNormal ); // turn direction from light
|
||||
VectorAdd( g_trace_lightvec, lightNormal, g_trace_lightvec );
|
||||
dm += size; // skip to next deluxmap
|
||||
}
|
||||
|
@ -341,12 +342,14 @@ check bspmodels to get light from
|
|||
*/
|
||||
static colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t lspot, vec3_t lvec )
|
||||
{
|
||||
float last_fraction;
|
||||
int i, maxEnts = 1;
|
||||
colorVec light, cv;
|
||||
float last_fraction;
|
||||
int i, maxEnts = 1;
|
||||
colorVec light, cv;
|
||||
|
||||
if( lspot ) VectorClear( lspot );
|
||||
if( lvec ) VectorClear( lvec );
|
||||
if( lspot )
|
||||
VectorClear( lspot );
|
||||
if( lvec )
|
||||
VectorClear( lvec );
|
||||
|
||||
if( WORLDMODEL && WORLDMODEL->lightdata )
|
||||
{
|
||||
|
@ -354,16 +357,16 @@ static colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t
|
|||
last_fraction = 1.0f;
|
||||
|
||||
// get light from bmodels too
|
||||
//if( CVAR_TO_BOOL( r_lighting_extended ))
|
||||
maxEnts = MAX_PHYSENTS;
|
||||
// if( CVAR_TO_BOOL( r_lighting_extended ))
|
||||
maxEnts = MAX_PHYSENTS;
|
||||
|
||||
// check all the bsp-models
|
||||
for( i = 0; i < maxEnts; i++ )
|
||||
{
|
||||
physent_t *pe = gEngfuncs.EV_GetPhysent( i );
|
||||
vec3_t offset, start_l, end_l;
|
||||
mnode_t *pnodes;
|
||||
matrix4x4 matrix;
|
||||
physent_t *pe = gEngfuncs.EV_GetPhysent( i );
|
||||
vec3_t offset, start_l, end_l;
|
||||
mnode_t *pnodes;
|
||||
matrix4x4 matrix;
|
||||
|
||||
if( !pe )
|
||||
break;
|
||||
|
@ -390,12 +393,14 @@ static colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t
|
|||
g_trace_fraction = 1.0f;
|
||||
|
||||
if( !R_RecursiveLightPoint( pe->model, pnodes, 0.0f, 1.0f, &cv, start_l, end_l ))
|
||||
continue; // didn't hit anything
|
||||
continue; // didn't hit anything
|
||||
|
||||
if( g_trace_fraction < last_fraction )
|
||||
{
|
||||
if( lspot ) VectorCopy( g_trace_lightspot, lspot );
|
||||
if( lvec ) VectorNormalize2( g_trace_lightvec, lvec );
|
||||
if( lspot )
|
||||
VectorCopy( g_trace_lightspot, lspot );
|
||||
if( lvec )
|
||||
VectorNormalize2( g_trace_lightvec, lvec );
|
||||
light.r = Q_min(( cv.r >> 8 ), 255 );
|
||||
light.g = Q_min(( cv.g >> 8 ), 255 );
|
||||
light.b = Q_min(( cv.b >> 8 ), 255 );
|
||||
|
@ -424,9 +429,9 @@ check bspmodels to get light from
|
|||
*/
|
||||
colorVec GAME_EXPORT R_LightVec( const vec3_t start, const vec3_t end, vec3_t lspot, vec3_t lvec )
|
||||
{
|
||||
colorVec light = R_LightVecInternal( start, end, lspot, lvec );
|
||||
colorVec light = R_LightVecInternal( start, end, lspot, lvec );
|
||||
|
||||
//light.r = light.g = light.b = 255;
|
||||
// light.r = light.g = light.b = 255;
|
||||
|
||||
if( lspot != NULL && lvec != NULL ) // CVAR_TO_BOOL( r_lighting_extended ) &&
|
||||
{
|
||||
|
@ -447,7 +452,7 @@ light from floor
|
|||
*/
|
||||
colorVec GAME_EXPORT R_LightPoint( const vec3_t p0 )
|
||||
{
|
||||
vec3_t p1;
|
||||
vec3_t p1;
|
||||
|
||||
VectorSet( p1, p0[0], p0[1], p0[2] - 2048.0f );
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -67,17 +67,17 @@ void Matrix4x4_CreateProjection( matrix4x4 out, float xMax, float xMin, float yM
|
|||
|
||||
void Matrix4x4_CreateOrtho( matrix4x4 out, float xLeft, float xRight, float yBottom, float yTop, float zNear, float zFar )
|
||||
{
|
||||
out[0][0] = 2.0f / (xRight - xLeft);
|
||||
out[1][1] = 2.0f / (yTop - yBottom);
|
||||
out[2][2] = -2.0f / (zFar - zNear);
|
||||
out[0][0] = 2.0f / ( xRight - xLeft );
|
||||
out[1][1] = 2.0f / ( yTop - yBottom );
|
||||
out[2][2] = -2.0f / ( zFar - zNear );
|
||||
out[3][3] = 1.0f;
|
||||
out[0][1] = out[0][2] = out[1][0] = out[1][2] = out[3][0] = out[3][1] = out[3][2] = 0.0f;
|
||||
|
||||
out[2][0] = 0.0f;
|
||||
out[2][1] = 0.0f;
|
||||
out[0][3] = -(xRight + xLeft) / (xRight - xLeft);
|
||||
out[1][3] = -(yTop + yBottom) / (yTop - yBottom);
|
||||
out[2][3] = -(zFar + zNear) / (zFar - zNear);
|
||||
out[0][3] = -( xRight + xLeft ) / ( xRight - xLeft );
|
||||
out[1][3] = -( yTop + yBottom ) / ( yTop - yBottom );
|
||||
out[2][3] = -( zFar + zNear ) / ( zFar - zNear );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -121,33 +121,34 @@ void Matrix4x4_CreateTranslate( matrix4x4 out, float x, float y, float z )
|
|||
|
||||
void Matrix4x4_CreateRotate( matrix4x4 out, float angle, float x, float y, float z )
|
||||
{
|
||||
float len, c, s;
|
||||
float len, c, s;
|
||||
|
||||
len = x * x + y * y + z * z;
|
||||
if( len != 0.0f ) len = 1.0f / sqrt( len );
|
||||
if( len != 0.0f )
|
||||
len = 1.0f / sqrt( len );
|
||||
x *= len;
|
||||
y *= len;
|
||||
z *= len;
|
||||
|
||||
angle *= (-M_PI_F / 180.0f);
|
||||
angle *= ( -M_PI_F / 180.0f );
|
||||
SinCos( angle, &s, &c );
|
||||
|
||||
out[0][0]=x * x + c * (1 - x * x);
|
||||
out[0][1]=x * y * (1 - c) + z * s;
|
||||
out[0][2]=z * x * (1 - c) - y * s;
|
||||
out[0][3]=0.0f;
|
||||
out[1][0]=x * y * (1 - c) - z * s;
|
||||
out[1][1]=y * y + c * (1 - y * y);
|
||||
out[1][2]=y * z * (1 - c) + x * s;
|
||||
out[1][3]=0.0f;
|
||||
out[2][0]=z * x * (1 - c) + y * s;
|
||||
out[2][1]=y * z * (1 - c) - x * s;
|
||||
out[2][2]=z * z + c * (1 - z * z);
|
||||
out[2][3]=0.0f;
|
||||
out[3][0]=0.0f;
|
||||
out[3][1]=0.0f;
|
||||
out[3][2]=0.0f;
|
||||
out[3][3]=1.0f;
|
||||
out[0][0] = x * x + c * ( 1 - x * x );
|
||||
out[0][1] = x * y * ( 1 - c ) + z * s;
|
||||
out[0][2] = z * x * ( 1 - c ) - y * s;
|
||||
out[0][3] = 0.0f;
|
||||
out[1][0] = x * y * ( 1 - c ) - z * s;
|
||||
out[1][1] = y * y + c * ( 1 - y * y );
|
||||
out[1][2] = y * z * ( 1 - c ) + x * s;
|
||||
out[1][3] = 0.0f;
|
||||
out[2][0] = z * x * ( 1 - c ) + y * s;
|
||||
out[2][1] = y * z * ( 1 - c ) - x * s;
|
||||
out[2][2] = z * z + c * ( 1 - z * z );
|
||||
out[2][3] = 0.0f;
|
||||
out[3][0] = 0.0f;
|
||||
out[3][1] = 0.0f;
|
||||
out[3][2] = 0.0f;
|
||||
out[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
static void Matrix4x4_CreateScale( matrix4x4 out, float x )
|
||||
|
|
|
@ -21,29 +21,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "r_local.h"
|
||||
|
||||
#define NUM_MIPS 4
|
||||
#define NUM_MIPS 4
|
||||
|
||||
surfcache_t *d_initial_rover;
|
||||
qboolean d_roverwrapped;
|
||||
int d_minmip;
|
||||
float d_scalemip[NUM_MIPS-1];
|
||||
surfcache_t *d_initial_rover;
|
||||
qboolean d_roverwrapped;
|
||||
int d_minmip;
|
||||
float d_scalemip[NUM_MIPS - 1];
|
||||
|
||||
static float basemip[NUM_MIPS-1] = {1.0, 0.5*0.8, 0.25*0.8};
|
||||
static float basemip[NUM_MIPS - 1] = {1.0, 0.5 * 0.8, 0.25 * 0.8};
|
||||
|
||||
|
||||
//int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
|
||||
// int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
|
||||
|
||||
//int d_pix_min, d_pix_max, d_pix_shift;
|
||||
// int d_pix_min, d_pix_max, d_pix_shift;
|
||||
|
||||
int d_scantable[MAXHEIGHT];
|
||||
short *zspantable[MAXHEIGHT];
|
||||
int d_scantable[MAXHEIGHT];
|
||||
short *zspantable[MAXHEIGHT];
|
||||
struct qfrustum_s qfrustum;
|
||||
/*
|
||||
================
|
||||
D_Patch
|
||||
================
|
||||
*/
|
||||
static void D_Patch (void)
|
||||
static void D_Patch( void )
|
||||
{
|
||||
}
|
||||
/*
|
||||
|
@ -52,12 +52,12 @@ D_ViewChanged
|
|||
================
|
||||
*/
|
||||
|
||||
void D_ViewChanged (void)
|
||||
void D_ViewChanged( void )
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
scale_for_mip = xscale;
|
||||
if (yscale > xscale)
|
||||
if( yscale > xscale )
|
||||
scale_for_mip = yscale;
|
||||
|
||||
d_zrowbytes = vid.width * 2;
|
||||
|
@ -72,27 +72,27 @@ void D_ViewChanged (void)
|
|||
if (d_pix_max < 1)
|
||||
d_pix_max = 1;*/
|
||||
|
||||
//d_vrectx = RI.vrect.x;
|
||||
//d_vrecty = RI.vrect.y;
|
||||
//d_vrectright_particle = gpGlobals->width - d_pix_max;
|
||||
//d_vrectbottom_particle =
|
||||
// gpGlobals->height - d_pix_max;
|
||||
// d_vrectx = RI.vrect.x;
|
||||
// d_vrecty = RI.vrect.y;
|
||||
// d_vrectright_particle = gpGlobals->width - d_pix_max;
|
||||
// d_vrectbottom_particle =
|
||||
// gpGlobals->height - d_pix_max;
|
||||
|
||||
for (i=0 ; i<vid.height; i++)
|
||||
for( i = 0; i < vid.height; i++ )
|
||||
{
|
||||
d_scantable[i] = i*r_screenwidth;
|
||||
zspantable[i] = d_pzbuffer + i*d_zwidth;
|
||||
d_scantable[i] = i * r_screenwidth;
|
||||
zspantable[i] = d_pzbuffer + i * d_zwidth;
|
||||
}
|
||||
|
||||
/*
|
||||
** clear Z-buffer and color-buffers if we're doing the gallery
|
||||
*/
|
||||
if ( !RI.drawWorld )
|
||||
if( !RI.drawWorld )
|
||||
{
|
||||
memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof( d_pzbuffer[0] ) );
|
||||
memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof( d_pzbuffer[0] ));
|
||||
}
|
||||
|
||||
D_Patch ();
|
||||
D_Patch();
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,24 +102,24 @@ void D_ViewChanged (void)
|
|||
R_TransformFrustum
|
||||
===================
|
||||
*/
|
||||
void R_TransformFrustum (void)
|
||||
void R_TransformFrustum( void )
|
||||
{
|
||||
int i;
|
||||
vec3_t v, v2;
|
||||
int i;
|
||||
vec3_t v, v2;
|
||||
|
||||
for (i=0 ; i<4 ; i++)
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
v[0] = qfrustum.screenedge[i].normal[2];
|
||||
v[1] = -qfrustum.screenedge[i].normal[0];
|
||||
v[2] = qfrustum.screenedge[i].normal[1];
|
||||
|
||||
v2[0] = v[1]*RI.vright[0] + v[2]*RI.vup[0] + v[0]*RI.vforward[0];
|
||||
v2[1] = v[1]*RI.vright[1] + v[2]*RI.vup[1] + v[0]*RI.vforward[1];
|
||||
v2[2] = v[1]*RI.vright[2] + v[2]*RI.vup[2] + v[0]*RI.vforward[2];
|
||||
v2[0] = v[1] * RI.vright[0] + v[2] * RI.vup[0] + v[0] * RI.vforward[0];
|
||||
v2[1] = v[1] * RI.vright[1] + v[2] * RI.vup[1] + v[0] * RI.vforward[1];
|
||||
v2[2] = v[1] * RI.vright[2] + v[2] * RI.vup[2] + v[0] * RI.vforward[2];
|
||||
|
||||
VectorCopy (v2, qfrustum.view_clipplanes[i].normal);
|
||||
VectorCopy( v2, qfrustum.view_clipplanes[i].normal );
|
||||
|
||||
qfrustum.view_clipplanes[i].dist = DotProduct (tr.modelorg, v2);
|
||||
qfrustum.view_clipplanes[i].dist = DotProduct( tr.modelorg, v2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,11 +129,11 @@ void R_TransformFrustum (void)
|
|||
TransformVector
|
||||
================
|
||||
*/
|
||||
void TransformVector (vec3_t in, vec3_t out)
|
||||
void TransformVector( vec3_t in, vec3_t out )
|
||||
{
|
||||
out[0] = DotProduct(in,RI.vright);
|
||||
out[1] = DotProduct(in,RI.vup);
|
||||
out[2] = DotProduct(in,RI.vforward);
|
||||
out[0] = DotProduct( in, RI.vright );
|
||||
out[1] = DotProduct( in, RI.vup );
|
||||
out[2] = DotProduct( in, RI.vforward );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -141,29 +141,29 @@ void TransformVector (vec3_t in, vec3_t out)
|
|||
R_SetUpFrustumIndexes
|
||||
===============
|
||||
*/
|
||||
static void R_SetUpFrustumIndexes (void)
|
||||
static void R_SetUpFrustumIndexes( void )
|
||||
{
|
||||
int i, j, *pindex;
|
||||
int i, j, *pindex;
|
||||
|
||||
pindex = qfrustum.frustum_indexes;
|
||||
|
||||
for (i=0 ; i<4 ; i++)
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
for (j=0 ; j<3 ; j++)
|
||||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
if (qfrustum.view_clipplanes[i].normal[j] < 0)
|
||||
if( qfrustum.view_clipplanes[i].normal[j] < 0 )
|
||||
{
|
||||
pindex[j] = j;
|
||||
pindex[j+3] = j+3;
|
||||
pindex[j + 3] = j + 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
pindex[j] = j+3;
|
||||
pindex[j+3] = j;
|
||||
pindex[j] = j + 3;
|
||||
pindex[j + 3] = j;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: do just once at start
|
||||
// FIXME: do just once at start
|
||||
qfrustum.pfrustum_indexes[i] = pindex;
|
||||
pindex += 6;
|
||||
}
|
||||
|
@ -177,23 +177,23 @@ Called every time the vid structure or r_refdef changes.
|
|||
Guaranteed to be called before the first refresh
|
||||
===============
|
||||
*/
|
||||
static void R_ViewChanged (vrect_t *vr)
|
||||
static void R_ViewChanged( vrect_t *vr )
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
float verticalFieldOfView, horizontalFieldOfView, xOrigin, yOrigin;
|
||||
|
||||
RI.vrect = *vr;
|
||||
|
||||
horizontalFieldOfView = 2*tan((float)RI.fov_x/360.0f * M_PI_F);
|
||||
verticalFieldOfView = 2*tan((float)RI.fov_y/360.0f * M_PI_F);
|
||||
horizontalFieldOfView = 2 * tan((float)RI.fov_x / 360.0f * M_PI_F );
|
||||
verticalFieldOfView = 2 * tan((float)RI.fov_y / 360.0f * M_PI_F );
|
||||
|
||||
RI.fvrectx = (float)RI.vrect.x;
|
||||
RI.fvrectx_adj = (float)RI.vrect.x - 0.5f;
|
||||
RI.vrect_x_adj_shift20 = (RI.vrect.x<<20) + (1<<19) - 1;
|
||||
RI.vrect_x_adj_shift20 = ( RI.vrect.x << 20 ) + ( 1 << 19 ) - 1;
|
||||
RI.fvrecty = (float)RI.vrect.y;
|
||||
RI.fvrecty_adj = (float)RI.vrect.y - 0.5f;
|
||||
RI.vrectright = RI.vrect.x + RI.vrect.width;
|
||||
RI.vrectright_adj_shift20 = (RI.vrectright<<20) + (1<<19) - 1;
|
||||
RI.vrectright_adj_shift20 = ( RI.vrectright << 20 ) + ( 1 << 19 ) - 1;
|
||||
RI.fvrectright = (float)RI.vrectright;
|
||||
RI.fvrectright_adj = (float)RI.vrectright - 0.5f;
|
||||
RI.vrectrightedge = (float)RI.vrectright - 0.99f;
|
||||
|
@ -201,14 +201,14 @@ static void R_ViewChanged (vrect_t *vr)
|
|||
RI.fvrectbottom = (float)RI.vrectbottom;
|
||||
RI.fvrectbottom_adj = (float)RI.vrectbottom - 0.5f;
|
||||
|
||||
RI.aliasvrect.x = (int)(RI.vrect.x * r_aliasuvscale);
|
||||
RI.aliasvrect.y = (int)(RI.vrect.y * r_aliasuvscale);
|
||||
RI.aliasvrect.width = (int)(RI.vrect.width * r_aliasuvscale);
|
||||
RI.aliasvrect.height = (int)(RI.vrect.height * r_aliasuvscale);
|
||||
RI.aliasvrectright = RI.aliasvrect.x +
|
||||
RI.aliasvrect.width;
|
||||
RI.aliasvrectbottom = RI.aliasvrect.y +
|
||||
RI.aliasvrect.height;
|
||||
RI.aliasvrect.x = (int)( RI.vrect.x * r_aliasuvscale );
|
||||
RI.aliasvrect.y = (int)( RI.vrect.y * r_aliasuvscale );
|
||||
RI.aliasvrect.width = (int)( RI.vrect.width * r_aliasuvscale );
|
||||
RI.aliasvrect.height = (int)( RI.vrect.height * r_aliasuvscale );
|
||||
RI.aliasvrectright = RI.aliasvrect.x
|
||||
+ RI.aliasvrect.width;
|
||||
RI.aliasvrectbottom = RI.aliasvrect.y
|
||||
+ RI.aliasvrect.height;
|
||||
|
||||
xOrigin = XCENTERING;
|
||||
yOrigin = YCENTERING;
|
||||
|
@ -219,11 +219,11 @@ static void R_ViewChanged (vrect_t *vr)
|
|||
// the polygon rasterization will never render in the first row or column
|
||||
// but will definately render in the [range] row and column, so adjust the
|
||||
// buffer origin to get an exact edge to edge fill
|
||||
xcenter = ((float)RI.vrect.width * XCENTERING) +
|
||||
RI.vrect.x - 0.5f;
|
||||
xcenter = ((float)RI.vrect.width * XCENTERING )
|
||||
+ RI.vrect.x - 0.5f;
|
||||
aliasxcenter = xcenter * r_aliasuvscale;
|
||||
ycenter = ((float)RI.vrect.height * YCENTERING) +
|
||||
RI.vrect.y - 0.5f;
|
||||
ycenter = ((float)RI.vrect.height * YCENTERING )
|
||||
+ RI.vrect.y - 0.5f;
|
||||
aliasycenter = ycenter * r_aliasuvscale;
|
||||
|
||||
xscale = RI.vrect.width / horizontalFieldOfView;
|
||||
|
@ -233,38 +233,38 @@ static void R_ViewChanged (vrect_t *vr)
|
|||
yscale = xscale;
|
||||
aliasyscale = yscale * r_aliasuvscale;
|
||||
yscaleinv = 1.0f / yscale;
|
||||
//xscaleshrink = (RI.vrect.width-6)/RI.horizontalFieldOfView;
|
||||
//yscaleshrink = xscaleshrink;
|
||||
// xscaleshrink = (RI.vrect.width-6)/RI.horizontalFieldOfView;
|
||||
// yscaleshrink = xscaleshrink;
|
||||
|
||||
// left side clip
|
||||
qfrustum.screenedge[0].normal[0] = -1.0f / (xOrigin*horizontalFieldOfView);
|
||||
qfrustum.screenedge[0].normal[0] = -1.0f / ( xOrigin * horizontalFieldOfView );
|
||||
qfrustum.screenedge[0].normal[1] = 0;
|
||||
qfrustum.screenedge[0].normal[2] = 1;
|
||||
qfrustum.screenedge[0].type = PLANE_ANYZ;
|
||||
|
||||
// right side clip
|
||||
qfrustum.screenedge[1].normal[0] =
|
||||
1.0f / ((1.0f-xOrigin)*horizontalFieldOfView);
|
||||
qfrustum.screenedge[1].normal[0]
|
||||
= 1.0f / (( 1.0f - xOrigin ) * horizontalFieldOfView );
|
||||
qfrustum.screenedge[1].normal[1] = 0;
|
||||
qfrustum.screenedge[1].normal[2] = 1;
|
||||
qfrustum.screenedge[1].type = PLANE_ANYZ;
|
||||
|
||||
// top side clip
|
||||
qfrustum.screenedge[2].normal[0] = 0;
|
||||
qfrustum.screenedge[2].normal[1] = -1.0f / (yOrigin*verticalFieldOfView);
|
||||
qfrustum.screenedge[2].normal[1] = -1.0f / ( yOrigin * verticalFieldOfView );
|
||||
qfrustum.screenedge[2].normal[2] = 1;
|
||||
qfrustum.screenedge[2].type = PLANE_ANYZ;
|
||||
|
||||
// bottom side clip
|
||||
qfrustum.screenedge[3].normal[0] = 0;
|
||||
qfrustum.screenedge[3].normal[1] = 1.0f / ((1.0f-yOrigin)*verticalFieldOfView);
|
||||
qfrustum.screenedge[3].normal[1] = 1.0f / (( 1.0f - yOrigin ) * verticalFieldOfView );
|
||||
qfrustum.screenedge[3].normal[2] = 1;
|
||||
qfrustum.screenedge[3].type = PLANE_ANYZ;
|
||||
|
||||
for (i=0 ; i<4 ; i++)
|
||||
VectorNormalize (qfrustum.screenedge[i].normal);
|
||||
for( i = 0; i < 4; i++ )
|
||||
VectorNormalize( qfrustum.screenedge[i].normal );
|
||||
|
||||
D_ViewChanged ();
|
||||
D_ViewChanged();
|
||||
}
|
||||
|
||||
|
||||
|
@ -273,29 +273,29 @@ static void R_ViewChanged (vrect_t *vr)
|
|||
R_SetupFrame
|
||||
===============
|
||||
*/
|
||||
void R_SetupFrameQ (void)
|
||||
void R_SetupFrameQ( void )
|
||||
{
|
||||
int i;
|
||||
vrect_t vrect;
|
||||
int i;
|
||||
vrect_t vrect;
|
||||
|
||||
if (r_fullbright->flags & FCVAR_CHANGED)
|
||||
if( r_fullbright->flags & FCVAR_CHANGED )
|
||||
{
|
||||
r_fullbright->flags &= ~FCVAR_CHANGED;
|
||||
D_FlushCaches( ); // so all lighting changes
|
||||
D_FlushCaches( ); // so all lighting changes
|
||||
}
|
||||
|
||||
//tr.framecount++;
|
||||
// tr.framecount++;
|
||||
|
||||
|
||||
// build the transformation matrix for the given view angles
|
||||
VectorCopy (RI.vieworg, tr.modelorg);
|
||||
VectorCopy( RI.vieworg, tr.modelorg );
|
||||
|
||||
//AngleVectors (RI.viewangles, RI.vforward, RI.vright, RI.vup);
|
||||
// AngleVectors (RI.viewangles, RI.vforward, RI.vright, RI.vup);
|
||||
|
||||
// current viewleaf
|
||||
if ( RI.drawWorld )
|
||||
if( RI.drawWorld )
|
||||
{
|
||||
RI.viewleaf = gEngfuncs.Mod_PointInLeaf (RI.vieworg, WORLDMODEL->nodes);
|
||||
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.vieworg, WORLDMODEL->nodes );
|
||||
r_viewcluster = RI.viewleaf->cluster;
|
||||
}
|
||||
|
||||
|
@ -315,16 +315,16 @@ void R_SetupFrameQ (void)
|
|||
d_viewbuffer = (void *)vid.buffer;
|
||||
r_screenwidth = vid.rowbytes;
|
||||
|
||||
R_ViewChanged (&vrect);
|
||||
R_ViewChanged( &vrect );
|
||||
|
||||
// start off with just the four screen edge clip planes
|
||||
R_TransformFrustum ();
|
||||
R_SetUpFrustumIndexes ();
|
||||
R_TransformFrustum();
|
||||
R_SetUpFrustumIndexes();
|
||||
|
||||
// save base values
|
||||
VectorCopy (RI.vforward, RI.base_vpn);
|
||||
VectorCopy (RI.vright, RI.base_vright);
|
||||
VectorCopy (RI.vup, RI.base_vup);
|
||||
VectorCopy( RI.vforward, RI.base_vpn );
|
||||
VectorCopy( RI.vright, RI.base_vright );
|
||||
VectorCopy( RI.vup, RI.base_vup );
|
||||
|
||||
// clear frame counts
|
||||
/* c_faceclip = 0;
|
||||
|
@ -341,13 +341,13 @@ void R_SetupFrameQ (void)
|
|||
d_initial_rover = sc_rover;
|
||||
|
||||
d_minmip = sw_mipcap.value;
|
||||
if (d_minmip > 3)
|
||||
if( d_minmip > 3 )
|
||||
d_minmip = 3;
|
||||
else if (d_minmip < 0)
|
||||
else if( d_minmip < 0 )
|
||||
d_minmip = 0;
|
||||
|
||||
for (i=0 ; i<(NUM_MIPS-1) ; i++)
|
||||
for( i = 0; i < ( NUM_MIPS - 1 ); i++ )
|
||||
d_scalemip[i] = basemip[i] * sw_mipscale.value;
|
||||
|
||||
//d_aflatcolor = 0;
|
||||
// d_aflatcolor = 0;
|
||||
}
|
||||
|
|
|
@ -21,21 +21,21 @@ GNU General Public License for more details.
|
|||
#include "pm_local.h"
|
||||
#include "studio.h"
|
||||
|
||||
static float gTracerSize[11] = { 1.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static float gTracerSize[11] = { 1.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static color24 gTracerColors[] =
|
||||
{
|
||||
{ 255, 255, 255 }, // White
|
||||
{ 255, 0, 0 }, // Red
|
||||
{ 0, 255, 0 }, // Green
|
||||
{ 0, 0, 255 }, // Blue
|
||||
{ 0, 0, 0 }, // Tracer default, filled in from cvars, etc.
|
||||
{ 255, 167, 17 }, // Yellow-orange sparks
|
||||
{ 255, 130, 90 }, // Yellowish streaks (garg)
|
||||
{ 55, 60, 144 }, // Blue egon streak
|
||||
{ 255, 130, 90 }, // More Yellowish streaks (garg)
|
||||
{ 255, 140, 90 }, // More Yellowish streaks (garg)
|
||||
{ 200, 130, 90 }, // More red streaks (garg)
|
||||
{ 255, 120, 70 }, // Darker red streaks (garg)
|
||||
{ 255, 255, 255 }, // White
|
||||
{ 255, 0, 0 }, // Red
|
||||
{ 0, 255, 0 }, // Green
|
||||
{ 0, 0, 255 }, // Blue
|
||||
{ 0, 0, 0 }, // Tracer default, filled in from cvars, etc.
|
||||
{ 255, 167, 17 }, // Yellow-orange sparks
|
||||
{ 255, 130, 90 }, // Yellowish streaks (garg)
|
||||
{ 55, 60, 144 }, // Blue egon streak
|
||||
{ 255, 130, 90 }, // More Yellowish streaks (garg)
|
||||
{ 255, 140, 90 }, // More Yellowish streaks (garg)
|
||||
{ 200, 130, 90 }, // More red streaks (garg)
|
||||
{ 255, 120, 70 }, // Darker red streaks (garg)
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -47,23 +47,23 @@ update particle color, position, free expired and draw it
|
|||
*/
|
||||
void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_particles, float partsize )
|
||||
{
|
||||
particle_t *p;
|
||||
vec3_t right, up;
|
||||
color24 color;
|
||||
int alpha;
|
||||
float size;
|
||||
particle_t *p;
|
||||
vec3_t right, up;
|
||||
color24 color;
|
||||
int alpha;
|
||||
float size;
|
||||
|
||||
if( !cl_active_particles )
|
||||
return; // nothing to draw?
|
||||
return; // nothing to draw?
|
||||
|
||||
//pglEnable( GL_BLEND );
|
||||
//pglDisable( GL_ALPHA_TEST );
|
||||
//pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
// pglEnable( GL_BLEND );
|
||||
// pglDisable( GL_ALPHA_TEST );
|
||||
// pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
GL_SetRenderMode( kRenderTransAdd );
|
||||
|
||||
GL_Bind( XASH_TEXTURE0, tr.particleTexture );
|
||||
//pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
//pglDepthMask( GL_FALSE );
|
||||
// pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
// pglDepthMask( GL_FALSE );
|
||||
|
||||
for( p = cl_active_particles; p; p = p->next )
|
||||
{
|
||||
|
@ -72,12 +72,14 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
|||
size = partsize; // get initial size of particle
|
||||
|
||||
// scale up to keep particles from disappearing
|
||||
size += (p->org[0] - RI.vieworg[0]) * RI.cull_vforward[0];
|
||||
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[0] - RI.vieworg[0] ) * RI.cull_vforward[0];
|
||||
size += ( p->org[1] - RI.vieworg[1] ) * RI.cull_vforward[1];
|
||||
size += ( p->org[2] - RI.vieworg[2] ) * RI.cull_vforward[2];
|
||||
|
||||
if( size < 20.0f ) size = partsize;
|
||||
else size = partsize + size * 0.002f;
|
||||
if( size < 20.0f )
|
||||
size = partsize;
|
||||
else
|
||||
size = partsize + size * 0.002f;
|
||||
|
||||
// scale the axes by radius
|
||||
VectorScale( RI.cull_vright, size, right );
|
||||
|
@ -86,15 +88,15 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
|||
p->color = bound( 0, p->color, 255 );
|
||||
color = tr.palette[p->color];
|
||||
|
||||
alpha = 255 * (p->die - gp_cl->time) * 16.0f;
|
||||
alpha = 255 * ( p->die - gp_cl->time ) * 16.0f;
|
||||
if( alpha > 255 || p->type == pt_static )
|
||||
alpha = 255;
|
||||
|
||||
//TriColor4ub( LightToTexGamma( color.r ),
|
||||
// TriColor4ub( LightToTexGamma( color.r ),
|
||||
// LightToTexGamma( color.g ),
|
||||
// LightToTexGamma( color.b ), alpha );
|
||||
//TriBrightness( alpha / 255.0f );
|
||||
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
|
||||
// LightToTexGamma( color.b ), alpha );
|
||||
// TriBrightness( alpha / 255.0f );
|
||||
_TriColor4f( 1.0f * alpha / 255 / 255 * color.r, 1.0f * alpha / 255 / 255 * color.g, 1.0f * alpha / 255 / 255 * color.b, 1.0f );
|
||||
|
||||
TriBegin( TRI_QUADS );
|
||||
TriTexCoord2f( 0.0f, 1.0f );
|
||||
|
@ -113,7 +115,7 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
|||
}
|
||||
|
||||
TriEnd();
|
||||
//pglDepthMask( GL_TRUE );
|
||||
// pglDepthMask( GL_TRUE );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -125,8 +127,8 @@ check tracer bbox
|
|||
*/
|
||||
static qboolean CL_CullTracer( particle_t *p, const vec3_t start, const vec3_t end )
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
int i;
|
||||
vec3_t mins, maxs;
|
||||
int i;
|
||||
return false;
|
||||
/*
|
||||
// compute the bounding box
|
||||
|
@ -163,18 +165,18 @@ update tracer color, position, free expired and draw it
|
|||
*/
|
||||
void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
|
||||
{
|
||||
float scale, atten, gravity;
|
||||
vec3_t screenLast, screen;
|
||||
vec3_t start, end, delta;
|
||||
particle_t *p;
|
||||
float scale, atten, gravity;
|
||||
vec3_t screenLast, screen;
|
||||
vec3_t start, end, delta;
|
||||
particle_t *p;
|
||||
|
||||
// update tracer color if this is changed
|
||||
if( FBitSet( tracerred->flags|tracergreen->flags|tracerblue->flags|traceralpha->flags, FCVAR_CHANGED ))
|
||||
if( FBitSet( tracerred->flags | tracergreen->flags | tracerblue->flags | traceralpha->flags, FCVAR_CHANGED ))
|
||||
{
|
||||
color24 *customColors = &gTracerColors[4];
|
||||
customColors->r = (byte)(tracerred->value * traceralpha->value * 255);
|
||||
customColors->g = (byte)(tracergreen->value * traceralpha->value * 255);
|
||||
customColors->b = (byte)(tracerblue->value * traceralpha->value * 255);
|
||||
customColors->r = (byte)( tracerred->value * traceralpha->value * 255 );
|
||||
customColors->g = (byte)( tracergreen->value * traceralpha->value * 255 );
|
||||
customColors->b = (byte)( tracerblue->value * traceralpha->value * 255 );
|
||||
ClearBits( tracerred->flags, FCVAR_CHANGED );
|
||||
ClearBits( tracergreen->flags, FCVAR_CHANGED );
|
||||
ClearBits( tracerblue->flags, FCVAR_CHANGED );
|
||||
|
@ -182,26 +184,28 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
|||
}
|
||||
|
||||
if( !cl_active_tracers )
|
||||
return; // nothing to draw?
|
||||
return; // nothing to draw?
|
||||
|
||||
GL_SetRenderMode( kRenderTransAdd );
|
||||
|
||||
if( !TriSpriteTexture( gEngfuncs.GetDefaultSprite( REF_DOT_SPRITE ), 0 ))
|
||||
return;
|
||||
|
||||
//pglEnable( GL_BLEND );
|
||||
//pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
|
||||
//pglDisable( GL_ALPHA_TEST );
|
||||
//pglDepthMask( GL_FALSE );
|
||||
// pglEnable( GL_BLEND );
|
||||
// pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
|
||||
// pglDisable( GL_ALPHA_TEST );
|
||||
// pglDepthMask( GL_FALSE );
|
||||
|
||||
gravity = frametime * tr.movevars->gravity;
|
||||
scale = 1.0 - (frametime * 0.9);
|
||||
if( scale < 0.0f ) scale = 0.0f;
|
||||
scale = 1.0 - ( frametime * 0.9 );
|
||||
if( scale < 0.0f )
|
||||
scale = 0.0f;
|
||||
|
||||
for( p = cl_active_tracers; p; p = p->next )
|
||||
{
|
||||
atten = (p->die - gp_cl->time);
|
||||
if( atten > 0.1f ) atten = 0.1f;
|
||||
atten = ( p->die - gp_cl->time );
|
||||
if( atten > 0.1f )
|
||||
atten = 0.1f;
|
||||
|
||||
VectorScale( p->vel, ( p->ramp * atten ), delta );
|
||||
VectorAdd( p->org, delta, end );
|
||||
|
@ -209,10 +213,10 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
|||
|
||||
if( !CL_CullTracer( p, start, end ))
|
||||
{
|
||||
vec3_t verts[4], tmp2;
|
||||
vec3_t tmp, normal;
|
||||
color24 color;
|
||||
short alpha = p->packedColor;
|
||||
vec3_t verts[4], tmp2;
|
||||
vec3_t tmp, normal;
|
||||
color24 color;
|
||||
short alpha = p->packedColor;
|
||||
|
||||
// Transform point into screen space
|
||||
TriWorldToScreen( start, screen );
|
||||
|
@ -242,19 +246,19 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
|||
}
|
||||
|
||||
color = gTracerColors[p->color];
|
||||
//TriColor4ub( color.r, color.g, color.b, p->packedColor );
|
||||
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
|
||||
// TriColor4ub( color.r, color.g, color.b, p->packedColor );
|
||||
_TriColor4f( 1.0f * alpha / 255 / 255 * color.r, 1.0f * alpha / 255 / 255 * color.g, 1.0f * alpha / 255 / 255 * color.b, 1.0f );
|
||||
|
||||
|
||||
TriBegin( TRI_QUADS );
|
||||
TriTexCoord2f( 0.0f, 0.8f );
|
||||
TriVertex3fv( verts[2] );
|
||||
TriTexCoord2f( 1.0f, 0.8f );
|
||||
TriVertex3fv( verts[3] );
|
||||
TriTexCoord2f( 1.0f, 0.0f );
|
||||
TriVertex3fv( verts[1] );
|
||||
TriTexCoord2f( 0.0f, 0.0f );
|
||||
TriVertex3fv( verts[0] );
|
||||
TriTexCoord2f( 0.0f, 0.8f );
|
||||
TriVertex3fv( verts[2] );
|
||||
TriTexCoord2f( 1.0f, 0.8f );
|
||||
TriVertex3fv( verts[3] );
|
||||
TriTexCoord2f( 1.0f, 0.0f );
|
||||
TriVertex3fv( verts[1] );
|
||||
TriTexCoord2f( 0.0f, 0.0f );
|
||||
TriVertex3fv( verts[0] );
|
||||
TriEnd();
|
||||
}
|
||||
|
||||
|
@ -267,8 +271,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
|||
p->vel[1] *= scale;
|
||||
p->vel[2] -= gravity;
|
||||
|
||||
p->packedColor = 255 * (p->die - gp_cl->time) * 2;
|
||||
if( p->packedColor > 255 ) p->packedColor = 255;
|
||||
p->packedColor = 255 * ( p->die - gp_cl->time ) * 2;
|
||||
if( p->packedColor > 255 )
|
||||
p->packedColor = 255;
|
||||
}
|
||||
else if( p->type == pt_slowgrav )
|
||||
{
|
||||
|
@ -276,7 +281,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
|||
}
|
||||
}
|
||||
|
||||
//pglDepthMask( GL_TRUE );
|
||||
// pglDepthMask( GL_TRUE );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -288,7 +293,7 @@ allow to draw effects from custom renderer
|
|||
*/
|
||||
void GAME_EXPORT CL_DrawParticlesExternal( const ref_viewpass_t *rvp, qboolean trans_pass, float frametime )
|
||||
{
|
||||
ref_instance_t oldRI = RI;
|
||||
ref_instance_t oldRI = RI;
|
||||
|
||||
R_SetupRefParams( rvp );
|
||||
R_SetupFrustum();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,81 +23,81 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "r_local.h"
|
||||
|
||||
#define MAXLEFTCLIPEDGES 100
|
||||
#define MAXLEFTCLIPEDGES 100
|
||||
|
||||
// !!! if these are changed, they must be changed in asm_draw.h too !!!
|
||||
#define FULLY_CLIPPED_CACHED 0x80000000
|
||||
#define FRAMECOUNT_MASK 0x7FFFFFFF
|
||||
#define FULLY_CLIPPED_CACHED 0x80000000
|
||||
#define FRAMECOUNT_MASK 0x7FFFFFFF
|
||||
|
||||
unsigned int cacheoffset;
|
||||
unsigned int cacheoffset;
|
||||
|
||||
int c_faceclip; // number of faces clipped
|
||||
int c_faceclip; // number of faces clipped
|
||||
|
||||
|
||||
clipplane_t *entity_clipplanes;
|
||||
clipplane_t world_clipplanes[16];
|
||||
clipplane_t *entity_clipplanes;
|
||||
clipplane_t world_clipplanes[16];
|
||||
|
||||
medge_t *r_pedge;
|
||||
medge_t *r_pedge;
|
||||
|
||||
qboolean r_leftclipped, r_rightclipped;
|
||||
static qboolean makeleftedge, makerightedge;
|
||||
qboolean r_nearzionly;
|
||||
qboolean r_leftclipped, r_rightclipped;
|
||||
static qboolean makeleftedge, makerightedge;
|
||||
qboolean r_nearzionly;
|
||||
|
||||
int sintable[1280];
|
||||
int intsintable[1280];
|
||||
int blanktable[1280]; // PGM
|
||||
int sintable[1280];
|
||||
int intsintable[1280];
|
||||
int blanktable[1280]; // PGM
|
||||
|
||||
mvertex_t r_leftenter, r_leftexit;
|
||||
mvertex_t r_rightenter, r_rightexit;
|
||||
mvertex_t r_leftenter, r_leftexit;
|
||||
mvertex_t r_rightenter, r_rightexit;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float u,v;
|
||||
int ceilv;
|
||||
float u, v;
|
||||
int ceilv;
|
||||
} evert_t;
|
||||
|
||||
int r_emitted;
|
||||
float r_nearzi;
|
||||
float r_u1, r_v1, r_lzi1;
|
||||
int r_ceilv1;
|
||||
int r_emitted;
|
||||
float r_nearzi;
|
||||
float r_u1, r_v1, r_lzi1;
|
||||
int r_ceilv1;
|
||||
|
||||
qboolean r_lastvertvalid;
|
||||
int r_skyframe;
|
||||
qboolean r_lastvertvalid;
|
||||
int r_skyframe;
|
||||
|
||||
msurface_t *r_skyfaces;
|
||||
mplane_t r_skyplanes[6];
|
||||
mtexinfo_t r_skytexinfo[6];
|
||||
mvertex_t *r_skyverts;
|
||||
medge_t *r_skyedges;
|
||||
int *r_skysurfedges;
|
||||
msurface_t *r_skyfaces;
|
||||
mplane_t r_skyplanes[6];
|
||||
mtexinfo_t r_skytexinfo[6];
|
||||
mvertex_t *r_skyverts;
|
||||
medge_t *r_skyedges;
|
||||
int *r_skysurfedges;
|
||||
|
||||
// I just copied this data from a box map...
|
||||
int skybox_planes[12] = {2,-128, 0,-128, 2,128, 1,128, 0,128, 1,-128};
|
||||
int skybox_planes[12] = {2, -128, 0, -128, 2, 128, 1, 128, 0, 128, 1, -128};
|
||||
|
||||
int box_surfedges[24] = { 1,2,3,4, -1,5,6,7, 8,9,-6,10, -2,-7,-9,11,
|
||||
12,-3,-11,-8, -12,-10,-5,-4};
|
||||
int box_edges[24] = { 1,2, 2,3, 3,4, 4,1, 1,5, 5,6, 6,2, 7,8, 8,6, 5,7, 8,3, 7,4};
|
||||
int box_surfedges[24] = { 1, 2, 3, 4, -1, 5, 6, 7, 8, 9, -6, 10, -2, -7, -9, 11,
|
||||
12, -3, -11, -8, -12, -10, -5, -4};
|
||||
int box_edges[24] = { 1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 2, 7, 8, 8, 6, 5, 7, 8, 3, 7, 4};
|
||||
|
||||
int box_faces[6] = {0,0,2,2,2,0};
|
||||
int box_faces[6] = {0, 0, 2, 2, 2, 0};
|
||||
|
||||
vec3_t box_vecs[6][2] = {
|
||||
{ {0,-1,0}, {-1,0,0} },
|
||||
{ {0,1,0}, {0,0,-1} },
|
||||
{ {0,-1,0}, {1,0,0} },
|
||||
{ {1,0,0}, {0,0,-1} },
|
||||
{ {0,-1,0}, {0,0,-1} },
|
||||
{ {-1,0,0}, {0,0,-1} }
|
||||
vec3_t box_vecs[6][2] = {
|
||||
{ {0, -1, 0}, {-1, 0, 0} },
|
||||
{ {0, 1, 0}, {0, 0, -1} },
|
||||
{ {0, -1, 0}, {1, 0, 0} },
|
||||
{ {1, 0, 0}, {0, 0, -1} },
|
||||
{ {0, -1, 0}, {0, 0, -1} },
|
||||
{ {-1, 0, 0}, {0, 0, -1} }
|
||||
};
|
||||
|
||||
float box_verts[8][3] = {
|
||||
{-1,-1,-1},
|
||||
{-1,1,-1},
|
||||
{1,1,-1},
|
||||
{1,-1,-1},
|
||||
{-1,-1,1},
|
||||
{-1,1,1},
|
||||
{1,-1,1},
|
||||
{1,1,1}
|
||||
float box_verts[8][3] = {
|
||||
{-1, -1, -1},
|
||||
{-1, 1, -1},
|
||||
{1, 1, -1},
|
||||
{1, -1, -1},
|
||||
{-1, -1, 1},
|
||||
{-1, 1, 1},
|
||||
{1, -1, 1},
|
||||
{1, 1, 1}
|
||||
};
|
||||
|
||||
// down, west, up, north, east, south
|
||||
|
@ -108,18 +108,18 @@ float box_verts[8][3] = {
|
|||
R_EmitEdge
|
||||
================
|
||||
*/
|
||||
static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
|
||||
static void R_EmitEdge( mvertex_t *pv0, mvertex_t *pv1 )
|
||||
{
|
||||
edge_t *edge, *pcheck;
|
||||
int u_check;
|
||||
float u, u_step;
|
||||
vec3_t local, transformed;
|
||||
float *world;
|
||||
int v, v2, ceilv0;
|
||||
float scale, lzi0, u0, v0;
|
||||
int side;
|
||||
edge_t *edge, *pcheck;
|
||||
int u_check;
|
||||
float u, u_step;
|
||||
vec3_t local, transformed;
|
||||
float *world;
|
||||
int v, v2, ceilv0;
|
||||
float scale, lzi0, u0, v0;
|
||||
int side;
|
||||
|
||||
if (r_lastvertvalid)
|
||||
if( r_lastvertvalid )
|
||||
{
|
||||
u0 = r_u1;
|
||||
v0 = r_v1;
|
||||
|
@ -130,84 +130,84 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
|
|||
{
|
||||
world = &pv0->position[0];
|
||||
|
||||
// transform and project
|
||||
VectorSubtract (world, tr.modelorg, local);
|
||||
TransformVector (local, transformed);
|
||||
// transform and project
|
||||
VectorSubtract( world, tr.modelorg, local );
|
||||
TransformVector( local, transformed );
|
||||
|
||||
if (transformed[2] < NEAR_CLIP)
|
||||
if( transformed[2] < NEAR_CLIP )
|
||||
transformed[2] = NEAR_CLIP;
|
||||
|
||||
lzi0 = 1.0f / transformed[2];
|
||||
|
||||
// FIXME: build x/yscale into transform?
|
||||
// FIXME: build x/yscale into transform?
|
||||
scale = xscale * lzi0;
|
||||
u0 = (xcenter + scale*transformed[0]);
|
||||
if (u0 < RI.fvrectx_adj)
|
||||
u0 = ( xcenter + scale * transformed[0] );
|
||||
if( u0 < RI.fvrectx_adj )
|
||||
u0 = RI.fvrectx_adj;
|
||||
if (u0 > RI.fvrectright_adj)
|
||||
if( u0 > RI.fvrectright_adj )
|
||||
u0 = RI.fvrectright_adj;
|
||||
|
||||
scale = yscale * lzi0;
|
||||
v0 = (ycenter - scale*transformed[1]);
|
||||
if (v0 < RI.fvrecty_adj)
|
||||
v0 = ( ycenter - scale * transformed[1] );
|
||||
if( v0 < RI.fvrecty_adj )
|
||||
v0 = RI.fvrecty_adj;
|
||||
if (v0 > RI.fvrectbottom_adj)
|
||||
if( v0 > RI.fvrectbottom_adj )
|
||||
v0 = RI.fvrectbottom_adj;
|
||||
|
||||
ceilv0 = (int) ceil(v0);
|
||||
ceilv0 = (int) ceil( v0 );
|
||||
}
|
||||
|
||||
world = &pv1->position[0];
|
||||
|
||||
// transform and project
|
||||
VectorSubtract (world, tr.modelorg, local);
|
||||
TransformVector (local, transformed);
|
||||
VectorSubtract( world, tr.modelorg, local );
|
||||
TransformVector( local, transformed );
|
||||
|
||||
if (transformed[2] < NEAR_CLIP)
|
||||
if( transformed[2] < NEAR_CLIP )
|
||||
transformed[2] = NEAR_CLIP;
|
||||
|
||||
r_lzi1 = 1.0f / transformed[2];
|
||||
|
||||
scale = xscale * r_lzi1;
|
||||
r_u1 = (xcenter + scale*transformed[0]);
|
||||
if (r_u1 < RI.fvrectx_adj)
|
||||
r_u1 = ( xcenter + scale * transformed[0] );
|
||||
if( r_u1 < RI.fvrectx_adj )
|
||||
r_u1 = RI.fvrectx_adj;
|
||||
if (r_u1 > RI.fvrectright_adj)
|
||||
if( r_u1 > RI.fvrectright_adj )
|
||||
r_u1 = RI.fvrectright_adj;
|
||||
|
||||
scale = yscale * r_lzi1;
|
||||
r_v1 = (ycenter - scale*transformed[1]);
|
||||
if (r_v1 < RI.fvrecty_adj)
|
||||
r_v1 = ( ycenter - scale * transformed[1] );
|
||||
if( r_v1 < RI.fvrecty_adj )
|
||||
r_v1 = RI.fvrecty_adj;
|
||||
if (r_v1 > RI.fvrectbottom_adj)
|
||||
if( r_v1 > RI.fvrectbottom_adj )
|
||||
r_v1 = RI.fvrectbottom_adj;
|
||||
|
||||
if (r_lzi1 > lzi0)
|
||||
if( r_lzi1 > lzi0 )
|
||||
lzi0 = r_lzi1;
|
||||
|
||||
if (lzi0 > r_nearzi) // for mipmap finding
|
||||
if( lzi0 > r_nearzi ) // for mipmap finding
|
||||
r_nearzi = lzi0;
|
||||
|
||||
// for right edges, all we want is the effect on 1/z
|
||||
if (r_nearzionly)
|
||||
if( r_nearzionly )
|
||||
return;
|
||||
|
||||
r_emitted = 1;
|
||||
|
||||
r_ceilv1 = (int) ceil(r_v1);
|
||||
r_ceilv1 = (int) ceil( r_v1 );
|
||||
|
||||
|
||||
// create the edge
|
||||
if (ceilv0 == r_ceilv1 || ceilv0 < 0 )
|
||||
if( ceilv0 == r_ceilv1 || ceilv0 < 0 )
|
||||
{
|
||||
// we cache unclipped horizontal edges as fully clipped
|
||||
if (cacheoffset != 0x7FFFFFFF)
|
||||
// we cache unclipped horizontal edges as fully clipped
|
||||
if( cacheoffset != 0x7FFFFFFF )
|
||||
{
|
||||
cacheoffset = FULLY_CLIPPED_CACHED |
|
||||
(tr.framecount & FRAMECOUNT_MASK);
|
||||
cacheoffset = FULLY_CLIPPED_CACHED
|
||||
| ( tr.framecount & FRAMECOUNT_MASK );
|
||||
}
|
||||
|
||||
return; // horizontal edge
|
||||
return; // horizontal edge
|
||||
}
|
||||
|
||||
side = ceilv0 > r_ceilv1;
|
||||
|
@ -218,9 +218,9 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
|
|||
|
||||
edge->nearzi = lzi0;
|
||||
|
||||
if (side == 0)
|
||||
if( side == 0 )
|
||||
{
|
||||
// trailing edge (go from p1 to p2)
|
||||
// trailing edge (go from p1 to p2)
|
||||
v = ceilv0;
|
||||
v2 = r_ceilv1 - 1;
|
||||
|
||||
|
@ -233,12 +233,12 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
|
|||
edge->surfs[0] = surface_p - surfaces;
|
||||
edge->surfs[1] = 0;
|
||||
|
||||
u_step = ((r_u1 - u0) / (r_v1 - v0));
|
||||
u = u0 + ((float)v - v0) * u_step;
|
||||
u_step = (( r_u1 - u0 ) / ( r_v1 - v0 ));
|
||||
u = u0 + ((float)v - v0 ) * u_step;
|
||||
}
|
||||
else
|
||||
{
|
||||
// leading edge (go from p2 to p1)
|
||||
// leading edge (go from p2 to p1)
|
||||
v2 = ceilv0 - 1;
|
||||
v = r_ceilv1;
|
||||
|
||||
|
@ -251,12 +251,12 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
|
|||
edge->surfs[0] = 0;
|
||||
edge->surfs[1] = surface_p - surfaces;
|
||||
|
||||
u_step = ((u0 - r_u1) / (v0 - r_v1));
|
||||
u = r_u1 + ((float)v - r_v1) * u_step;
|
||||
u_step = (( u0 - r_u1 ) / ( v0 - r_v1 ));
|
||||
u = r_u1 + ((float)v - r_v1 ) * u_step;
|
||||
}
|
||||
|
||||
edge->u_step = u_step*0x100000;
|
||||
edge->u = u*0x100000 + 0xFFFFF;
|
||||
edge->u_step = u_step * 0x100000;
|
||||
edge->u = u * 0x100000 + 0xFFFFF;
|
||||
|
||||
// we need to do this to avoid stepping off the edges if a very nearly
|
||||
// horizontal edge is less than epsilon above a scan, and numeric error causes
|
||||
|
@ -269,9 +269,9 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
|
|||
edge->u = x;
|
||||
if (edge->u > r)
|
||||
edge->u = r;*/
|
||||
if (edge->u < RI.vrect_x_adj_shift20)
|
||||
if( edge->u < RI.vrect_x_adj_shift20 )
|
||||
edge->u = RI.vrect_x_adj_shift20;
|
||||
if (edge->u > RI.vrectright_adj_shift20)
|
||||
if( edge->u > RI.vrectright_adj_shift20 )
|
||||
edge->u = RI.vrectright_adj_shift20;
|
||||
|
||||
|
||||
|
@ -279,10 +279,10 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
|
|||
// sort the edge in normally
|
||||
//
|
||||
u_check = edge->u;
|
||||
if (edge->surfs[0])
|
||||
u_check++; // sort trailers after leaders
|
||||
if( edge->surfs[0] )
|
||||
u_check++; // sort trailers after leaders
|
||||
|
||||
if (!newedges[v] || newedges[v]->u >= u_check)
|
||||
if( !newedges[v] || newedges[v]->u >= u_check )
|
||||
{
|
||||
edge->next = newedges[v];
|
||||
newedges[v] = edge;
|
||||
|
@ -290,7 +290,7 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
|
|||
else
|
||||
{
|
||||
pcheck = newedges[v];
|
||||
while (pcheck->next && pcheck->next->u < u_check)
|
||||
while( pcheck->next && pcheck->next->u < u_check )
|
||||
pcheck = pcheck->next;
|
||||
edge->next = pcheck->next;
|
||||
pcheck->next = edge;
|
||||
|
@ -306,100 +306,101 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
|
|||
R_ClipEdge
|
||||
================
|
||||
*/
|
||||
static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
|
||||
static void R_ClipEdge( mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip )
|
||||
{
|
||||
float d0, d1, f;
|
||||
mvertex_t clipvert;
|
||||
float d0, d1, f;
|
||||
mvertex_t clipvert;
|
||||
|
||||
if (clip)
|
||||
if( clip )
|
||||
{
|
||||
do
|
||||
{
|
||||
d0 = DotProduct (pv0->position, clip->normal) - clip->dist;
|
||||
d1 = DotProduct (pv1->position, clip->normal) - clip->dist;
|
||||
d0 = DotProduct( pv0->position, clip->normal ) - clip->dist;
|
||||
d1 = DotProduct( pv1->position, clip->normal ) - clip->dist;
|
||||
|
||||
if (d0 >= 0)
|
||||
if( d0 >= 0 )
|
||||
{
|
||||
// point 0 is unclipped
|
||||
if (d1 >= 0)
|
||||
// point 0 is unclipped
|
||||
if( d1 >= 0 )
|
||||
{
|
||||
// both points are unclipped
|
||||
// both points are unclipped
|
||||
continue;
|
||||
}
|
||||
|
||||
// only point 1 is clipped
|
||||
// only point 1 is clipped
|
||||
|
||||
// we don't cache clipped edges
|
||||
// we don't cache clipped edges
|
||||
cacheoffset = 0x7FFFFFFF;
|
||||
|
||||
f = d0 / (d0 - d1);
|
||||
clipvert.position[0] = pv0->position[0] +
|
||||
f * (pv1->position[0] - pv0->position[0]);
|
||||
clipvert.position[1] = pv0->position[1] +
|
||||
f * (pv1->position[1] - pv0->position[1]);
|
||||
clipvert.position[2] = pv0->position[2] +
|
||||
f * (pv1->position[2] - pv0->position[2]);
|
||||
f = d0 / ( d0 - d1 );
|
||||
clipvert.position[0] = pv0->position[0]
|
||||
+ f * ( pv1->position[0] - pv0->position[0] );
|
||||
clipvert.position[1] = pv0->position[1]
|
||||
+ f * ( pv1->position[1] - pv0->position[1] );
|
||||
clipvert.position[2] = pv0->position[2]
|
||||
+ f * ( pv1->position[2] - pv0->position[2] );
|
||||
|
||||
if (clip->leftedge)
|
||||
if( clip->leftedge )
|
||||
{
|
||||
r_leftclipped = true;
|
||||
r_leftexit = clipvert;
|
||||
}
|
||||
else if (clip->rightedge)
|
||||
else if( clip->rightedge )
|
||||
{
|
||||
r_rightclipped = true;
|
||||
r_rightexit = clipvert;
|
||||
}
|
||||
|
||||
R_ClipEdge (pv0, &clipvert, clip->next);
|
||||
R_ClipEdge( pv0, &clipvert, clip->next );
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// point 0 is clipped
|
||||
if (d1 < 0)
|
||||
// point 0 is clipped
|
||||
if( d1 < 0 )
|
||||
{
|
||||
// both points are clipped
|
||||
// we do cache fully clipped edges
|
||||
if (!r_leftclipped)
|
||||
cacheoffset = FULLY_CLIPPED_CACHED |
|
||||
(tr.framecount & FRAMECOUNT_MASK);
|
||||
// both points are clipped
|
||||
// we do cache fully clipped edges
|
||||
if( !r_leftclipped )
|
||||
cacheoffset = FULLY_CLIPPED_CACHED
|
||||
| ( tr.framecount & FRAMECOUNT_MASK );
|
||||
return;
|
||||
}
|
||||
|
||||
// only point 0 is clipped
|
||||
// only point 0 is clipped
|
||||
r_lastvertvalid = false;
|
||||
|
||||
// we don't cache partially clipped edges
|
||||
// we don't cache partially clipped edges
|
||||
cacheoffset = 0x7FFFFFFF;
|
||||
|
||||
f = d0 / (d0 - d1);
|
||||
clipvert.position[0] = pv0->position[0] +
|
||||
f * (pv1->position[0] - pv0->position[0]);
|
||||
clipvert.position[1] = pv0->position[1] +
|
||||
f * (pv1->position[1] - pv0->position[1]);
|
||||
clipvert.position[2] = pv0->position[2] +
|
||||
f * (pv1->position[2] - pv0->position[2]);
|
||||
f = d0 / ( d0 - d1 );
|
||||
clipvert.position[0] = pv0->position[0]
|
||||
+ f * ( pv1->position[0] - pv0->position[0] );
|
||||
clipvert.position[1] = pv0->position[1]
|
||||
+ f * ( pv1->position[1] - pv0->position[1] );
|
||||
clipvert.position[2] = pv0->position[2]
|
||||
+ f * ( pv1->position[2] - pv0->position[2] );
|
||||
|
||||
if (clip->leftedge)
|
||||
if( clip->leftedge )
|
||||
{
|
||||
r_leftclipped = true;
|
||||
r_leftenter = clipvert;
|
||||
}
|
||||
else if (clip->rightedge)
|
||||
else if( clip->rightedge )
|
||||
{
|
||||
r_rightclipped = true;
|
||||
r_rightenter = clipvert;
|
||||
}
|
||||
|
||||
R_ClipEdge (&clipvert, pv1, clip->next);
|
||||
R_ClipEdge( &clipvert, pv1, clip->next );
|
||||
return;
|
||||
}
|
||||
} while ((clip = clip->next) != NULL);
|
||||
}
|
||||
while(( clip = clip->next ) != NULL );
|
||||
}
|
||||
|
||||
// add the edge
|
||||
R_EmitEdge (pv0, pv1);
|
||||
R_EmitEdge( pv0, pv1 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -407,18 +408,18 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
|
|||
R_EmitCachedEdge
|
||||
================
|
||||
*/
|
||||
static void R_EmitCachedEdge (void)
|
||||
static void R_EmitCachedEdge( void )
|
||||
{
|
||||
edge_t *pedge_t;
|
||||
edge_t *pedge_t;
|
||||
|
||||
pedge_t = (edge_t *)((uintptr_t)r_edges + r_pedge->cachededgeoffset);
|
||||
pedge_t = (edge_t *)((uintptr_t)r_edges + r_pedge->cachededgeoffset );
|
||||
|
||||
if (!pedge_t->surfs[0])
|
||||
if( !pedge_t->surfs[0] )
|
||||
pedge_t->surfs[0] = surface_p - surfaces;
|
||||
else
|
||||
pedge_t->surfs[1] = surface_p - surfaces;
|
||||
|
||||
if (pedge_t->nearzi > r_nearzi) // for mipmap finding
|
||||
if( pedge_t->nearzi > r_nearzi )// for mipmap finding
|
||||
r_nearzi = pedge_t->nearzi;
|
||||
|
||||
r_emitted = 1;
|
||||
|
@ -430,43 +431,43 @@ static void R_EmitCachedEdge (void)
|
|||
R_RenderFace
|
||||
================
|
||||
*/
|
||||
void R_RenderFace (msurface_t *fa, int clipflags)
|
||||
void R_RenderFace( msurface_t *fa, int clipflags )
|
||||
{
|
||||
int i, lindex;
|
||||
unsigned mask;
|
||||
mplane_t *pplane;
|
||||
float distinv;
|
||||
vec3_t p_normal;
|
||||
medge_t *pedges, tedge;
|
||||
clipplane_t *pclip;
|
||||
int i, lindex;
|
||||
unsigned mask;
|
||||
mplane_t *pplane;
|
||||
float distinv;
|
||||
vec3_t p_normal;
|
||||
medge_t *pedges, tedge;
|
||||
clipplane_t *pclip;
|
||||
|
||||
// translucent surfaces are not drawn by the edge renderer
|
||||
if (fa->flags & (SURF_DRAWTURB|SURF_TRANSPARENT))
|
||||
if( fa->flags & ( SURF_DRAWTURB | SURF_TRANSPARENT ))
|
||||
{
|
||||
//fa->nextalphasurface = r_alpha_surfaces;
|
||||
//r_alpha_surfaces = fa;
|
||||
//return;
|
||||
// fa->nextalphasurface = r_alpha_surfaces;
|
||||
// r_alpha_surfaces = fa;
|
||||
// return;
|
||||
}
|
||||
|
||||
// sky surfaces encountered in the world will cause the
|
||||
// environment box surfaces to be emited
|
||||
if ( fa->flags & SURF_DRAWSKY )
|
||||
if( fa->flags & SURF_DRAWSKY )
|
||||
{
|
||||
//R_EmitSkyBox ();
|
||||
// return;
|
||||
// R_EmitSkyBox ();
|
||||
// return;
|
||||
}
|
||||
|
||||
// skip out if no more surfs
|
||||
if ((surface_p) >= surf_max)
|
||||
if(( surface_p ) >= surf_max )
|
||||
{
|
||||
// r_outofsurfaces++;
|
||||
// r_outofsurfaces++;
|
||||
return;
|
||||
}
|
||||
|
||||
// ditto if not enough edges left, or switch to auxedges if possible
|
||||
if ((edge_p + fa->numedges + 4) >= edge_max)
|
||||
if(( edge_p + fa->numedges + 4 ) >= edge_max )
|
||||
{
|
||||
//r_outofedges += fa->numedges;
|
||||
// r_outofedges += fa->numedges;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -475,9 +476,9 @@ void R_RenderFace (msurface_t *fa, int clipflags)
|
|||
// set up clip planes
|
||||
pclip = NULL;
|
||||
|
||||
for (i=3, mask = 0x08 ; i>=0 ; i--, mask >>= 1)
|
||||
for( i = 3, mask = 0x08; i >= 0; i--, mask >>= 1 )
|
||||
{
|
||||
if (clipflags & mask)
|
||||
if( clipflags & mask )
|
||||
{
|
||||
qfrustum.view_clipplanes[i].next = pclip;
|
||||
pclip = &qfrustum.view_clipplanes[i];
|
||||
|
@ -492,21 +493,21 @@ void R_RenderFace (msurface_t *fa, int clipflags)
|
|||
pedges = RI.currentmodel->edges;
|
||||
r_lastvertvalid = false;
|
||||
|
||||
for (i=0 ; i<fa->numedges ; i++)
|
||||
for( i = 0; i < fa->numedges; i++ )
|
||||
{
|
||||
lindex = RI.currentmodel->surfedges[fa->firstedge + i];
|
||||
|
||||
if (lindex > 0)
|
||||
if( lindex > 0 )
|
||||
{
|
||||
r_pedge = &pedges[lindex];
|
||||
|
||||
// if the edge is cached, we can just reuse the edge
|
||||
if (!insubmodel)
|
||||
// if the edge is cached, we can just reuse the edge
|
||||
if( !insubmodel )
|
||||
{
|
||||
if (r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED)
|
||||
if( r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED )
|
||||
{
|
||||
if ((r_pedge->cachededgeoffset & FRAMECOUNT_MASK) ==
|
||||
tr.framecount)
|
||||
if(( r_pedge->cachededgeoffset & FRAMECOUNT_MASK )
|
||||
== tr.framecount )
|
||||
{
|
||||
r_lastvertvalid = false;
|
||||
continue;
|
||||
|
@ -514,29 +515,29 @@ void R_RenderFace (msurface_t *fa, int clipflags)
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((((uintptr_t)edge_p - (uintptr_t)r_edges) >
|
||||
r_pedge->cachededgeoffset) &&
|
||||
(((edge_t *)((uintptr_t)r_edges +
|
||||
r_pedge->cachededgeoffset))->owner == r_pedge))
|
||||
if((((uintptr_t)edge_p - (uintptr_t)r_edges )
|
||||
> r_pedge->cachededgeoffset )
|
||||
&& (((edge_t *)((uintptr_t)r_edges
|
||||
+ r_pedge->cachededgeoffset ))->owner == r_pedge ))
|
||||
{
|
||||
R_EmitCachedEdge ();
|
||||
R_EmitCachedEdge();
|
||||
r_lastvertvalid = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// assume it's cacheable
|
||||
// assume it's cacheable
|
||||
cacheoffset = (byte *)edge_p - (byte *)r_edges;
|
||||
r_leftclipped = r_rightclipped = false;
|
||||
R_ClipEdge (&r_pcurrentvertbase[r_pedge->v[0]],
|
||||
&r_pcurrentvertbase[r_pedge->v[1]],
|
||||
pclip);
|
||||
R_ClipEdge( &r_pcurrentvertbase[r_pedge->v[0]],
|
||||
&r_pcurrentvertbase[r_pedge->v[1]],
|
||||
pclip );
|
||||
r_pedge->cachededgeoffset = cacheoffset;
|
||||
|
||||
if (r_leftclipped)
|
||||
if( r_leftclipped )
|
||||
makeleftedge = true;
|
||||
if (r_rightclipped)
|
||||
if( r_rightclipped )
|
||||
makerightedge = true;
|
||||
r_lastvertvalid = true;
|
||||
}
|
||||
|
@ -544,13 +545,13 @@ void R_RenderFace (msurface_t *fa, int clipflags)
|
|||
{
|
||||
lindex = -lindex;
|
||||
r_pedge = &pedges[lindex];
|
||||
// if the edge is cached, we can just reuse the edge
|
||||
if (!insubmodel)
|
||||
// if the edge is cached, we can just reuse the edge
|
||||
if( !insubmodel )
|
||||
{
|
||||
if (r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED)
|
||||
if( r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED )
|
||||
{
|
||||
if ((r_pedge->cachededgeoffset & FRAMECOUNT_MASK) ==
|
||||
tr.framecount)
|
||||
if(( r_pedge->cachededgeoffset & FRAMECOUNT_MASK )
|
||||
== tr.framecount )
|
||||
{
|
||||
r_lastvertvalid = false;
|
||||
continue;
|
||||
|
@ -558,31 +559,31 @@ void R_RenderFace (msurface_t *fa, int clipflags)
|
|||
}
|
||||
else
|
||||
{
|
||||
// it's cached if the cached edge is valid and is owned
|
||||
// by this medge_t
|
||||
if ((((uintptr_t)edge_p - (uintptr_t)r_edges) >
|
||||
r_pedge->cachededgeoffset) &&
|
||||
(((edge_t *)((uintptr_t)r_edges +
|
||||
r_pedge->cachededgeoffset))->owner == r_pedge))
|
||||
// it's cached if the cached edge is valid and is owned
|
||||
// by this medge_t
|
||||
if((((uintptr_t)edge_p - (uintptr_t)r_edges )
|
||||
> r_pedge->cachededgeoffset )
|
||||
&& (((edge_t *)((uintptr_t)r_edges
|
||||
+ r_pedge->cachededgeoffset ))->owner == r_pedge ))
|
||||
{
|
||||
R_EmitCachedEdge ();
|
||||
R_EmitCachedEdge();
|
||||
r_lastvertvalid = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// assume it's cacheable
|
||||
// assume it's cacheable
|
||||
cacheoffset = (byte *)edge_p - (byte *)r_edges;
|
||||
r_leftclipped = r_rightclipped = false;
|
||||
R_ClipEdge (&r_pcurrentvertbase[r_pedge->v[1]],
|
||||
&r_pcurrentvertbase[r_pedge->v[0]],
|
||||
pclip);
|
||||
R_ClipEdge( &r_pcurrentvertbase[r_pedge->v[1]],
|
||||
&r_pcurrentvertbase[r_pedge->v[0]],
|
||||
pclip );
|
||||
r_pedge->cachededgeoffset = cacheoffset;
|
||||
|
||||
if (r_leftclipped)
|
||||
if( r_leftclipped )
|
||||
makeleftedge = true;
|
||||
if (r_rightclipped)
|
||||
if( r_rightclipped )
|
||||
makerightedge = true;
|
||||
r_lastvertvalid = true;
|
||||
}
|
||||
|
@ -591,24 +592,24 @@ void R_RenderFace (msurface_t *fa, int clipflags)
|
|||
// if there was a clip off the left edge, add that edge too
|
||||
// FIXME: faster to do in screen space?
|
||||
// FIXME: share clipped edges?
|
||||
if (makeleftedge)
|
||||
if( makeleftedge )
|
||||
{
|
||||
r_pedge = &tedge;
|
||||
r_lastvertvalid = false;
|
||||
R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next);
|
||||
R_ClipEdge( &r_leftexit, &r_leftenter, pclip->next );
|
||||
}
|
||||
|
||||
// if there was a clip off the right edge, get the right r_nearzi
|
||||
if (makerightedge)
|
||||
if( makerightedge )
|
||||
{
|
||||
r_pedge = &tedge;
|
||||
r_lastvertvalid = false;
|
||||
r_nearzionly = true;
|
||||
R_ClipEdge (&r_rightexit, &r_rightenter, qfrustum.view_clipplanes[1].next);
|
||||
R_ClipEdge( &r_rightexit, &r_rightenter, qfrustum.view_clipplanes[1].next );
|
||||
}
|
||||
|
||||
// if no edges made it out, return without posting the surface
|
||||
if (!r_emitted)
|
||||
if( !r_emitted )
|
||||
return;
|
||||
|
||||
// r_polycount++;
|
||||
|
@ -624,15 +625,15 @@ void R_RenderFace (msurface_t *fa, int clipflags)
|
|||
|
||||
pplane = fa->plane;
|
||||
// FIXME: cache this?
|
||||
TransformVector (pplane->normal, p_normal);
|
||||
TransformVector( pplane->normal, p_normal );
|
||||
// FIXME: cache this?
|
||||
distinv = 1.0f / (pplane->dist - DotProduct (tr.modelorg, pplane->normal));
|
||||
distinv = 1.0f / ( pplane->dist - DotProduct( tr.modelorg, pplane->normal ));
|
||||
|
||||
surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv;
|
||||
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
|
||||
surface_p->d_ziorigin = p_normal[2] * distinv -
|
||||
xcenter * surface_p->d_zistepu -
|
||||
ycenter * surface_p->d_zistepv;
|
||||
surface_p->d_ziorigin = p_normal[2] * distinv
|
||||
- xcenter * surface_p->d_zistepu
|
||||
- ycenter * surface_p->d_zistepv;
|
||||
|
||||
surface_p++;
|
||||
}
|
||||
|
@ -643,15 +644,15 @@ void R_RenderFace (msurface_t *fa, int clipflags)
|
|||
R_RenderBmodelFace
|
||||
================
|
||||
*/
|
||||
void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
|
||||
void R_RenderBmodelFace( bedge_t *pedges, msurface_t *psurf )
|
||||
{
|
||||
int i;
|
||||
unsigned mask;
|
||||
mplane_t *pplane;
|
||||
float distinv;
|
||||
vec3_t p_normal;
|
||||
medge_t tedge;
|
||||
clipplane_t *pclip;
|
||||
int i;
|
||||
unsigned mask;
|
||||
mplane_t *pplane;
|
||||
float distinv;
|
||||
vec3_t p_normal;
|
||||
medge_t tedge;
|
||||
clipplane_t *pclip;
|
||||
|
||||
/*if (psurf->texinfo->flags & (SURF_TRANS33|SURF_TRANS66))
|
||||
{
|
||||
|
@ -661,16 +662,16 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
|
|||
}*/
|
||||
|
||||
// skip out if no more surfs
|
||||
if (surface_p >= surf_max)
|
||||
if( surface_p >= surf_max )
|
||||
{
|
||||
//r_outofsurfaces++;
|
||||
// r_outofsurfaces++;
|
||||
return;
|
||||
}
|
||||
|
||||
// ditto if not enough edges left, or switch to auxedges if possible
|
||||
if ((edge_p + psurf->numedges + 4) >= edge_max)
|
||||
if(( edge_p + psurf->numedges + 4 ) >= edge_max )
|
||||
{
|
||||
//r_outofedges += psurf->numedges;
|
||||
// r_outofedges += psurf->numedges;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -682,9 +683,9 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
|
|||
// set up clip planes
|
||||
pclip = NULL;
|
||||
|
||||
for (i=3, mask = 0x08 ; i>=0 ; i--, mask >>= 1)
|
||||
for( i = 3, mask = 0x08; i >= 0; i--, mask >>= 1 )
|
||||
{
|
||||
if (r_clipflags & mask)
|
||||
if( r_clipflags & mask )
|
||||
{
|
||||
qfrustum.view_clipplanes[i].next = pclip;
|
||||
pclip = &qfrustum.view_clipplanes[i];
|
||||
|
@ -700,39 +701,39 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
|
|||
// can be used?
|
||||
r_lastvertvalid = false;
|
||||
|
||||
for ( ; pedges ; pedges = pedges->pnext)
|
||||
for( ; pedges; pedges = pedges->pnext )
|
||||
{
|
||||
r_leftclipped = r_rightclipped = false;
|
||||
R_ClipEdge (pedges->v[0], pedges->v[1], pclip);
|
||||
R_ClipEdge( pedges->v[0], pedges->v[1], pclip );
|
||||
|
||||
if (r_leftclipped)
|
||||
if( r_leftclipped )
|
||||
makeleftedge = true;
|
||||
if (r_rightclipped)
|
||||
if( r_rightclipped )
|
||||
makerightedge = true;
|
||||
}
|
||||
|
||||
// if there was a clip off the left edge, add that edge too
|
||||
// FIXME: faster to do in screen space?
|
||||
// FIXME: share clipped edges?
|
||||
if (makeleftedge)
|
||||
if( makeleftedge )
|
||||
{
|
||||
r_pedge = &tedge;
|
||||
R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next);
|
||||
R_ClipEdge( &r_leftexit, &r_leftenter, pclip->next );
|
||||
}
|
||||
|
||||
// if there was a clip off the right edge, get the right r_nearzi
|
||||
if (makerightedge)
|
||||
if( makerightedge )
|
||||
{
|
||||
r_pedge = &tedge;
|
||||
r_nearzionly = true;
|
||||
R_ClipEdge (&r_rightexit, &r_rightenter, qfrustum.view_clipplanes[1].next);
|
||||
R_ClipEdge( &r_rightexit, &r_rightenter, qfrustum.view_clipplanes[1].next );
|
||||
}
|
||||
|
||||
// if no edges made it out, return without posting the surface
|
||||
if (!r_emitted)
|
||||
if( !r_emitted )
|
||||
return;
|
||||
|
||||
//r_polycount++;
|
||||
// r_polycount++;
|
||||
|
||||
surface_p->msurf = psurf;
|
||||
surface_p->nearzi = r_nearzi;
|
||||
|
@ -745,15 +746,15 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
|
|||
|
||||
pplane = psurf->plane;
|
||||
// FIXME: cache this?
|
||||
TransformVector (pplane->normal, p_normal);
|
||||
TransformVector( pplane->normal, p_normal );
|
||||
// FIXME: cache this?
|
||||
distinv = 1.0f / (pplane->dist - DotProduct (tr.modelorg, pplane->normal));
|
||||
distinv = 1.0f / ( pplane->dist - DotProduct( tr.modelorg, pplane->normal ));
|
||||
|
||||
surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv;
|
||||
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
|
||||
surface_p->d_ziorigin = p_normal[2] * distinv -
|
||||
xcenter * surface_p->d_zistepu -
|
||||
ycenter * surface_p->d_zistepv;
|
||||
surface_p->d_ziorigin = p_normal[2] * distinv
|
||||
- xcenter * surface_p->d_zistepu
|
||||
- ycenter * surface_p->d_zistepv;
|
||||
|
||||
surface_p++;
|
||||
}
|
||||
|
|
1406
ref/soft/r_scan.c
1406
ref/soft/r_scan.c
File diff suppressed because it is too large
Load diff
|
@ -19,13 +19,13 @@ GNU General Public License for more details.
|
|||
#include "studio.h"
|
||||
#include "entity_types.h"
|
||||
|
||||
#define GLARE_FALLOFF 19000.0f
|
||||
#define GLARE_FALLOFF 19000.0f
|
||||
|
||||
char sprite_name[MAX_QPATH];
|
||||
char group_suffix[8];
|
||||
static uint r_texFlags = 0;
|
||||
static int sprite_version;
|
||||
float sprite_radius;
|
||||
char sprite_name[MAX_QPATH];
|
||||
char group_suffix[8];
|
||||
static uint r_texFlags = 0;
|
||||
static int sprite_version;
|
||||
float sprite_radius;
|
||||
|
||||
/*
|
||||
====================
|
||||
|
@ -46,11 +46,11 @@ upload a single frame
|
|||
*/
|
||||
static const byte *R_SpriteLoadFrame( model_t *mod, const void *pin, mspriteframe_t **ppframe, int num )
|
||||
{
|
||||
dspriteframe_t pinframe;
|
||||
mspriteframe_t *pspriteframe;
|
||||
int gl_texturenum = 0;
|
||||
char texname[128];
|
||||
int bytes = 1;
|
||||
dspriteframe_t pinframe;
|
||||
mspriteframe_t *pspriteframe;
|
||||
int gl_texturenum = 0;
|
||||
char texname[128];
|
||||
int bytes = 1;
|
||||
|
||||
memcpy( &pinframe, pin, sizeof( dspriteframe_t ));
|
||||
|
||||
|
@ -80,7 +80,7 @@ static const byte *R_SpriteLoadFrame( model_t *mod, const void *pin, mspritefram
|
|||
pspriteframe->gl_texturenum = gl_texturenum;
|
||||
*ppframe = pspriteframe;
|
||||
|
||||
return ( const byte* )(( const byte* )pin + sizeof( dspriteframe_t ) + pinframe.width * pinframe.height * bytes );
|
||||
return (const byte *)((const byte *)pin + sizeof( dspriteframe_t ) + pinframe.width * pinframe.height * bytes );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -92,22 +92,22 @@ upload a group frames
|
|||
*/
|
||||
static const void *R_SpriteLoadGroup( model_t *mod, const void *pin, mspriteframe_t **ppframe, int framenum )
|
||||
{
|
||||
const dspritegroup_t *pingroup;
|
||||
mspritegroup_t *pspritegroup;
|
||||
const dspriteinterval_t *pin_intervals;
|
||||
float *poutintervals;
|
||||
int i, groupsize, numframes;
|
||||
const void *ptemp;
|
||||
const dspritegroup_t *pingroup;
|
||||
mspritegroup_t *pspritegroup;
|
||||
const dspriteinterval_t *pin_intervals;
|
||||
float *poutintervals;
|
||||
int i, groupsize, numframes;
|
||||
const void *ptemp;
|
||||
|
||||
pingroup = (const dspritegroup_t *)pin;
|
||||
numframes = pingroup->numframes;
|
||||
|
||||
groupsize = sizeof( mspritegroup_t ) + (numframes - 1) * sizeof( pspritegroup->frames[0] );
|
||||
groupsize = sizeof( mspritegroup_t ) + ( numframes - 1 ) * sizeof( pspritegroup->frames[0] );
|
||||
pspritegroup = Mem_Calloc( mod->mempool, groupsize );
|
||||
pspritegroup->numframes = numframes;
|
||||
|
||||
*ppframe = (mspriteframe_t *)pspritegroup;
|
||||
pin_intervals = (const dspriteinterval_t *)(pingroup + 1);
|
||||
pin_intervals = (const dspriteinterval_t *)( pingroup + 1 );
|
||||
poutintervals = Mem_Calloc( mod->mempool, numframes * sizeof( float ));
|
||||
pspritegroup->intervals = poutintervals;
|
||||
|
||||
|
@ -138,11 +138,11 @@ load sprite model
|
|||
*/
|
||||
void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, uint texFlags )
|
||||
{
|
||||
const dsprite_t *pin;
|
||||
const short *numi = NULL;
|
||||
const byte *pframetype;
|
||||
msprite_t *psprite;
|
||||
int i;
|
||||
const dsprite_t *pin;
|
||||
const short *numi = NULL;
|
||||
const byte *pframetype;
|
||||
msprite_t *psprite;
|
||||
int i;
|
||||
|
||||
pin = buffer;
|
||||
psprite = mod->cache.data;
|
||||
|
@ -150,7 +150,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
|
|||
if( pin->version == SPRITE_VERSION_Q1 || pin->version == SPRITE_VERSION_32 )
|
||||
numi = NULL;
|
||||
else if( pin->version == SPRITE_VERSION_HL )
|
||||
numi = (const short *)((const byte*)buffer + sizeof( dsprite_hl_t ));
|
||||
numi = (const short *)((const byte *)buffer + sizeof( dsprite_hl_t ));
|
||||
|
||||
r_texFlags = texFlags;
|
||||
sprite_version = pin->version;
|
||||
|
@ -159,16 +159,16 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
|
|||
|
||||
if( numi == NULL )
|
||||
{
|
||||
rgbdata_t *pal;
|
||||
rgbdata_t *pal;
|
||||
|
||||
pal = gEngfuncs.FS_LoadImage( "#id.pal", (byte *)&i, 768 );
|
||||
pframetype = ((const byte*)buffer + sizeof( dsprite_q1_t )); // pinq1 + 1
|
||||
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
|
||||
pframetype = ((const byte *)buffer + sizeof( dsprite_q1_t )); // pinq1 + 1
|
||||
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
|
||||
}
|
||||
else if( *numi == 256 )
|
||||
{
|
||||
const byte *src = (const byte *)(numi+1);
|
||||
rgbdata_t *pal;
|
||||
const byte *src = (const byte *)( numi + 1 );
|
||||
rgbdata_t *pal;
|
||||
|
||||
// install palette
|
||||
switch( psprite->texFormat )
|
||||
|
@ -184,7 +184,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
|
|||
break;
|
||||
}
|
||||
|
||||
pframetype = (const byte *)(src + 768);
|
||||
pframetype = (const byte *)( src + 768 );
|
||||
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
|
||||
}
|
||||
else
|
||||
|
@ -198,7 +198,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
|
|||
|
||||
for( i = 0; i < mod->numframes; i++ )
|
||||
{
|
||||
frametype_t frametype;
|
||||
frametype_t frametype;
|
||||
dframetype_t dframetype;
|
||||
|
||||
memcpy( &dframetype, pframetype, sizeof( dframetype ));
|
||||
|
@ -220,10 +220,12 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
|
|||
pframetype = R_SpriteLoadGroup( mod, pframetype + sizeof( dframetype_t ), &psprite->frames[i].frameptr, i );
|
||||
break;
|
||||
}
|
||||
if( pframetype == NULL ) break; // technically an error
|
||||
if( pframetype == NULL )
|
||||
break; // technically an error
|
||||
}
|
||||
|
||||
if( loaded ) *loaded = true; // done
|
||||
if( loaded )
|
||||
*loaded = true; // done
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -235,10 +237,10 @@ release sprite model and frames
|
|||
*/
|
||||
void Mod_SpriteUnloadTextures( void *data )
|
||||
{
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
mspriteframe_t *pspriteframe;
|
||||
int i, j;
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
mspriteframe_t *pspriteframe;
|
||||
int i, j;
|
||||
|
||||
psprite = data;
|
||||
|
||||
|
@ -275,12 +277,12 @@ assume pModel is valid
|
|||
*/
|
||||
mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
|
||||
{
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
mspriteframe_t *pspriteframe = NULL;
|
||||
float *pintervals, fullinterval;
|
||||
int i, numframes;
|
||||
float targettime;
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
mspriteframe_t *pspriteframe = NULL;
|
||||
float *pintervals, fullinterval;
|
||||
int i, numframes;
|
||||
float targettime;
|
||||
|
||||
Assert( pModel != NULL );
|
||||
psprite = pModel->cache.data;
|
||||
|
@ -305,13 +307,13 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
|
|||
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
||||
pintervals = pspritegroup->intervals;
|
||||
numframes = pspritegroup->numframes;
|
||||
fullinterval = pintervals[numframes-1];
|
||||
fullinterval = pintervals[numframes - 1];
|
||||
|
||||
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
|
||||
// are positive, so we don't have to worry about division by zero
|
||||
targettime = gp_cl->time - ((int)( gp_cl->time / fullinterval )) * fullinterval;
|
||||
|
||||
for( i = 0; i < (numframes - 1); i++ )
|
||||
for( i = 0; i < ( numframes - 1 ); i++ )
|
||||
{
|
||||
if( pintervals[i] > targettime )
|
||||
break;
|
||||
|
@ -320,7 +322,7 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
|
|||
}
|
||||
else if( psprite->frames[frame].type == FRAME_ANGLED )
|
||||
{
|
||||
int angleframe = (int)(Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8) - 4) & 7;
|
||||
int angleframe = (int)( Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8 ) - 4 ) & 7;
|
||||
|
||||
// e.g. doom-style sprite monsters
|
||||
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
||||
|
@ -340,19 +342,19 @@ between frames where are we lerping
|
|||
*/
|
||||
static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe, mspriteframe_t **curframe )
|
||||
{
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
int i, j, numframes, frame;
|
||||
float lerpFrac, time, jtime, jinterval;
|
||||
float *pintervals, fullinterval, targettime;
|
||||
int m_fDoInterp;
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
int i, j, numframes, frame;
|
||||
float lerpFrac, time, jtime, jinterval;
|
||||
float *pintervals, fullinterval, targettime;
|
||||
int m_fDoInterp;
|
||||
|
||||
psprite = ent->model->cache.data;
|
||||
frame = (int)ent->curstate.frame;
|
||||
lerpFrac = 1.0f;
|
||||
|
||||
// misc info
|
||||
m_fDoInterp = (ent->curstate.effects & EF_NOINTERP) ? false : true;
|
||||
m_fDoInterp = ( ent->curstate.effects & EF_NOINTERP ) ? false : true;
|
||||
|
||||
if( frame < 0 )
|
||||
{
|
||||
|
@ -386,7 +388,8 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
|
|||
ent->latched.sequencetime = gp_cl->time;
|
||||
lerpFrac = 0.0f;
|
||||
}
|
||||
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * 11.0f;
|
||||
else
|
||||
lerpFrac = ( gp_cl->time - ent->latched.sequencetime ) * 11.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -410,26 +413,28 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
|
|||
}
|
||||
|
||||
// get the interpolated frames
|
||||
if( oldframe ) *oldframe = psprite->frames[ent->latched.prevblending[0]].frameptr;
|
||||
if( curframe ) *curframe = psprite->frames[frame].frameptr;
|
||||
if( oldframe )
|
||||
*oldframe = psprite->frames[ent->latched.prevblending[0]].frameptr;
|
||||
if( curframe )
|
||||
*curframe = psprite->frames[frame].frameptr;
|
||||
}
|
||||
else if( psprite->frames[frame].type == FRAME_GROUP )
|
||||
{
|
||||
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
||||
pintervals = pspritegroup->intervals;
|
||||
numframes = pspritegroup->numframes;
|
||||
fullinterval = pintervals[numframes-1];
|
||||
fullinterval = pintervals[numframes - 1];
|
||||
jinterval = pintervals[1] - pintervals[0];
|
||||
time = gp_cl->time;
|
||||
jtime = 0.0f;
|
||||
|
||||
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
|
||||
// are positive, so we don't have to worry about division by zero
|
||||
targettime = time - ((int)(time / fullinterval)) * fullinterval;
|
||||
targettime = time - ((int)( time / fullinterval )) * fullinterval;
|
||||
|
||||
// LordHavoc: since I can't measure the time properly when it loops from numframes - 1 to 0,
|
||||
// i instead measure the time of the first frame, hoping it is consistent
|
||||
for( i = 0, j = numframes - 1; i < (numframes - 1); i++ )
|
||||
for( i = 0, j = numframes - 1; i < ( numframes - 1 ); i++ )
|
||||
{
|
||||
if( pintervals[i] > targettime )
|
||||
break;
|
||||
|
@ -439,18 +444,21 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
|
|||
}
|
||||
|
||||
if( m_fDoInterp )
|
||||
lerpFrac = (targettime - jtime) / jinterval;
|
||||
else j = i; // no lerping
|
||||
lerpFrac = ( targettime - jtime ) / jinterval;
|
||||
else
|
||||
j = i; // no lerping
|
||||
|
||||
// get the interpolated frames
|
||||
if( oldframe ) *oldframe = pspritegroup->frames[j];
|
||||
if( curframe ) *curframe = pspritegroup->frames[i];
|
||||
if( oldframe )
|
||||
*oldframe = pspritegroup->frames[j];
|
||||
if( curframe )
|
||||
*curframe = pspritegroup->frames[i];
|
||||
}
|
||||
else if( psprite->frames[frame].type == FRAME_ANGLED )
|
||||
{
|
||||
// e.g. doom-style sprite monsters
|
||||
float yaw = ent->angles[YAW];
|
||||
int angleframe = (int)(Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8) - 4) & 7;
|
||||
float yaw = ent->angles[YAW];
|
||||
int angleframe = (int)( Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8 ) - 4 ) & 7;
|
||||
|
||||
if( m_fDoInterp )
|
||||
{
|
||||
|
@ -472,7 +480,8 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
|
|||
ent->latched.sequencetime = gp_cl->time;
|
||||
lerpFrac = 0.0f;
|
||||
}
|
||||
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * ent->curstate.framerate;
|
||||
else
|
||||
lerpFrac = ( gp_cl->time - ent->latched.sequencetime ) * ent->curstate.framerate;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -488,10 +497,12 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
|
|||
}
|
||||
|
||||
pspritegroup = (mspritegroup_t *)psprite->frames[ent->latched.prevblending[0]].frameptr;
|
||||
if( oldframe ) *oldframe = pspritegroup->frames[angleframe];
|
||||
if( oldframe )
|
||||
*oldframe = pspritegroup->frames[angleframe];
|
||||
|
||||
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
||||
if( curframe ) *curframe = pspritegroup->frames[angleframe];
|
||||
if( curframe )
|
||||
*curframe = pspritegroup->frames[angleframe];
|
||||
}
|
||||
|
||||
return lerpFrac;
|
||||
|
@ -506,8 +517,8 @@ Cull sprite model by bbox
|
|||
*/
|
||||
static qboolean R_CullSpriteModel( cl_entity_t *e, vec3_t origin )
|
||||
{
|
||||
vec3_t sprite_mins, sprite_maxs;
|
||||
float scale = 1.0f;
|
||||
vec3_t sprite_mins, sprite_maxs;
|
||||
float scale = 1.0f;
|
||||
|
||||
if( !e->model->cache.data )
|
||||
return true;
|
||||
|
@ -536,16 +547,16 @@ Set sprite brightness factor
|
|||
*/
|
||||
static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, float *pscale )
|
||||
{
|
||||
float dist, brightness;
|
||||
vec3_t glowDist;
|
||||
pmtrace_t *tr;
|
||||
float dist, brightness;
|
||||
vec3_t glowDist;
|
||||
pmtrace_t *tr;
|
||||
|
||||
VectorSubtract( origin, RI.vieworg, glowDist );
|
||||
dist = VectorLength( glowDist );
|
||||
|
||||
if( RP_NORMALPASS( ))
|
||||
{
|
||||
tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE));
|
||||
tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : ( PM_GLASS_IGNORE | PM_STUDIO_IGNORE ));
|
||||
|
||||
if(( 1.0f - tr->fraction ) * dist > 8.0f )
|
||||
return 0.0f;
|
||||
|
@ -572,8 +583,8 @@ static qboolean R_SpriteOccluded( cl_entity_t *e, vec3_t origin, float *pscale )
|
|||
{
|
||||
if( e->curstate.rendermode == kRenderGlow )
|
||||
{
|
||||
float blend;
|
||||
vec3_t v;
|
||||
float blend;
|
||||
vec3_t v;
|
||||
|
||||
TriWorldToScreen( origin, v );
|
||||
|
||||
|
@ -604,7 +615,7 @@ R_DrawSpriteQuad
|
|||
*/
|
||||
static void R_DrawSpriteQuad( mspriteframe_t *frame, vec3_t org, vec3_t v_right, vec3_t v_up, float scale )
|
||||
{
|
||||
vec3_t point;
|
||||
vec3_t point;
|
||||
image_t *image;
|
||||
|
||||
r_stats.c_sprite_polys++;
|
||||
|
@ -614,22 +625,22 @@ static void R_DrawSpriteQuad( mspriteframe_t *frame, vec3_t org, vec3_t v_right,
|
|||
r_affinetridesc.skinheight = image->height;*/
|
||||
|
||||
TriBegin( TRI_QUADS );
|
||||
TriTexCoord2f( 0.0f, 1.0f );
|
||||
VectorMA( org, frame->down * scale, v_up, point );
|
||||
VectorMA( point, frame->left * scale, v_right, point );
|
||||
TriVertex3fv( point );
|
||||
TriTexCoord2f( 0.0f, 0.0f );
|
||||
VectorMA( org, frame->up * scale, v_up, point );
|
||||
VectorMA( point, frame->left * scale, v_right, point );
|
||||
TriVertex3fv( point );
|
||||
TriTexCoord2f( 1.0f, 0.0f );
|
||||
VectorMA( org, frame->up * scale, v_up, point );
|
||||
VectorMA( point, frame->right * scale, v_right, point );
|
||||
TriVertex3fv( point );
|
||||
TriTexCoord2f( 1.0f, 1.0f );
|
||||
VectorMA( org, frame->down * scale, v_up, point );
|
||||
VectorMA( point, frame->right * scale, v_right, point );
|
||||
TriVertex3fv( point );
|
||||
TriTexCoord2f( 0.0f, 1.0f );
|
||||
VectorMA( org, frame->down * scale, v_up, point );
|
||||
VectorMA( point, frame->left * scale, v_right, point );
|
||||
TriVertex3fv( point );
|
||||
TriTexCoord2f( 0.0f, 0.0f );
|
||||
VectorMA( org, frame->up * scale, v_up, point );
|
||||
VectorMA( point, frame->left * scale, v_right, point );
|
||||
TriVertex3fv( point );
|
||||
TriTexCoord2f( 1.0f, 0.0f );
|
||||
VectorMA( org, frame->up * scale, v_up, point );
|
||||
VectorMA( point, frame->right * scale, v_right, point );
|
||||
TriVertex3fv( point );
|
||||
TriTexCoord2f( 1.0f, 1.0f );
|
||||
VectorMA( org, frame->down * scale, v_up, point );
|
||||
VectorMA( point, frame->right * scale, v_right, point );
|
||||
TriVertex3fv( point );
|
||||
TriEnd();
|
||||
}
|
||||
|
||||
|
@ -689,26 +700,26 @@ R_DrawSpriteModel
|
|||
*/
|
||||
void R_DrawSpriteModel( cl_entity_t *e )
|
||||
{
|
||||
mspriteframe_t *frame, *oldframe;
|
||||
msprite_t *psprite;
|
||||
model_t *model;
|
||||
int i, type;
|
||||
float angle, dot, sr, cr;
|
||||
float lerp = 1.0f, ilerp, scale;
|
||||
vec3_t v_forward, v_right, v_up;
|
||||
vec3_t origin, color, color2;
|
||||
mspriteframe_t *frame, *oldframe;
|
||||
msprite_t *psprite;
|
||||
model_t *model;
|
||||
int i, type;
|
||||
float angle, dot, sr, cr;
|
||||
float lerp = 1.0f, ilerp, scale;
|
||||
vec3_t v_forward, v_right, v_up;
|
||||
vec3_t origin, color, color2;
|
||||
|
||||
if( RI.params & RP_ENVVIEW )
|
||||
return;
|
||||
|
||||
model = e->model;
|
||||
psprite = (msprite_t * )model->cache.data;
|
||||
VectorCopy( e->origin, origin ); // set render origin
|
||||
psprite = (msprite_t *)model->cache.data;
|
||||
VectorCopy( e->origin, origin ); // set render origin
|
||||
|
||||
// do movewith
|
||||
if( e->curstate.aiment > 0 && e->curstate.movetype == MOVETYPE_FOLLOW )
|
||||
{
|
||||
cl_entity_t *parent;
|
||||
cl_entity_t *parent;
|
||||
|
||||
parent = CL_GetEntityByIndex( e->curstate.aiment );
|
||||
|
||||
|
@ -717,14 +728,16 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
|||
if( parent->model->type == mod_studio && e->curstate.body > 0 )
|
||||
{
|
||||
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;
|
||||
if( !scale ) scale = 1.0f;
|
||||
if( !scale )
|
||||
scale = 1.0f;
|
||||
|
||||
if( R_SpriteOccluded( e, origin, &scale ))
|
||||
return; // sprite culled
|
||||
|
@ -758,12 +771,13 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
|||
color2[1] = (float)lightColor.g * ( 1.0f / 255.0f );
|
||||
color2[2] = (float)lightColor.b * ( 1.0f / 255.0f );
|
||||
// NOTE: sprites with 'lightmap' looks ugly when alpha func is GL_GREATER 0.0
|
||||
// pglAlphaFunc( GL_GREATER, 0.5f );
|
||||
// pglAlphaFunc( GL_GREATER, 0.5f );
|
||||
}
|
||||
|
||||
if( R_SpriteAllowLerping( e, psprite ))
|
||||
lerp = R_GetSpriteFrameInterpolant( e, &oldframe, &frame );
|
||||
else frame = oldframe = R_GetSpriteFrame( model, e->curstate.frame, e->angles[YAW] );
|
||||
else
|
||||
frame = oldframe = R_GetSpriteFrame( model, e->curstate.frame, e->angles[YAW] );
|
||||
|
||||
type = psprite->type;
|
||||
|
||||
|
@ -775,28 +789,28 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
|||
{
|
||||
case SPR_ORIENTED:
|
||||
AngleVectors( e->angles, v_forward, v_right, v_up );
|
||||
VectorScale( v_forward, 0.01f, v_forward ); // to avoid z-fighting
|
||||
VectorScale( v_forward, 0.01f, v_forward ); // to avoid z-fighting
|
||||
VectorSubtract( origin, v_forward, origin );
|
||||
break;
|
||||
case SPR_FACING_UPRIGHT:
|
||||
VectorSet( v_right, origin[1] - RI.vieworg[1], -(origin[0] - RI.vieworg[0]), 0.0f );
|
||||
VectorSet( v_right, origin[1] - RI.vieworg[1], -( origin[0] - RI.vieworg[0] ), 0.0f );
|
||||
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
|
||||
VectorNormalize( v_right );
|
||||
break;
|
||||
case SPR_FWD_PARALLEL_UPRIGHT:
|
||||
dot = RI.vforward[2];
|
||||
if(( dot > 0.999848f ) || ( dot < -0.999848f )) // cos(1 degree) = 0.999848
|
||||
if(( dot > 0.999848f ) || ( dot < -0.999848f )) // cos(1 degree) = 0.999848
|
||||
return; // invisible
|
||||
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
|
||||
VectorSet( v_right, RI.vforward[1], -RI.vforward[0], 0.0f );
|
||||
VectorNormalize( v_right );
|
||||
break;
|
||||
case SPR_FWD_PARALLEL_ORIENTED:
|
||||
angle = e->angles[ROLL] * (M_PI2 / 360.0f);
|
||||
angle = e->angles[ROLL] * ( M_PI2 / 360.0f );
|
||||
SinCos( angle, &sr, &cr );
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
v_right[i] = (RI.vright[i] * cr + RI.vup[i] * sr);
|
||||
v_right[i] = ( RI.vright[i] * cr + RI.vup[i] * sr );
|
||||
v_up[i] = RI.vright[i] * -sr + RI.vup[i] * cr;
|
||||
}
|
||||
break;
|
||||
|
@ -807,8 +821,8 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
|||
break;
|
||||
}
|
||||
|
||||
//if( psprite->facecull == SPR_CULL_NONE )
|
||||
//GL_Cull( GL_NONE );
|
||||
// if( psprite->facecull == SPR_CULL_NONE )
|
||||
// GL_Cull( GL_NONE );
|
||||
|
||||
if( oldframe == frame )
|
||||
{
|
||||
|
|
1044
ref/soft/r_studio.c
1044
ref/soft/r_studio.c
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -3,29 +3,29 @@
|
|||
// not really draw alias models here, but use this to draw triangles
|
||||
|
||||
|
||||
affinetridesc_t r_affinetridesc;
|
||||
affinetridesc_t r_affinetridesc;
|
||||
|
||||
|
||||
int r_aliasblendcolor;
|
||||
int r_aliasblendcolor;
|
||||
|
||||
|
||||
float aliastransform[3][4];
|
||||
float aliasworldtransform[3][4];
|
||||
float aliasoldworldtransform[3][4];
|
||||
float aliastransform[3][4];
|
||||
float aliasworldtransform[3][4];
|
||||
float aliasoldworldtransform[3][4];
|
||||
|
||||
float s_ziscale;
|
||||
static vec3_t s_alias_forward, s_alias_right, s_alias_up;
|
||||
float s_ziscale;
|
||||
static vec3_t s_alias_forward, s_alias_right, s_alias_up;
|
||||
|
||||
|
||||
#define NUMVERTEXNORMALS 162
|
||||
#define NUMVERTEXNORMALS 162
|
||||
|
||||
float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
||||
float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
||||
#include "anorms.h"
|
||||
};
|
||||
|
||||
|
||||
void R_AliasSetUpTransform (void);
|
||||
void R_AliasProjectAndClipTestFinalVert (finalvert_t *fv);
|
||||
void R_AliasSetUpTransform( void );
|
||||
void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv );
|
||||
|
||||
void R_AliasTransformFinalVerts( int numpoints, finalvert_t *fv, dtrivertx_t *oldv, dtrivertx_t *newv );
|
||||
|
||||
|
@ -41,7 +41,7 @@ R_AliasCheckBBox
|
|||
#define BBOX_MUST_CLIP_Z 2
|
||||
#define BBOX_TRIVIAL_REJECT 8
|
||||
|
||||
static void VectorInverse (vec3_t v)
|
||||
static void VectorInverse( vec3_t v )
|
||||
{
|
||||
v[0] = -v[0];
|
||||
v[1] = -v[1];
|
||||
|
@ -53,11 +53,11 @@ static void VectorInverse (vec3_t v)
|
|||
R_SetUpWorldTransform
|
||||
================
|
||||
*/
|
||||
void R_SetUpWorldTransform (void)
|
||||
void R_SetUpWorldTransform( void )
|
||||
{
|
||||
int i;
|
||||
static float viewmatrix[3][4];
|
||||
vec3_t angles;
|
||||
int i;
|
||||
static float viewmatrix[3][4];
|
||||
vec3_t angles;
|
||||
|
||||
// TODO: should really be stored with the entity instead of being reconstructed
|
||||
// TODO: should use a look-up table
|
||||
|
@ -72,23 +72,23 @@ void R_SetUpWorldTransform (void)
|
|||
|
||||
// TODO: can do this with simple matrix rearrangement
|
||||
|
||||
memset( aliasworldtransform, 0, sizeof( aliasworldtransform ) );
|
||||
memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ) );
|
||||
memset( aliasworldtransform, 0, sizeof( aliasworldtransform ));
|
||||
memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ));
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][0] = s_alias_forward[i];
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][0] = s_alias_forward[i];
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][1] = -s_alias_right[i];
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][2] = s_alias_up[i];
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][2] = s_alias_up[i];
|
||||
}
|
||||
|
||||
aliasworldtransform[0][3] = -RI.vieworg[0];
|
||||
aliasworldtransform[1][3] = -RI.vieworg[1];
|
||||
aliasworldtransform[2][3] = -RI.vieworg[2];
|
||||
|
||||
//aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
|
||||
//aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
|
||||
//aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2]-r_origin[2];
|
||||
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
|
||||
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
|
||||
// aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2]-r_origin[2];
|
||||
|
||||
// FIXME: can do more efficiently than full concatenation
|
||||
// memcpy( rotationmatrix, t2matrix, sizeof( rotationmatrix ) );
|
||||
|
@ -96,11 +96,11 @@ void R_SetUpWorldTransform (void)
|
|||
// R_ConcatTransforms (t2matrix, tmatrix, rotationmatrix);
|
||||
|
||||
// TODO: should be global, set when vright, etc., set
|
||||
VectorCopy (RI.vright, viewmatrix[0]);
|
||||
VectorCopy (RI.vup, viewmatrix[1]);
|
||||
VectorInverse (viewmatrix[1]);
|
||||
//VectorScale(viewmatrix[1], -1, viewmatrix[1]);
|
||||
VectorCopy (RI.vforward, viewmatrix[2]);
|
||||
VectorCopy( RI.vright, viewmatrix[0] );
|
||||
VectorCopy( RI.vup, viewmatrix[1] );
|
||||
VectorInverse( viewmatrix[1] );
|
||||
// VectorScale(viewmatrix[1], -1, viewmatrix[1]);
|
||||
VectorCopy( RI.vforward, viewmatrix[2] );
|
||||
|
||||
viewmatrix[0][3] = 0;
|
||||
viewmatrix[1][3] = 0;
|
||||
|
@ -108,16 +108,16 @@ void R_SetUpWorldTransform (void)
|
|||
|
||||
// memcpy( aliasworldtransform, rotationmatrix, sizeof( aliastransform ) );
|
||||
|
||||
//R_ConcatTransforms (viewmatrix, aliasworldtransform, aliastransform);
|
||||
Matrix3x4_ConcatTransforms(aliastransform, viewmatrix, aliasworldtransform );
|
||||
// R_ConcatTransforms (viewmatrix, aliasworldtransform, aliastransform);
|
||||
Matrix3x4_ConcatTransforms( aliastransform, viewmatrix, aliasworldtransform );
|
||||
|
||||
aliasworldtransform[0][3] = 0;
|
||||
aliasworldtransform[1][3] = 0;
|
||||
aliasworldtransform[2][3] = 0;
|
||||
|
||||
//aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0];
|
||||
//aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1];
|
||||
//aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2];
|
||||
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0];
|
||||
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1];
|
||||
// aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2];
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,11 +126,11 @@ void R_SetUpWorldTransform (void)
|
|||
R_AliasSetUpTransform
|
||||
================
|
||||
*/
|
||||
void R_AliasSetUpTransform (void)
|
||||
void R_AliasSetUpTransform( void )
|
||||
{
|
||||
int i;
|
||||
static float viewmatrix[3][4];
|
||||
vec3_t angles;
|
||||
int i;
|
||||
static float viewmatrix[3][4];
|
||||
vec3_t angles;
|
||||
|
||||
// TODO: should really be stored with the entity instead of being reconstructed
|
||||
// TODO: should use a look-up table
|
||||
|
@ -145,23 +145,23 @@ void R_AliasSetUpTransform (void)
|
|||
|
||||
// TODO: can do this with simple matrix rearrangement
|
||||
|
||||
memset( aliasworldtransform, 0, sizeof( aliasworldtransform ) );
|
||||
memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ) );
|
||||
memset( aliasworldtransform, 0, sizeof( aliasworldtransform ));
|
||||
memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ));
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][0] = s_alias_forward[i];
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][0] = s_alias_forward[i];
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][1] = -s_alias_right[i];
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][2] = s_alias_up[i];
|
||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][2] = s_alias_up[i];
|
||||
}
|
||||
|
||||
aliasworldtransform[0][3] = RI.currententity->origin[0]-RI.vieworg[0];
|
||||
aliasworldtransform[1][3] = RI.currententity->origin[1]-RI.vieworg[1];
|
||||
aliasworldtransform[2][3] = RI.currententity->origin[2]-RI.vieworg[2];
|
||||
aliasworldtransform[0][3] = RI.currententity->origin[0] - RI.vieworg[0];
|
||||
aliasworldtransform[1][3] = RI.currententity->origin[1] - RI.vieworg[1];
|
||||
aliasworldtransform[2][3] = RI.currententity->origin[2] - RI.vieworg[2];
|
||||
|
||||
//aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
|
||||
//aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
|
||||
//aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2]-r_origin[2];
|
||||
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
|
||||
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
|
||||
// aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2]-r_origin[2];
|
||||
|
||||
// FIXME: can do more efficiently than full concatenation
|
||||
// memcpy( rotationmatrix, t2matrix, sizeof( rotationmatrix ) );
|
||||
|
@ -169,11 +169,11 @@ void R_AliasSetUpTransform (void)
|
|||
// R_ConcatTransforms (t2matrix, tmatrix, rotationmatrix);
|
||||
|
||||
// TODO: should be global, set when vright, etc., set
|
||||
VectorCopy (RI.vright, viewmatrix[0]);
|
||||
VectorCopy (RI.vup, viewmatrix[1]);
|
||||
VectorInverse (viewmatrix[1]);
|
||||
//VectorScale(viewmatrix[1], -1, viewmatrix[1]);
|
||||
VectorCopy (RI.vforward, viewmatrix[2]);
|
||||
VectorCopy( RI.vright, viewmatrix[0] );
|
||||
VectorCopy( RI.vup, viewmatrix[1] );
|
||||
VectorInverse( viewmatrix[1] );
|
||||
// VectorScale(viewmatrix[1], -1, viewmatrix[1]);
|
||||
VectorCopy( RI.vforward, viewmatrix[2] );
|
||||
|
||||
viewmatrix[0][3] = 0;
|
||||
viewmatrix[1][3] = 0;
|
||||
|
@ -181,16 +181,16 @@ void R_AliasSetUpTransform (void)
|
|||
|
||||
// memcpy( aliasworldtransform, rotationmatrix, sizeof( aliastransform ) );
|
||||
|
||||
//R_ConcatTransforms (viewmatrix, aliasworldtransform, aliastransform);
|
||||
Matrix3x4_ConcatTransforms(aliastransform, viewmatrix, aliasworldtransform );
|
||||
// R_ConcatTransforms (viewmatrix, aliasworldtransform, aliastransform);
|
||||
Matrix3x4_ConcatTransforms( aliastransform, viewmatrix, aliasworldtransform );
|
||||
|
||||
aliasworldtransform[0][3] = RI.currententity->origin[0];
|
||||
aliasworldtransform[1][3] = RI.currententity->origin[1];
|
||||
aliasworldtransform[2][3] = RI.currententity->origin[2];
|
||||
|
||||
//aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0];
|
||||
//aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1];
|
||||
//aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2];
|
||||
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0];
|
||||
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1];
|
||||
// aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -200,8 +200,8 @@ R_AliasProjectAndClipTestFinalVert
|
|||
*/
|
||||
void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv )
|
||||
{
|
||||
float zi;
|
||||
float x, y, z;
|
||||
float zi;
|
||||
float x, y, z;
|
||||
|
||||
// project points
|
||||
x = fv->xyz[0];
|
||||
|
@ -211,16 +211,16 @@ void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv )
|
|||
|
||||
fv->zi = zi * s_ziscale;
|
||||
|
||||
fv->u = (x * aliasxscale * zi) + aliasxcenter;
|
||||
fv->v = (y * aliasyscale * zi) + aliasycenter;
|
||||
fv->u = ( x * aliasxscale * zi ) + aliasxcenter;
|
||||
fv->v = ( y * aliasyscale * zi ) + aliasycenter;
|
||||
|
||||
if (fv->u < RI.aliasvrect.x)
|
||||
if( fv->u < RI.aliasvrect.x )
|
||||
fv->flags |= ALIAS_LEFT_CLIP;
|
||||
if (fv->v < RI.aliasvrect.y)
|
||||
if( fv->v < RI.aliasvrect.y )
|
||||
fv->flags |= ALIAS_TOP_CLIP;
|
||||
if (fv->u > RI.aliasvrectright)
|
||||
if( fv->u > RI.aliasvrectright )
|
||||
fv->flags |= ALIAS_RIGHT_CLIP;
|
||||
if (fv->v > RI.aliasvrectbottom)
|
||||
if( fv->v > RI.aliasvrectbottom )
|
||||
fv->flags |= ALIAS_BOTTOM_CLIP;
|
||||
}
|
||||
|
||||
|
@ -228,15 +228,15 @@ void R_SetupFinalVert( finalvert_t *fv, float x, float y, float z, int light, in
|
|||
{
|
||||
vec3_t v = {x, y, z};
|
||||
|
||||
fv->xyz[0] = DotProduct(v, aliastransform[0]) + aliastransform[0][3];
|
||||
fv->xyz[1] = DotProduct(v, aliastransform[1]) + aliastransform[1][3];
|
||||
fv->xyz[2] = DotProduct(v, aliastransform[2]) + aliastransform[2][3];
|
||||
fv->xyz[0] = DotProduct( v, aliastransform[0] ) + aliastransform[0][3];
|
||||
fv->xyz[1] = DotProduct( v, aliastransform[1] ) + aliastransform[1][3];
|
||||
fv->xyz[2] = DotProduct( v, aliastransform[2] ) + aliastransform[2][3];
|
||||
|
||||
fv->flags = 0;
|
||||
|
||||
fv->l = light;
|
||||
|
||||
if ( fv->xyz[2] < ALIAS_Z_CLIP_PLANE )
|
||||
if( fv->xyz[2] < ALIAS_Z_CLIP_PLANE )
|
||||
{
|
||||
fv->flags |= ALIAS_Z_CLIP;
|
||||
}
|
||||
|
@ -249,14 +249,14 @@ void R_SetupFinalVert( finalvert_t *fv, float x, float y, float z, int light, in
|
|||
fv->t = t << 16;
|
||||
}
|
||||
|
||||
void R_RenderTriangle( finalvert_t *fv1, finalvert_t *fv2, finalvert_t *fv3 )
|
||||
void R_RenderTriangle( finalvert_t *fv1, finalvert_t *fv2, finalvert_t *fv3 )
|
||||
{
|
||||
|
||||
if ( fv1->flags & fv2->flags & fv3->flags )
|
||||
return ; // completely clipped
|
||||
if( fv1->flags & fv2->flags & fv3->flags )
|
||||
return; // completely clipped
|
||||
|
||||
if ( ! (fv1->flags | fv2->flags | fv3->flags) )
|
||||
{ // totally unclipped
|
||||
if( !( fv1->flags | fv2->flags | fv3->flags ))
|
||||
{ // totally unclipped
|
||||
aliastriangleparms.a = fv1;
|
||||
aliastriangleparms.b = fv2;
|
||||
aliastriangleparms.c = fv3;
|
||||
|
@ -264,8 +264,8 @@ void R_RenderTriangle( finalvert_t *fv1, finalvert_t *fv2, finalvert_t *fv3 )
|
|||
R_DrawTriangle();
|
||||
}
|
||||
else
|
||||
{ // partially clipped
|
||||
R_AliasClipTriangle (fv1, fv2, fv3);
|
||||
{ // partially clipped
|
||||
R_AliasClipTriangle( fv1, fv2, fv3 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ GNU General Public License for more details.
|
|||
|
||||
static struct
|
||||
{
|
||||
int renderMode; // override kRenderMode from TriAPI
|
||||
vec4_t triRGBA;
|
||||
int renderMode; // override kRenderMode from TriAPI
|
||||
vec4_t triRGBA;
|
||||
} ds;
|
||||
|
||||
static finalvert_t triv[3];
|
||||
static int vertcount, n;
|
||||
static int mode;
|
||||
static short s, t;
|
||||
static uint light;
|
||||
static int vertcount, n;
|
||||
static int mode;
|
||||
static short s, t;
|
||||
static uint light;
|
||||
|
||||
/*
|
||||
===============================================================
|
||||
|
@ -82,16 +82,16 @@ _TriColor4f
|
|||
*/
|
||||
void GAME_EXPORT _TriColor4f( float rr, float gg, float bb, float aa )
|
||||
{
|
||||
//pglColor4f( r, g, b, a );
|
||||
unsigned short r,g,b;
|
||||
unsigned int major, minor;
|
||||
// pglColor4f( r, g, b, a );
|
||||
unsigned short r, g, b;
|
||||
unsigned int major, minor;
|
||||
|
||||
if( vid.rendermode == kRenderTransAdd || vid.rendermode == kRenderGlow )
|
||||
rr *= aa, gg *= aa, bb *= aa;
|
||||
|
||||
//gEngfuncs.Con_Printf("%d\n", vid.alpha);
|
||||
// gEngfuncs.Con_Printf("%d\n", vid.alpha);
|
||||
|
||||
light = (rr + gg + bb) * 31 / 3;
|
||||
light = ( rr + gg + bb ) * 31 / 3;
|
||||
if( light > 31 )
|
||||
light = 31;
|
||||
|
||||
|
@ -116,12 +116,12 @@ void GAME_EXPORT _TriColor4f( float rr, float gg, float bb, float aa )
|
|||
b = 31;
|
||||
|
||||
|
||||
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
|
||||
major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
|
||||
|
||||
// save minor GBRGBRGB
|
||||
minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0);
|
||||
minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
|
||||
|
||||
vid.color = major << 8 | (minor & 0xFF);
|
||||
vid.color = major << 8 | ( minor & 0xFF );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -132,10 +132,10 @@ TriColor4ub
|
|||
*/
|
||||
void TriColor4ub( byte r, byte g, byte b, byte a )
|
||||
{
|
||||
ds.triRGBA[0] = r * (1.0f / 255.0f);
|
||||
ds.triRGBA[1] = g * (1.0f / 255.0f);
|
||||
ds.triRGBA[2] = b * (1.0f / 255.0f);
|
||||
ds.triRGBA[3] = a * (1.0f / 255.0f);
|
||||
ds.triRGBA[0] = r * ( 1.0f / 255.0f );
|
||||
ds.triRGBA[1] = g * ( 1.0f / 255.0f );
|
||||
ds.triRGBA[2] = b * ( 1.0f / 255.0f );
|
||||
ds.triRGBA[3] = a * ( 1.0f / 255.0f );
|
||||
|
||||
_TriColor4f( ds.triRGBA[0], ds.triRGBA[1], ds.triRGBA[2], 1.0f );
|
||||
}
|
||||
|
@ -148,10 +148,10 @@ TriColor4ub
|
|||
*/
|
||||
void GAME_EXPORT _TriColor4ub( byte r, byte g, byte b, byte a )
|
||||
{
|
||||
_TriColor4f( r * (1.0f / 255.0f),
|
||||
g * (1.0f / 255.0f),
|
||||
b * (1.0f / 255.0f),
|
||||
a * (1.0f / 255.0f));
|
||||
_TriColor4f( r * ( 1.0f / 255.0f ),
|
||||
g * ( 1.0f / 255.0f ),
|
||||
b * ( 1.0f / 255.0f ),
|
||||
a * ( 1.0f / 255.0f ));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -161,11 +161,12 @@ TriColor4f
|
|||
*/
|
||||
void TriColor4f( float r, float g, float b, float a )
|
||||
{
|
||||
//if( a < 0.5 )
|
||||
// if( a < 0.5 )
|
||||
// a = 1;
|
||||
if( ds.renderMode == kRenderTransAlpha )
|
||||
TriColor4ub( r * 255.0f, g * 255.0f, b * 255.0f, a * 255.0f );
|
||||
else _TriColor4f( r * a, g * a, b * a, 1.0 );
|
||||
else
|
||||
_TriColor4f( r * a, g * a, b * a, 1.0 );
|
||||
|
||||
ds.triRGBA[0] = r;
|
||||
ds.triRGBA[1] = g;
|
||||
|
@ -182,8 +183,8 @@ TriTexCoord2f
|
|||
void GAME_EXPORT TriTexCoord2f( float u, float v )
|
||||
{
|
||||
double u1 = 0, v1 = 0;
|
||||
u = fmodf(u, 10);
|
||||
v = fmodf(v, 10);
|
||||
u = fmodf( u, 10 );
|
||||
v = fmodf( v, 10 );
|
||||
if( u < 1000 && u > -1000 )
|
||||
u1 = u;
|
||||
if( v < 1000 && v > -1000 )
|
||||
|
@ -199,8 +200,8 @@ void GAME_EXPORT TriTexCoord2f( float u, float v )
|
|||
v1 = v1 - 1;
|
||||
|
||||
|
||||
s = r_affinetridesc.skinwidth * bound(0.01,u1,0.99);
|
||||
t = r_affinetridesc.skinheight * bound(0.01,v1,0.99);
|
||||
s = r_affinetridesc.skinwidth * bound( 0.01, u1, 0.99 );
|
||||
t = r_affinetridesc.skinheight * bound( 0.01, v1, 0.99 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -224,35 +225,35 @@ void GAME_EXPORT TriVertex3f( float x, float y, float z )
|
|||
{
|
||||
if( mode == TRI_TRIANGLES )
|
||||
{
|
||||
R_SetupFinalVert( &triv[vertcount], x, y, z, light << 8,s,t);
|
||||
R_SetupFinalVert( &triv[vertcount], x, y, z, light << 8, s, t );
|
||||
vertcount++;
|
||||
if( vertcount == 3 )
|
||||
{
|
||||
R_RenderTriangle( &triv[0], &triv[1], &triv[2] );
|
||||
//R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
|
||||
// R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
|
||||
vertcount = 0;
|
||||
}
|
||||
}
|
||||
if( mode == TRI_TRIANGLE_FAN )
|
||||
{
|
||||
R_SetupFinalVert( &triv[vertcount], x, y, z, light << 8,s,t);
|
||||
R_SetupFinalVert( &triv[vertcount], x, y, z, light << 8, s, t );
|
||||
vertcount++;
|
||||
if( vertcount >= 3 )
|
||||
{
|
||||
R_RenderTriangle( &triv[0], &triv[1], &triv[2] );
|
||||
//R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
|
||||
// R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
|
||||
triv[1] = triv[2];
|
||||
vertcount = 2;
|
||||
}
|
||||
}
|
||||
if( mode == TRI_TRIANGLE_STRIP )
|
||||
{
|
||||
R_SetupFinalVert( &triv[n], x, y, z, light << 8,s,t);
|
||||
R_SetupFinalVert( &triv[n], x, y, z, light << 8, s, t );
|
||||
n++;
|
||||
vertcount++;
|
||||
if( n == 3 )
|
||||
n = 0;
|
||||
if (vertcount >= 3)
|
||||
if( vertcount >= 3 )
|
||||
{
|
||||
if( vertcount & 1 )
|
||||
R_RenderTriangle( &triv[0], &triv[1], &triv[2] );
|
||||
|
@ -283,7 +284,7 @@ bind current texture
|
|||
*/
|
||||
int TriSpriteTexture( model_t *pSpriteModel, int frame )
|
||||
{
|
||||
int gl_texturenum;
|
||||
int gl_texturenum;
|
||||
|
||||
if(( gl_texturenum = R_GetSpriteTexture( pSpriteModel, frame )) == 0 )
|
||||
return 0;
|
||||
|
@ -345,7 +346,7 @@ TriBrightness
|
|||
*/
|
||||
void TriBrightness( float brightness )
|
||||
{
|
||||
float r, g, b;
|
||||
float r, g, b;
|
||||
|
||||
r = ds.triRGBA[0] * ds.triRGBA[3] * brightness;
|
||||
g = ds.triRGBA[1] * ds.triRGBA[3] * brightness;
|
||||
|
|
Loading…
Add table
Reference in a new issue