Physics_Static.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __PHYSICS_STATIC_H__
  21. #define __PHYSICS_STATIC_H__
  22. /*
  23. ===============================================================================
  24. Physics for a non moving object using at most one collision model.
  25. ===============================================================================
  26. */
  27. typedef struct staticPState_s {
  28. idVec3 origin;
  29. idMat3 axis;
  30. idVec3 localOrigin;
  31. idMat3 localAxis;
  32. } staticPState_t;
  33. class idPhysics_Static : public idPhysics {
  34. public:
  35. CLASS_PROTOTYPE( idPhysics_Static );
  36. idPhysics_Static( void );
  37. ~idPhysics_Static( void );
  38. void Save( idSaveGame *savefile ) const;
  39. void Restore( idRestoreGame *savefile );
  40. public: // common physics interface
  41. void SetSelf( idEntity *e );
  42. void SetClipModel( idClipModel *model, float density, int id = 0, bool freeOld = true );
  43. idClipModel * GetClipModel( int id = 0 ) const;
  44. int GetNumClipModels( void ) const;
  45. void SetMass( float mass, int id = -1 );
  46. float GetMass( int id = -1 ) const;
  47. void SetContents( int contents, int id = -1 );
  48. int GetContents( int id = -1 ) const;
  49. void SetClipMask( int mask, int id = -1 );
  50. int GetClipMask( int id = -1 ) const;
  51. const idBounds & GetBounds( int id = -1 ) const;
  52. const idBounds & GetAbsBounds( int id = -1 ) const;
  53. bool Evaluate( int timeStepMSec, int endTimeMSec );
  54. void UpdateTime( int endTimeMSec );
  55. int GetTime( void ) const;
  56. void GetImpactInfo( const int id, const idVec3 &point, impactInfo_t *info ) const;
  57. void ApplyImpulse( const int id, const idVec3 &point, const idVec3 &impulse );
  58. void AddForce( const int id, const idVec3 &point, const idVec3 &force );
  59. void Activate( void );
  60. void PutToRest( void );
  61. bool IsAtRest( void ) const;
  62. int GetRestStartTime( void ) const;
  63. bool IsPushable( void ) const;
  64. void SaveState( void );
  65. void RestoreState( void );
  66. void SetOrigin( const idVec3 &newOrigin, int id = -1 );
  67. void SetAxis( const idMat3 &newAxis, int id = -1 );
  68. void Translate( const idVec3 &translation, int id = -1 );
  69. void Rotate( const idRotation &rotation, int id = -1 );
  70. const idVec3 & GetOrigin( int id = 0 ) const;
  71. const idMat3 & GetAxis( int id = 0 ) const;
  72. void SetLinearVelocity( const idVec3 &newLinearVelocity, int id = 0 );
  73. void SetAngularVelocity( const idVec3 &newAngularVelocity, int id = 0 );
  74. const idVec3 & GetLinearVelocity( int id = 0 ) const;
  75. const idVec3 & GetAngularVelocity( int id = 0 ) const;
  76. void SetGravity( const idVec3 &newGravity );
  77. const idVec3 & GetGravity( void ) const;
  78. const idVec3 & GetGravityNormal( void ) const;
  79. void ClipTranslation( trace_t &results, const idVec3 &translation, const idClipModel *model ) const;
  80. void ClipRotation( trace_t &results, const idRotation &rotation, const idClipModel *model ) const;
  81. int ClipContents( const idClipModel *model ) const;
  82. void DisableClip( void );
  83. void EnableClip( void );
  84. void UnlinkClip( void );
  85. void LinkClip( void );
  86. bool EvaluateContacts( void );
  87. int GetNumContacts( void ) const;
  88. const contactInfo_t & GetContact( int num ) const;
  89. void ClearContacts( void );
  90. void AddContactEntity( idEntity *e );
  91. void RemoveContactEntity( idEntity *e );
  92. bool HasGroundContacts( void ) const;
  93. bool IsGroundEntity( int entityNum ) const;
  94. bool IsGroundClipModel( int entityNum, int id ) const;
  95. void SetPushed( int deltaTime );
  96. const idVec3 & GetPushedLinearVelocity( const int id = 0 ) const;
  97. const idVec3 & GetPushedAngularVelocity( const int id = 0 ) const;
  98. void SetMaster( idEntity *master, const bool orientated = true );
  99. const trace_t * GetBlockingInfo( void ) const;
  100. idEntity * GetBlockingEntity( void ) const;
  101. int GetLinearEndTime( void ) const;
  102. int GetAngularEndTime( void ) const;
  103. void WriteToSnapshot( idBitMsgDelta &msg ) const;
  104. void ReadFromSnapshot( const idBitMsgDelta &msg );
  105. protected:
  106. idEntity * self; // entity using this physics object
  107. staticPState_t current; // physics state
  108. idClipModel * clipModel; // collision model
  109. // master
  110. bool hasMaster;
  111. bool isOrientated;
  112. };
  113. #endif /* !__PHYSICS_STATIC_H__ */