//========================== // V_CalcRefdef //========================== void V_CalcRefdef( struct ref_params_s *pparams ) { //pause = pparams->paused; //if( pause ) return; if( pparams->intermission ) { V_CalcIntermisionRefdef( pparams ); } else if( pparams->viewentity > pparams->maxclients ) { V_CalcCameraRefdef( pparams ); } else if( gHUD.m_iCameraMode ) { V_CalcThirdPersonRefdef( pparams ); } else { V_CalcFirstPersonRefdef( pparams ); } // fog that can be controlled from server-side V_CalcGlobalFog( pparams ); }
/* ================ 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; }