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.

84 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ENGINE_ICOLLIDEABLE_H
  8. #define ENGINE_ICOLLIDEABLE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. enum SolidType_t;
  13. class IHandleEntity;
  14. struct Ray_t;
  15. struct model_t;
  16. class Vector;
  17. class QAngle;
  18. class CGameTrace;
  19. typedef CGameTrace trace_t;
  20. class IClientUnknown;
  21. abstract_class ICollideable
  22. {
  23. public:
  24. // Gets at the entity handle associated with the collideable
  25. virtual IHandleEntity *GetEntityHandle() = 0;
  26. // These methods return the bounds of an OBB measured in "collision" space
  27. // which can be retreived through the CollisionToWorldTransform or
  28. // GetCollisionOrigin/GetCollisionAngles methods
  29. virtual const Vector& OBBMinsPreScaled() const = 0;
  30. virtual const Vector& OBBMaxsPreScaled() const = 0;
  31. virtual const Vector& OBBMins() const = 0;
  32. virtual const Vector& OBBMaxs() const = 0;
  33. // Returns the bounds of a world-space box used when the collideable is being traced
  34. // against as a trigger. It's only valid to call these methods if the solid flags
  35. // have the FSOLID_USE_TRIGGER_BOUNDS flag set.
  36. virtual void WorldSpaceTriggerBounds( Vector *pVecWorldMins, Vector *pVecWorldMaxs ) const = 0;
  37. // custom collision test
  38. virtual bool TestCollision( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr ) = 0;
  39. // Perform hitbox test, returns true *if hitboxes were tested at all*!!
  40. virtual bool TestHitboxes( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr ) = 0;
  41. // Returns the BRUSH model index if this is a brush model. Otherwise, returns -1.
  42. virtual int GetCollisionModelIndex() = 0;
  43. // Return the model, if it's a studio model.
  44. virtual const model_t* GetCollisionModel() = 0;
  45. // Get angles and origin.
  46. virtual const Vector& GetCollisionOrigin() const = 0;
  47. virtual const QAngle& GetCollisionAngles() const = 0;
  48. virtual const matrix3x4_t& CollisionToWorldTransform() const = 0;
  49. // Return a SOLID_ define.
  50. virtual SolidType_t GetSolid() const = 0;
  51. virtual int GetSolidFlags() const = 0;
  52. // Gets at the containing class...
  53. virtual IClientUnknown* GetIClientUnknown() = 0;
  54. // We can filter out collisions based on collision group
  55. virtual int GetCollisionGroup() const = 0;
  56. // Returns a world-aligned box guaranteed to surround *everything* in the collision representation
  57. // Note that this will surround hitboxes, trigger bounds, physics.
  58. // It may or may not be a tight-fitting box and its volume may suddenly change
  59. virtual void WorldSpaceSurroundingBounds( Vector *pVecMins, Vector *pVecMaxs ) = 0;
  60. virtual bool ShouldTouchTrigger( int triggerSolidFlags ) const = 0;
  61. // returns NULL unless this collideable has specified FSOLID_ROOT_PARENT_ALIGNED
  62. virtual const matrix3x4_t *GetRootParentToWorldTransform() const = 0;
  63. };
  64. #endif // ENGINE_ICOLLIDEABLE_H