home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / physics / Push.h < prev   
C/C++ Source or Header  |  2005-11-14  |  4KB  |  87 lines

  1.  
  2. #ifndef __PUSH_H__
  3. #define __PUSH_H__
  4.  
  5. /*
  6. ===============================================================================
  7.  
  8.   Allows physics objects to be pushed geometrically.
  9.  
  10. ===============================================================================
  11. */
  12.  
  13. #define PUSHFL_ONLYMOVEABLE            1        // only push moveable entities
  14. #define PUSHFL_NOGROUNDENTITIES        2        // don't push entities the clip model rests upon
  15. #define PUSHFL_CLIP                    4        // also clip against all non-moveable entities
  16. #define PUSHFL_CRUSH                8        // kill blocking entities
  17. #define PUSHFL_APPLYIMPULSE            16        // apply impulse to pushed entities
  18.  
  19. //#define NEW_PUSH
  20.  
  21. class idPush {
  22. public:
  23.                     // Try to push other entities by moving the given entity.
  24.                     // If results.fraction < 1.0 the move was blocked by results.c.entityNum
  25.                     // Returns total mass of all pushed entities.
  26.     float            ClipTranslationalPush( trace_t &results, idEntity *pusher, const int flags,
  27.                                             const idVec3 &newOrigin, const idVec3 &move );
  28.  
  29.     float            ClipRotationalPush( trace_t &results, idEntity *pusher, const int flags,
  30.                                             const idMat3 &newAxis, const idRotation &rotation );
  31.  
  32.     float            ClipPush( trace_t &results, idEntity *pusher, const int flags,
  33.                                             const idVec3 &oldOrigin, const idMat3 &oldAxis,
  34.                                                 idVec3 &newOrigin, idMat3 &newAxis );
  35.  
  36.                     // initialize saving the positions of entities being pushed
  37.     void            InitSavingPushedEntityPositions( void );
  38.                     // move all pushed entities back to their previous position
  39.     void            RestorePushedEntityPositions( void );
  40.                     // returns the number of pushed entities
  41.     int                GetNumPushedEntities( void ) const { return numPushed; }
  42.                     // get the ith pushed entity
  43.     idEntity *        GetPushedEntity( int i ) const { assert( i >= 0 && i < numPushed ); return pushed[i].ent; }
  44.  
  45. private:
  46.     struct pushed_s {
  47.         idEntity *    ent;                    // pushed entity
  48.         idAngles    deltaViewAngles;        // actor delta view angles
  49.     }                pushed[MAX_GENTITIES];    // pushed entities
  50.     int                numPushed;                // number of pushed entities
  51.  
  52.     struct pushedGroup_s {
  53.         idEntity *    ent;
  54.         float        fraction;
  55.         bool        groundContact;
  56.         bool        test;
  57.     }                pushedGroup[MAX_GENTITIES];
  58.     int                pushedGroupSize;
  59.  
  60. private:
  61.     void            SaveEntityPosition( idEntity *ent );
  62.     bool            RotateEntityToAxial( idEntity *ent, idVec3 rotationPoint );
  63. #ifdef NEW_PUSH
  64.     bool            CanPushEntity( idEntity *ent, idEntity *pusher, idEntity *initialPusher, const int flags );
  65.     void            AddEntityToPushedGroup( idEntity *ent, float fraction, bool groundContact );
  66.     bool            IsFullyPushed( idEntity *ent );
  67.     bool            ClipTranslationAgainstPusher( trace_t &results, idEntity *ent, idEntity *pusher, const idVec3 &translation );
  68.     int                GetPushableEntitiesForTranslation( idEntity *pusher, idEntity *initialPusher, const int flags,
  69.                                             const idVec3 &translation, idEntity *entityList[], int maxEntities );
  70.     bool            ClipRotationAgainstPusher( trace_t &results, idEntity *ent, idEntity *pusher, const idRotation &rotation );
  71.     int                GetPushableEntitiesForRotation( idEntity *pusher, idEntity *initialPusher, const int flags,
  72.                                             const idRotation &rotation, idEntity *entityList[], int maxEntities );
  73. #else
  74.     void            ClipEntityRotation( trace_t &trace, const idEntity *ent, const idClipModel *clipModel,
  75.                                         idClipModel *skip, const idRotation &rotation );
  76.     void            ClipEntityTranslation( trace_t &trace, const idEntity *ent, const idClipModel *clipModel,
  77.                                         idClipModel *skip, const idVec3 &translation );
  78.     int                TryTranslatePushEntity( trace_t &results, idEntity *check, idClipModel *clipModel, const int flags,
  79.                                                 const idVec3 &newOrigin, const idVec3 &move );
  80.     int                TryRotatePushEntity( trace_t &results, idEntity *check, idClipModel *clipModel, const int flags,
  81.                                                 const idMat3 &newAxis, const idRotation &rotation );
  82.     int                DiscardEntities( idEntity *entityList[], int numEntities, int flags, idEntity *pusher );
  83. #endif
  84. };
  85.  
  86. #endif /* !__PUSH_H__ */
  87.