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.

127 lines
2.8 KiB

  1. //========= Copyright 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. bool m_IsRay; // are the extents zero?
  54. bool m_IsSwept; // is delta != 0?
  55. void Init( Vector const& start, Vector const& end )
  56. {
  57. VectorSubtract( end, start, m_Delta );
  58. m_IsSwept = (m_Delta.LengthSqr() != 0);
  59. VectorClear( m_Extents );
  60. m_IsRay = true;
  61. // Offset m_Start to be in the center of the box...
  62. VectorClear( m_StartOffset );
  63. VectorCopy( start, m_Start );
  64. }
  65. void Init( Vector const& start, Vector const& end, Vector const& mins, Vector const& maxs )
  66. {
  67. VectorSubtract( end, start, m_Delta );
  68. m_IsSwept = (m_Delta.LengthSqr() != 0);
  69. VectorSubtract( maxs, mins, m_Extents );
  70. m_Extents *= 0.5f;
  71. m_IsRay = (m_Extents.LengthSqr() < 1e-6);
  72. // Offset m_Start to be in the center of the box...
  73. VectorAdd( mins, maxs, m_StartOffset );
  74. m_StartOffset *= 0.5f;
  75. VectorAdd( start, m_StartOffset, m_Start );
  76. m_StartOffset *= -1.0f;
  77. }
  78. // compute inverse delta
  79. Vector InvDelta() const
  80. {
  81. Vector vecInvDelta;
  82. for ( int iAxis = 0; iAxis < 3; ++iAxis )
  83. {
  84. if ( m_Delta[iAxis] != 0.0f )
  85. {
  86. vecInvDelta[iAxis] = 1.0f / m_Delta[iAxis];
  87. }
  88. else
  89. {
  90. vecInvDelta[iAxis] = FLT_MAX;
  91. }
  92. }
  93. return vecInvDelta;
  94. }
  95. private:
  96. };
  97. #endif // CMODEL_H
  98. #include "gametrace.h"