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.

84 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #if !defined ( DLIGHTH )
  9. #define DLIGHTH
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "mathlib/vector.h"
  14. //-----------------------------------------------------------------------------
  15. // Dynamic light structure
  16. //-----------------------------------------------------------------------------
  17. enum
  18. {
  19. DLIGHT_NO_WORLD_ILLUMINATION = 0x1,
  20. DLIGHT_NO_MODEL_ILLUMINATION = 0x2,
  21. // NOTE: These two features are used to dynamically tweak the alpha on displacements
  22. // which is a special effect for selecting which texture to use. If
  23. // we ever change how alpha is stored for displacements, we'll have to kill this feature
  24. DLIGHT_ADD_DISPLACEMENT_ALPHA = 0x4,
  25. DLIGHT_SUBTRACT_DISPLACEMENT_ALPHA = 0x8,
  26. DLIGHT_DISPLACEMENT_MASK = (DLIGHT_ADD_DISPLACEMENT_ALPHA | DLIGHT_SUBTRACT_DISPLACEMENT_ALPHA),
  27. };
  28. // This is the lighting value that is used to determine when something can be
  29. // culle from lighting because it is close enough to black to be virtually black.
  30. //#define MIN_LIGHTING_VALUE (1.0f/256.0f)
  31. // This is the broken value of MIN_LIGHTING_VALUE that we have to take into consideration
  32. // to make sure that the lighting for dlights look the same as they did in HL2.
  33. // We'll use the real MIN_LIGHTING_VALUE above to calculate larger radii for dynamic
  34. // light sources.
  35. //#define HL2_BROKEN_MIN_LIGHTING_VALUE (20.0f/256.0f)
  36. struct dlight_t
  37. {
  38. int flags;
  39. Vector origin;
  40. float radius;
  41. ColorRGBExp32 color; // Light color with exponent
  42. float die; // stop lighting after this time
  43. float decay; // drop this each second
  44. float minlight; // don't add when contributing less
  45. int key;
  46. int style; // lightstyle
  47. // For spotlights. Use m_OuterAngle == 0 for point lights
  48. Vector m_Direction; // center of the light cone
  49. float m_InnerAngle;
  50. float m_OuterAngle;
  51. // see comments above about HL2_BROKEN_MIN_LIGHTING_VALUE and MIN_LIGHTING_VALUE
  52. // THIS SHOULD ONLY GET CALLED FROM THE ENGINE
  53. float GetRadius() const
  54. {
  55. // return FastSqrt( radius * radius * ( HL2_BROKEN_MIN_LIGHTING_VALUE / MIN_LIGHTING_VALUE ) );
  56. return radius;
  57. }
  58. // see comments above about HL2_BROKEN_MIN_LIGHTING_VALUE and MIN_LIGHTING_VALUE
  59. // THIS SHOULD ONLY GET CALLED FROM THE ENGINE
  60. float GetRadiusSquared() const
  61. {
  62. // return radius * radius * ( HL2_BROKEN_MIN_LIGHTING_VALUE / MIN_LIGHTING_VALUE );
  63. return radius * radius;
  64. }
  65. // THIS SHOULD ONLY GET CALLED FROM THE ENGINE
  66. float IsRadiusGreaterThanZero() const
  67. {
  68. // don't bother calculating the new radius if you just want to know if it is greater than zero.
  69. return radius > 0.0f;
  70. }
  71. };
  72. #endif