codemp/cgame/cg_localents.c File Reference

#include "cg_local.h"

Go to the source code of this file.

Defines

#define MAX_LOCAL_ENTITIES   512
#define NUMBER_SIZE   8

Functions

void CG_InitLocalEntities (void)
void CG_FreeLocalEntity (localEntity_t *le)
localEntity_tCG_AllocLocalEntity (void)
void CG_BloodTrail (localEntity_t *le)
void CG_FragmentBounceMark (localEntity_t *le, trace_t *trace)
void CG_FragmentBounceSound (localEntity_t *le, trace_t *trace)
void CG_ReflectVelocity (localEntity_t *le, trace_t *trace)
void CG_AddFragment (localEntity_t *le)
void CG_AddFadeRGB (localEntity_t *le)
void CG_AddRefEntity (localEntity_t *le)
void CG_AddScorePlum (localEntity_t *le)
void CG_AddOLine (localEntity_t *le)
void CG_AddLine (localEntity_t *le)
void CG_AddLocalEntities (void)

Variables

localEntity_t cg_localEntities [MAX_LOCAL_ENTITIES]
localEntity_t cg_activeLocalEntities
localEntity_tcg_freeLocalEntities


Define Documentation

#define MAX_LOCAL_ENTITIES   512
 

Definition at line 9 of file cg_localents.c.

Referenced by CG_InitLocalEntities().

#define NUMBER_SIZE   8
 

Definition at line 637 of file cg_localents.c.

Referenced by CG_AddScorePlum().


Function Documentation

void CG_AddFadeRGB localEntity_t le  ) 
 

Definition at line 348 of file cg_localents.c.

References cg, localEntity_s::color, localEntity_s::endTime, localEntity_s::lifeRate, localEntity_t, localEntity_s::refEntity, refEntity_t::shaderRGBA, cg_t::time, and trap_R_AddRefEntityToScene().

Referenced by CG_AddLocalEntities().

00348                                         {
00349         refEntity_t *re;
00350         float c;
00351 
00352         re = &le->refEntity;
00353 
00354         c = ( le->endTime - cg.time ) * le->lifeRate;
00355         c *= 0xff;
00356 
00357         re->shaderRGBA[0] = le->color[0] * c;
00358         re->shaderRGBA[1] = le->color[1] * c;
00359         re->shaderRGBA[2] = le->color[2] * c;
00360         re->shaderRGBA[3] = le->color[3] * c;
00361 
00362         trap_R_AddRefEntityToScene( re );
00363 }

void CG_AddFragment localEntity_t le  ) 
 

Definition at line 234 of file cg_localents.c.

References localEntity_s::angles, AnglesToAxis(), refEntity_t::axis, BG_EvaluateTrajectory(), localEntity_s::bounceSound, cg, CG_BloodTrail(), CG_FragmentBounceMark(), CG_FragmentBounceSound(), CG_FreeLocalEntity(), CG_ReflectVelocity(), CG_Trace(), CHAN_AUTO, CONTENTS_NODROP, CONTENTS_SOLID, trace_t::endpos, localEntity_s::endTime, ENTITYNUM_WORLD, localEntity_s::forceAlpha, trace_t::fraction, localEntity_s::leBounceSoundType, LEBS_BLOOD, LEF_TUMBLE, localEntity_s::leFlags, localEntity_t, NULL, refEntity_t::origin, localEntity_s::pos, localEntity_s::refEntity, refEntity_t::renderfx, RF_FORCE_ENT_ALPHA, ScaleModelAxis(), refEntity_t::shaderRGBA, SINK_TIME, trace_t::startsolid, cg_t::time, TR_STATIONARY, trap_CM_PointContents(), trap_R_AddRefEntityToScene(), trap_S_StartSound(), trajectory_t::trBase, trajectory_t::trType, vec3_t, and VectorCopy.

Referenced by CG_AddLocalEntities().

00234                                          {
00235         vec3_t  newOrigin;
00236         trace_t trace;
00237 
00238         if (le->forceAlpha)
00239         {
00240                 le->refEntity.renderfx |= RF_FORCE_ENT_ALPHA;
00241                 le->refEntity.shaderRGBA[3] = le->forceAlpha;
00242         }
00243 
00244         if ( le->pos.trType == TR_STATIONARY ) {
00245                 // sink into the ground if near the removal time
00246                 int             t;
00247                 float   t_e;
00248                 
00249                 t = le->endTime - cg.time;
00250                 if ( t < (SINK_TIME*2) ) {
00251                         le->refEntity.renderfx |= RF_FORCE_ENT_ALPHA;
00252                         t_e = (float)((float)(le->endTime - cg.time)/(SINK_TIME*2));
00253                         t_e = (int)((t_e)*255);
00254 
00255                         if (t_e > 255)
00256                         {
00257                                 t_e = 255;
00258                         }
00259                         if (t_e < 1)
00260                         {
00261                                 t_e = 1;
00262                         }
00263 
00264                         if (le->refEntity.shaderRGBA[3] && t_e > le->refEntity.shaderRGBA[3])
00265                         {
00266                                 t_e = le->refEntity.shaderRGBA[3];
00267                         }
00268 
00269                         le->refEntity.shaderRGBA[3] = t_e;
00270 
00271                         trap_R_AddRefEntityToScene( &le->refEntity );
00272                 } else {
00273                         trap_R_AddRefEntityToScene( &le->refEntity );
00274                 }
00275 
00276                 return;
00277         }
00278 
00279         // calculate new position
00280         BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );
00281 
00282         // trace a line from previous position to new position
00283         CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID );
00284         if ( trace.fraction == 1.0 ) {
00285                 // still in free fall
00286                 VectorCopy( newOrigin, le->refEntity.origin );
00287 
00288                 if ( le->leFlags & LEF_TUMBLE ) {
00289                         vec3_t angles;
00290 
00291                         BG_EvaluateTrajectory( &le->angles, cg.time, angles );
00292                         AnglesToAxis( angles, le->refEntity.axis );
00293                         ScaleModelAxis(&le->refEntity);
00294                 }
00295 
00296                 trap_R_AddRefEntityToScene( &le->refEntity );
00297 
00298                 // add a blood trail
00299                 if ( le->leBounceSoundType == LEBS_BLOOD ) {
00300                         CG_BloodTrail( le );
00301                 }
00302 
00303                 return;
00304         }
00305 
00306         // if it is in a nodrop zone, remove it
00307         // this keeps gibs from waiting at the bottom of pits of death
00308         // and floating levels
00309         if ( trap_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) {
00310                 CG_FreeLocalEntity( le );
00311                 return;
00312         }
00313 
00314         if (!trace.startsolid)
00315         {
00316                 // leave a mark
00317                 CG_FragmentBounceMark( le, &trace );
00318 
00319                 // do a bouncy sound
00320                 CG_FragmentBounceSound( le, &trace );
00321 
00322                 if (le->bounceSound)
00323                 { //specified bounce sound (debris)
00324                         trap_S_StartSound(le->pos.trBase, ENTITYNUM_WORLD, CHAN_AUTO, le->bounceSound);
00325                 }
00326 
00327                 // reflect the velocity on the trace plane
00328                 CG_ReflectVelocity( le, &trace );
00329 
00330                 trap_R_AddRefEntityToScene( &le->refEntity );
00331         }
00332 }

void CG_AddLine localEntity_t le  ) 
 

Definition at line 770 of file cg_localents.c.

References localEntity_t, localEntity_s::refEntity, refEntity_t::reType, RT_LINE, and trap_R_AddRefEntityToScene().

Referenced by CG_AddLocalEntities().

00771 {
00772         refEntity_t     *re;
00773 
00774         re = &le->refEntity;
00775 
00776         re->reType = RT_LINE;
00777 
00778         trap_R_AddRefEntityToScene( re );
00779 }

void CG_AddLocalEntities void   ) 
 

Definition at line 789 of file cg_localents.c.

References cg, cg_activeLocalEntities, CG_AddFadeRGB(), CG_AddFragment(), CG_AddLine(), CG_AddOLine(), CG_AddRefEntity(), CG_AddScorePlum(), CG_Error(), CG_FreeLocalEntity(), localEntity_s::endTime, LE_EXPLOSION, LE_FADE_RGB, LE_FADE_SCALE_MODEL, LE_FALL_SCALE_FADE, LE_FRAGMENT, LE_LINE, LE_MARK, LE_MOVE_SCALE_FADE, LE_OLINE, LE_PUFF, LE_SCALE_FADE, LE_SCOREPLUM, LE_SHOWREFENTITY, LE_SPRITE_EXPLOSION, localEntity_s::leType, localEntity_t, localEntity_s::prev, and cg_t::time.

Referenced by CG_DrawActiveFrame().

00789                                  {
00790         localEntity_t   *le, *next;
00791 
00792         // walk the list backwards, so any new local entities generated
00793         // (trails, marks, etc) will be present this frame
00794         le = cg_activeLocalEntities.prev;
00795         for ( ; le != &cg_activeLocalEntities ; le = next ) {
00796                 // grab next now, so if the local entity is freed we
00797                 // still have it
00798                 next = le->prev;
00799 
00800                 if ( cg.time >= le->endTime ) {
00801                         CG_FreeLocalEntity( le );
00802                         continue;
00803                 }
00804                 switch ( le->leType ) {
00805                 default:
00806                         CG_Error( "Bad leType: %i", le->leType );
00807                         break;
00808 
00809                 case LE_MARK:
00810                         break;
00811 
00812                 case LE_SPRITE_EXPLOSION:
00813                         CG_AddSpriteExplosion( le );
00814                         break;
00815 
00816                 case LE_EXPLOSION:
00817                         CG_AddExplosion( le );
00818                         break;
00819 
00820                 case LE_FADE_SCALE_MODEL:
00821                         CG_AddFadeScaleModel( le );
00822                         break;
00823 
00824                 case LE_FRAGMENT:                       // gibs and brass
00825                         CG_AddFragment( le );
00826                         break;
00827 
00828                 case LE_PUFF:
00829                         CG_AddPuff( le );
00830                         break;
00831 
00832                 case LE_MOVE_SCALE_FADE:                // water bubbles
00833                         CG_AddMoveScaleFade( le );
00834                         break;
00835 
00836                 case LE_FADE_RGB:                               // teleporters, railtrails
00837                         CG_AddFadeRGB( le );
00838                         break;
00839 
00840                 case LE_FALL_SCALE_FADE: // gib blood trails
00841                         CG_AddFallScaleFade( le );
00842                         break;
00843 
00844                 case LE_SCALE_FADE:             // rocket trails
00845                         CG_AddScaleFade( le );
00846                         break;
00847 
00848                 case LE_SCOREPLUM:
00849                         CG_AddScorePlum( le );
00850                         break;
00851 
00852                 case LE_OLINE:
00853                         CG_AddOLine( le );
00854                         break;
00855 
00856                 case LE_SHOWREFENTITY:
00857                         CG_AddRefEntity( le );
00858                         break;
00859 
00860                 case LE_LINE:                                   // oriented lines for FX
00861                         CG_AddLine( le );
00862                         break;
00863                 }
00864         }
00865 }

void CG_AddOLine localEntity_t le  ) 
 

Definition at line 725 of file cg_localents.c.

References localEntity_s::alpha, cg, CG_FreeLocalEntity(), localEntity_s::dalpha, localEntity_s::data, refEntity_t::data, localEntity_s::endTime, localEntity_t, localEntity_s::refEntity, refEntity_t::reType, refEntity_t::rotation, RT_ORIENTEDLINE, refEntity_t::shaderRGBA, refEntity_t::shaderTexCoord, localEntity_s::startTime, cg_t::time, and trap_R_AddRefEntityToScene().

Referenced by CG_AddLocalEntities().

00726 {
00727         refEntity_t     *re;
00728         float           frac, alpha;
00729 
00730         re = &le->refEntity;
00731 
00732         frac = (cg.time - le->startTime) / ( float ) ( le->endTime - le->startTime );
00733         if ( frac > 1 ) 
00734                 frac = 1.0;     // can happen during connection problems
00735         else if (frac < 0)
00736                 frac = 0.0;
00737 
00738         // Use the liferate to set the scale over time.
00739         re->data.line.width = le->data.line.width + (le->data.line.dwidth * frac);
00740         if (re->data.line.width <= 0)
00741         {
00742                 CG_FreeLocalEntity( le );
00743                 return;
00744         }
00745 
00746         // We will assume here that we want additive transparency effects.
00747         alpha = le->alpha + (le->dalpha * frac);
00748         re->shaderRGBA[0] = 0xff * alpha;
00749         re->shaderRGBA[1] = 0xff * alpha;
00750         re->shaderRGBA[2] = 0xff * alpha;
00751         re->shaderRGBA[3] = 0xff * alpha;       // Yes, we could apply c to this too, but fading the color is better for lines.
00752 
00753         re->shaderTexCoord[0] = 1;
00754         re->shaderTexCoord[1] = 1;
00755 
00756         re->rotation = 90;
00757 
00758         re->reType = RT_ORIENTEDLINE;
00759 
00760         trap_R_AddRefEntityToScene( re );
00761 }

void CG_AddRefEntity localEntity_t le  ) 
 

Definition at line 624 of file cg_localents.c.

References cg, CG_FreeLocalEntity(), localEntity_s::endTime, localEntity_t, localEntity_s::refEntity, cg_t::time, and trap_R_AddRefEntityToScene().

Referenced by CG_AddLocalEntities().

00624                                           {
00625         if (le->endTime < cg.time) {
00626                 CG_FreeLocalEntity( le );
00627                 return;
00628         }
00629         trap_R_AddRefEntityToScene( &le->refEntity );
00630 }

void CG_AddScorePlum localEntity_t le  ) 
 

Definition at line 639 of file cg_localents.c.

References cg, CG_FreeLocalEntity(), cgs, refEntity_t::customShader, localEntity_s::endTime, localEntity_s::lifeRate, localEntity_t, M_PI, cgs_t::media, NUMBER_SIZE, cgMedia_t::numberShaders, refEntity_t::origin, localEntity_s::pos, qfalse, qtrue, refEntity_t::radius, localEntity_s::radius, cg_t::refdef, localEntity_s::refEntity, refEntity_t::shaderRGBA, sin(), cg_t::time, trap_R_AddRefEntityToScene(), trajectory_t::trBase, vec3_t, VectorCopy, VectorMA, VectorNormalize(), VectorSubtract, and refdef_t::vieworg.

Referenced by CG_AddLocalEntities().

00639                                           {
00640         refEntity_t     *re;
00641         vec3_t          origin, delta, dir, vec, up = {0, 0, 1};
00642         float           c, len;
00643         int                     i, score, digits[10], numdigits, negative;
00644 
00645         re = &le->refEntity;
00646 
00647         c = ( le->endTime - cg.time ) * le->lifeRate;
00648 
00649         score = le->radius;
00650         if (score < 0) {
00651                 re->shaderRGBA[0] = 0xff;
00652                 re->shaderRGBA[1] = 0x11;
00653                 re->shaderRGBA[2] = 0x11;
00654         }
00655         else {
00656                 re->shaderRGBA[0] = 0xff;
00657                 re->shaderRGBA[1] = 0xff;
00658                 re->shaderRGBA[2] = 0xff;
00659                 if (score >= 50) {
00660                         re->shaderRGBA[1] = 0;
00661                 } else if (score >= 20) {
00662                         re->shaderRGBA[0] = re->shaderRGBA[1] = 0;
00663                 } else if (score >= 10) {
00664                         re->shaderRGBA[2] = 0;
00665                 } else if (score >= 2) {
00666                         re->shaderRGBA[0] = re->shaderRGBA[2] = 0;
00667                 }
00668 
00669         }
00670         if (c < 0.25)
00671                 re->shaderRGBA[3] = 0xff * 4 * c;
00672         else
00673                 re->shaderRGBA[3] = 0xff;
00674 
00675         re->radius = NUMBER_SIZE / 2;
00676 
00677         VectorCopy(le->pos.trBase, origin);
00678         origin[2] += 110 - c * 100;
00679 
00680         VectorSubtract(cg.refdef.vieworg, origin, dir);
00681         CrossProduct(dir, up, vec);
00682         VectorNormalize(vec);
00683 
00684         VectorMA(origin, -10 + 20 * sin(c * 2 * M_PI), vec, origin);
00685 
00686         // if the view would be "inside" the sprite, kill the sprite
00687         // so it doesn't add too much overdraw
00688         VectorSubtract( origin, cg.refdef.vieworg, delta );
00689         len = VectorLength( delta );
00690         if ( len < 20 ) {
00691                 CG_FreeLocalEntity( le );
00692                 return;
00693         }
00694 
00695         negative = qfalse;
00696         if (score < 0) {
00697                 negative = qtrue;
00698                 score = -score;
00699         }
00700 
00701         for (numdigits = 0; !(numdigits && !score); numdigits++) {
00702                 digits[numdigits] = score % 10;
00703                 score = score / 10;
00704         }
00705 
00706         if (negative) {
00707                 digits[numdigits] = 10;
00708                 numdigits++;
00709         }
00710 
00711         for (i = 0; i < numdigits; i++) {
00712                 VectorMA(origin, (float) (((float) numdigits / 2) - i) * NUMBER_SIZE, vec, re->origin);
00713                 re->customShader = cgs.media.numberShaders[digits[numdigits-1-i]];
00714                 trap_R_AddRefEntityToScene( re );
00715         }
00716 }

localEntity_t* CG_AllocLocalEntity void   ) 
 

Definition at line 60 of file cg_localents.c.

References cg_activeLocalEntities, cg_freeLocalEntities, CG_FreeLocalEntity(), localEntity_t, memset(), localEntity_s::next, and localEntity_s::prev.

Referenced by CG_Bleed(), CG_BubbleTrail(), CG_Chunks(), CG_LaunchGib(), CG_MakeExplosion(), CG_ScorePlum(), CG_SmokePuff(), CG_TestLine(), CG_ThrowChunk(), FX_AddOrientedLine(), and FX_DEMP2_AltDetonate().

00060                                              {
00061         localEntity_t   *le;
00062 
00063         if ( !cg_freeLocalEntities ) {
00064                 // no free entities, so free the one at the end of the chain
00065                 // remove the oldest active entity
00066                 CG_FreeLocalEntity( cg_activeLocalEntities.prev );
00067         }
00068 
00069         le = cg_freeLocalEntities;
00070         cg_freeLocalEntities = cg_freeLocalEntities->next;
00071 
00072         memset( le, 0, sizeof( *le ) );
00073 
00074         // link into the active list
00075         le->next = cg_activeLocalEntities.next;
00076         le->prev = &cg_activeLocalEntities;
00077         cg_activeLocalEntities.next->prev = le;
00078         cg_activeLocalEntities.next = le;
00079         return le;
00080 }

void CG_BloodTrail localEntity_t le  ) 
 

Definition at line 101 of file cg_localents.c.

References BG_EvaluateTrajectory(), cg, CG_SmokePuff(), cg_t::frametime, LE_FALL_SCALE_FADE, localEntity_s::leType, localEntity_t, localEntity_s::pos, cg_t::time, trajectory_t::trDelta, vec3_origin, and vec3_t.

Referenced by CG_AddFragment().

00101                                         {
00102         int             t;
00103         int             t2;
00104         int             step;
00105         vec3_t  newOrigin;
00106         localEntity_t   *blood;
00107 
00108         step = 150;
00109         t = step * ( (cg.time - cg.frametime + step ) / step );
00110         t2 = step * ( cg.time / step );
00111 
00112         for ( ; t <= t2; t += step ) {
00113                 BG_EvaluateTrajectory( &le->pos, t, newOrigin );
00114 
00115                 blood = CG_SmokePuff( newOrigin, vec3_origin, 
00116                                           20,           // radius
00117                                           1, 1, 1, 1,   // color
00118                                           2000,         // trailTime
00119                                           t,            // startTime
00120                                           0,            // fadeInTime
00121                                           0,            // flags
00122                                           /*cgs.media.bloodTrailShader*/0 );
00123                 // use the optimized version
00124                 blood->leType = LE_FALL_SCALE_FADE;
00125                 // drop a total of 40 units over its lifetime
00126                 blood->pos.trDelta[2] = 40;
00127         }
00128 }

void CG_FragmentBounceMark localEntity_t le,
trace_t trace
 

Definition at line 136 of file cg_localents.c.

References localEntity_s::leMarkType, LEMT_BLOOD, LEMT_BURN, LEMT_NONE, localEntity_t, and rand().

Referenced by CG_AddFragment().

00136                                                                 {
00137         int                     radius;
00138 
00139         if ( le->leMarkType == LEMT_BLOOD ) {
00140 
00141                 radius = 16 + (rand()&31);
00142 //              CG_ImpactMark( cgs.media.bloodMarkShader, trace->endpos, trace->plane.normal, random()*360,
00143 //                      1,1,1,1, qtrue, radius, qfalse );
00144         } else if ( le->leMarkType == LEMT_BURN ) {
00145 
00146                 radius = 8 + (rand()&15);
00147 //              CG_ImpactMark( cgs.media.burnMarkShader, trace->endpos, trace->plane.normal, random()*360,
00148 //                      1,1,1,1, qtrue, radius, qfalse );
00149         }
00150 
00151 
00152         // don't allow a fragment to make multiple marks, or they
00153         // pile up while settling
00154         le->leMarkType = LEMT_NONE;
00155 }

void CG_FragmentBounceSound localEntity_t le,
trace_t trace
 

Definition at line 162 of file cg_localents.c.

References cgs, CHAN_AUTO, trace_t::endpos, ENTITYNUM_WORLD, localEntity_s::leBounceSoundType, LEBS_METAL, LEBS_NONE, LEBS_ROCK, localEntity_t, cgs_t::media, cgMedia_t::metalBounceSound, Q_irand(), rand(), cgMedia_t::rockBounceSound, sfxHandle_t, and trap_S_StartSound().

Referenced by CG_AddFragment().

00162                                                                  {
00163         // half the fragments will make a bounce sounds
00164         if ( rand() & 1 ) 
00165         {
00166                 sfxHandle_t     s = 0;
00167 
00168                 switch( le->leBounceSoundType )
00169                 {
00170                 case LEBS_ROCK:
00171                         s = cgs.media.rockBounceSound[Q_irand(0,1)];
00172                         break;
00173                 case LEBS_METAL:
00174                         s = cgs.media.metalBounceSound[Q_irand(0,1)];// FIXME: make sure that this sound is registered properly...might still be rock bounce sound....
00175                         break;
00176                 default:
00177                         return;
00178                 }
00179 
00180                 if ( s )
00181                 {
00182                         trap_S_StartSound( trace->endpos, ENTITYNUM_WORLD, CHAN_AUTO, s );
00183                 }
00184 
00185                 // bouncers only make the sound once...
00186                 // FIXME: arbitrary...change if it bugs you
00187                 le->leBounceSoundType = LEBS_NONE;
00188         } 
00189         else if ( rand() & 1 )
00190         {
00191                 // we may end up bouncing again, but each bounce reduces the chance of playing the sound again or they may make a lot of noise when they settle
00192                 // FIXME: maybe just always do this??
00193                 le->leBounceSoundType = LEBS_NONE;
00194         }
00195 }

void CG_FreeLocalEntity localEntity_t le  ) 
 

Definition at line 39 of file cg_localents.c.

References CG_Error(), cg_freeLocalEntities, localEntity_t, localEntity_s::next, and localEntity_s::prev.

Referenced by CG_AddFragment(), CG_AddLocalEntities(), CG_AddOLine(), CG_AddRefEntity(), CG_AddScorePlum(), and CG_AllocLocalEntity().

00039                                              {
00040         if ( !le->prev ) {
00041                 CG_Error( "CG_FreeLocalEntity: not active" );
00042         }
00043 
00044         // remove from the doubly linked active list
00045         le->prev->next = le->next;
00046         le->next->prev = le->prev;
00047 
00048         // the free list is only singly linked
00049         le->next = cg_freeLocalEntities;
00050         cg_freeLocalEntities = le;
00051 }

void CG_InitLocalEntities void   ) 
 

Definition at line 21 of file cg_localents.c.

References cg_activeLocalEntities, cg_freeLocalEntities, cg_localEntities, MAX_LOCAL_ENTITIES, memset(), localEntity_s::next, and localEntity_s::prev.

Referenced by CG_Init().

00021                                      {
00022         int             i;
00023 
00024         memset( cg_localEntities, 0, sizeof( cg_localEntities ) );
00025         cg_activeLocalEntities.next = &cg_activeLocalEntities;
00026         cg_activeLocalEntities.prev = &cg_activeLocalEntities;
00027         cg_freeLocalEntities = cg_localEntities;
00028         for ( i = 0 ; i < MAX_LOCAL_ENTITIES - 1 ; i++ ) {
00029                 cg_localEntities[i].next = &cg_localEntities[i+1];
00030         }
00031 }

void CG_ReflectVelocity localEntity_t le,
trace_t trace
 

Definition at line 203 of file cg_localents.c.

References trace_t::allsolid, BG_EvaluateTrajectoryDelta(), localEntity_s::bounceFactor, cg, DotProduct, trace_t::endpos, trace_t::fraction, cg_t::frametime, localEntity_t, cplane_s::normal, trace_t::plane, localEntity_s::pos, cg_t::time, TR_STATIONARY, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trTime, trajectory_t::trType, vec3_t, VectorCopy, VectorMA, and VectorScale.

Referenced by CG_AddFragment().

00203                                                              {
00204         vec3_t  velocity;
00205         float   dot;
00206         int             hitTime;
00207 
00208         // reflect the velocity on the trace plane
00209         hitTime = cg.time - cg.frametime + cg.frametime * trace->fraction;
00210         BG_EvaluateTrajectoryDelta( &le->pos, hitTime, velocity );
00211         dot = DotProduct( velocity, trace->plane.normal );
00212         VectorMA( velocity, -2*dot, trace->plane.normal, le->pos.trDelta );
00213 
00214         VectorScale( le->pos.trDelta, le->bounceFactor, le->pos.trDelta );
00215 
00216         VectorCopy( trace->endpos, le->pos.trBase );
00217         le->pos.trTime = cg.time;
00218 
00219         // check for stop, making sure that even on low FPS systems it doesn't bobble
00220         if ( trace->allsolid || 
00221                 ( trace->plane.normal[2] > 0 && 
00222                 ( le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2] ) ) ) {
00223                 le->pos.trType = TR_STATIONARY;
00224         } else {
00225 
00226         }
00227 }


Variable Documentation

localEntity_t cg_activeLocalEntities
 

Definition at line 11 of file cg_localents.c.

Referenced by CG_AddLocalEntities(), CG_AllocLocalEntity(), and CG_InitLocalEntities().

localEntity_t* cg_freeLocalEntities
 

Definition at line 12 of file cg_localents.c.

Referenced by CG_AllocLocalEntity(), CG_FreeLocalEntity(), and CG_InitLocalEntities().

localEntity_t cg_localEntities[MAX_LOCAL_ENTITIES]
 

Definition at line 10 of file cg_localents.c.

Referenced by CG_InitLocalEntities().