doom3-bfg/neo/d3xp/physics/Physics_Actor.h

115 lines
3.9 KiB
C
Raw Normal View History

2012-11-26 18:58:24 +00:00
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
2012-11-26 18:58:24 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
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.
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.
===========================================================================
*/
#ifndef __PHYSICS_ACTOR_H__
#define __PHYSICS_ACTOR_H__
/*
===================================================================================
Actor physics base class
An actor typically uses one collision model which is aligned with the gravity
direction. The collision model is usually a simple box with the origin at the
bottom center.
===================================================================================
*/
class idPhysics_Actor : public idPhysics_Base
{
2012-11-26 18:58:24 +00:00
public:
CLASS_PROTOTYPE( idPhysics_Actor );
idPhysics_Actor();
~idPhysics_Actor();
void Save( idSaveGame* savefile ) const;
void Restore( idRestoreGame* savefile );
// get delta yaw of master
2012-11-26 18:58:24 +00:00
float GetMasterDeltaYaw() const;
// returns the ground entity
idEntity* GetGroundEntity() const;
// align the clip model with the gravity direction
2012-11-26 18:58:24 +00:00
void SetClipModelAxis();
2012-11-26 18:58:24 +00:00
public: // common physics interface
void SetClipModel( idClipModel* model, float density, int id = 0, bool freeOld = true );
idClipModel* GetClipModel( int id = 0 ) const;
2012-11-26 18:58:24 +00:00
int GetNumClipModels() const;
2012-11-26 18:58:24 +00:00
void SetMass( float mass, int id = -1 );
float GetMass( int id = -1 ) const;
2012-11-26 18:58:24 +00:00
void SetContents( int contents, int id = -1 );
int GetContents( int id = -1 ) const;
const idBounds& GetBounds( int id = -1 ) const;
const idBounds& GetAbsBounds( int id = -1 ) const;
2012-11-26 18:58:24 +00:00
bool IsPushable() const;
const idVec3& GetOrigin( int id = 0 ) const;
const idMat3& GetAxis( int id = 0 ) const;
void SetGravity( const idVec3& newGravity );
const idMat3& GetGravityAxis() const;
void ClipTranslation( trace_t& results, const idVec3& translation, const idClipModel* model ) const;
void ClipRotation( trace_t& results, const idRotation& rotation, const idClipModel* model ) const;
int ClipContents( const idClipModel* model ) const;
2012-11-26 18:58:24 +00:00
void DisableClip();
void EnableClip();
2012-11-26 18:58:24 +00:00
void UnlinkClip();
void LinkClip();
2012-11-26 18:58:24 +00:00
bool EvaluateContacts();
2012-11-26 18:58:24 +00:00
protected:
idClipModel* clipModel; // clip model used for collision detection
2012-11-26 18:58:24 +00:00
idMat3 clipModelAxis; // axis of clip model aligned with gravity direction
2012-11-26 18:58:24 +00:00
// derived properties
float mass;
float invMass;
2012-11-26 18:58:24 +00:00
// master
idEntity* masterEntity;
2012-11-26 18:58:24 +00:00
float masterYaw;
float masterDeltaYaw;
2012-11-26 18:58:24 +00:00
// results of last evaluate
idEntityPtr<idEntity> groundEntityPtr;
};
#endif /* !__PHYSICS_ACTOR_H__ */