示例#1
0
文件: r_cull.cpp 项目: FWGS/XashXT
/*
=============
R_CullModel
=============
*/
bool R_CullModel( cl_entity_t *e, const Vector &origin, const Vector &mins, const Vector &maxs, float radius )
{
	if( e == GET_VIEWMODEL( ))
	{
		if( RI.params & RP_NONVIEWERREF )
			return true;
		return false;
	}

	// don't reflect this entity in mirrors
	if( e->curstate.effects & EF_NOREFLECT && RI.params & RP_MIRRORVIEW )
		return true;

	// draw only in mirrors
	if( e->curstate.effects & EF_REFLECTONLY && !( RI.params & RP_MIRRORVIEW ))
		return true;

	// never draw playermodel for himself flashlight while shadowpass is active
	if( RI.params & RP_SHADOWVIEW && RI.currentlight != NULL )
	{
		if( UTIL_IsLocal( e->index ) && UTIL_IsLocal( RI.currentlight->key ))
			return true;
          }

	if( RP_LOCALCLIENT( e ))
	{
		if( RI.params & RP_FORCE_NOPLAYER )
			return true;

		if( !RI.thirdPerson && UTIL_IsLocal( RI.refdef.viewentity ))
		{
			// player can view himself from the portal camera
			if(!( RI.params & ( RP_MIRRORVIEW|RP_PORTALVIEW|RP_SCREENVIEW|RP_SHADOWVIEW )))
				return true;
		}
	}

	if( R_CullSphere( origin, radius, RI.clipFlags ))
		return true;

	if( RI.params & ( RP_SKYPORTALVIEW|RP_PORTALVIEW ))
	{
		if( R_VisCullSphere( e->origin, radius ))
			return true;
	}

	return false;
}
示例#2
0
文件: r_misc.cpp 项目: emileb/XashXT
/*
================
HUD_UpdateFlashlight

update client flashlight
================
*/
void HUD_UpdateFlashlight( cl_entity_t *pEnt )
{
	Vector	v_angles, forward, right, up;
	Vector	v_origin;

	if( UTIL_IsLocal( pEnt->index ))
	{
		ref_params_t tmpRefDef = RI.refdef;

		// player seen through camera. Restore firstperson view here
		if( RI.refdef.viewentity > RI.refdef.maxclients )
			V_CalcFirstPersonRefdef( &tmpRefDef );

		v_angles = tmpRefDef.viewangles;
		v_origin = tmpRefDef.vieworg;
	}
	else
	{
		// restore viewangles from angles
		v_angles[PITCH] = -pEnt->angles[PITCH] * 3;
		v_angles[YAW] = pEnt->angles[YAW];
		v_angles[ROLL] = 0;	// no roll
		v_origin = pEnt->origin;
	}

	AngleVectors( v_angles, forward, NULL, NULL );

	Vector vecEnd = v_origin + forward * FLASHLIGHT_DISTANCE;

	pmtrace_t	trace;
	int traceFlags = PM_STUDIO_BOX;

	if( r_lighting_extended->value < 2 )
		traceFlags |= PM_GLASS_IGNORE;

	gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
	gEngfuncs.pEventAPI->EV_PlayerTrace( v_origin, vecEnd, traceFlags, -1, &trace );
	float falloff = trace.fraction * FLASHLIGHT_DISTANCE;

	if( falloff < 250.0f ) falloff = 1.0f;
	else falloff = 250.0f / falloff;

	falloff *= falloff;

	// update flashlight endpos
	dlight_t	*dl = gEngfuncs.pEfxAPI->CL_AllocDlight( pEnt->curstate.number );
	dl->origin = trace.endpos;
	dl->die = GET_CLIENT_TIME() + 0.01f; // die on next frame
	dl->color.r = bound( 0, 255 * falloff, 255 );
	dl->color.g = bound( 0, 255 * falloff, 255 );
	dl->color.b = bound( 0, 255 * falloff, 255 );
	dl->radius = 72;

}