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.

81 lines
2.3 KiB

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