Пример #1
0
/*
===============
CG_AddTrails
===============
*/
void CG_AddTrails(void) {
	trailJunc_t *j, *jNext;

	if (!initTrails) {
		CG_ClearTrails();
	}

	VectorCopy(cg.refdef_current->viewaxis[0], vforward);
	VectorCopy(cg.refdef_current->viewaxis[1], vright);
	VectorCopy(cg.refdef_current->viewaxis[2], vup);

	// update the settings for each junc
	j = activeTrails;
	while (j) {
		float lifeFrac = (float)(cg.time - j->spawnTime) / (float)(j->endTime - j->spawnTime);

		if (lifeFrac >= 1.0) {
			j->inuse = qfalse;          // flag it as dead
			j->width = j->widthEnd;
			j->alpha = j->alphaEnd;
			if (j->alpha > 1.0) {
				j->alpha = 1.0;
			} else if (j->alpha < 0.0) {
				j->alpha = 0.0;
			}
			VectorCopy(j->colorEnd, j->color);
		} else {
			j->width = j->widthStart + (j->widthEnd - j->widthStart) * lifeFrac;
			j->alpha = j->alphaStart + (j->alphaEnd - j->alphaStart) * lifeFrac;
			if (j->alpha > 1.0) {
				j->alpha = 1.0;
			} else if (j->alpha < 0.0) {
				j->alpha = 0.0;
			}
			VectorSubtract(j->colorEnd, j->colorStart, j->color);
			VectorMA(j->colorStart, lifeFrac, j->color, j->color);
		}

		j = j->nextGlobal;
	}

	// draw the trailHeads
	j = headTrails;
	while (j) {
		jNext = j->nextHead;        // in case it gets removed
		if (!j->inuse) {
			CG_FreeTrailJunc(j);
		} else {
			CG_AddTrailToScene(j, 0, 0);
		}
		j = jNext;
	}
}
Пример #2
0
/*
===========
CG_KillTrail
===========
*/
void CG_KillTrail(trailJunc_t *t)
{
	trailJunc_t *next;

	next = t->nextJunc;

	// kill the trail here
	t->nextJunc = NULL;

	if(next)
	{
		CG_FreeTrailJunc(next);
	}
}
Пример #3
0
/*
===========
CG_KillTrail
===========
*/
void CG_KillTrail(trailJunc_t *t) {
	trailJunc_t *next;

	if (!t->inuse && t->freed) {
		return;
	}
	next = t->nextJunc;
	if (next < &trailJuncs[0] || next >= &trailJuncs[MAX_TRAILJUNCS]) {
		next = NULL;
	}
	t->nextJunc = NULL;
	if (next) {
		if (next->nextJunc && next->nextJunc == t) {
			next->nextJunc = NULL;
		}
		CG_FreeTrailJunc(next);
	}
}