diff options
Diffstat (limited to 'src/sw_alias.c')
-rw-r--r-- | src/sw_alias.c | 365 |
1 files changed, 163 insertions, 202 deletions
diff --git a/src/sw_alias.c b/src/sw_alias.c index 33f52b6..3a12923 100644 --- a/src/sw_alias.c +++ b/src/sw_alias.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sw_local.h" #define LIGHT_MIN 5 // lowest light value we'll allow, to avoid the - // need for inner-loop light clamping +// need for inner-loop light clamping //PGM extern byte iractive; @@ -63,7 +63,7 @@ static vec3_t s_alias_forward, s_alias_right, s_alias_up; R_AliasTransformVector ================ */ -void R_AliasTransformVector(vec3_t in, vec3_t out, float xf[3][4] ) +void R_AliasTransformVector(vec3_t in, vec3_t out, float xf[3][4]) { out[0] = DotProduct(in, xf[0]) + xf[0][3]; out[1] = DotProduct(in, xf[1]) + xf[1][3]; @@ -76,9 +76,9 @@ void R_AliasTransformVector(vec3_t in, vec3_t out, float xf[3][4] ) ** ** Checks a specific alias frame bounding box */ -unsigned long R_AliasCheckFrameBBox( maliasframe_t *frame, float worldxf[3][4] ) +unsigned long R_AliasCheckFrameBBox(maliasframe_t *frame, float worldxf[3][4]) { - unsigned long aggregate_and_clipcode = ~0U, + unsigned long aggregate_and_clipcode = ~0U, aggregate_or_clipcode = 0; int i; vec3_t mins, maxs; @@ -88,63 +88,58 @@ unsigned long R_AliasCheckFrameBBox( maliasframe_t *frame, float worldxf[3][4] ) /* ** get the exact frame bounding box */ - for (i=0 ; i<3 ; i++) - { + for (i = 0; i < 3; i++) { mins[i] = frame->translate[i]; - maxs[i] = mins[i] + frame->scale[i]*255; + maxs[i] = mins[i] + frame->scale[i] * 255; } /* ** transform the min and max values into view space */ - R_AliasTransformVector( mins, transformed_min, aliastransform ); - R_AliasTransformVector( maxs, transformed_max, aliastransform ); + R_AliasTransformVector(mins, transformed_min, aliastransform); + R_AliasTransformVector(maxs, transformed_max, aliastransform); - if ( transformed_min[2] >= ALIAS_Z_CLIP_PLANE ) + if (transformed_min[2] >= ALIAS_Z_CLIP_PLANE) zfullyclipped = qfalse; - if ( transformed_max[2] >= ALIAS_Z_CLIP_PLANE ) + if (transformed_max[2] >= ALIAS_Z_CLIP_PLANE) zfullyclipped = qfalse; - if ( zfullyclipped ) - { + if (zfullyclipped) { return BBOX_TRIVIAL_REJECT; } - if ( zclipped ) - { - return ( BBOX_MUST_CLIP_XY | BBOX_MUST_CLIP_Z ); + if (zclipped) { + return (BBOX_MUST_CLIP_XY | BBOX_MUST_CLIP_Z); } /* ** build a transformed bounding box from the given min and max */ - for ( i = 0; i < 8; i++ ) - { + for (i = 0; i < 8; i++) { int j; vec3_t tmp, transformed; unsigned long clipcode = 0; - if ( i & 1 ) + if (i & 1) tmp[0] = mins[0]; else tmp[0] = maxs[0]; - if ( i & 2 ) + if (i & 2) tmp[1] = mins[1]; else tmp[1] = maxs[1]; - if ( i & 4 ) + if (i & 4) tmp[2] = mins[2]; else tmp[2] = maxs[2]; - R_AliasTransformVector( tmp, transformed, worldxf ); + R_AliasTransformVector(tmp, transformed, worldxf); - for ( j = 0; j < 4; j++ ) - { - float dp = DotProduct( transformed, view_clipplanes[j].normal ); + for (j = 0; j < 4; j++) { + float dp = DotProduct(transformed, view_clipplanes[j].normal); - if ( ( dp - view_clipplanes[j].dist ) < 0.0F ) + if ((dp - view_clipplanes[j].dist) < 0.0F) clipcode |= 1 << j; } @@ -152,12 +147,10 @@ unsigned long R_AliasCheckFrameBBox( maliasframe_t *frame, float worldxf[3][4] ) aggregate_or_clipcode |= clipcode; } - if ( aggregate_and_clipcode ) - { + if (aggregate_and_clipcode) { return BBOX_TRIVIAL_REJECT; } - if ( !aggregate_or_clipcode ) - { + if (!aggregate_or_clipcode) { return BBOX_TRIVIAL_ACCEPT; } @@ -169,33 +162,32 @@ unsigned long R_AliasCheckFrameBBox( maliasframe_t *frame, float worldxf[3][4] ) R_AliasCheckBBox ================ */ -qboolean R_AliasCheckBBox (void) +qboolean R_AliasCheckBBox(void) { unsigned long ccodes[2] = { 0, 0 }; - ccodes[0] = R_AliasCheckFrameBBox( r_thisframe, aliasworldtransform ); + ccodes[0] = R_AliasCheckFrameBBox(r_thisframe, aliasworldtransform); /* ** non-lerping model */ - if ( currententity->backlerp == 0 ) - { - if ( ccodes[0] == BBOX_TRIVIAL_ACCEPT ) + if (currententity->backlerp == 0) { + if (ccodes[0] == BBOX_TRIVIAL_ACCEPT) return BBOX_TRIVIAL_ACCEPT; - else if ( ccodes[0] & BBOX_TRIVIAL_REJECT ) + else if (ccodes[0] & BBOX_TRIVIAL_REJECT) return BBOX_TRIVIAL_REJECT; else - return ( ccodes[0] & ~BBOX_TRIVIAL_REJECT ); + return (ccodes[0] & ~BBOX_TRIVIAL_REJECT); } - ccodes[1] = R_AliasCheckFrameBBox( r_lastframe, aliasoldworldtransform ); + ccodes[1] = R_AliasCheckFrameBBox(r_lastframe, aliasoldworldtransform); - if ( ( ccodes[0] | ccodes[1] ) == BBOX_TRIVIAL_ACCEPT ) + if ((ccodes[0] | ccodes[1]) == BBOX_TRIVIAL_ACCEPT) return BBOX_TRIVIAL_ACCEPT; - else if ( ( ccodes[0] & ccodes[1] ) & BBOX_TRIVIAL_REJECT ) + else if ((ccodes[0] & ccodes[1]) & BBOX_TRIVIAL_REJECT) return BBOX_TRIVIAL_REJECT; else - return ( ccodes[0] | ccodes[1] ) & ~BBOX_TRIVIAL_REJECT; + return (ccodes[0] | ccodes[1]) & ~BBOX_TRIVIAL_REJECT; } @@ -204,7 +196,7 @@ qboolean R_AliasCheckBBox (void) R_AliasProjectAndClipTestFinalVert ================ */ -void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv ) +void R_AliasProjectAndClipTestFinalVert(finalvert_t *fv) { float zi; float x, y, z; @@ -227,7 +219,7 @@ void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv ) if (fv->u > r_refdef.aliasvrectright) fv->flags |= ALIAS_RIGHT_CLIP; if (fv->v > r_refdef.aliasvrectbottom) - fv->flags |= ALIAS_BOTTOM_CLIP; + fv->flags |= ALIAS_BOTTOM_CLIP; } /* @@ -235,26 +227,24 @@ void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv ) R_AliasTransformFinalVerts ================ */ -static void R_AliasTransformFinalVerts( int numpoints, finalvert_t *fv, maliasvert_t *oldv, maliasvert_t *newv ) +static void R_AliasTransformFinalVerts(int numpoints, finalvert_t *fv, maliasvert_t *oldv, maliasvert_t *newv) { int i; - for ( i = 0; i < numpoints; i++, fv++, oldv++, newv++ ) - { + for (i = 0; i < numpoints; i++, fv++, oldv++, newv++) { int temp; float lightcos; const vec_t *plightnormal; vec3_t lerped_vert; - lerped_vert[0] = r_lerp_move[0] + oldv->v[0]*r_lerp_backv[0] + newv->v[0]*r_lerp_frontv[0]; - lerped_vert[1] = r_lerp_move[1] + oldv->v[1]*r_lerp_backv[1] + newv->v[1]*r_lerp_frontv[1]; - lerped_vert[2] = r_lerp_move[2] + oldv->v[2]*r_lerp_backv[2] + newv->v[2]*r_lerp_frontv[2]; + lerped_vert[0] = r_lerp_move[0] + oldv->v[0] * r_lerp_backv[0] + newv->v[0] * r_lerp_frontv[0]; + lerped_vert[1] = r_lerp_move[1] + oldv->v[1] * r_lerp_backv[1] + newv->v[1] * r_lerp_frontv[1]; + lerped_vert[2] = r_lerp_move[2] + oldv->v[2] * r_lerp_backv[2] + newv->v[2] * r_lerp_frontv[2]; plightnormal = bytedirs[newv->lightnormalindex]; // PMM - added double damage shell - if ( currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM) ) - { + if (currententity->flags & (RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM)) { lerped_vert[0] += plightnormal[0] * POWERSUIT_SCALE; lerped_vert[1] += plightnormal[1] * POWERSUIT_SCALE; lerped_vert[2] += plightnormal[2] * POWERSUIT_SCALE; @@ -267,11 +257,10 @@ static void R_AliasTransformFinalVerts( int numpoints, finalvert_t *fv, maliasve fv->flags = 0; // lighting - lightcos = DotProduct (plightnormal, r_plightvec); + lightcos = DotProduct(plightnormal, r_plightvec); temp = r_ambientlight; - if (lightcos < 0) - { + if (lightcos < 0) { temp += (int)(r_shadelight * lightcos); // clamp; because we limited the minimum ambient and shading light, we @@ -282,13 +271,10 @@ static void R_AliasTransformFinalVerts( int numpoints, finalvert_t *fv, maliasve fv->l = temp; - if ( fv->xyz[2] < ALIAS_Z_CLIP_PLANE ) - { + if (fv->xyz[2] < ALIAS_Z_CLIP_PLANE) { fv->flags |= ALIAS_Z_CLIP; - } - else - { - R_AliasProjectAndClipTestFinalVert( fv ); + } else { + R_AliasProjectAndClipTestFinalVert(fv); } } } @@ -301,13 +287,14 @@ R_AliasPreparePoints General clipped case ================ */ -static void R_AliasPreparePoints (void) { +static void R_AliasPreparePoints(void) +{ int i; maliasst_t *pstverts; maliastri_t *ptri; finalvert_t *pfv[3]; finalvert_t finalverts[MAXALIASVERTS + - ((CACHE_SIZE - 1) / sizeof(finalvert_t)) + 3]; + ((CACHE_SIZE - 1) / sizeof(finalvert_t)) + 3]; finalvert_t *pfinalverts; //PGM @@ -319,25 +306,23 @@ static void R_AliasPreparePoints (void) { // put work vertexes on stack, cache aligned pfinalverts = (finalvert_t *) - (((long)&finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1)); + (((long)&finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1)); - R_AliasTransformFinalVerts( currentmodel->numverts, pfinalverts, - r_lastframe->verts, r_thisframe->verts ); + R_AliasTransformFinalVerts(currentmodel->numverts, pfinalverts, + r_lastframe->verts, r_thisframe->verts); // clip and draw all triangles // pstverts = currentmodel->sts; ptri = currentmodel->tris; - if ( ( currententity->flags & (RF_WEAPONMODEL|RF_LEFTHAND) ) == (RF_WEAPONMODEL|RF_LEFTHAND) ) - { - for (i=0 ; i<currentmodel->numtris ; i++, ptri++) - { + if ((currententity->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) == (RF_WEAPONMODEL | RF_LEFTHAND)) { + for (i = 0; i < currentmodel->numtris; i++, ptri++) { pfv[0] = &pfinalverts[ptri->index_xyz[0]]; pfv[1] = &pfinalverts[ptri->index_xyz[1]]; pfv[2] = &pfinalverts[ptri->index_xyz[2]]; - if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags ) + if (pfv[0]->flags & pfv[1]->flags & pfv[2]->flags) continue; // completely clipped // insert s/t coordinates @@ -350,29 +335,24 @@ static void R_AliasPreparePoints (void) { pfv[2]->s = pstverts[ptri->index_st[2]].s << 16; pfv[2]->t = pstverts[ptri->index_st[2]].t << 16; - if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) ) - { // totally unclipped + if (!(pfv[0]->flags | pfv[1]->flags | pfv[2]->flags)) { + // totally unclipped aliastriangleparms.a = pfv[2]; aliastriangleparms.b = pfv[1]; aliastriangleparms.c = pfv[0]; R_DrawTriangle(); - } - else - { - R_AliasClipTriangle (pfv[2], pfv[1], pfv[0]); + } else { + R_AliasClipTriangle(pfv[2], pfv[1], pfv[0]); } } - } - else - { - for (i=0 ; i<currentmodel->numtris ; i++, ptri++) - { + } else { + for (i = 0; i < currentmodel->numtris; i++, ptri++) { pfv[0] = &pfinalverts[ptri->index_xyz[0]]; pfv[1] = &pfinalverts[ptri->index_xyz[1]]; pfv[2] = &pfinalverts[ptri->index_xyz[2]]; - if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags ) + if (pfv[0]->flags & pfv[1]->flags & pfv[2]->flags) continue; // completely clipped // insert s/t coordinates @@ -385,17 +365,16 @@ static void R_AliasPreparePoints (void) { pfv[2]->s = pstverts[ptri->index_st[2]].s << 16; pfv[2]->t = pstverts[ptri->index_st[2]].t << 16; - if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) ) - { // totally unclipped + if (!(pfv[0]->flags | pfv[1]->flags | pfv[2]->flags)) { + // totally unclipped aliastriangleparms.a = pfv[0]; aliastriangleparms.b = pfv[1]; aliastriangleparms.c = pfv[2]; R_DrawTriangle(); - } - else - { // partially clipped - R_AliasClipTriangle (pfv[0], pfv[1], pfv[2]); + } else { + // partially clipped + R_AliasClipTriangle(pfv[0], pfv[1], pfv[2]); } } } @@ -407,7 +386,7 @@ static void R_AliasPreparePoints (void) { R_AliasSetUpTransform ================ */ -static void R_AliasSetUpTransform (void) +static void R_AliasSetUpTransform(void) { int i; static float viewmatrix[3][4]; @@ -416,50 +395,49 @@ static void R_AliasSetUpTransform (void) // TODO: should really be stored with the entity instead of being reconstructed // TODO: should use a look-up table // TODO: could cache lazily, stored in the entity -// +// angles[ROLL] = currententity->angles[ROLL]; angles[PITCH] = currententity->angles[PITCH]; angles[YAW] = currententity->angles[YAW]; - AngleVectors( angles, s_alias_forward, s_alias_right, s_alias_up ); + AngleVectors(angles, s_alias_forward, s_alias_right, s_alias_up); // 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][1] = -s_alias_right[i]; aliasoldworldtransform[i][0] = aliasworldtransform[i][2] = s_alias_up[i]; } - aliasworldtransform[0][3] = currententity->origin[0]-r_origin[0]; - aliasworldtransform[1][3] = currententity->origin[1]-r_origin[1]; - aliasworldtransform[2][3] = currententity->origin[2]-r_origin[2]; + aliasworldtransform[0][3] = currententity->origin[0] - r_origin[0]; + aliasworldtransform[1][3] = currententity->origin[1] - r_origin[1]; + aliasworldtransform[2][3] = currententity->origin[2] - r_origin[2]; - aliasoldworldtransform[0][3] = currententity->oldorigin[0]-r_origin[0]; - aliasoldworldtransform[1][3] = currententity->oldorigin[1]-r_origin[1]; - aliasoldworldtransform[2][3] = currententity->oldorigin[2]-r_origin[2]; + aliasoldworldtransform[0][3] = currententity->oldorigin[0] - r_origin[0]; + aliasoldworldtransform[1][3] = currententity->oldorigin[1] - r_origin[1]; + aliasoldworldtransform[2][3] = currententity->oldorigin[2] - r_origin[2]; // FIXME: can do more efficiently than full concatenation -// memcpy( rotationmatrix, t2matrix, sizeof( rotationmatrix ) ); +// memcpy(rotationmatrix, t2matrix, sizeof(rotationmatrix)); -// R_ConcatTransforms (t2matrix, tmatrix, rotationmatrix); +// R_ConcatTransforms(t2matrix, tmatrix, rotationmatrix); // TODO: should be global, set when vright, etc., set - VectorCopy (vright, viewmatrix[0]); - VectorCopy (vup, viewmatrix[1]); - VectorNegate (viewmatrix[1], viewmatrix[1]); - VectorCopy (vpn, viewmatrix[2]); + VectorCopy(vright, viewmatrix[0]); + VectorCopy(vup, viewmatrix[1]); + VectorNegate(viewmatrix[1], viewmatrix[1]); + VectorCopy(vpn, viewmatrix[2]); viewmatrix[0][3] = 0; viewmatrix[1][3] = 0; viewmatrix[2][3] = 0; -// memcpy( aliasworldtransform, rotationmatrix, sizeof( aliastransform ) ); +// memcpy(aliasworldtransform, rotationmatrix, sizeof(aliastransform)); - R_ConcatTransforms (viewmatrix, aliasworldtransform, aliastransform); + R_ConcatTransforms(viewmatrix, aliasworldtransform, aliastransform); aliasworldtransform[0][3] = currententity->origin[0]; aliasworldtransform[1][3] = currententity->origin[1]; @@ -475,34 +453,32 @@ static void R_AliasSetUpTransform (void) R_AliasSetupSkin =============== */ -static qboolean R_AliasSetupSkin (void) +static qboolean R_AliasSetupSkin(void) { int skinnum; image_t *pskindesc; if (currententity->skin) - pskindesc = IMG_ForHandle( currententity->skin ); - else - { + pskindesc = IMG_ForHandle(currententity->skin); + else { skinnum = currententity->skinnum; - if ((skinnum >= currentmodel->numskins) || (skinnum < 0)) - { - Com_DPrintf( "R_AliasSetupSkin %s: no such skin # %d\n", - currentmodel->name, skinnum); + if ((skinnum >= currentmodel->numskins) || (skinnum < 0)) { + Com_DPrintf("R_AliasSetupSkin %s: no such skin # %d\n", + currentmodel->name, skinnum); skinnum = 0; } pskindesc = currentmodel->skins[skinnum]; } - if ( !pskindesc ) + if (!pskindesc) return qfalse; r_affinetridesc.pskin = pskindesc->pixels[0]; r_affinetridesc.skinwidth = pskindesc->width; r_affinetridesc.skinheight = pskindesc->height; - R_PolysetUpdateTables (); // FIXME: precalc edge lookups + R_PolysetUpdateTables(); // FIXME: precalc edge lookups return qtrue; } @@ -515,40 +491,35 @@ R_AliasSetupLighting FIXME: put lighting into tables ================ */ -static void R_AliasSetupLighting (void) +static void R_AliasSetupLighting(void) { alight_t lighting; - float lightvec[3] = {-1, 0, 0}; + float lightvec[3] = { -1, 0, 0}; vec3_t light; int i, j; // all components of light should be identical in software - if ( currententity->flags & RF_FULLBRIGHT ) - { - for (i=0 ; i<3 ; i++) + if (currententity->flags & RF_FULLBRIGHT) { + for (i = 0; i < 3; i++) light[i] = 1.0; - } - else - { - R_LightPoint (currententity->origin, light); + } else { + R_LightPoint(currententity->origin, light); } - if ( currententity->flags & RF_MINLIGHT ) - { - for (i=0 ; i<3 ; i++) + if (currententity->flags & RF_MINLIGHT) { + for (i = 0; i < 3; i++) if (light[i] < 0.1) light[i] = 0.1; } - if ( currententity->flags & RF_GLOW ) - { // bonus items will pulse with time + if (currententity->flags & RF_GLOW) { + // bonus items will pulse with time float scale; float min; - scale = 0.1 * sin(r_newrefdef.time*7); - for (i=0 ; i<3 ; i++) - { + scale = 0.1 * sin(r_newrefdef.time * 7); + for (i = 0; i < 3; i++) { min = light[i] * 0.8; light[i] += scale; if (light[i] < min) @@ -556,7 +527,7 @@ static void R_AliasSetupLighting (void) } } - j = (light[0] + light[1] + light[2])*0.3333*255; + j = (light[0] + light[1] + light[2]) * 0.3333 * 255; lighting.ambientlight = j; lighting.shadelight = j; @@ -589,9 +560,9 @@ static void R_AliasSetupLighting (void) r_shadelight *= VID_GRADES; // rotate the lighting vector into the model's frame of reference - r_plightvec[0] = DotProduct( lighting.plightvec, s_alias_forward ); - r_plightvec[1] = -DotProduct( lighting.plightvec, s_alias_right ); - r_plightvec[2] = DotProduct( lighting.plightvec, s_alias_up ); + r_plightvec[0] = DotProduct(lighting.plightvec, s_alias_forward); + r_plightvec[1] = -DotProduct(lighting.plightvec, s_alias_right); + r_plightvec[2] = DotProduct(lighting.plightvec, s_alias_up); } @@ -601,18 +572,19 @@ R_AliasSetupFrames ================= */ -static void R_AliasSetupFrames( void ) { +static void R_AliasSetupFrames(void) +{ int thisframe = currententity->frame; int lastframe = currententity->oldframe; - if( thisframe >= currentmodel->numframes || thisframe < 0 ) { - Com_DPrintf( "%s: %s: no such thisframe %d\n", - __func__, currentmodel->name, thisframe); + if (thisframe >= currentmodel->numframes || thisframe < 0) { + Com_DPrintf("%s: %s: no such thisframe %d\n", + __func__, currentmodel->name, thisframe); thisframe = 0; } - if( lastframe >= currentmodel->numframes || lastframe < 0 ) { - Com_DPrintf( "%s: %s: no such lastframe %d\n", - __func__, currentmodel->name, lastframe); + if (lastframe >= currentmodel->numframes || lastframe < 0) { + Com_DPrintf("%s: %s: no such lastframe %d\n", + __func__, currentmodel->name, lastframe); lastframe = 0; } @@ -625,7 +597,7 @@ static void R_AliasSetupFrames( void ) { ** ** Precomputes lerp coefficients used for the whole frame. */ -static void R_AliasSetUpLerpData( float backlerp ) +static void R_AliasSetUpLerpData(float backlerp) { float frontlerp; vec3_t translation, vectors[3]; @@ -636,12 +608,12 @@ static void R_AliasSetUpLerpData( float backlerp ) /* ** convert entity's angles into discrete vectors for R, U, and F */ - AngleVectors (currententity->angles, vectors[0], vectors[1], vectors[2]); + AngleVectors(currententity->angles, vectors[0], vectors[1], vectors[2]); /* ** translation is the vector from last position to this position */ - VectorSubtract (currententity->oldorigin, currententity->origin, translation); + VectorSubtract(currententity->oldorigin, currententity->origin, translation); /* ** move should be the delta back to the previous frame * backlerp @@ -650,27 +622,26 @@ static void R_AliasSetUpLerpData( float backlerp ) r_lerp_move[1] = -DotProduct(translation, vectors[1]); // left r_lerp_move[2] = DotProduct(translation, vectors[2]); // up - VectorAdd( r_lerp_move, r_lastframe->translate, r_lerp_move ); + VectorAdd(r_lerp_move, r_lastframe->translate, r_lerp_move); - for (i=0 ; i<3 ; i++) - { - r_lerp_move[i] = backlerp*r_lerp_move[i] + frontlerp * r_thisframe->translate[i]; + for (i = 0; i < 3; i++) { + r_lerp_move[i] = backlerp * r_lerp_move[i] + frontlerp * r_thisframe->translate[i]; } - for (i=0 ; i<3 ; i++) - { + for (i = 0; i < 3; i++) { r_lerp_frontv[i] = frontlerp * r_thisframe->scale[i]; r_lerp_backv[i] = backlerp * r_lastframe->scale[i]; } } -static void R_AliasSetupBlend( void ) { - extern void (*d_pdrawspans)( void * ); - extern void R_PolysetDrawSpans8_Opaque( void * ); - extern void R_PolysetDrawSpans8_33( void * ); - extern void R_PolysetDrawSpans8_66( void * ); - extern void R_PolysetDrawSpansConstant8_33( void * ); - extern void R_PolysetDrawSpansConstant8_66( void * ); +static void R_AliasSetupBlend(void) +{ + extern void (*d_pdrawspans)(void *); + extern void R_PolysetDrawSpans8_Opaque(void *); + extern void R_PolysetDrawSpans8_33(void *); + extern void R_PolysetDrawSpans8_66(void *); + extern void R_PolysetDrawSpansConstant8_33(void *); + extern void R_PolysetDrawSpansConstant8_66(void *); int color; @@ -679,50 +650,45 @@ static void R_AliasSetupBlend( void ) { */ // PMM - added double damage shell // PMM - reordered to handle blending - color = currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM); - if ( color ) - { + color = currententity->flags & (RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM); + if (color) { // PMM - added double // PMM - reordered, new shells after old shells (so they get overriden) - if ( color == RF_SHELL_RED ) + if (color == RF_SHELL_RED) r_aliasblendcolor = SHELL_RED_COLOR; - else if ( color == RF_SHELL_GREEN ) + else if (color == RF_SHELL_GREEN) r_aliasblendcolor = SHELL_GREEN_COLOR; - else if ( color == RF_SHELL_BLUE ) + else if (color == RF_SHELL_BLUE) r_aliasblendcolor = SHELL_BLUE_COLOR; - else if ( color == (RF_SHELL_RED | RF_SHELL_GREEN) ) + else if (color == (RF_SHELL_RED | RF_SHELL_GREEN)) r_aliasblendcolor = SHELL_RG_COLOR; - else if ( color == (RF_SHELL_RED | RF_SHELL_BLUE) ) + else if (color == (RF_SHELL_RED | RF_SHELL_BLUE)) r_aliasblendcolor = SHELL_RB_COLOR; - else if ( color == (RF_SHELL_BLUE | RF_SHELL_GREEN) ) + else if (color == (RF_SHELL_BLUE | RF_SHELL_GREEN)) r_aliasblendcolor = SHELL_BG_COLOR; // PMM - added this .. it's yellowish - else if ( color == (RF_SHELL_DOUBLE) ) + else if (color == (RF_SHELL_DOUBLE)) r_aliasblendcolor = SHELL_DOUBLE_COLOR; - else if ( color == (RF_SHELL_HALF_DAM) ) + else if (color == (RF_SHELL_HALF_DAM)) r_aliasblendcolor = SHELL_HALF_DAM_COLOR; // pmm else r_aliasblendcolor = SHELL_WHITE_COLOR; - if ( currententity->alpha > 0.33 ) + if (currententity->alpha > 0.33) d_pdrawspans = R_PolysetDrawSpansConstant8_66; else d_pdrawspans = R_PolysetDrawSpansConstant8_33; - } - else if ( currententity->flags & RF_TRANSLUCENT ) - { - if ( currententity->alpha > 0.66 ) + } else if (currententity->flags & RF_TRANSLUCENT) { + if (currententity->alpha > 0.66) d_pdrawspans = R_PolysetDrawSpans8_Opaque; - else if ( currententity->alpha > 0.33 ) + else if (currententity->alpha > 0.33) d_pdrawspans = R_PolysetDrawSpans8_66; else d_pdrawspans = R_PolysetDrawSpans8_33; - } - else - { + } else { d_pdrawspans = R_PolysetDrawSpans8_Opaque; } } @@ -732,13 +698,12 @@ static void R_AliasSetupBlend( void ) { R_AliasDrawModel ================ */ -void R_AliasDrawModel (void) +void R_AliasDrawModel(void) { - if ( r_lerpmodels->value == 0 ) + if (r_lerpmodels->value == 0) currententity->backlerp = 0; - if ( ( currententity->flags & (RF_WEAPONMODEL|RF_LEFTHAND) ) == (RF_WEAPONMODEL|RF_LEFTHAND) ) - { + if ((currententity->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) == (RF_WEAPONMODEL | RF_LEFTHAND)) { aliasxscale = -aliasxscale; } @@ -751,42 +716,38 @@ void R_AliasDrawModel (void) // see if the bounding box lets us trivially reject, also sets // trivial accept status - if ( R_AliasCheckBBox() == BBOX_TRIVIAL_REJECT ) - { - if ( ( currententity->flags & (RF_WEAPONMODEL|RF_LEFTHAND) ) == (RF_WEAPONMODEL|RF_LEFTHAND) ) - { + if (R_AliasCheckBBox() == BBOX_TRIVIAL_REJECT) { + if ((currententity->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) == (RF_WEAPONMODEL | RF_LEFTHAND)) { aliasxscale = -aliasxscale; } return; } // set up the skin and verify it exists - if ( !R_AliasSetupSkin () ) - { - Com_DPrintf( "R_AliasDrawModel %s: NULL skin found\n", - currentmodel->name); + if (!R_AliasSetupSkin()) { + Com_DPrintf("R_AliasDrawModel %s: NULL skin found\n", + currentmodel->name); return; } r_amodels_drawn++; - R_AliasSetupLighting (); + R_AliasSetupLighting(); R_AliasSetupBlend(); - + /* ** compute this_frame and old_frame addresses */ - R_AliasSetUpLerpData( currententity->backlerp ); + R_AliasSetUpLerpData(currententity->backlerp); if (currententity->flags & RF_DEPTHHACK) s_ziscale = (float)0x8000 * (float)0x10000 * 3.0; else s_ziscale = (float)0x8000 * (float)0x10000; - R_AliasPreparePoints (); + R_AliasPreparePoints(); - if ( ( currententity->flags & (RF_WEAPONMODEL|RF_LEFTHAND) ) == (RF_WEAPONMODEL|RF_LEFTHAND) ) - { + if ((currententity->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) == (RF_WEAPONMODEL | RF_LEFTHAND)) { aliasxscale = -aliasxscale; } } |