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.

111 lines
3.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef GAMETRACE_H
  7. #define GAMETRACE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "cmodel.h"
  12. #include "utlvector.h"
  13. #include "ihandleentity.h"
  14. #include "ispatialpartition.h"
  15. #if defined( CLIENT_DLL )
  16. class C_BaseEntity;
  17. #else
  18. class CBaseEntity;
  19. #endif
  20. //-----------------------------------------------------------------------------
  21. // Purpose: A trace is returned when a box is swept through the world
  22. // NOTE: eventually more of this class should be moved up into the base class!!
  23. //-----------------------------------------------------------------------------
  24. class CGameTrace : public CBaseTrace
  25. {
  26. public:
  27. // Returns true if hEnt points at the world entity.
  28. // If this returns true, then you can't use GetHitBoxIndex().
  29. bool DidHitWorld() const;
  30. // Returns true if we hit something and it wasn't the world.
  31. bool DidHitNonWorldEntity() const;
  32. // Gets the entity's network index if the trace has hit an entity.
  33. // If not, returns -1.
  34. int GetEntityIndex() const;
  35. // Returns true if there was any kind of impact at all
  36. bool DidHit() const;
  37. // The engine doesn't know what a CBaseEntity is, so it has a backdoor to
  38. // let it get at the edict.
  39. #if defined( ENGINE_DLL )
  40. void SetEdict( edict_t *pEdict );
  41. edict_t* GetEdict() const;
  42. #endif
  43. public:
  44. float fractionleftsolid; // time we left a solid, only valid if we started in solid
  45. csurface_t surface; // surface hit (impact surface)
  46. int hitgroup; // 0 == generic, non-zero is specific body part
  47. short physicsbone; // physics bone hit by trace in studio
  48. unsigned short worldSurfaceIndex; // Index of the msurface2_t, if applicable
  49. #if defined( CLIENT_DLL )
  50. C_BaseEntity *m_pEnt;
  51. #else
  52. CBaseEntity *m_pEnt;
  53. #endif
  54. // NOTE: this member is overloaded.
  55. // If hEnt points at the world entity, then this is the static prop index.
  56. // Otherwise, this is the hitbox index.
  57. int hitbox; // box hit by trace in studio
  58. CGameTrace() : m_pEnt(NULL) {}
  59. private:
  60. // No copy constructors allowed
  61. CGameTrace(const CGameTrace& vOther);
  62. };
  63. //-----------------------------------------------------------------------------
  64. // Returns true if there was any kind of impact at all
  65. //-----------------------------------------------------------------------------
  66. inline bool CGameTrace::DidHit() const
  67. {
  68. return fraction < 1 || allsolid || startsolid;
  69. }
  70. typedef CGameTrace trace_t;
  71. //=============================================================================
  72. class ITraceListData
  73. {
  74. public:
  75. virtual ~ITraceListData() {}
  76. virtual void Reset() = 0;
  77. virtual bool IsEmpty() = 0;
  78. // CanTraceRay will return true if the current volume encloses the ray
  79. // NOTE: The leaflist trace will NOT check this. Traces are intersected
  80. // against the culled volume exclusively.
  81. virtual bool CanTraceRay( const Ray_t &ray ) = 0;
  82. };
  83. #endif // GAMETRACE_H