本文整理汇总了C++中CG_FreeLocalEntity函数的典型用法代码示例。如果您正苦于以下问题:C++ CG_FreeLocalEntity函数的具体用法?C++ CG_FreeLocalEntity怎么用?C++ CG_FreeLocalEntity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CG_FreeLocalEntity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CG_AddFireEffect
/*
================
CG_AddFireEffect
================
*/
static void CG_AddFireEffect( localEntity_t *le ) {
refEntity_t *re;
trace_t trace;
re = &le->refEntity;
if ( le->pos.trType == TR_STATIONARY ) {
if ( le->leFlags & LEF_LESSOVERDRAW ) {
// avoid too much overdraw
if ( CG_NearbyDrawnLeCount( le, re->origin, le->leType, 52 + !!cg_lowDetailEffects.integer * 24 ) > 0 ) return;
}
// add to refresh list
trap_R_AddRefEntityToScene( re );
return;
}
// calculate position
BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );
// check for water
if ( trap_CM_PointContents( re->origin, 0 ) & CONTENTS_WATER ) {
// do a trace to get water surface normals
CG_Trace( &trace, re->oldorigin, NULL, NULL, re->origin, le->owner, MASK_WATER );
CG_FreeLocalEntity( le );
CG_MakeExplosion( trace.endpos, trace.plane.normal,
cgs.media.ringFlashModel, cgs.media.vaporShader,
500, qfalse, qtrue );
return;
}
// do a trace sometimes
if ( le->ti.trailTime++ > 5 ) {
le->ti.trailTime = 0;
CG_Trace( &trace, re->oldorigin, NULL, NULL, re->origin, le->owner, MASK_SHOT );
VectorCopy( trace.endpos, re->origin );
VectorCopy( trace.endpos, re->oldorigin );
// hit something
if ( trace.fraction < 1.0 ) {
// free le if another one is nearby, otherwise make it stationary
if ( CG_CheckDistance( re->origin, le->leType, TR_STATIONARY, re->customShader, 200, 32 ) ) {
CG_FreeLocalEntity( le );
return;
} else {
le->pos.trType = TR_STATIONARY;
}
}
}
if ( le->leFlags & LEF_LESSOVERDRAW ) {
// avoid too much overdraw
if ( CG_NearbyDrawnLeCount( le, re->origin, le->leType, 52 + !!cg_lowDetailEffects.integer * 24 ) > 0 ) return;
}
// add to refresh list
trap_R_AddRefEntityToScene( re );
}
示例2: CG_AddGore
void CG_AddGore( localEntity_t *le ) {
vec3_t newOrigin;
trace_t trace;
if ( le->pos.trType == TR_STATIONARY ) {
// sink into the ground if near the removal time
//int t;
//float oldZ;
CG_FreeLocalEntity( le ); // kill it
return;
}
// calculate new position
BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );
// trace a line from previous position to new position
CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID );
if ( trace.fraction == 1.0 ) {
// still in free fall
VectorCopy( newOrigin, le->refEntity.origin );
if ( le->leFlags & LEF_TUMBLE ) {
vec3_t angles;
BG_EvaluateTrajectory( &le->angles, cg.time, angles );
AnglesToAxis( angles, le->refEntity.axis );
}
trap_R_AddRefEntityToScene( &le->refEntity );
CG_SmallBloodTrail( le );
return;
}
// if it is in a nodrop zone, remove it
// this keeps gibs from waiting at the bottom of pits of death
// and floating levels
if ( trap_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) {
CG_FreeLocalEntity( le );
return;
}
// leave a mark
CG_GoreMark( le, &trace );
// do a juicy sound
CG_SplatSound( le, &trace );
CG_JustSplat( le, &trace );
trap_R_AddRefEntityToScene( &le->refEntity );
}
示例3: CG_AddRefEntity
/*
===================
CG_AddRefEntity
===================
*/
void CG_AddRefEntity( localEntity_t *le ) {
if (le->endTime < cg.time) {
CG_FreeLocalEntity( le );
return;
}
CG_AddRefEntityWithMinLight( &le->refEntity );
}
示例4: CG_AddPuff
/*
==================
CG_AddPuff
==================
*/
static void CG_AddPuff( localEntity_t *le ) {
refEntity_t *re;
float c;
vec3_t delta;
float len;
re = &le->refEntity;
// fade / grow time
c = ( le->endTime - cg.time ) / (float)( le->endTime - le->startTime );
re->shaderRGBA[0] = le->color[0] * c;
re->shaderRGBA[1] = le->color[1] * c;
re->shaderRGBA[2] = le->color[2] * c;
if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) {
re->radius = le->radius * ( 1.0 - c ) + 8;
}
BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );
// if the view would be "inside" the sprite, kill the sprite
// so it doesn't add too much overdraw
VectorSubtract( re->origin, cg.refdef.vieworg, delta );
len = VectorLength( delta );
if ( len < le->radius ) {
CG_FreeLocalEntity( le );
return;
}
trap->R_AddRefEntityToScene( re );
}
示例5: CG_ResetMissileEntity
/*
================
CG_ResetMissileEntity
================
*/
void CG_ResetMissileEntity( centity_t *cent ) {
// link trajectory
cent->ti.trPos = ¢->currentState.pos;
cent->ti.weapon = cent->currentState.weapon;
// check for predicted missiles if necessary
if ( cg.predictWeapons && cent->currentState.clientNum == cg.snap->ps.clientNum ) {
localEntity_t *le;
le = cg_activeLocalEntities.prev;
for ( ; le != &cg_activeLocalEntities ; le = le->prev ) {
// the first (and oldest) missile le is the one represented by the new one
if ( le->leType == LE_MISSILE && weLi[le->ti.weapon].prediction != PR_FLAME ) {
// set the correct trailTime
cent->ti.trailTime = le->ti.trailTime;
VectorCopy( le->ti.lastPos, cent->ti.lastPos );
// free the local entity
CG_FreeLocalEntity( le );
return;
}
}
}
// there isn't a predicted missile, use normal trailTime reset
cent->ti.trailTime = cent->currentState.pos.trTime + TRAIL_DELAY;
BG_EvaluateTrajectory( cent->ti.trPos, cent->ti.trailTime, cent->ti.lastPos );
}
示例6: CG_AddFallScaleFade
/*
=================
CG_AddFallScaleFade
This is just an optimized CG_AddMoveScaleFade
For blood mists that drift down, fade out, and are
removed if the view passes through them.
There are often 100+ of these, so it needs to be simple.
=================
*/
static void CG_AddFallScaleFade( localEntity_t *le ) {
refEntity_t *re;
gfixed c;
bvec3_t delta;
bfixed len;
re = &le->refEntity;
// fade time
c = MAKE_GFIXED( le->endTime - cg.time ) * le->lifeRate;
re->shaderRGBA[3] = FIXED_TO_INT(GFIXED(255,0) * c * le->color[3]);
re->origin[2] = le->pos.trBase[2] - MAKE_BFIXED( GFIXED_1 - c ) * le->pos.trDelta[2];
re->radius = le->radius * MAKE_BFIXED( GFIXED_1 - c ) + BFIXED(16,0);
// if the view would be "inside" the sprite, kill the sprite
// so it doesn't add too much overdraw
VectorSubtract( re->origin, cg.refdef.vieworg, delta );
len = FIXED_VEC3LEN( delta );
if ( len < le->radius ) {
CG_FreeLocalEntity( le );
return;
}
_CG_trap_R_AddRefEntityToScene( re );
}
示例7: CG_FreeLocalEntity
/*
===================
CG_AllocLocalEntity
Will allways succeed, even if it requires freeing an old active entity
===================
*/
localEntity_t *CG_AllocLocalEntity( void ) {
localEntity_t *le;
if ( !cg_freeLocalEntities ) {
// no free entities, so free the one at the end of the chain
// remove the oldest active entity
CG_FreeLocalEntity( cg_activeLocalEntities.prev );
}
// Ridah, debugging
localEntCount++;
// trap_Print( va("AllocLocalEntity: locelEntCount = %d\n", localEntCount) );
// done.
le = cg_freeLocalEntities;
cg_freeLocalEntities = cg_freeLocalEntities->next;
memset( le, 0, sizeof( *le ) );
// link into the active list
le->next = cg_activeLocalEntities.next;
le->prev = &cg_activeLocalEntities;
cg_activeLocalEntities.next->prev = le;
cg_activeLocalEntities.next = le;
return le;
}
示例8: CG_AddFallScaleFade
/*
=================
CG_AddFallScaleFade
This is just an optimized CG_AddMoveScaleFade
For blood mists that drift down, fade out, and are
removed if the view passes through them.
There are often 100+ of these, so it needs to be simple.
=================
*/
static void CG_AddFallScaleFade( localEntity_t *le ) {
refEntity_t *re;
float c;
vec3_t delta;
float len;
re = &le->refEntity;
// fade time
c = ( le->endTime - cg.time ) * le->lifeRate;
re->shaderRGBA[3] = 0xff * c * le->color[3];
re->origin[2] = le->pos.trBase[2] - ( 1.0 - c ) * le->pos.trDelta[2];
re->radius = le->radius * ( 1.0 - c ) + 16;
// if the view would be "inside" the sprite, kill the sprite
// so it doesn't add too much overdraw
VectorSubtract( re->origin, cg.refdef.vieworg, delta );
len = VectorLength( delta );
if ( len < le->radius ) {
CG_FreeLocalEntity( le );
return;
}
trap->R_AddRefEntityToScene( re );
}
示例9: CG_AddRefEntity
void CG_AddRefEntity( localEntity_t *le ) {
if ( le->endTime < cg.time ) {
CG_FreeLocalEntity( le );
return;
}
SE_R_AddRefEntityToScene( &le->refEntity, MAX_CLIENTS );
}
示例10: CG_AddOLine
// For forcefields/other rectangular things
void CG_AddOLine( localEntity_t *le ) {
refEntity_t *re;
float frac, alpha;
re = &le->refEntity;
frac = (cg.time - le->startTime) / (float)(le->endTime - le->startTime);
if ( frac > 1 )
frac = 1.0f; // can happen during connection problems
else if ( frac < 0 )
frac = 0.0f;
// Use the liferate to set the scale over time.
re->data.line.width = le->data.line.width + (le->data.line.dwidth * frac);
if ( re->data.line.width <= 0 ) {
CG_FreeLocalEntity( le );
return;
}
// We will assume here that we want additive transparency effects.
alpha = le->alpha + (le->dalpha * frac);
re->shaderRGBA[0] = 0xff * alpha;
re->shaderRGBA[1] = 0xff * alpha;
re->shaderRGBA[2] = 0xff * alpha;
re->shaderRGBA[3] = 0xff * alpha; // Yes, we could apply c to this too, but fading the color is better for lines.
re->shaderTexCoord.x = 1;
re->shaderTexCoord.y = 1;
re->rotation = 90;
re->reType = RT_ORIENTEDLINE;
SE_R_AddRefEntityToScene( re, MAX_CLIENTS );
}
示例11: CG_AddRefEntity
/*
===================
CG_AddRefEntity
===================
*/
void CG_AddRefEntity( localEntity_t *le ) {
if (le->endTime < cg.time) {
CG_FreeLocalEntity( le );
return;
}
trap->R_AddRefEntityToScene( &le->refEntity );
}
示例12: CG_AddScaleFade
// For rocket smokes that hang in place, fade out, and are removed if the view passes through them.
// There are often many of these, so it needs to be simple.
static void CG_AddScaleFade( localEntity_t *le ) {
refEntity_t *re;
float c;
vector3 delta;
float len;
refdef_t *refdef = CG_GetRefdef();
re = &le->refEntity;
// fade / grow time
c = (le->endTime - cg.time) * le->lifeRate;
re->shaderRGBA[3] = 0xff * c * le->color[3];
re->radius = le->radius * (1.0f - c) + 8;
// if the view would be "inside" the sprite, kill the sprite
// so it doesn't add too much overdraw
VectorSubtract( &re->origin, &refdef->vieworg, &delta );
len = VectorLength( &delta );
if ( len < le->radius ) {
CG_FreeLocalEntity( le );
return;
}
SE_R_AddRefEntityToScene( re, MAX_CLIENTS );
}
示例13: CG_AddScaleFade
/*
===================
CG_AddScaleFade
For rocket smokes that hang in place, fade out, and are
removed if the view passes through them.
There are often many of these, so it needs to be simple.
===================
*/
static void CG_AddScaleFade( localEntity_t *le ) {
refEntity_t *re;
float c;
vec3_t delta;
float len;
re = &le->refEntity;
// fade / grow time
c = ( le->endTime - cg.time ) * le->lifeRate;
re->shaderRGBA[3] = 0xff * c * le->color[3];
re->radius = le->radius * ( 1.0 - c ) + 8;
// if the view would be "inside" the sprite, kill the sprite
// so it doesn't add too much overdraw
VectorSubtract( re->origin, cg.refdef.vieworg, delta );
len = VectorLength( delta );
if ( len < le->radius ) {
CG_FreeLocalEntity( le );
return;
}
CG_AddRefEntityWithMinLight( re );
}
示例14: CG_AddLine2
/*
===================
CG_AddLine2
For trek, for beams and the like.
===================
*/
void CG_AddLine2( localEntity_t *le )
{
refEntity_t *re;
float frac, alpha;
vec3_t curRGB;
re = &le->refEntity;
frac = (cg.time - le->startTime) / ( float ) ( le->endTime - le->startTime );
if ( frac > 1 )
frac = 1.0; // can happen during connection problems
else if (frac < 0)
frac = 0.0;
// Use the liferate to set the scale over time.
re->data.line.width = le->data.line2.width + (le->data.line2.dwidth * frac);
re->data.line.width2 = le->data.line2.width2 + (le->data.line2.dwidth2 * frac);
if (re->data.line.width <= 0)
{
CG_FreeLocalEntity( le );
return;
}
// We will assume here that we want additive transparency effects.
alpha = le->alpha + (le->dalpha * frac);
VectorMA(le->data.line2.startRGB, frac, le->data.line2.dRGB, curRGB);
re->shaderRGBA[0] = 0xff * alpha * curRGB[0];
re->shaderRGBA[1] = 0xff * alpha * curRGB[1];
re->shaderRGBA[2] = 0xff * alpha * curRGB[2];
re->shaderRGBA[3] = 0xff * alpha; // Yes, we could apply c to this too, but fading the color is better for lines.
re->reType = RT_LINE2;
trap_R_AddRefEntityToScene( re );
}
示例15: CG_AddFallScaleFade
// This is just an optimized CG_AddMoveScaleFade for blood mists that drift down, fade out, and are removed if the view passes through them.
// There are often 100+ of these, so it needs to be simple.
static void CG_AddFallScaleFade( localEntity_t *le ) {
refEntity_t *re;
float c;
vector3 delta;
float len;
re = &le->refEntity;
// fade time
c = ( le->endTime - cg.time ) * le->lifeRate;
re->shaderRGBA[3] = (byte)(255 * c * le->color.a);
re->origin.z = le->pos.trBase.z - ( 1.0f - c ) * le->pos.trDelta.z;
re->radius = le->radius * ( 1.0f - c ) + 16;
// if the view would be "inside" the sprite, kill the sprite so it doesn't add too much overdraw
VectorSubtract( &re->origin, &cg.refdef.vieworg, &delta );
len = VectorLength( &delta );
if ( len < le->radius ) {
CG_FreeLocalEntity( le );
return;
}
trap->R_AddRefEntityToScene( re );
}