Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include "cbase.h"
  3. //-----------------------------------------------------------------------------
  4. // Purpose: Calculate the FOV for the intro sequence (needed by both server and client)
  5. //-----------------------------------------------------------------------------
  6. float ScriptInfo_CalculateFOV( float flFOVBlendStartTime, float flNextFOVBlendTime, int nFOV, int nNextFOV, bool bSplineRamp )
  7. {
  8. // Handle the spline case
  9. if ( bSplineRamp )
  10. {
  11. //If we're past the zoom time, just take the new value and stop transitioning
  12. float deltaTime = (float)( gpGlobals->curtime - flFOVBlendStartTime ) / ( flNextFOVBlendTime - flFOVBlendStartTime );
  13. if ( deltaTime >= 1.0f )
  14. return nNextFOV;
  15. float flResult = SimpleSplineRemapVal( deltaTime, 0.0f, 1.0f, (float) nFOV, (float) nNextFOV );
  16. // Msg("FOV BLENDING: curtime %.2f StartedAt %.2f FinishAt: %.2f\n", gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime );
  17. // Msg(" Perc: %.2f Start: %d End: %d FOV: %.2f\n", SimpleSplineRemapVal( deltaTime, 0.0f, 1.0f, nFOV, nNextFOV ), nFOV, nNextFOV, flResult );
  18. return flResult;
  19. }
  20. // Common, linear blend
  21. if ( (flNextFOVBlendTime - flFOVBlendStartTime) != 0 )
  22. {
  23. float flResult = RemapValClamped( gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime, (float) nFOV, (float) nNextFOV );
  24. // Msg("FOV BLENDING: curtime %.2f StartedAt %.2f FinishAt: %.2f\n", gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime );
  25. // Msg(" Perc: %.2f Start: %d End: %d FOV: %.2f\n", RemapValClamped( gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime, 0.0, 1.0 ), nFOV, nNextFOV, flResult );
  26. return flResult;
  27. }
  28. // Msg("FOV BLENDING: JUMPED TO NEXT FOV (%d)\n", nNextFOV );
  29. return nNextFOV;
  30. }