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.

165 lines
4.0 KiB

  1. //====== Copyright c 1996-2007, Valve Corporation, All rights reserved. =======//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef MDLLIB_STRIPINFO_H
  7. #define MDLLIB_STRIPINFO_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "mdllib/mdllib.h"
  12. #include "mdllib_utils.h"
  13. #include "UtlSortVector.h"
  14. //
  15. // CMdlStripInfo
  16. // Implementation of IMdlStripInfo interface
  17. //
  18. class CMdlStripInfo : public IMdlStripInfo
  19. {
  20. public:
  21. CMdlStripInfo();
  22. ~CMdlStripInfo() { m_ps3studioBatches.PurgeAndDeleteElements(); }
  23. //
  24. // Serialization
  25. //
  26. public:
  27. // Save the strip info to the buffer (appends to the end)
  28. virtual bool Serialize( CUtlBuffer &bufStorage ) const;
  29. // Load the strip info from the buffer (reads from the current position as much as needed)
  30. virtual bool UnSerialize( CUtlBuffer &bufData );
  31. //
  32. // Stripping info state
  33. //
  34. public:
  35. // Returns the checksums that the stripping info was generated for:
  36. // plChecksumOriginal if non-NULL will hold the checksum of the original model submitted for stripping
  37. // plChecksumStripped if non-NULL will hold the resulting checksum of the stripped model
  38. virtual bool GetCheckSum( long *plChecksumOriginal, long *plChecksumStripped ) const;
  39. //
  40. // Stripping
  41. //
  42. public:
  43. //
  44. // StripHardwareVertsBuffer
  45. // The main function that strips the vhv buffer
  46. // vhvBuffer - vhv buffer, updated, size reduced
  47. //
  48. virtual bool StripHardwareVertsBuffer( CUtlBuffer &vhvBuffer );
  49. //
  50. // StripModelBuffer
  51. // The main function that strips the mdl buffer
  52. // mdlBuffer - mdl buffer, updated
  53. //
  54. virtual bool StripModelBuffer( CUtlBuffer &mdlBuffer );
  55. //
  56. // StripVertexDataBuffer
  57. // The main function that strips the vvd buffer
  58. // vvdBuffer - vvd buffer, updated, size reduced
  59. //
  60. virtual bool StripVertexDataBuffer( CUtlBuffer &vvdBuffer );
  61. //
  62. // StripOptimizedModelBuffer
  63. // The main function that strips the vtx buffer
  64. // vtxBuffer - vtx buffer, updated, size reduced
  65. //
  66. virtual bool StripOptimizedModelBuffer( CUtlBuffer &vtxBuffer );
  67. //
  68. // Release the object with "delete this"
  69. //
  70. public:
  71. virtual void DeleteThis();
  72. public:
  73. void Reset();
  74. public:
  75. enum Mode
  76. {
  77. MODE_UNINITIALIZED = 0,
  78. MODE_NO_CHANGE = 1,
  79. MODE_STRIP_LOD_1N = 2,
  80. MODE_PS3_PARTITIONS = 3,
  81. MODE_PS3_FORMAT_BASIC = 4,
  82. };
  83. //
  84. // Internal data used for stripping
  85. //
  86. public:
  87. int m_eMode;
  88. long m_lChecksumOld, m_lChecksumNew;
  89. CGrowableBitVec m_vtxVerts;
  90. CUtlSortVector< unsigned short, CLessSimple< unsigned short > > m_vtxIndices;
  91. //
  92. // PS3 partitioning data
  93. //
  94. public:
  95. struct Ps3studioPartition_t
  96. {
  97. CUtlVector< uint16 > m_arrLocalIndices;
  98. CUtlVector< uint32 > m_arrVertOriginalIndices;
  99. CUtlVector< uint32 > m_arrStripLocalOriginalIndices;
  100. uint32 m_nIoBufferSize;
  101. // -- not serialized in .vsi --
  102. uint32 m_nEdgeDmaInputIdx;
  103. uint32 m_nEdgeDmaInputVtx;
  104. uint32 m_nEdgeDmaInputEnd;
  105. // compressed idx information
  106. uint8 *m_pEdgeCompressedIdx;
  107. uint16 m_uiEdgeCompressedIdxDmaTagSize[2];
  108. // compressed vtx information
  109. uint8 *m_pEdgeCompressedVtx;
  110. uint32 *m_pEdgeCompressedVtxFixedOffsets;
  111. uint16 m_uiEdgeCompressedVtxDmaTagSize[3];
  112. uint32 m_uiEdgeCompressedVtxFixedOffsetsSize;
  113. };
  114. struct Ps3studioBatch_t
  115. {
  116. CUtlVector< Ps3studioPartition_t * > m_arrPartitions;
  117. uint32 m_uiModelIndexOffset;
  118. uint32 m_uiVhvIndexOffset;
  119. ~Ps3studioBatch_t() { m_arrPartitions.PurgeAndDeleteElements(); }
  120. };
  121. CUtlVector< Ps3studioBatch_t * > m_ps3studioBatches;
  122. CUtlVector< uint32 > m_ps3studioStripGroupHeaderBatchOffset;
  123. //
  124. // Mesh ranges fixup
  125. //
  126. public:
  127. struct MdlRangeItem
  128. {
  129. /* implicit */ MdlRangeItem( int offOld = 0, int numOld = 0, int offNew = 0, int numNew = 0 ) :
  130. m_offOld( offOld ), m_offNew( offNew ), m_numOld( numOld ), m_numNew( numNew ) {}
  131. int m_offOld, m_offNew;
  132. int m_numOld, m_numNew;
  133. bool operator < ( MdlRangeItem const &x ) const { return m_offNew < x.m_offNew; }
  134. };
  135. CUtlSortVector< CMdlStripInfo::MdlRangeItem, CLessSimple< CMdlStripInfo::MdlRangeItem > > m_vtxMdlOffsets;
  136. };
  137. #endif // #ifndef MDLLIB_STRIPINFO_H