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.

42 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include "stdafx.h"
  3. #include "simplify.h"
  4. extern IPhysicsCollision *physcollision;
  5. vcollide_t *ConvertVCollideToPHX( const vcollide_t *pCollideIn, const simplifyparams_t &params, int *pSize, bool bStoreSurfaceprops, bool bStoreSolidNames )
  6. {
  7. Assert( !pCollideIn->isPacked );
  8. vcollide_t *pCollideOut = new vcollide_t;
  9. pCollideOut->solids = new CPhysCollide *[pCollideIn->solidCount];
  10. pCollideOut->solidCount = pCollideIn->solidCount;
  11. *pSize = 0;
  12. for ( int i = 0; i < pCollideIn->solidCount; i++ )
  13. {
  14. Assert( pCollideIn->solids[i] );
  15. pCollideOut->solids[i] = SimplifyCollide( pCollideIn->solids[i], i, params );
  16. Assert( pCollideOut->solids[i] );
  17. int collideSize = physcollision->CollideSize( pCollideOut->solids[i] );
  18. *pSize += collideSize;
  19. }
  20. int packedTextSize;
  21. pCollideOut->pKeyValues = (char *)physcollision->PackVCollideText( pCollideIn->pKeyValues, &packedTextSize, bStoreSolidNames, bStoreSurfaceprops );
  22. pCollideOut->isPacked = true;
  23. pCollideOut->descSize = packedTextSize;
  24. *pSize += packedTextSize;
  25. return pCollideOut;
  26. }
  27. void DestroyPHX( vcollide_t *pCollide )
  28. {
  29. for ( int i = 0; i < pCollide->solidCount; i++ )
  30. {
  31. physcollision->DestroyCollide( pCollide->solids[i] );
  32. }
  33. delete[] pCollide->solids;
  34. physcollision->DestroyVCollideText( pCollide->pKeyValues );
  35. delete pCollide;
  36. }