Counter Strike : Global Offensive Source Code
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.

94 lines
2.9 KiB

  1. //========= Copyright � 1996-2005, 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. class IClientRenderable;
  15. //-----------------------------------------------------------------------------
  16. // Dynamic light structure
  17. //-----------------------------------------------------------------------------
  18. enum
  19. {
  20. DLIGHT_NO_WORLD_ILLUMINATION = 0x1,
  21. DLIGHT_NO_MODEL_ILLUMINATION = 0x2,
  22. // NOTE: These two features are used to dynamically tweak the alpha on displacements
  23. // which is a special effect for selecting which texture to use. If
  24. // we ever change how alpha is stored for displacements, we'll have to kill this feature
  25. DLIGHT_ADD_DISPLACEMENT_ALPHA = 0x4,
  26. DLIGHT_SUBTRACT_DISPLACEMENT_ALPHA = 0x8,
  27. DLIGHT_DISPLACEMENT_MASK = (DLIGHT_ADD_DISPLACEMENT_ALPHA | DLIGHT_SUBTRACT_DISPLACEMENT_ALPHA),
  28. };
  29. // This is the lighting value that is used to determine when something can be
  30. // culle from lighting because it is close enough to black to be virtually black.
  31. //#define MIN_LIGHTING_VALUE (1.0f/256.0f)
  32. // This is the broken value of MIN_LIGHTING_VALUE that we have to take into consideration
  33. // to make sure that the lighting for dlights look the same as they did in HL2.
  34. // We'll use the real MIN_LIGHTING_VALUE above to calculate larger radii for dynamic
  35. // light sources.
  36. //#define HL2_BROKEN_MIN_LIGHTING_VALUE (20.0f/256.0f)
  37. struct dlight_t
  38. {
  39. int flags;
  40. Vector origin;
  41. float radius;
  42. ColorRGBExp32 color; // Light color with exponent
  43. float die; // stop lighting after this time
  44. float decay; // drop this each second
  45. float minlight; // don't add when contributing less
  46. int key;
  47. int style; // lightstyle
  48. // For spotlights. Use m_OuterAngle == 0 for point lights
  49. Vector m_Direction; // center of the light cone
  50. float m_InnerAngle;
  51. float m_OuterAngle;
  52. // If this ptr is set, the dlight will only affect this particular client renderable
  53. const IClientRenderable* m_pExclusiveLightReceiver;
  54. dlight_t()
  55. : m_pExclusiveLightReceiver( NULL )
  56. {
  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 GetRadius() const
  61. {
  62. // return FastSqrt( radius * radius * ( HL2_BROKEN_MIN_LIGHTING_VALUE / MIN_LIGHTING_VALUE ) );
  63. return radius;
  64. }
  65. // see comments above about HL2_BROKEN_MIN_LIGHTING_VALUE and MIN_LIGHTING_VALUE
  66. // THIS SHOULD ONLY GET CALLED FROM THE ENGINE
  67. float GetRadiusSquared() const
  68. {
  69. // return radius * radius * ( HL2_BROKEN_MIN_LIGHTING_VALUE / MIN_LIGHTING_VALUE );
  70. return radius * radius;
  71. }
  72. // THIS SHOULD ONLY GET CALLED FROM THE ENGINE
  73. float IsRadiusGreaterThanZero() const
  74. {
  75. // don't bother calculating the new radius if you just want to know if it is greater than zero.
  76. return radius > 0.0f;
  77. }
  78. };
  79. #endif