Esempio n. 1
0
/*
===============
R_SetupParticles

moved all non-drawing code to R_UpdateParticles
===============
*/
void R_SetupParticles (void)
{
	particle_t		*p;
	int				i = 0;
	
	if (!r_particles.value)
		return;
	
	for (p=active_particles ; p ; p=p->next)
	{
		// improve sound when many particles
		if (++i % 8192 == 0)
			S_ExtraUpdateTime ();
		
		R_AddToAlpha (ALPHA_PARTICLE, R_GetAlphaDist(p->org), p, NULL, 0);
		
		rs_c_particles++; // r_speeds
	}
}
Esempio n. 2
0
/*
================
SV_Physics

================
*/
void SV_Physics (void)
{
	int			i;
	edict_t		*ent;

// let the progs know that a new frame has started
#ifdef HEXEN2_SUPPORT
	edict_t		*ent2;
	vec3_t		oldOrigin, oldAngle;
	int			originMoved, c;
#endif

	PR_GLOBAL(self) = EDICT_TO_PROG(sv.edicts);
	PR_GLOBAL(other) = EDICT_TO_PROG(sv.edicts);
	PR_GLOBAL(time) = sv.time;
	PR_ExecuteProgram (PR_GLOBAL(StartFrame));

//SV_CheckAllEnts ();

// treat each object in turn
	ent = sv.edicts;
	for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
	{
		if (ent->free)
			continue;

	#ifndef RQM_SV_ONLY
		if (!isDedicated && ((i+1) % 100 == 0))
			S_ExtraUpdateTime (); // BJP: Improve sound when many entities
	#endif

	#ifdef HEXEN2_SUPPORT
		if (hexen2)
		{
			ent2 = PROG_TO_EDICT (ent->v.movechain);
			if (ent2 != sv.edicts)
			{
				VectorCopy (ent->v.origin, oldOrigin);
				VectorCopy (ent->v.angles, oldAngle);
			}
		}
	#endif

		if (pr_global_ptrs.force_retouch && *pr_global_ptrs.force_retouch)
			SV_LinkEdict (ent, true);	// force retouch even for stationary

		if (i > 0 && i <= svs.maxclients)
			SV_Physics_Client (ent, i);
		else if (ent->v.movetype == MOVETYPE_PUSH)
			SV_Physics_Pusher (ent);
		else if (ent->v.movetype == MOVETYPE_NONE)
			SV_Physics_None (ent);
		else if (ent->v.movetype == MOVETYPE_NOCLIP)
			SV_Physics_Noclip (ent);
		else if (ent->v.movetype == MOVETYPE_STEP)
			SV_Physics_Step (ent);
	#ifdef HEXEN2_SUPPORT
		else if	((hexen2) && (ent->v.movetype == MOVETYPE_PUSHPULL))
			SV_Physics_Step (ent);
	#endif
		else if (ent->v.movetype == MOVETYPE_TOSS 
		|| ent->v.movetype == MOVETYPE_BOUNCE
	#ifdef HEXEN2_SUPPORT
		|| ((hexen2) && ((ent->v.movetype == MOVETYPE_BOUNCEMISSILE) || (ent->v.movetype == MOVETYPE_SWIM)))
	#endif
		|| ent->v.movetype == MOVETYPE_FLY
		|| ent->v.movetype == MOVETYPE_FLYMISSILE)
			SV_Physics_Toss (ent);
		else
			Sys_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype);			

	#ifdef HEXEN2_SUPPORT
		if ((hexen2) && (ent2 != sv.edicts))
		{
			originMoved = !VectorCompare(ent->v.origin, oldOrigin);
			if (originMoved || !VectorCompare(ent->v.angles, oldAngle))
			{
				VectorSubtract(ent->v.origin, oldOrigin, oldOrigin);
				VectorSubtract(ent->v.angles, oldAngle, oldAngle);

				for (c=0; c<10; c++)
				{   // chain a max of 10 objects
					if (ent2->free) break;

					VectorAdd(oldOrigin, ent2->v.origin, ent2->v.origin);
					if ((int) ent2->v.flags & FL_MOVECHAIN_ANGLE)
					{
						VectorAdd(oldAngle, ent2->v.angles, ent2->v.angles);
					}

					if (originMoved && ent2->v.chainmoved)
					{	// callback function
						*pr_global_ptrs.self = EDICT_TO_PROG(ent2);
						*pr_global_ptrs.other = EDICT_TO_PROG(ent);
						PR_ExecuteProgram(ent2->v.chainmoved);
					}

					ent2 = PROG_TO_EDICT( ent2->v.movechain );
					if (ent2 == sv.edicts) break;

				}
			}
		}
	#endif
	}
	
	if (pr_global_ptrs.force_retouch && *pr_global_ptrs.force_retouch)
		PR_GLOBAL(force_retouch)--;

	sv.time += host_frametime;
}