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.

124 lines
5.1 KiB

  1. //========= Copyright � 1996-2005, 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. struct AABB_t;
  17. cmodel_t *CM_LoadMap( const char *pPathName, bool allowReusePrevious, texinfo_t *pTexinfo, int texInfoCount, unsigned *checksum );
  18. void CM_FreeMap( void );
  19. cmodel_t *CM_InlineModel( const char *name ); // *1, *2, etc
  20. cmodel_t *CM_InlineModelNumber( int index ); // 1, 2, etc
  21. int CM_InlineModelContents( int index ); // 1, 2, etc
  22. int CM_NumClusters( void );
  23. char *CM_EntityString( void );
  24. void CM_DiscardEntityString( void );
  25. // returns an ORed contents mask
  26. int CM_PointContents( const Vector &p, int headnode, int contentsMask );
  27. int CM_TransformedPointContents( const Vector& p, int headnode, const Vector& origin, const QAngle& angles );
  28. // sets the default values in a trace
  29. void CM_ClearTrace( trace_t *trace );
  30. const byte *CM_ClusterPVS( int cluster );
  31. int CM_ClusterPVSSize();
  32. const byte *CM_Vis( byte *dest, int destlen, int cluster, int visType );
  33. int CM_PointLeafnum( const Vector& p );
  34. void CM_SnapPointToReferenceLeaf(const Vector &referenceLeafPoint, float tolerance, Vector *pSnapPoint);
  35. // call with topnode set to the headnode, returns with topnode
  36. // set to the first node that splits the box
  37. int CM_BoxLeafnums( const Vector& mins, const Vector& maxs, int *list,
  38. int listsize, int *topnode, int cmodelIndex = 0 );
  39. //int CM_TransformedBoxContents( const Vector& pos, const Vector& mins, const Vector& maxs, int headnode, const Vector& origin, const QAngle& angles );
  40. // Versions that accept rays...
  41. void CM_TransformedBoxTrace (const Ray_t& ray, int headnode, int brushmask, const Vector& origin, QAngle const& angles, trace_t& tr );
  42. void CM_BoxTrace (const Ray_t& ray, int headnode, int brushmask, bool computeEndpt, trace_t& tr );
  43. struct OcclusionTestResults_t;
  44. bool CM_IsFullyOccluded( const AABB_t &aabb1, const AABB_t &aabb2 );
  45. bool CM_IsFullyOccluded( const VectorAligned &p0, const VectorAligned &vExtents1, const VectorAligned &p1, const VectorAligned &vExtents2, OcclusionTestResults_t * pResults = NULL );
  46. bool CM_IsFullyOccluded_WithShadow( const AABB_t &aabb1, const AABB_t &aabb2, const Vector &vShadow );
  47. void CM_BoxTraceAgainstLeafList( const Ray_t &ray, const CTraceListData &traceData, int nBrushMask, trace_t &trace );
  48. void CM_RayLeafnums( const Ray_t &ray, int *pLeafList, int nMaxLeafCount, int &nLeafCount );
  49. int CM_LeafContents( int leafnum );
  50. int CM_LeafCluster( int leafnum );
  51. int CM_LeafArea( int leafnum );
  52. int CM_LeafFlags( int leafnum );
  53. void CM_SetAreaPortalState( int portalnum, int isOpen );
  54. void CM_SetAreaPortalStates( const int *portalnums, const int *isOpen, int nPortals );
  55. bool CM_AreasConnected( int area1, int area2 );
  56. void CM_LeavesConnected( const Vector &vecOrigin, int nCount, const int *pLeaves, bool *pIsConnected );
  57. int CM_WriteAreaBits( byte *buffer, int buflen, int area );
  58. // Given a view origin (which tells us the area to start looking in) and a portal key,
  59. // fill in the plane that leads out of this area (it points into whatever area it leads to).
  60. bool CM_GetAreaPortalPlane( const Vector &vViewOrigin, int portalKey, VPlane *pPlane );
  61. bool CM_HeadnodeVisible( int headnode, const byte *visbits, int vissize );
  62. // Test to see if the given box is in the given PVS/PAS
  63. int CM_BoxVisible( const Vector& mins, const Vector& maxs, const byte *visbits, int vissize );
  64. typedef struct cmodel_collision_s cmodel_collision_t;
  65. vcollide_t *CM_GetVCollide( int modelIndex );
  66. vcollide_t* CM_VCollideForModel( int modelindex, const model_t* pModel );
  67. // gets a virtual physcollide for a displacement
  68. CPhysCollide *CM_PhysCollideForDisp( int index );
  69. int CM_SurfacepropsForDisp( int index );
  70. void CM_CreateDispPhysCollide( dphysdisp_t *pDispLump, int dispLumpSize );
  71. void CM_DestroyDispPhysCollide();
  72. void CM_WorldSpaceCenter( ICollideable *pCollideable, Vector *pCenter );
  73. void CM_WorldSpaceBounds( ICollideable *pCollideable, Vector *pMins, Vector *pMaxs );
  74. void CM_WorldAlignBounds( ICollideable *pCollideable, Vector *pMins, Vector *pMaxs );
  75. void CM_SetupAreaFloodNums( byte areaFloodNums[MAX_MAP_AREAS], int *pNumAreas );
  76. //-----------------------------------------------------------------------------
  77. // This can be used as a replacement for CM_PointLeafnum if the successive
  78. // origins will be close to each other.
  79. //
  80. // It caches the distance to the closest plane leading
  81. // out of whatever leaf it was in last time you asked for the leaf index, and
  82. // if it's within that distance the next time you ask for it, it'll
  83. //-----------------------------------------------------------------------------
  84. class CFastPointLeafNum
  85. {
  86. public:
  87. CFastPointLeafNum();
  88. int GetLeaf( const Vector &vPos );
  89. void Reset( void ); // level change, etc. position <--> leaf mapping has changed.
  90. private:
  91. int m_iCachedLeaf;
  92. Vector m_vCachedPos;
  93. float m_flDistToExitLeafSqr;
  94. };
  95. #endif // CMODEL_ENGINE_H