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.

77 lines
2.3 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =====//
  2. //
  3. // Dme version of a body group list
  4. //
  5. //===========================================================================//
  6. #include "mdlobjects/dmebodygrouplist.h"
  7. #include "datamodel/dmelementfactoryhelper.h"
  8. #include "mdlobjects/dmebodygroup.h"
  9. #include "mdlobjects/dmelodlist.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //-----------------------------------------------------------------------------
  13. // Expose this class to the scene database
  14. //-----------------------------------------------------------------------------
  15. IMPLEMENT_ELEMENT_FACTORY( DmeBodyGroupList, CDmeBodyGroupList );
  16. //-----------------------------------------------------------------------------
  17. // Purpose:
  18. //-----------------------------------------------------------------------------
  19. void CDmeBodyGroupList::OnConstruction()
  20. {
  21. m_BodyGroups.Init( this, "bodyGroupList" );
  22. }
  23. void CDmeBodyGroupList::OnDestruction()
  24. {
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Finds a body group by name
  28. //-----------------------------------------------------------------------------
  29. CDmeBodyGroup *CDmeBodyGroupList::FindBodyGroup( const char *pName )
  30. {
  31. int nCount = m_BodyGroups.Count();
  32. for ( int i = 0; i < nCount; ++i )
  33. {
  34. if ( !Q_stricmp( pName, m_BodyGroups[i]->GetName() ) )
  35. return m_BodyGroups[i];
  36. }
  37. return NULL;
  38. }
  39. //-----------------------------------------------------------------------------
  40. // Gets the 'main' body part (used for compilation)
  41. //-----------------------------------------------------------------------------
  42. CDmeLODList *CDmeBodyGroupList::GetMainBodyPart()
  43. {
  44. if ( m_BodyGroups.Count() == 0 )
  45. return NULL;
  46. CDmeBodyGroup *pMainBodyGroup = FindBodyGroup( "default" );
  47. if ( !pMainBodyGroup )
  48. {
  49. pMainBodyGroup = m_BodyGroups[0];
  50. }
  51. CDmeLODList *pLODList = CastElement< CDmeLODList >( pMainBodyGroup->FindBodyPart( "default" ) );
  52. if ( pLODList )
  53. return pLODList;
  54. const int nBodypartCount = pMainBodyGroup->m_BodyParts.Count();
  55. for ( int i = 0; i < nBodypartCount; ++i )
  56. {
  57. pLODList = CastElement< CDmeLODList >( pMainBodyGroup->m_BodyParts[ i ] );
  58. if ( pLODList && pLODList->m_LODs.Count() > 0 )
  59. return pLODList;
  60. }
  61. return NULL;
  62. }