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.

134 lines
3.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #ifndef CMODEL_H
  10. #define CMODEL_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "trace.h"
  15. #include "tier0/dbg.h"
  16. #include "basehandle.h"
  17. struct edict_t;
  18. struct model_t;
  19. /*
  20. ==============================================================
  21. COLLISION DETECTION
  22. ==============================================================
  23. */
  24. #include "bspflags.h"
  25. //#include "mathlib/vector.h"
  26. // gi.BoxEdicts() can return a list of either solid or trigger entities
  27. // FIXME: eliminate AREA_ distinction?
  28. #define AREA_SOLID 1
  29. #define AREA_TRIGGERS 2
  30. #include "vcollide.h"
  31. struct cmodel_t
  32. {
  33. Vector mins, maxs;
  34. Vector origin; // for sounds or lights
  35. int headnode;
  36. vcollide_t vcollisionData;
  37. };
  38. struct csurface_t
  39. {
  40. const char *name;
  41. short surfaceProps;
  42. unsigned short flags; // BUGBUG: These are declared per surface, not per material, but this database is per-material now
  43. };
  44. //-----------------------------------------------------------------------------
  45. // A ray...
  46. //-----------------------------------------------------------------------------
  47. struct Ray_t
  48. {
  49. VectorAligned m_Start; // starting point, centered within the extents
  50. VectorAligned m_Delta; // direction + length of the ray
  51. VectorAligned m_StartOffset; // Add this to m_Start to get the actual ray start
  52. VectorAligned m_Extents; // Describes an axis aligned box extruded along a ray
  53. const matrix3x4_t *m_pWorldAxisTransform;
  54. bool m_IsRay; // are the extents zero?
  55. bool m_IsSwept; // is delta != 0?
  56. Ray_t() : m_pWorldAxisTransform( NULL ) {}
  57. void Init( Vector const& start, Vector const& end )
  58. {
  59. Assert( &end );
  60. VectorSubtract( end, start, m_Delta );
  61. m_IsSwept = (m_Delta.LengthSqr() != 0);
  62. VectorClear( m_Extents );
  63. m_pWorldAxisTransform = NULL;
  64. m_IsRay = true;
  65. // Offset m_Start to be in the center of the box...
  66. VectorClear( m_StartOffset );
  67. VectorCopy( start, m_Start );
  68. }
  69. void Init( Vector const& start, Vector const& end, Vector const& mins, Vector const& maxs )
  70. {
  71. Assert( &end );
  72. VectorSubtract( end, start, m_Delta );
  73. m_pWorldAxisTransform = NULL;
  74. m_IsSwept = (m_Delta.LengthSqr() != 0);
  75. VectorSubtract( maxs, mins, m_Extents );
  76. m_Extents *= 0.5f;
  77. m_IsRay = (m_Extents.LengthSqr() < 1e-6);
  78. Assert(m_Extents.x >=0 && m_Extents.y >= 0 && m_Extents.z >= 0);
  79. // Offset m_Start to be in the center of the box...
  80. VectorAdd( mins, maxs, m_StartOffset );
  81. m_StartOffset *= 0.5f;
  82. VectorAdd( start, m_StartOffset, m_Start );
  83. m_StartOffset *= -1.0f;
  84. }
  85. // compute inverse delta
  86. Vector InvDelta() const
  87. {
  88. Vector vecInvDelta;
  89. for ( int iAxis = 0; iAxis < 3; ++iAxis )
  90. {
  91. if ( m_Delta[iAxis] != 0.0f )
  92. {
  93. vecInvDelta[iAxis] = 1.0f / m_Delta[iAxis];
  94. }
  95. else
  96. {
  97. vecInvDelta[iAxis] = FLT_MAX;
  98. }
  99. }
  100. return vecInvDelta;
  101. }
  102. private:
  103. };
  104. #endif // CMODEL_H
  105. #include "gametrace.h"