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.

82 lines
2.7 KiB

  1. //====== Copyright � 1996-2008, Valve Corporation, All rights reserved. =====//
  2. //
  3. // A list of DmeSequences's
  4. //
  5. //===========================================================================//
  6. #include "datamodel/dmelementfactoryhelper.h"
  7. #include "mdlobjects/dmesequence.h"
  8. #include "mdlobjects/dmesequencelist.h"
  9. #include "mdlobjects/dmeik.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( DmeSequenceList, CDmeSequenceList );
  16. //-----------------------------------------------------------------------------
  17. //
  18. //-----------------------------------------------------------------------------
  19. void CDmeSequenceList::OnConstruction()
  20. {
  21. m_Sequences.Init( this, "sequences" );
  22. m_eIkChainList.Init( this, "ikChainList" );
  23. }
  24. //-----------------------------------------------------------------------------
  25. //
  26. //-----------------------------------------------------------------------------
  27. void CDmeSequenceList::OnDestruction()
  28. {
  29. }
  30. //-----------------------------------------------------------------------------
  31. // Returns a sorted of the sequences in the m_Sequences attribute in order of priority
  32. // Sequences that are referred to come before the sequences that refer to them
  33. //-----------------------------------------------------------------------------
  34. void CDmeSequenceList::GetSortedSequenceList( CUtlVector< CDmeSequenceBase * > &sortedSequenceList ) const
  35. {
  36. sortedSequenceList.RemoveAll();
  37. const int nSequenceCount = m_Sequences.Count();
  38. sortedSequenceList.EnsureCapacity( nSequenceCount );
  39. for ( int i = 0; i < nSequenceCount; ++i )
  40. {
  41. CDmeSequenceBase *pDmeSequenceBase = m_Sequences[i];
  42. if ( !pDmeSequenceBase )
  43. continue;
  44. sortedSequenceList.AddToTail( pDmeSequenceBase );
  45. }
  46. qsort( sortedSequenceList.Base(), sortedSequenceList.Count(), sizeof( CDmeSequenceBase * ), CDmeSequenceBase::QSortFunction );
  47. }
  48. //-----------------------------------------------------------------------------
  49. // Sorts the sequences in the m_Sequences attribute in order of priority
  50. // Sequences that are referred to come before the sequences that refer to them
  51. //-----------------------------------------------------------------------------
  52. void CDmeSequenceList::SortSequences()
  53. {
  54. CUtlVector< CDmeSequenceBase * > sortedSequenceList;
  55. GetSortedSequenceList( sortedSequenceList );
  56. m_Sequences.RemoveAll();
  57. m_Sequences.EnsureCount( sortedSequenceList.Count() );
  58. for ( int i = 0; i < m_Sequences.Count(); ++i )
  59. {
  60. m_Sequences.Set( i, sortedSequenceList[i] );
  61. }
  62. }