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.

66 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef PHYSICS_IMPACT_DAMAGE_H
  7. #define PHYSICS_IMPACT_DAMAGE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. struct impactentry_t
  12. {
  13. float impulse;
  14. float damage;
  15. };
  16. // UNDONE: Add a flag to turn off aggregation of mass in object systems (e.g. ragdolls, vehicles)?
  17. struct impactdamagetable_t
  18. {
  19. impactentry_t *linearTable;
  20. impactentry_t *angularTable;
  21. int linearCount; // array size of linearTable
  22. int angularCount; // array size of angularTable
  23. float minSpeedSqr; // minimum squared impact speed for damage
  24. float minRotSpeedSqr;
  25. float minMass; // minimum mass to do damage
  26. // filter out reall small objects, set all to zero to disable
  27. float smallMassMax;
  28. float smallMassCap;
  29. float smallMassMinSpeedSqr;
  30. // exaggerate the effects of really large objects, set all to 1 to disable
  31. float largeMassMin;
  32. float largeMassScale;
  33. float largeMassFallingScale; // emphasize downward impacts so that this will kill instead of stress (we have more information here than there)
  34. float myMinVelocity; // filter out any energy lost by me unless my velocity is greater than this
  35. };
  36. extern impactdamagetable_t gDefaultNPCImpactDamageTable;
  37. extern impactdamagetable_t gDefaultPlayerImpactDamageTable;
  38. extern impactdamagetable_t gDefaultPlayerVehicleImpactDamageTable;
  39. // NOTE Default uses default NPC table
  40. float CalculateDefaultPhysicsDamage( int index, gamevcollisionevent_t *pEvent, float energyScale, bool allowStaticDamage, int &damageTypeOut, string_t iszDamageTableName = NULL_STRING, bool bDamageFromHeldObjects = false );
  41. // use passes in the table
  42. float CalculatePhysicsImpactDamage( int index, gamevcollisionevent_t *pEvent, const impactdamagetable_t &table, float energyScale, bool allowStaticDamage, int &damageTypeOut, bool bDamageFromHeldObjects = false );
  43. struct vphysics_objectstress_t
  44. {
  45. float exertedStress;
  46. float receivedStress;
  47. bool hasNonStaticStress;
  48. bool hasLargeObjectContact;
  49. };
  50. float CalculateObjectStress( IPhysicsObject *pObject, CBaseEntity *pOwnerEntity, vphysics_objectstress_t *pOutput );
  51. #endif // PHYSICS_IMPACT_DAMAGE_H