doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Push.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 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.
23 
24 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.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __PUSH_H__
30 #define __PUSH_H__
31 
32 /*
33 ===============================================================================
34 
35  Allows physics objects to be pushed geometrically.
36 
37 ===============================================================================
38 */
39 
40 #define PUSHFL_ONLYMOVEABLE 1 // only push moveable entities
41 #define PUSHFL_NOGROUNDENTITIES 2 // don't push entities the clip model rests upon
42 #define PUSHFL_CLIP 4 // also clip against all non-moveable entities
43 #define PUSHFL_CRUSH 8 // kill blocking entities
44 #define PUSHFL_APPLYIMPULSE 16 // apply impulse to pushed entities
45 
46 //#define NEW_PUSH
47 
48 class idPush {
49 public:
50  // Try to push other entities by moving the given entity.
51  // If results.fraction < 1.0 the move was blocked by results.c.entityNum
52  // Returns total mass of all pushed entities.
53  float ClipTranslationalPush( trace_t &results, idEntity *pusher, const int flags,
54  const idVec3 &newOrigin, const idVec3 &move );
55 
56  float ClipRotationalPush( trace_t &results, idEntity *pusher, const int flags,
57  const idMat3 &newAxis, const idRotation &rotation );
58 
59  float ClipPush( trace_t &results, idEntity *pusher, const int flags,
60  const idVec3 &oldOrigin, const idMat3 &oldAxis,
61  idVec3 &newOrigin, idMat3 &newAxis );
62 
63  // initialize saving the positions of entities being pushed
65  // move all pushed entities back to their previous position
66  void RestorePushedEntityPositions( void );
67  // returns the number of pushed entities
68  int GetNumPushedEntities( void ) const { return numPushed; }
69  // get the ith pushed entity
70  idEntity * GetPushedEntity( int i ) const { assert( i >= 0 && i < numPushed ); return pushed[i].ent; }
71 
72 private:
73  struct pushed_s {
74  idEntity * ent; // pushed entity
75  idAngles deltaViewAngles; // actor delta view angles
76  } pushed[MAX_GENTITIES]; // pushed entities
77  int numPushed; // number of pushed entities
78 
79  struct pushedGroup_s {
81  float fraction;
83  bool test;
86 
87 private:
88  void SaveEntityPosition( idEntity *ent );
89  bool RotateEntityToAxial( idEntity *ent, idVec3 rotationPoint );
90 #ifdef NEW_PUSH
91  bool CanPushEntity( idEntity *ent, idEntity *pusher, idEntity *initialPusher, const int flags );
92  void AddEntityToPushedGroup( idEntity *ent, float fraction, bool groundContact );
93  bool IsFullyPushed( idEntity *ent );
94  bool ClipTranslationAgainstPusher( trace_t &results, idEntity *ent, idEntity *pusher, const idVec3 &translation );
95  int GetPushableEntitiesForTranslation( idEntity *pusher, idEntity *initialPusher, const int flags,
96  const idVec3 &translation, idEntity *entityList[], int maxEntities );
97  bool ClipRotationAgainstPusher( trace_t &results, idEntity *ent, idEntity *pusher, const idRotation &rotation );
98  int GetPushableEntitiesForRotation( idEntity *pusher, idEntity *initialPusher, const int flags,
99  const idRotation &rotation, idEntity *entityList[], int maxEntities );
100 #else
101  void ClipEntityRotation( trace_t &trace, const idEntity *ent, const idClipModel *clipModel,
102  idClipModel *skip, const idRotation &rotation );
103  void ClipEntityTranslation( trace_t &trace, const idEntity *ent, const idClipModel *clipModel,
104  idClipModel *skip, const idVec3 &translation );
105  int TryTranslatePushEntity( trace_t &results, idEntity *check, idClipModel *clipModel, const int flags,
106  const idVec3 &newOrigin, const idVec3 &move );
107  int TryRotatePushEntity( trace_t &results, idEntity *check, idClipModel *clipModel, const int flags,
108  const idMat3 &newAxis, const idRotation &rotation );
109  int DiscardEntities( idEntity *entityList[], int numEntities, int flags, idEntity *pusher );
110 #endif
111 };
112 
113 #endif /* !__PUSH_H__ */
void ClipEntityTranslation(trace_t &trace, const idEntity *ent, const idClipModel *clipModel, idClipModel *skip, const idVec3 &translation)
Definition: Push.cpp:686
float ClipPush(trace_t &results, idEntity *pusher, const int flags, const idVec3 &oldOrigin, const idMat3 &oldAxis, idVec3 &newOrigin, idMat3 &newAxis)
Definition: Push.cpp:1390
assert(prefInfo.fullscreenBtn)
bool groundContact
Definition: Push.h:82
#define MAX_GENTITIES
Definition: Game_local.h:83
void ClipEntityRotation(trace_t &trace, const idEntity *ent, const idClipModel *clipModel, idClipModel *skip, const idRotation &rotation)
Definition: Push.cpp:668
Definition: Push.h:48
void SaveEntityPosition(idEntity *ent)
Definition: Push.cpp:49
idEntity * ent
Definition: Push.h:80
void InitSavingPushedEntityPositions(void)
Definition: Push.cpp:40
Definition: Vector.h:316
float ClipTranslationalPush(trace_t &results, idEntity *pusher, const int flags, const idVec3 &newOrigin, const idVec3 &move)
Definition: Push.cpp:1042
int i
Definition: process.py:33
void RestorePushedEntityPositions(void)
Definition: Push.cpp:84
idEntity * GetPushedEntity(int i) const
Definition: Push.h:70
int numPushed
Definition: Push.h:77
int TryTranslatePushEntity(trace_t &results, idEntity *check, idClipModel *clipModel, const int flags, const idVec3 &newOrigin, const idVec3 &move)
Definition: Push.cpp:866
bool RotateEntityToAxial(idEntity *ent, idVec3 rotationPoint)
Definition: Push.cpp:105
int pushedGroupSize
Definition: Push.h:85
idAngles deltaViewAngles
Definition: Push.h:75
int DiscardEntities(idEntity *entityList[], int numEntities, int flags, idEntity *pusher)
Definition: Push.cpp:993
int TryRotatePushEntity(trace_t &results, idEntity *check, idClipModel *clipModel, const int flags, const idMat3 &newAxis, const idRotation &rotation)
Definition: Push.cpp:708
Definition: Matrix.h:333
int GetNumPushedEntities(void) const
Definition: Push.h:68
idEntity * ent
Definition: Push.h:74
struct idPush::pushedGroup_s pushedGroup[MAX_GENTITIES]
struct idPush::pushed_s pushed[MAX_GENTITIES]
float ClipRotationalPush(trace_t &results, idEntity *pusher, const int flags, const idMat3 &newAxis, const idRotation &rotation)
Definition: Push.cpp:1222