Physics_Actor.h (4055B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition 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 BFG Edition 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 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition 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 BFG Edition 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 __PHYSICS_ACTOR_H__ 30 #define __PHYSICS_ACTOR_H__ 31 32 /* 33 =================================================================================== 34 35 Actor physics base class 36 37 An actor typically uses one collision model which is aligned with the gravity 38 direction. The collision model is usually a simple box with the origin at the 39 bottom center. 40 41 =================================================================================== 42 */ 43 44 class idPhysics_Actor : public idPhysics_Base { 45 46 public: 47 CLASS_PROTOTYPE( idPhysics_Actor ); 48 49 idPhysics_Actor(); 50 ~idPhysics_Actor(); 51 52 void Save( idSaveGame *savefile ) const; 53 void Restore( idRestoreGame *savefile ); 54 55 // get delta yaw of master 56 float GetMasterDeltaYaw() const; 57 // returns the ground entity 58 idEntity * GetGroundEntity() const; 59 // align the clip model with the gravity direction 60 void SetClipModelAxis(); 61 62 public: // common physics interface 63 void SetClipModel( idClipModel *model, float density, int id = 0, bool freeOld = true ); 64 idClipModel * GetClipModel( int id = 0 ) const; 65 int GetNumClipModels() const; 66 67 void SetMass( float mass, int id = -1 ); 68 float GetMass( int id = -1 ) const; 69 70 void SetContents( int contents, int id = -1 ); 71 int GetContents( int id = -1 ) const; 72 73 const idBounds & GetBounds( int id = -1 ) const; 74 const idBounds & GetAbsBounds( int id = -1 ) const; 75 76 bool IsPushable() const; 77 78 const idVec3 & GetOrigin( int id = 0 ) const; 79 const idMat3 & GetAxis( int id = 0 ) const; 80 81 void SetGravity( const idVec3 &newGravity ); 82 const idMat3 & GetGravityAxis() const; 83 84 void ClipTranslation( trace_t &results, const idVec3 &translation, const idClipModel *model ) const; 85 void ClipRotation( trace_t &results, const idRotation &rotation, const idClipModel *model ) const; 86 int ClipContents( const idClipModel *model ) const; 87 88 void DisableClip(); 89 void EnableClip(); 90 91 void UnlinkClip(); 92 void LinkClip(); 93 94 bool EvaluateContacts(); 95 96 protected: 97 idClipModel * clipModel; // clip model used for collision detection 98 idMat3 clipModelAxis; // axis of clip model aligned with gravity direction 99 100 // derived properties 101 float mass; 102 float invMass; 103 104 // master 105 idEntity * masterEntity; 106 float masterYaw; 107 float masterDeltaYaw; 108 109 // results of last evaluate 110 idEntityPtr<idEntity> groundEntityPtr; 111 }; 112 113 #endif /* !__PHYSICS_ACTOR_H__ */