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.

101 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "entityoutput.h"
  8. #include "ndebugoverlay.h"
  9. #include "func_bulletshield.h"
  10. #include "collisionutils.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. extern ConVar ent_debugkeys;
  14. extern ConVar showtriggers;
  15. LINK_ENTITY_TO_CLASS( func_bulletshield, CFuncBulletShield );
  16. BEGIN_DATADESC( CFuncBulletShield )
  17. /*
  18. DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputTurnOn ),
  19. DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputTurnOff ),
  20. DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ),
  21. DEFINE_KEYFIELD( m_iDisabled, FIELD_INTEGER, "StartDisabled" ),
  22. DEFINE_KEYFIELD( m_iSolidity, FIELD_INTEGER, "Solidity" ),
  23. DEFINE_KEYFIELD( m_bSolidBsp, FIELD_BOOLEAN, "solidbsp" ),
  24. DEFINE_KEYFIELD( m_iszExcludedClass, FIELD_STRING, "excludednpc" ),
  25. DEFINE_KEYFIELD( m_bInvertExclusion, FIELD_BOOLEAN, "invert_exclusion" ),
  26. */
  27. END_DATADESC()
  28. void CFuncBulletShield::Spawn( void )
  29. {
  30. BaseClass::Spawn();
  31. AddSolidFlags( FSOLID_CUSTOMRAYTEST );
  32. AddSolidFlags( FSOLID_CUSTOMBOXTEST );
  33. // SetSolid(SOLID_CUSTOM);
  34. VPhysicsDestroyObject();
  35. }
  36. /*
  37. bool IntersectRayWithOBB( const Vector &vecRayStart, const Vector &vecRayDelta,
  38. const matrix3x4_t &matOBBToWorld, const Vector &vecOBBMins, const Vector &vecOBBMaxs,
  39. float flTolerance, CBaseTrace *pTrace );
  40. bool IntersectRayWithOBB( const Vector &vecRayOrigin, const Vector &vecRayDelta,
  41. const Vector &vecBoxOrigin, const QAngle &angBoxRotation,
  42. const Vector &vecOBBMins, const Vector &vecOBBMaxs, float flTolerance, CBaseTrace *pTrace );
  43. bool IntersectRayWithOBB( const Ray_t &ray, const Vector &vecBoxOrigin, const QAngle &angBoxRotation,
  44. const Vector &vecOBBMins, const Vector &vecOBBMaxs, float flTolerance, CBaseTrace *pTrace );
  45. bool IntersectRayWithOBB( const Ray_t &ray, const matrix3x4_t &matOBBToWorld,
  46. const Vector &vecOBBMins, const Vector &vecOBBMaxs, float flTolerance, CBaseTrace *pTrace );
  47. bool IntersectRayWithOBB( const Vector &vecRayStart, const Vector &vecRayDelta,
  48. const matrix3x4_t &matOBBToWorld, const Vector &vecOBBMins, const Vector &vecOBBMaxs,
  49. float flTolerance, BoxTraceInfo_t *pTrace );
  50. */
  51. bool CFuncBulletShield::TestCollision( const Ray_t &ray, unsigned int mask, trace_t& trace )
  52. {
  53. // ignore unless a shot
  54. if ((mask & MASK_SHOT) == MASK_SHOT)
  55. {
  56. // use obb collision
  57. ICollideable *pCol = GetCollideable();
  58. Assert(pCol);
  59. return IntersectRayWithOBB(ray,pCol->GetCollisionOrigin(),pCol->GetCollisionAngles(),
  60. pCol->OBBMins(),pCol->OBBMaxs(),1.0f,&trace);
  61. /*
  62. const model_t *pModel = this->GetCollisionModel();
  63. if ( pModel && pModel->type == mod_brush )
  64. {
  65. int nModelIndex = this->GetCollisionModelIndex();
  66. cmodel_t *pCModel = CM_InlineModelNumber( nModelIndex - 1 );
  67. int nHeadNode = pCModel->headnode;
  68. CM_TransformedBoxTrace( ray, nHeadNode, fMask, this->GetCollisionOrigin(), this->GetCollisionAngles(), *pTrace );
  69. return true;
  70. }
  71. return false;
  72. */
  73. // return BaseClass::TestCollision( ray, mask, trace );
  74. }
  75. else
  76. return false;
  77. }