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.

118 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. // $NoKeywords: $
  5. //=============================================================================//
  6. #ifndef CMODEL_ENGINE_H
  7. #define CMODEL_ENGINE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "cmodel.h"
  12. #include "cmodel_private.h"
  13. #include "mathlib/vplane.h"
  14. #include "bspfile.h"
  15. class ICollideable;
  16. cmodel_t *CM_LoadMap( const char *name, bool allowReusePrevious, unsigned *checksum );
  17. void CM_FreeMap( void );
  18. cmodel_t *CM_InlineModel( const char *name ); // *1, *2, etc
  19. cmodel_t *CM_InlineModelNumber( int index ); // 1, 2, etc
  20. int CM_InlineModelContents( int index ); // 1, 2, etc
  21. int CM_NumClusters( void );
  22. char *CM_EntityString( void );
  23. void CM_DiscardEntityString( void );
  24. // returns an ORed contents mask
  25. int CM_PointContents( const Vector &p, int headnode );
  26. int CM_TransformedPointContents( const Vector& p, int headnode, const Vector& origin, const QAngle& angles );
  27. // sets the default values in a trace
  28. void CM_ClearTrace( trace_t *trace );
  29. const byte *CM_ClusterPVS( int cluster );
  30. int CM_ClusterPVSSize();
  31. const byte *CM_Vis( byte *dest, int destlen, int cluster, int visType );
  32. int CM_PointLeafnum( const Vector& p );
  33. void CM_SnapPointToReferenceLeaf(const Vector &referenceLeafPoint, float tolerance, Vector *pSnapPoint);
  34. // call with topnode set to the headnode, returns with topnode
  35. // set to the first node that splits the box
  36. int CM_BoxLeafnums( const Vector& mins, const Vector& maxs, int *list,
  37. int listsize, int *topnode );
  38. //int CM_TransformedBoxContents( const Vector& pos, const Vector& mins, const Vector& maxs, int headnode, const Vector& origin, const QAngle& angles );
  39. // Versions that accept rays...
  40. void CM_TransformedBoxTrace (const Ray_t& ray, int headnode, int brushmask, const Vector& origin, QAngle const& angles, trace_t& tr );
  41. void CM_BoxTrace (const Ray_t& ray, int headnode, int brushmask, bool computeEndpt, trace_t& tr );
  42. void CM_BoxTraceAgainstLeafList( const Ray_t &ray, int *pLeafList, int nLeafCount, int nBrushMask, bool bComputeEndpoint, trace_t &trace );
  43. void CM_RayLeafnums( const Ray_t &ray, int *pLeafList, int nMaxLeafCount, int &nLeafCount );
  44. int CM_LeafContents( int leafnum );
  45. int CM_LeafCluster( int leafnum );
  46. int CM_LeafArea( int leafnum );
  47. int CM_LeafFlags( int leafnum );
  48. void CM_SetAreaPortalState( int portalnum, int isOpen );
  49. void CM_SetAreaPortalStates( const int *portalnums, const int *isOpen, int nPortals );
  50. bool CM_AreasConnected( int area1, int area2 );
  51. int CM_WriteAreaBits( byte *buffer, int buflen, int area );
  52. // Given a view origin (which tells us the area to start looking in) and a portal key,
  53. // fill in the plane that leads out of this area (it points into whatever area it leads to).
  54. bool CM_GetAreaPortalPlane( const Vector &vViewOrigin, int portalKey, VPlane *pPlane );
  55. bool CM_HeadnodeVisible( int headnode, const byte *visbits, int vissize );
  56. // Test to see if the given box is in the given PVS/PAS
  57. int CM_BoxVisible( const Vector& mins, const Vector& maxs, const byte *visbits, int vissize );
  58. typedef struct cmodel_collision_s cmodel_collision_t;
  59. vcollide_t *CM_GetVCollide( int modelIndex );
  60. vcollide_t* CM_VCollideForModel( int modelindex, const model_t* pModel );
  61. // gets a virtual physcollide for a displacement
  62. CPhysCollide *CM_PhysCollideForDisp( int index );
  63. int CM_SurfacepropsForDisp( int index );
  64. void CM_CreateDispPhysCollide( dphysdisp_t *pDispLump, int dispLumpSize );
  65. void CM_DestroyDispPhysCollide();
  66. void CM_WorldSpaceCenter( ICollideable *pCollideable, Vector *pCenter );
  67. void CM_WorldSpaceBounds( ICollideable *pCollideable, Vector *pMins, Vector *pMaxs );
  68. void CM_WorldAlignBounds( ICollideable *pCollideable, Vector *pMins, Vector *pMaxs );
  69. void CM_SetupAreaFloodNums( byte areaFloodNums[MAX_MAP_AREAS], int *pNumAreas );
  70. //-----------------------------------------------------------------------------
  71. // This can be used as a replacement for CM_PointLeafnum if the successive
  72. // origins will be close to each other.
  73. //
  74. // It caches the distance to the closest plane leading
  75. // out of whatever leaf it was in last time you asked for the leaf index, and
  76. // if it's within that distance the next time you ask for it, it'll
  77. //-----------------------------------------------------------------------------
  78. class CFastPointLeafNum
  79. {
  80. public:
  81. CFastPointLeafNum();
  82. int GetLeaf( const Vector &vPos );
  83. private:
  84. int m_iCachedLeaf;
  85. Vector m_vCachedPos;
  86. float m_flDistToExitLeafSqr;
  87. };
  88. #endif // CMODEL_ENGINE_H