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.

86 lines
2.4 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =====//
  2. //
  3. // Dme version of a hitbox
  4. //
  5. //===========================================================================//
  6. // Valve includes
  7. #include "mdlobjects/dmelodlist.h"
  8. #include "datamodel/dmelementfactoryhelper.h"
  9. #include "mdlobjects/dmelod.h"
  10. #include "mdlobjects/dmeeyeball.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. //-----------------------------------------------------------------------------
  14. // Expose this class to the scene database
  15. //-----------------------------------------------------------------------------
  16. IMPLEMENT_ELEMENT_FACTORY( DmeLODList, CDmeLODList );
  17. //-----------------------------------------------------------------------------
  18. // Purpose:
  19. //-----------------------------------------------------------------------------
  20. void CDmeLODList::OnConstruction()
  21. {
  22. m_LODs.Init( this, "lodList" );
  23. m_EyeballList.Init( this, "eyeballList" );
  24. }
  25. //-----------------------------------------------------------------------------
  26. //
  27. //-----------------------------------------------------------------------------
  28. void CDmeLODList::OnDestruction()
  29. {
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Returns the number of LODs in this body part, can be 0
  33. //-----------------------------------------------------------------------------
  34. int CDmeLODList::LODCount() const
  35. {
  36. return m_LODs.Count();
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Returns the root LOD. This is the one with the switch metric 0
  40. //-----------------------------------------------------------------------------
  41. CDmeLOD* CDmeLODList::GetRootLOD()
  42. {
  43. int nCount = m_LODs.Count();
  44. int nMinIndex = -1;
  45. float flMinMetric = FLT_MAX;
  46. for ( int i = 0; i < nCount; ++i )
  47. {
  48. if ( m_LODs[i]->m_flSwitchMetric < flMinMetric )
  49. {
  50. nMinIndex = i;
  51. flMinMetric = m_LODs[i]->m_flSwitchMetric;
  52. if ( flMinMetric == 0.0f )
  53. break;
  54. }
  55. }
  56. return ( nMinIndex >= 0 ) ? m_LODs[nMinIndex] : NULL;
  57. }
  58. //-----------------------------------------------------------------------------
  59. // Returns the shadow LOD
  60. //-----------------------------------------------------------------------------
  61. CDmeLOD* CDmeLODList::GetShadowLOD()
  62. {
  63. int nCount = m_LODs.Count();
  64. for ( int i = 0; i < nCount; ++i )
  65. {
  66. if ( m_LODs[i]->m_bIsShadowLOD )
  67. return m_LODs[i];
  68. }
  69. return NULL;
  70. }