29 #include "../../idlib/precompiled.h"
32 #include "../Game_local.h"
87 forwardmove = cmd.forwardmove;
88 rightmove = cmd.rightmove;
98 max = abs( forwardmove );
99 if ( abs( rightmove ) > max ) {
100 max = abs( rightmove );
102 if ( abs( upmove ) > max ) {
110 total =
idMath::Sqrt( (
float) forwardmove * forwardmove + rightmove * rightmove + upmove * upmove );
111 scale = (
float) playerSpeed * max / ( 127.0f * total );
126 float addspeed, accelspeed, currentspeed;
129 addspeed = wishspeed - currentspeed;
133 accelspeed = accel *
frametime * wishspeed;
134 if (accelspeed > addspeed) {
135 accelspeed = addspeed;
146 wishVelocity = wishdir * wishspeed;
151 if (canPush > pushLen) {
166 #define MAX_CLIP_PLANES 5
169 int i,
j, k, pushFlags;
170 int bumpcount, numbumps, numplanes;
171 float d, time_left, into, totalMass;
173 idVec3 end, stepEnd, primal_velocity, endVelocity, endClipVelocity, clipVelocity;
174 trace_t trace, stepTrace, downTrace;
175 bool nearGround, stepped, pushed;
184 primal_velocity = endVelocity;
209 for ( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) {
217 time_left -= time_left * trace.
fraction;
225 stepped = pushed =
false;
269 time_left -= time_left * stepTrace.
fraction;
293 if ( totalMass > 0.0
f ) {
300 time_left -= time_left * trace.
fraction;
325 for ( i = 0; i < numplanes; i++ ) {
326 if ( ( trace.
c.
normal * planes[i] ) > 0.999f ) {
331 if ( i < numplanes ) {
334 planes[numplanes] = trace.
c.
normal;
342 for ( i = 0; i < numplanes; i++ ) {
344 if ( into >= 0.1
f ) {
353 endClipVelocity = endVelocity;
357 for ( j = 0; j < numplanes; j++ ) {
361 if ( ( clipVelocity * planes[j] ) >= 0.1
f ) {
370 if ( ( clipVelocity * planes[i] ) >= 0 ) {
375 dir = planes[
i].
Cross( planes[j] );
378 clipVelocity = d * dir;
380 dir = planes[
i].
Cross( planes[j] );
382 d = dir * endVelocity;
383 endClipVelocity = d * dir;
386 for ( k = 0; k < numplanes; k++ ) {
387 if ( k == i || k == j ) {
390 if ( ( clipVelocity * planes[k] ) >= 0.1
f ) {
402 endVelocity = endClipVelocity;
426 if ( clipVelocity * endClipVelocity < 0.0
f ) {
430 return (
bool)( bumpcount == 0 );
442 float speed, newspeed, control;
452 if ( speed < 1.0
f ) {
490 newspeed = speed - drop;
653 float oldVel, newVel;
697 waterScale = 1.0f - ( 1.0f -
PM_SWIMSCALE ) * waterScale;
725 if ( newVel > 1.0
f ) {
727 if ( oldVel > 1.0
f ) {
760 if ( forward <= 0 ) {
775 float speed, drop, friction, newspeed, stopspeed;
776 float scale, wishspeed;
781 if ( speed < 20.0
f ) {
786 if ( speed < stopspeed ) {
793 newspeed = speed - drop;
806 wishspeed = wishdir.Normalize();
856 float wishspeed,
scale;
864 if ( upscale > 1.0
f ) {
867 else if ( upscale < -1.0
f ) {
941 memset( &trace, 0,
sizeof( trace ) );
964 bool hadGroundContacts;
1043 if ( !hadGroundContacts ) {
1108 bounds[1][2] = maxZ;
1160 end = start + tracedist * forward;
1282 if ( contents & MASK_WATER ) {
1289 if ( contents & MASK_WATER ) {
1715 idVec3 masterOrigin, oldOrigin;
1726 self->GetMasterPosition( masterOrigin, masterAxis );
1840 self->GetMasterPosition( masterOrigin, masterAxis );
1892 self->GetMasterPosition( masterOrigin, masterAxis );
1973 self->GetMasterPosition( masterOrigin, masterAxis );
int GetWaterType(void) const
const float PM_WATERACCELERATE
void WriteTrace(const trace_t &trace)
idCVar pm_usecylinder("pm_usecylinder","0", CVAR_GAME|CVAR_NETWORKSYNC|CVAR_BOOL,"use a cylinder approximation instead of a bounding box for player collision detection")
idCVar pm_crouchheight("pm_crouchheight","38", CVAR_GAME|CVAR_NETWORKSYNC|CVAR_FLOAT,"height of player's bounding box while crouched")
idMat3 mat3_identity(idVec3(1, 0, 0), idVec3(0, 1, 0), idVec3(0, 0, 1))
const idMaterial * groundMaterial
void ReadMaterial(const idMaterial *&material)
void CorrectAllSolid(trace_t &trace, int contents)
void Printf(const char *fmt,...) const id_attribute((format(printf
bool EvaluateContacts(void)
type * GetEntity(void) const
waterLevel_t GetWaterLevel(void) const
float GetFloat(void) const
const int PLAYER_VELOCITY_TOTAL_BITS
GLenum GLenum GLenum GLenum GLenum scale
const int PMF_TIME_KNOCKBACK
idMat3 Transpose(void) const
void InitSavingPushedEntityPositions(void)
void Set(const float x, const float y, const float z)
bool IsOutsideWorld(void) const
const idMat3 & GetAxis(void) const
void WriteBits(int value, int numBits)
static float ClampFloat(float min, float max, float value)
const idVec3 & GetPushedLinearVelocity(const int id=0) const
void ReadBool(bool &value)
float ClipTranslationalPush(trace_t &results, idEntity *pusher, const int flags, const idVec3 &newOrigin, const idVec3 &move)
static float Sqrt(float x)
#define PUSHFL_NOGROUNDENTITIES
const idVec3 & GetOrigin(void) const
GLuint GLuint GLsizei GLenum type
float GetStepUp(void) const
void SetPlayerInput(const usercmd_t &cmd, const idAngles &newViewAngles)
virtual void ApplyImpulse(idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse)
idVec3 Cross(const idVec3 &a) const
int ReadBits(int numBits) const
void ReadUsercmd(usercmd_t &usercmd)
bool HasJumped(void) const
void WriteVec3(const idVec3 &vec)
void SetDebugLevel(bool set)
void WriteMaterial(const idMaterial *material)
void WriteBool(const bool value)
float CmdScale(const usercmd_t &cmd) const
void WriteUsercmd(const usercmd_t &usercmd)
const float PLAYER_VELOCITY_MAX
void void void Warning(const char *fmt,...) const id_attribute((format(printf
#define PUSHFL_ONLYMOVEABLE
void Translate(const idVec3 &translation, int id=-1)
void ReadTrace(trace_t &trace)
bool Evaluate(int timeStepMSec, int endTimeMSec)
const float PM_AIRACCELERATE
idCVar pm_normalheight("pm_normalheight","74", CVAR_GAME|CVAR_NETWORKSYNC|CVAR_FLOAT,"height of player's bounding box while standing")
void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)
const int PLAYER_MOVEMENT_FLAGS_BITS
void SetMaxStepHeight(const float newMaxStepHeight)
int GetRestStartTime(void) const
const int PMF_TIME_WATERJUMP
void ReadFloat(float &value)
void WriteDeltaFloat(float oldValue, float newValue)
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
bool OnLadder(void) const
virtual void GetImpactInfo(idEntity *ent, int id, const idVec3 &point, impactInfo_t *info)
void WriteFloat(const float value)
const float PM_LADDERSPEED
void SetPushed(int deltaTime)
const idVec3 & GetLinearVelocity(int id=0) const
const idBounds & GetBounds(void) const
const int PLAYER_VELOCITY_MANTISSA_BITS
const float PM_WATERFRICTION
const int PLAYER_MOVEMENT_TYPE_BITS
const int GetSurfaceFlags(void) const
float GetMaxStepHeight(void) const
float ReadDeltaFloat(float oldValue) const
const int PLAYER_VELOCITY_EXPONENT_BITS
float LengthSqr(void) const
void Rotate(const idRotation &rotation, int id=-1)
const float PM_NOCLIPFRICTION
const float PM_AIRFRICTION
static int BitsForInteger(int i)
#define PUSHFL_APPLYIMPULSE
const float MIN_WALK_NORMAL
const idVec3 & PlayerGetOrigin(void) const
const float PM_FLYACCELERATE
void GetImpactInfo(const int id, const idVec3 &point, impactInfo_t *info) const
void ApplyImpulse(const int id, const idVec3 &point, const idVec3 &impulse)
END_CLASS const float PM_STOPSPEED
const char * ToString(int precision=2) const
void WriteInt(const int value)
idList< contactInfo_t > contacts
idEntity * entities[MAX_GENTITIES]
idCVar pm_deadheight("pm_deadheight","20", CVAR_GAME|CVAR_NETWORKSYNC|CVAR_FLOAT,"height of player's bounding box while dead")
void idPhysics_Player_RestorePState(idRestoreGame *savefile, playerPState_t &state)
void Restore(idRestoreGame *savefile)
void ProjectOntoPlane(const idVec3 &normal, const float overBounce=1.0f)
void WriteAngles(const idAngles &angles)
bool CheckWaterJump(void)
void UpdateTime(int endTimeMSec)
void Accelerate(const idVec3 &wishdir, const float wishspeed, const float accel)
bool LoadModel(const char *name)
const idMat3 & ToMat3(void) const
bool IsAtRest(void) const
void idPhysics_Player_SavePState(idSaveGame *savefile, const playerPState_t &state)
bool IsCrouching(void) const
int ReadDeltaLong(int oldValue) const
void SetSpeed(const float newWalkSpeed, const float newCrouchSpeed)
int Contents(const idVec3 &start, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity)
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
void WriteDeltaLong(int oldValue, int newValue)
void ReadVec3(idVec3 &vec)
idEntityPtr< idEntity > groundEntityPtr
const char * c_str(void) const
void MovePlayer(int msec)
void ClearPushedVelocity(void)
void SetOrigin(const idVec3 &newOrigin, int id=-1)
void ReadAngles(idAngles &angles)
const float PM_ACCELERATE
float ReadFloat(void) const
void ReadFromSnapshot(const idBitMsgDelta &msg)
void SetMovementType(const pmtype_t type)
bool HasGroundContacts(void) const
void WriteToSnapshot(idBitMsgDelta &msg) const
void ActivateContactEntities(void)
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID
bool Translation(trace_t &results, const idVec3 &start, const idVec3 &end, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity)
const float PM_FLYFRICTION
void SetAxis(const idMat3 &newAxis, int id=-1)
void ToVectors(idVec3 *forward, idVec3 *right=NULL, idVec3 *up=NULL) const
void SetMaxJumpHeight(const float newMaxJumpHeight)
void SetKnockBack(const int knockBackTime)
void Save(idSaveGame *savefile) const
bool HasSteppedUp(void) const
void SetPosition(const idVec3 &newOrigin, const idMat3 &newAxis)
static const float M_MS2SEC
void SetMaster(idEntity *master, const bool orientated=true)
bool SlideMove(bool gravity, bool stepUp, bool stepDown, bool push)
const int PMF_STEPPED_DOWN
static int BitsForFloat(float f)