Allow headset to dictate refresh rate for game

This commit is contained in:
Simon 2020-10-16 20:45:26 +01:00
parent 01b67f3b35
commit 70c4e81938
25 changed files with 127 additions and 99 deletions

View file

@ -1051,13 +1051,16 @@ static bool destroyed = false;
float Doom3Quest_GetFOV() float Doom3Quest_GetFOV()
{ {
if (vrFOV == 0.0f) {
vrFOV = vrapi_GetSystemPropertyInt(&gAppState.Java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X); vrFOV = vrapi_GetSystemPropertyInt(&gAppState.Java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X);
}
return vrFOV; return vrFOV;
} }
int Doom3Quest_GetRefresh()
{
return Doom3Quest_initialised ? vrapi_GetSystemPropertyInt(&gAppState.Java, VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE) : 60;
}
static void ovrApp_HandleVrModeChanges( ovrApp * app ) static void ovrApp_HandleVrModeChanges( ovrApp * app )
{ {
if ( app->Resumed != false && app->NativeWindow != NULL ) if ( app->Resumed != false && app->NativeWindow != NULL )
@ -1585,8 +1588,11 @@ void * AppThreadFunction(void * parm ) {
// Create the scene if not yet created. // Create the scene if not yet created.
ovrScene_Create( m_width, m_height, &gAppState.Scene, &java ); ovrScene_Create( m_width, m_height, &gAppState.Scene, &java );
//Set the screen refresh //Set the screen refresh - only for Quest 1
bool quest1 = false;
if (quest1) {
vrapi_SetDisplayRefreshRate(gAppState.Ovr, DISPLAY_REFRESH); vrapi_SetDisplayRefreshRate(gAppState.Ovr, DISPLAY_REFRESH);
}
//Run loading loop until we are ready to start QzDoom //Run loading loop until we are ready to start QzDoom
while (!destroyed && !Doom3Quest_initialised) { while (!destroyed && !Doom3Quest_initialised) {

View file

@ -66,6 +66,8 @@ void controlMouse(ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemo
//Called from engine code //Called from engine code
int Doom3Quest_GetRefresh();
bool Doom3Quest_useScreenLayer(); bool Doom3Quest_useScreenLayer();
void Doom3Quest_GetScreenRes(int *width, int *height); void Doom3Quest_GetScreenRes(int *width, int *height);

View file

@ -59,7 +59,6 @@ extern bool inMenu;
extern bool inGameGuiActive; extern bool inGameGuiActive;
extern bool objectiveSystemActive; extern bool objectiveSystemActive;
extern bool inCinematic; extern bool inCinematic;
const int USERCMD_HZ = 60;
void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking, void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
@ -379,7 +378,7 @@ void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDomina
//approximately even out the positional movement on a per frame basis (especially when fps is much lower than 60) //approximately even out the positional movement on a per frame basis (especially when fps is much lower than 60)
static float lastSampleTime = 0; static float lastSampleTime = 0;
float sampleTime = Sys_Milliseconds(); float sampleTime = Sys_Milliseconds();
float vr_positional_factor = 2400.0f * ((1000.0f / USERCMD_HZ) / (sampleTime-lastSampleTime)); float vr_positional_factor = 2400.0f * ((1000.0f / (float)Doom3Quest_GetRefresh()) / (sampleTime-lastSampleTime));
lastSampleTime = sampleTime; lastSampleTime = sampleTime;
//This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the //This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the

View file

@ -35,6 +35,8 @@ If you have questions concerning this license or the applicable additional terms
#include "framework/UsercmdGen.h" #include "framework/UsercmdGen.h"
#include "renderer/RenderSystem.h"
/* /*
================ ================
usercmd_t::ByteSwap usercmd_t::ByteSwap

View file

@ -37,8 +37,10 @@ If you have questions concerning this license or the applicable additional terms
=============================================================================== ===============================================================================
*/ */
const int USERCMD_HZ = 60; //const int USERCMD_HZ = 60;
const int USERCMD_MSEC = 1000 / USERCMD_HZ; //const int USERCMD_MSEC = 1000 / USERCMD_HZ;
#define USERCMD_MSEC (1000 / (renderSystem ? renderSystem->GetRefresh() : 60))
// usercmd_t->button bits // usercmd_t->button bits
const int BUTTON_ATTACK = BIT(0); const int BUTTON_ATTACK = BIT(0);

View file

@ -1860,7 +1860,7 @@ void idAFEntity_VehicleSimple::Think( void ) {
origin = suspension[i]->GetWheelOrigin(); origin = suspension[i]->GetWheelOrigin();
velocity = body->GetPointVelocity( origin ) * body->GetWorldAxis()[0]; velocity = body->GetPointVelocity( origin ) * body->GetWorldAxis()[0];
wheelAngles[i] += velocity * MS2SEC( gameLocal.msec ) / wheelRadius; wheelAngles[i] += velocity * MS2SEC( USERCMD_MSEC ) / wheelRadius;
// additional rotation about the wheel axis // additional rotation about the wheel axis
wheelRotation.SetAngle( RAD2DEG( wheelAngles[i] ) ); wheelRotation.SetAngle( RAD2DEG( wheelAngles[i] ) );
@ -2052,7 +2052,7 @@ void idAFEntity_VehicleFourWheels::Think( void ) {
if ( force == 0.0f ) { if ( force == 0.0f ) {
velocity = wheels[i]->GetLinearVelocity() * wheels[i]->GetWorldAxis()[0]; velocity = wheels[i]->GetLinearVelocity() * wheels[i]->GetWorldAxis()[0];
} }
wheelAngles[i] += velocity * MS2SEC( gameLocal.msec ) / wheelRadius; wheelAngles[i] += velocity * MS2SEC( USERCMD_MSEC ) / wheelRadius;
// give the wheel joint an additional rotation about the wheel axis // give the wheel joint an additional rotation about the wheel axis
rotation.SetAngle( RAD2DEG( wheelAngles[i] ) ); rotation.SetAngle( RAD2DEG( wheelAngles[i] ) );
axis = af.GetPhysics()->GetAxis( 0 ); axis = af.GetPhysics()->GetAxis( 0 );
@ -2242,7 +2242,7 @@ void idAFEntity_VehicleSixWheels::Think( void ) {
if ( force == 0.0f ) { if ( force == 0.0f ) {
velocity = wheels[i]->GetLinearVelocity() * wheels[i]->GetWorldAxis()[0]; velocity = wheels[i]->GetLinearVelocity() * wheels[i]->GetWorldAxis()[0];
} }
wheelAngles[i] += velocity * MS2SEC( gameLocal.msec ) / wheelRadius; wheelAngles[i] += velocity * MS2SEC( USERCMD_MSEC ) / wheelRadius;
// give the wheel joint an additional rotation about the wheel axis // give the wheel joint an additional rotation about the wheel axis
rotation.SetAngle( RAD2DEG( wheelAngles[i] ) ); rotation.SetAngle( RAD2DEG( wheelAngles[i] ) );
axis = af.GetPhysics()->GetAxis( 0 ); axis = af.GetPhysics()->GetAxis( 0 );

View file

@ -514,9 +514,9 @@ void idCameraAnim::Think( void ) {
return; return;
} }
if ( frameRate == USERCMD_HZ ) { if ( frameRate == renderSystem->GetRefresh() ) {
frameTime = gameLocal.time - starttime; frameTime = gameLocal.time - starttime;
frame = frameTime / gameLocal.msec; frame = frameTime / USERCMD_MSEC;
} else { } else {
frameTime = ( gameLocal.time - starttime ) * frameRate; frameTime = ( gameLocal.time - starttime ) * frameRate;
frame = frameTime / 1000; frame = frameTime / 1000;
@ -564,9 +564,9 @@ void idCameraAnim::GetViewParms( renderView_t *view ) {
return; return;
} }
if ( frameRate == USERCMD_HZ ) { if ( frameRate == renderSystem->GetRefresh() ) {
frameTime = gameLocal.time - starttime; frameTime = gameLocal.time - starttime;
frame = frameTime / gameLocal.msec; frame = frameTime / USERCMD_MSEC;
lerp = 0.0f; lerp = 0.0f;
} else { } else {
frameTime = ( gameLocal.time - starttime ) * frameRate; frameTime = ( gameLocal.time - starttime ) * frameRate;
@ -586,7 +586,7 @@ void idCameraAnim::GetViewParms( renderView_t *view ) {
} }
if ( g_debugCinematic.GetBool() ) { if ( g_debugCinematic.GetBool() ) {
int prevFrameTime = ( gameLocal.time - starttime - gameLocal.msec ) * frameRate; int prevFrameTime = ( gameLocal.time - starttime - USERCMD_MSEC ) * frameRate;
int prevFrame = prevFrameTime / 1000; int prevFrame = prevFrameTime / 1000;
int prevCut; int prevCut;
@ -659,7 +659,7 @@ void idCameraAnim::GetViewParms( renderView_t *view ) {
static int lastFrame = 0; static int lastFrame = 0;
static idVec3 lastFrameVec( 0.0f, 0.0f, 0.0f ); static idVec3 lastFrameVec( 0.0f, 0.0f, 0.0f );
if ( gameLocal.time != lastFrame ) { if ( gameLocal.time != lastFrame ) {
gameRenderWorld->DebugBounds( colorCyan, idBounds( view->vieworg ).Expand( 16.0f ), vec3_origin, gameLocal.msec ); gameRenderWorld->DebugBounds( colorCyan, idBounds( view->vieworg ).Expand( 16.0f ), vec3_origin, USERCMD_MSEC );
gameRenderWorld->DebugLine( colorRed, view->vieworg, view->vieworg + idVec3( 0.0f, 0.0f, 2.0f ), 10000, false ); gameRenderWorld->DebugLine( colorRed, view->vieworg, view->vieworg + idVec3( 0.0f, 0.0f, 2.0f ), 10000, false );
gameRenderWorld->DebugLine( colorCyan, lastFrameVec, view->vieworg, 10000, false ); gameRenderWorld->DebugLine( colorCyan, lastFrameVec, view->vieworg, 10000, false );
gameRenderWorld->DebugLine( colorYellow, view->vieworg + view->viewaxis[ 0 ] * 64.0f, view->vieworg + view->viewaxis[ 0 ] * 66.0f, 10000, false ); gameRenderWorld->DebugLine( colorYellow, view->vieworg + view->viewaxis[ 0 ] * 64.0f, view->vieworg + view->viewaxis[ 0 ] * 66.0f, 10000, false );

View file

@ -481,7 +481,7 @@ void idEntity::Spawn( void ) {
renderEntity.entityNum = entityNumber; renderEntity.entityNum = entityNumber;
// go dormant within 5 frames so that when the map starts most monsters are dormant // go dormant within 5 frames so that when the map starts most monsters are dormant
dormantStart = gameLocal.time - DELAY_DORMANT_TIME + gameLocal.msec * 5; dormantStart = gameLocal.time - DELAY_DORMANT_TIME + USERCMD_MSEC * 5;
origin = renderEntity.origin; origin = renderEntity.origin;
axis = renderEntity.axis; axis = renderEntity.axis;

View file

@ -2218,7 +2218,7 @@ gameReturn_t idGameLocal::RunFrame( const usercmd_t *clientCmds ) {
// update the game time // update the game time
framenum++; framenum++;
previousTime = time; previousTime = time;
time += msec; time += USERCMD_MSEC;
realClientTime = time; realClientTime = time;
#ifdef GAME_DLL #ifdef GAME_DLL
@ -3553,7 +3553,7 @@ idGameLocal::AlertAI
void idGameLocal::AlertAI( idEntity *ent ) { void idGameLocal::AlertAI( idEntity *ent ) {
if ( ent && ent->IsType( idActor::Type ) ) { if ( ent && ent->IsType( idActor::Type ) ) {
// alert them for the next frame // alert them for the next frame
lastAIAlertTime = time + msec; lastAIAlertTime = time + USERCMD_MSEC;
lastAIAlertEntity = static_cast<idActor *>( ent ); lastAIAlertEntity = static_cast<idActor *>( ent );
} }
} }
@ -3958,7 +3958,7 @@ void idGameLocal::SetCamera( idCamera *cam ) {
} else { } else {
inCinematic = false; inCinematic = false;
cinematicStopTime = time + msec; cinematicStopTime = time + USERCMD_MSEC;
// restore r_znear // restore r_znear
cvarSystem->SetCVarFloat( "r_znear", 3.0f ); cvarSystem->SetCVarFloat( "r_znear", 3.0f );

View file

@ -274,7 +274,7 @@ public:
int framenum; int framenum;
int previousTime; // time in msec of last frame int previousTime; // time in msec of last frame
int time; // in msec int time; // in msec
static const int msec = USERCMD_MSEC; // time since last update in milliseconds // static const int msec = USERCMD_MSEC; // time since last update in milliseconds
int vacuumAreaNum; // -1 if level doesn't have any outside areas int vacuumAreaNum; // -1 if level doesn't have any outside areas
@ -426,7 +426,7 @@ public:
// added the following to assist licensees with merge issues // added the following to assist licensees with merge issues
int GetFrameNum() const { return framenum; }; int GetFrameNum() const { return framenum; };
int GetTime() const { return time; }; int GetTime() const { return time; };
int GetMSec() const { return msec; }; int GetMSec() const { return USERCMD_MSEC; };
int GetNextClientNum( int current ) const; int GetNextClientNum( int current ) const;
idPlayer * GetClientByNum( int current ) const; idPlayer * GetClientByNum( int current ) const;

View file

@ -994,7 +994,7 @@ void idGameLocal::ClientReadSnapshot( int clientNum, int sequence, const int gam
// update the game time // update the game time
framenum = gameFrame; framenum = gameFrame;
time = gameTime; time = gameTime;
previousTime = time - msec; previousTime = time - USERCMD_MSEC;
// so that StartSound/StopSound doesn't risk skipping // so that StartSound/StopSound doesn't risk skipping
isNewFrame = true; isNewFrame = true;
@ -1492,7 +1492,7 @@ gameReturn_t idGameLocal::ClientPrediction( int clientNum, const usercmd_t *clie
// update the game time // update the game time
framenum++; framenum++;
previousTime = time; previousTime = time;
time += msec; time += USERCMD_MSEC;
// update the real client time and the new frame flag // update the real client time and the new frame flag
if ( time > realClientTime ) { if ( time > realClientTime ) {

View file

@ -392,14 +392,14 @@ bool idMoveable::FollowInitialSplinePath( void ) {
if ( initialSpline != NULL ) { if ( initialSpline != NULL ) {
if ( gameLocal.time < initialSpline->GetTime( initialSpline->GetNumValues() - 1 ) ) { if ( gameLocal.time < initialSpline->GetTime( initialSpline->GetNumValues() - 1 ) ) {
idVec3 splinePos = initialSpline->GetCurrentValue( gameLocal.time ); idVec3 splinePos = initialSpline->GetCurrentValue( gameLocal.time );
idVec3 linearVelocity = ( splinePos - physicsObj.GetOrigin() ) * USERCMD_HZ; idVec3 linearVelocity = ( splinePos - physicsObj.GetOrigin() ) * renderSystem->GetRefresh();
physicsObj.SetLinearVelocity( linearVelocity ); physicsObj.SetLinearVelocity( linearVelocity );
idVec3 splineDir = initialSpline->GetCurrentFirstDerivative( gameLocal.time ); idVec3 splineDir = initialSpline->GetCurrentFirstDerivative( gameLocal.time );
idVec3 dir = initialSplineDir * physicsObj.GetAxis(); idVec3 dir = initialSplineDir * physicsObj.GetAxis();
idVec3 angularVelocity = dir.Cross( splineDir ); idVec3 angularVelocity = dir.Cross( splineDir );
angularVelocity.Normalize(); angularVelocity.Normalize();
angularVelocity *= idMath::ACos16( dir * splineDir / splineDir.Length() ) * USERCMD_HZ; angularVelocity *= idMath::ACos16( dir * splineDir / splineDir.Length() ) * renderSystem->GetRefresh();
physicsObj.SetAngularVelocity( angularVelocity ); physicsObj.SetAngularVelocity( angularVelocity );
return true; return true;
} else { } else {

View file

@ -4930,7 +4930,7 @@ void idPlayer::BobCycle( const idVec3 &pushVelocity ) {
// check for footstep / splash sounds // check for footstep / splash sounds
old = bobCycle; old = bobCycle;
bobCycle = (int)( old + bobmove * gameLocal.msec ) & 255; bobCycle = (int)( old + bobmove * USERCMD_MSEC ) & 255;
bobFoot = ( bobCycle & 128 ) >> 7; bobFoot = ( bobCycle & 128 ) >> 7;
bobfracsin = idMath::Fabs( sin( ( bobCycle & 127 ) / 127.0 * idMath::PI ) ); bobfracsin = idMath::Fabs( sin( ( bobCycle & 127 ) / 127.0 * idMath::PI ) );
}*/ }*/
@ -5883,7 +5883,7 @@ void idPlayer::AdjustSpeed( void ) {
bobFrac = 0.0f; bobFrac = 0.0f;
} else if ( !physicsObj.OnLadder() && ( usercmd.buttons & BUTTON_RUN ) && ( usercmd.forwardmove || usercmd.rightmove ) && ( usercmd.upmove >= 0 ) ) { } else if ( !physicsObj.OnLadder() && ( usercmd.buttons & BUTTON_RUN ) && ( usercmd.forwardmove || usercmd.rightmove ) && ( usercmd.upmove >= 0 ) ) {
if ( !gameLocal.isMultiplayer && !physicsObj.IsCrouching() && !PowerUpActive( ADRENALINE ) ) { if ( !gameLocal.isMultiplayer && !physicsObj.IsCrouching() && !PowerUpActive( ADRENALINE ) ) {
stamina -= MS2SEC( gameLocal.msec ); stamina -= MS2SEC( USERCMD_MSEC );
} }
if ( stamina < 0 ) { if ( stamina < 0 ) {
stamina = 0; stamina = 0;
@ -5904,7 +5904,7 @@ void idPlayer::AdjustSpeed( void ) {
rate *= 1.25f; rate *= 1.25f;
} }
stamina += rate * MS2SEC( gameLocal.msec ); stamina += rate * MS2SEC( USERCMD_MSEC );
if ( stamina > pm_stamina.GetFloat() ) { if ( stamina > pm_stamina.GetFloat() ) {
stamina = pm_stamina.GetFloat(); stamina = pm_stamina.GetFloat();
} }

View file

@ -1430,7 +1430,7 @@ void idGuidedProjectile::Launch( const idVec3 &start, const idVec3 &dir, const i
angles = vel.ToAngles(); angles = vel.ToAngles();
speed = vel.Length(); speed = vel.Length();
rndScale = spawnArgs.GetAngles( "random", "15 15 0" ); rndScale = spawnArgs.GetAngles( "random", "15 15 0" );
turn_max = spawnArgs.GetFloat( "turn_max", "180" ) / ( float )USERCMD_HZ; turn_max = spawnArgs.GetFloat( "turn_max", "180" ) / ( float )(renderSystem->GetRefresh());
clamp_dist = spawnArgs.GetFloat( "clamp_dist", "256" ); clamp_dist = spawnArgs.GetFloat( "clamp_dist", "256" );
burstMode = spawnArgs.GetBool( "burstMode" ); burstMode = spawnArgs.GetBool( "burstMode" );
unGuided = false; unGuided = false;

View file

@ -1330,7 +1330,7 @@ void idTarget_SetFov::Event_Activate( idEntity *activator ) {
cinematic = true; cinematic = true;
idPlayer *player = gameLocal.GetLocalPlayer(); idPlayer *player = gameLocal.GetLocalPlayer();
fovSetting.Init( gameLocal.time, SEC2MS( spawnArgs.GetFloat( "time" ) ), player ? player->DefaultFov() : g_fov.GetFloat(), spawnArgs.GetFloat( "fov" ) ); fovSetting.Init( gameLocal.time, SEC2MS( spawnArgs.GetFloat( "time" ) ), player ? player->DefaultFov() : renderSystem->GetFOV(), spawnArgs.GetFloat( "fov" ) );
BecomeActive( TH_THINK ); BecomeActive( TH_THINK );
} }

View file

@ -1143,7 +1143,7 @@ void idAI::Think( void ) {
} }
/* this still draws in retail builds.. not sure why.. don't care at this point. /* this still draws in retail builds.. not sure why.. don't care at this point.
if ( !aas && developer.GetBool() && !fl.hidden && !num_cinematics ) { if ( !aas && developer.GetBool() && !fl.hidden && !num_cinematics ) {
gameRenderWorld->DrawText( "No AAS", physicsObj.GetAbsBounds().GetCenter(), 0.1f, colorWhite, gameLocal.GetLocalPlayer()->viewAngles.ToMat3(), 1, gameLocal.msec ); gameRenderWorld->DrawText( "No AAS", physicsObj.GetAbsBounds().GetCenter(), 0.1f, colorWhite, gameLocal.GetLocalPlayer()->viewAngles.ToMat3(), 1, USERCMD_MSEC );
} }
*/ */
@ -1442,7 +1442,7 @@ float idAI::TravelDistance( const idVec3 &start, const idVec3 &end ) const {
dist = delta.LengthFast(); dist = delta.LengthFast();
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorBlue, start, end, gameLocal.msec, false ); gameRenderWorld->DebugLine( colorBlue, start, end, USERCMD_MSEC, false );
gameRenderWorld->DrawText( va( "%d", ( int )dist ), ( start + end ) * 0.5f, 0.1f, colorWhite, gameLocal.GetLocalPlayer()->viewAngles.ToMat3() ); gameRenderWorld->DrawText( va( "%d", ( int )dist ), ( start + end ) * 0.5f, 0.1f, colorWhite, gameLocal.GetLocalPlayer()->viewAngles.ToMat3() );
} }
@ -1463,7 +1463,7 @@ float idAI::TravelDistance( const idVec3 &start, const idVec3 &end ) const {
dist = delta.LengthFast(); dist = delta.LengthFast();
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorBlue, start, end, gameLocal.msec, false ); gameRenderWorld->DebugLine( colorBlue, start, end, USERCMD_MSEC, false );
gameRenderWorld->DrawText( va( "%d", ( int )dist ), ( start + end ) * 0.5f, 0.1f, colorWhite, gameLocal.GetLocalPlayer()->viewAngles.ToMat3() ); gameRenderWorld->DrawText( va( "%d", ( int )dist ), ( start + end ) * 0.5f, 0.1f, colorWhite, gameLocal.GetLocalPlayer()->viewAngles.ToMat3() );
} }
@ -2276,7 +2276,7 @@ bool idAI::GetMovePos( idVec3 &seekPos ) {
seekPos = org + move.moveDir * 2048.0f; seekPos = org + move.moveDir * 2048.0f;
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorYellow, org, seekPos, gameLocal.msec, true ); gameRenderWorld->DebugLine( colorYellow, org, seekPos, USERCMD_MSEC, true );
} }
} else { } else {
AI_DEST_UNREACHABLE = false; AI_DEST_UNREACHABLE = false;
@ -2400,18 +2400,18 @@ void idAI::Turn( void ) {
current_yaw = idMath::AngleNormalize180( anim_turn_yaw + rotateAxis[ 0 ].ToYaw() ); current_yaw = idMath::AngleNormalize180( anim_turn_yaw + rotateAxis[ 0 ].ToYaw() );
} else { } else {
diff = idMath::AngleNormalize180( ideal_yaw - current_yaw ); diff = idMath::AngleNormalize180( ideal_yaw - current_yaw );
turnVel += AI_TURN_SCALE * diff * MS2SEC( gameLocal.msec ); turnVel += AI_TURN_SCALE * diff * MS2SEC( USERCMD_MSEC );
if ( turnVel > turnRate ) { if ( turnVel > turnRate ) {
turnVel = turnRate; turnVel = turnRate;
} else if ( turnVel < -turnRate ) { } else if ( turnVel < -turnRate ) {
turnVel = -turnRate; turnVel = -turnRate;
} }
turnAmount = turnVel * MS2SEC( gameLocal.msec ); turnAmount = turnVel * MS2SEC( USERCMD_MSEC );
if ( ( diff >= 0.0f ) && ( turnAmount >= diff ) ) { if ( ( diff >= 0.0f ) && ( turnAmount >= diff ) ) {
turnVel = diff / MS2SEC( gameLocal.msec ); turnVel = diff / MS2SEC( USERCMD_MSEC );
turnAmount = diff; turnAmount = diff;
} else if ( ( diff <= 0.0f ) && ( turnAmount <= diff ) ) { } else if ( ( diff <= 0.0f ) && ( turnAmount <= diff ) ) {
turnVel = diff / MS2SEC( gameLocal.msec ); turnVel = diff / MS2SEC( USERCMD_MSEC );
turnAmount = diff; turnAmount = diff;
} }
current_yaw += turnAmount; current_yaw += turnAmount;
@ -2426,9 +2426,9 @@ void idAI::Turn( void ) {
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
const idVec3 &org = physicsObj.GetOrigin(); const idVec3 &org = physicsObj.GetOrigin();
gameRenderWorld->DebugLine( colorRed, org, org + idAngles( 0, ideal_yaw, 0 ).ToForward() * 64, gameLocal.msec ); gameRenderWorld->DebugLine( colorRed, org, org + idAngles( 0, ideal_yaw, 0 ).ToForward() * 64, USERCMD_MSEC );
gameRenderWorld->DebugLine( colorGreen, org, org + idAngles( 0, current_yaw, 0 ).ToForward() * 48, gameLocal.msec ); gameRenderWorld->DebugLine( colorGreen, org, org + idAngles( 0, current_yaw, 0 ).ToForward() * 48, USERCMD_MSEC );
gameRenderWorld->DebugLine( colorYellow, org, org + idAngles( 0, current_yaw + turnVel, 0 ).ToForward() * 32, gameLocal.msec ); gameRenderWorld->DebugLine( colorYellow, org, org + idAngles( 0, current_yaw + turnVel, 0 ).ToForward() * 32, USERCMD_MSEC );
} }
} }
@ -2516,7 +2516,7 @@ void idAI::GetMoveDelta( const idMat3 &oldaxis, const idMat3 &axis, idVec3 &delt
idVec3 oldModelOrigin; idVec3 oldModelOrigin;
idVec3 modelOrigin; idVec3 modelOrigin;
animator.GetDelta( gameLocal.time - gameLocal.msec, gameLocal.time, delta ); animator.GetDelta( gameLocal.time - USERCMD_MSEC, gameLocal.time, delta );
delta = axis * delta; delta = axis * delta;
if ( modelOffset != vec3_zero ) { if ( modelOffset != vec3_zero ) {
@ -2555,8 +2555,8 @@ void idAI::CheckObstacleAvoidance( const idVec3 &goalPos, idVec3 &newPos ) {
AI_OBSTACLE_IN_PATH = false; AI_OBSTACLE_IN_PATH = false;
foundPath = FindPathAroundObstacles( &physicsObj, aas, enemy.GetEntity(), origin, goalPos, path ); foundPath = FindPathAroundObstacles( &physicsObj, aas, enemy.GetEntity(), origin, goalPos, path );
if ( ai_showObstacleAvoidance.GetBool() ) { if ( ai_showObstacleAvoidance.GetBool() ) {
gameRenderWorld->DebugLine( colorBlue, goalPos + idVec3( 1.0f, 1.0f, 0.0f ), goalPos + idVec3( 1.0f, 1.0f, 64.0f ), gameLocal.msec ); gameRenderWorld->DebugLine( colorBlue, goalPos + idVec3( 1.0f, 1.0f, 0.0f ), goalPos + idVec3( 1.0f, 1.0f, 64.0f ), USERCMD_MSEC );
gameRenderWorld->DebugLine( foundPath ? colorYellow : colorRed, path.seekPos, path.seekPos + idVec3( 0.0f, 0.0f, 64.0f ), gameLocal.msec ); gameRenderWorld->DebugLine( foundPath ? colorYellow : colorRed, path.seekPos, path.seekPos + idVec3( 0.0f, 0.0f, 64.0f ), USERCMD_MSEC );
} }
if ( !foundPath ) { if ( !foundPath ) {
@ -2730,9 +2730,9 @@ void idAI::AnimMove( void ) {
} }
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, gameLocal.msec ); gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, USERCMD_MSEC );
gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, gameLocal.msec ); gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, USERCMD_MSEC );
gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, gameLocal.msec, true ); gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, USERCMD_MSEC, true );
DrawRoute(); DrawRoute();
} }
} }
@ -2750,7 +2750,7 @@ idVec3 Seek( idVec3 &vel, const idVec3 &org, const idVec3 &goal, float predictio
// predict our position // predict our position
predictedPos = org + vel * prediction; predictedPos = org + vel * prediction;
goalDelta = goal - predictedPos; goalDelta = goal - predictedPos;
seekVel = goalDelta * MS2SEC( gameLocal.msec ); seekVel = goalDelta * MS2SEC( USERCMD_MSEC );
return seekVel; return seekVel;
} }
@ -2812,8 +2812,8 @@ void idAI::SlideMove( void ) {
// seek the goal position // seek the goal position
goalDelta = goalPos - predictedPos; goalDelta = goalPos - predictedPos;
vel -= vel * AI_FLY_DAMPENING * MS2SEC( gameLocal.msec ); vel -= vel * AI_FLY_DAMPENING * MS2SEC( USERCMD_MSEC );
vel += goalDelta * MS2SEC( gameLocal.msec ); vel += goalDelta * MS2SEC( USERCMD_MSEC );
// cap our speed // cap our speed
vel.Truncate( fly_speed ); vel.Truncate( fly_speed );
@ -2856,9 +2856,9 @@ void idAI::SlideMove( void ) {
} }
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, gameLocal.msec ); gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, USERCMD_MSEC );
gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, gameLocal.msec ); gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, USERCMD_MSEC );
gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, gameLocal.msec, true ); gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, USERCMD_MSEC, true );
DrawRoute(); DrawRoute();
} }
} }
@ -2918,7 +2918,7 @@ void idAI::AddFlyBob( idVec3 &vel ) {
if ( fly_bob_strength ) { if ( fly_bob_strength ) {
t = MS2SEC( gameLocal.time + entityNumber * 497 ); t = MS2SEC( gameLocal.time + entityNumber * 497 );
fly_bob_add = ( viewAxis[ 1 ] * idMath::Sin16( t * fly_bob_horz ) + viewAxis[ 2 ] * idMath::Sin16( t * fly_bob_vert ) ) * fly_bob_strength; fly_bob_add = ( viewAxis[ 1 ] * idMath::Sin16( t * fly_bob_horz ) + viewAxis[ 2 ] * idMath::Sin16( t * fly_bob_vert ) ) * fly_bob_strength;
vel += fly_bob_add * MS2SEC( gameLocal.msec ); vel += fly_bob_add * MS2SEC( USERCMD_MSEC );
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
const idVec3 &origin = physicsObj.GetOrigin(); const idVec3 &origin = physicsObj.GetOrigin();
gameRenderWorld->DebugArrow( colorOrange, origin, origin + fly_bob_add, 0 ); gameRenderWorld->DebugArrow( colorOrange, origin, origin + fly_bob_add, 0 );
@ -2953,7 +2953,7 @@ void idAI::AdjustFlyHeight( idVec3 &vel, const idVec3 &goalPos ) {
} }
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugBounds( goLower ? colorRed : colorGreen, physicsObj.GetBounds(), path.endPos, gameLocal.msec ); gameRenderWorld->DebugBounds( goLower ? colorRed : colorGreen, physicsObj.GetBounds(), path.endPos, USERCMD_MSEC );
} }
} }
@ -2997,11 +2997,11 @@ void idAI::AdjustFlySpeed( idVec3 &vel ) {
float speed; float speed;
// apply dampening // apply dampening
vel -= vel * AI_FLY_DAMPENING * MS2SEC( gameLocal.msec ); vel -= vel * AI_FLY_DAMPENING * MS2SEC( USERCMD_MSEC );
// gradually speed up/slow down to desired speed // gradually speed up/slow down to desired speed
speed = vel.Normalize(); speed = vel.Normalize();
speed += ( move.speed - speed ) * MS2SEC( gameLocal.msec ); speed += ( move.speed - speed ) * MS2SEC( USERCMD_MSEC );
if ( speed < 0.0f ) { if ( speed < 0.0f ) {
speed = 0.0f; speed = 0.0f;
} else if ( move.speed && ( speed > move.speed ) ) { } else if ( move.speed && ( speed > move.speed ) ) {
@ -3104,11 +3104,11 @@ void idAI::FlyMove( void ) {
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorCyan, oldorigin, physicsObj.GetOrigin(), 4000 ); gameRenderWorld->DebugLine( colorCyan, oldorigin, physicsObj.GetOrigin(), 4000 );
gameRenderWorld->DebugBounds( colorOrange, physicsObj.GetBounds(), org, gameLocal.msec ); gameRenderWorld->DebugBounds( colorOrange, physicsObj.GetBounds(), org, USERCMD_MSEC );
gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, gameLocal.msec ); gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, USERCMD_MSEC );
gameRenderWorld->DebugLine( colorRed, org, org + physicsObj.GetLinearVelocity(), gameLocal.msec, true ); gameRenderWorld->DebugLine( colorRed, org, org + physicsObj.GetLinearVelocity(), USERCMD_MSEC, true );
gameRenderWorld->DebugLine( colorBlue, org, goalPos, gameLocal.msec, true ); gameRenderWorld->DebugLine( colorBlue, org, goalPos, USERCMD_MSEC, true );
gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, gameLocal.msec, true ); gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, USERCMD_MSEC, true );
DrawRoute(); DrawRoute();
} }
} }
@ -3145,9 +3145,9 @@ void idAI::StaticMove( void ) {
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
const idVec3 &org = physicsObj.GetOrigin(); const idVec3 &org = physicsObj.GetOrigin();
gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, gameLocal.msec ); gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, USERCMD_MSEC );
gameRenderWorld->DebugLine( colorBlue, org, move.moveDest, gameLocal.msec, true ); gameRenderWorld->DebugLine( colorBlue, org, move.moveDest, USERCMD_MSEC, true );
gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, gameLocal.msec, true ); gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, USERCMD_MSEC, true );
} }
} }
@ -3809,8 +3809,8 @@ void idAI::UpdateEnemyPosition( void ) {
} }
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugBounds( colorLtGrey, enemyEnt->GetPhysics()->GetBounds(), lastReachableEnemyPos, gameLocal.msec ); gameRenderWorld->DebugBounds( colorLtGrey, enemyEnt->GetPhysics()->GetBounds(), lastReachableEnemyPos, USERCMD_MSEC );
gameRenderWorld->DebugBounds( colorWhite, enemyEnt->GetPhysics()->GetBounds(), lastVisibleReachableEnemyPos, gameLocal.msec ); gameRenderWorld->DebugBounds( colorWhite, enemyEnt->GetPhysics()->GetBounds(), lastVisibleReachableEnemyPos, USERCMD_MSEC );
} }
} }
@ -4294,7 +4294,7 @@ bool idAI::TestMelee( void ) const {
enemyBounds.TranslateSelf( enemyOrg ); enemyBounds.TranslateSelf( enemyOrg );
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugBounds( colorYellow, bounds, vec3_zero, gameLocal.msec ); gameRenderWorld->DebugBounds( colorYellow, bounds, vec3_zero, USERCMD_MSEC );
} }
if ( !bounds.IntersectsBounds( enemyBounds ) ) { if ( !bounds.IntersectsBounds( enemyBounds ) ) {
@ -4746,7 +4746,7 @@ bool idAI::UpdateAnimationControllers( void ) {
} }
eyeOffset.z = eyepos.z - physicsObj.GetOrigin().z; eyeOffset.z = eyepos.z - physicsObj.GetOrigin().z;
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorRed, eyepos, eyepos + orientationJointAxis[ 0 ] * 32.0f, gameLocal.msec ); gameRenderWorld->DebugLine( colorRed, eyepos, eyepos + orientationJointAxis[ 0 ] * 32.0f, USERCMD_MSEC );
} }
} else { } else {
eyepos = GetEyePosition(); eyepos = GetEyePosition();
@ -4788,9 +4788,9 @@ bool idAI::UpdateAnimationControllers( void ) {
newLookAng.pitch = 0.0f; newLookAng.pitch = 0.0f;
#if 0 #if 0
gameRenderWorld->DebugLine( colorRed, orientationJointPos, focusPos, gameLocal.msec ); gameRenderWorld->DebugLine( colorRed, orientationJointPos, focusPos, USERCMD_MSEC );
gameRenderWorld->DebugLine( colorYellow, orientationJointPos, orientationJointPos + orientationJointAxis[ 0 ] * 32.0f, gameLocal.msec ); gameRenderWorld->DebugLine( colorYellow, orientationJointPos, orientationJointPos + orientationJointAxis[ 0 ] * 32.0f, USERCMD_MSEC );
gameRenderWorld->DebugLine( colorGreen, orientationJointPos, orientationJointPos + newLookAng.ToForward() * 48.0f, gameLocal.msec ); gameRenderWorld->DebugLine( colorGreen, orientationJointPos, orientationJointPos + newLookAng.ToForward() * 48.0f, USERCMD_MSEC );
#endif #endif
// determine pitch from joint position // determine pitch from joint position
@ -5031,12 +5031,12 @@ void idCombatNode::DrawDebugInfo( void ) {
idVec3 pos3 = org + rightDir * node->min_dist; idVec3 pos3 = org + rightDir * node->min_dist;
idVec3 pos4 = org + rightDir * cone_dist; idVec3 pos4 = org + rightDir * cone_dist;
gameRenderWorld->DebugLine( color, node->GetPhysics()->GetOrigin(), ( pos1 + pos3 ) * 0.5f, gameLocal.msec ); gameRenderWorld->DebugLine( color, node->GetPhysics()->GetOrigin(), ( pos1 + pos3 ) * 0.5f, USERCMD_MSEC );
gameRenderWorld->DebugLine( color, pos1, pos2, gameLocal.msec ); gameRenderWorld->DebugLine( color, pos1, pos2, USERCMD_MSEC );
gameRenderWorld->DebugLine( color, pos1, pos3, gameLocal.msec ); gameRenderWorld->DebugLine( color, pos1, pos3, USERCMD_MSEC );
gameRenderWorld->DebugLine( color, pos3, pos4, gameLocal.msec ); gameRenderWorld->DebugLine( color, pos3, pos4, USERCMD_MSEC );
gameRenderWorld->DebugLine( color, pos2, pos4, gameLocal.msec ); gameRenderWorld->DebugLine( color, pos2, pos4, USERCMD_MSEC );
gameRenderWorld->DebugBounds( color, bounds, org, gameLocal.msec ); gameRenderWorld->DebugBounds( color, bounds, org, USERCMD_MSEC );
} }
} }
} }

View file

@ -750,7 +750,7 @@ void idAI::Event_MeleeAttackToJoint( const char *jointname, const char *meleeDef
start = GetEyePosition(); start = GetEyePosition();
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorYellow, start, end, gameLocal.msec ); gameRenderWorld->DebugLine( colorYellow, start, end, USERCMD_MSEC );
} }
gameLocal.clip.TranslationEntities( trace, start, end, NULL, mat3_identity, MASK_SHOT_BOUNDINGBOX, this ); gameLocal.clip.TranslationEntities( trace, start, end, NULL, mat3_identity, MASK_SHOT_BOUNDINGBOX, this );
@ -1665,8 +1665,8 @@ void idAI::Event_TestChargeAttack( void ) {
idAI::PredictPath( this, aas, physicsObj.GetOrigin(), end - physicsObj.GetOrigin(), 1000, 1000, ( move.moveType == MOVETYPE_FLY ) ? SE_BLOCKED : ( SE_ENTER_OBSTACLE | SE_BLOCKED | SE_ENTER_LEDGE_AREA ), path ); idAI::PredictPath( this, aas, physicsObj.GetOrigin(), end - physicsObj.GetOrigin(), 1000, 1000, ( move.moveType == MOVETYPE_FLY ) ? SE_BLOCKED : ( SE_ENTER_OBSTACLE | SE_BLOCKED | SE_ENTER_LEDGE_AREA ), path );
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), end, gameLocal.msec ); gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), end, USERCMD_MSEC );
gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), end, gameLocal.msec ); gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), end, USERCMD_MSEC );
} }
if ( ( path.endEvent == 0 ) || ( path.blockingEntity == enemyEnt ) ) { if ( ( path.endEvent == 0 ) || ( path.blockingEntity == enemyEnt ) ) {
@ -1711,8 +1711,8 @@ void idAI::Event_TestAnimMoveTowardEnemy( const char *animname ) {
idAI::PredictPath( this, aas, physicsObj.GetOrigin(), moveVec, 1000, 1000, ( move.moveType == MOVETYPE_FLY ) ? SE_BLOCKED : ( SE_ENTER_OBSTACLE | SE_BLOCKED | SE_ENTER_LEDGE_AREA ), path ); idAI::PredictPath( this, aas, physicsObj.GetOrigin(), moveVec, 1000, 1000, ( move.moveType == MOVETYPE_FLY ) ? SE_BLOCKED : ( SE_ENTER_OBSTACLE | SE_BLOCKED | SE_ENTER_LEDGE_AREA ), path );
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), physicsObj.GetOrigin() + moveVec, gameLocal.msec ); gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), physicsObj.GetOrigin() + moveVec, USERCMD_MSEC );
gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), physicsObj.GetOrigin() + moveVec, gameLocal.msec ); gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), physicsObj.GetOrigin() + moveVec, USERCMD_MSEC );
} }
idThread::ReturnInt( path.endEvent == 0 ); idThread::ReturnInt( path.endEvent == 0 );
@ -1739,8 +1739,8 @@ void idAI::Event_TestAnimMove( const char *animname ) {
idAI::PredictPath( this, aas, physicsObj.GetOrigin(), moveVec, 1000, 1000, ( move.moveType == MOVETYPE_FLY ) ? SE_BLOCKED : ( SE_ENTER_OBSTACLE | SE_BLOCKED | SE_ENTER_LEDGE_AREA ), path ); idAI::PredictPath( this, aas, physicsObj.GetOrigin(), moveVec, 1000, 1000, ( move.moveType == MOVETYPE_FLY ) ? SE_BLOCKED : ( SE_ENTER_OBSTACLE | SE_BLOCKED | SE_ENTER_LEDGE_AREA ), path );
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), physicsObj.GetOrigin() + moveVec, gameLocal.msec ); gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), physicsObj.GetOrigin() + moveVec, USERCMD_MSEC );
gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), physicsObj.GetOrigin() + moveVec, gameLocal.msec ); gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), physicsObj.GetOrigin() + moveVec, USERCMD_MSEC );
} }
idThread::ReturnInt( path.endEvent == 0 ); idThread::ReturnInt( path.endEvent == 0 );
@ -1757,10 +1757,10 @@ void idAI::Event_TestMoveToPosition( const idVec3 &position ) {
idAI::PredictPath( this, aas, physicsObj.GetOrigin(), position - physicsObj.GetOrigin(), 1000, 1000, ( move.moveType == MOVETYPE_FLY ) ? SE_BLOCKED : ( SE_ENTER_OBSTACLE | SE_BLOCKED | SE_ENTER_LEDGE_AREA ), path ); idAI::PredictPath( this, aas, physicsObj.GetOrigin(), position - physicsObj.GetOrigin(), 1000, 1000, ( move.moveType == MOVETYPE_FLY ) ? SE_BLOCKED : ( SE_ENTER_OBSTACLE | SE_BLOCKED | SE_ENTER_LEDGE_AREA ), path );
if ( ai_debugMove.GetBool() ) { if ( ai_debugMove.GetBool() ) {
gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), position, gameLocal.msec ); gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), position, USERCMD_MSEC );
gameRenderWorld->DebugBounds( colorYellow, physicsObj.GetBounds(), position, gameLocal.msec ); gameRenderWorld->DebugBounds( colorYellow, physicsObj.GetBounds(), position, USERCMD_MSEC );
if ( path.endEvent ) { if ( path.endEvent ) {
gameRenderWorld->DebugBounds( colorRed, physicsObj.GetBounds(), path.endPos, gameLocal.msec ); gameRenderWorld->DebugBounds( colorRed, physicsObj.GetBounds(), path.endPos, USERCMD_MSEC );
} }
} }

View file

@ -88,7 +88,7 @@ void idDebugGraph::Draw( const idVec4 &color, float scale ) const {
vec1 = pos + axis[ 2 ] * value1 - axis[ 1 ] * ( i - 1 ) + axis[ 0 ] * samples.Num(); vec1 = pos + axis[ 2 ] * value1 - axis[ 1 ] * ( i - 1 ) + axis[ 0 ] * samples.Num();
vec2 = pos + axis[ 2 ] * value2 - axis[ 1 ] * i + axis[ 0 ] * samples.Num(); vec2 = pos + axis[ 2 ] * value2 - axis[ 1 ] * i + axis[ 0 ] * samples.Num();
gameRenderWorld->DebugLine( color, vec1, vec2, gameLocal.msec, false ); gameRenderWorld->DebugLine( color, vec1, vec2, USERCMD_MSEC, false );
value1 = value2; value1 = value2;
} }
} }

View file

@ -33,6 +33,8 @@ If you have questions concerning this license or the applicable additional terms
#include "physics/Force_Drag.h" #include "physics/Force_Drag.h"
#include "renderer/RenderSystem.h"
CLASS_DECLARATION( idForce, idForce_Drag ) CLASS_DECLARATION( idForce, idForce_Drag )
END_CLASS END_CLASS
@ -139,9 +141,9 @@ void idForce_Drag::Evaluate( int time ) {
l2 = dir2.Normalize(); l2 = dir2.Normalize();
rotation.Set( centerOfMass, dir2.Cross( dir1 ), RAD2DEG( idMath::ACos( dir1 * dir2 ) ) ); rotation.Set( centerOfMass, dir2.Cross( dir1 ), RAD2DEG( idMath::ACos( dir1 * dir2 ) ) );
physics->SetAngularVelocity( rotation.ToAngularVelocity() / MS2SEC( USERCMD_MSEC ), id ); physics->SetAngularVelocity( rotation.ToAngularVelocity() / MS2SEC( 1000 / renderSystem->GetRefresh() ), id );
velocity = physics->GetLinearVelocity( id ) * damping + dir1 * ( ( l1 - l2 ) * ( 1.0f - damping ) / MS2SEC( USERCMD_MSEC ) ); velocity = physics->GetLinearVelocity( id ) * damping + dir1 * ( ( l1 - l2 ) * ( 1.0f - damping ) / MS2SEC( 1000 / renderSystem->GetRefresh() ) );
physics->SetLinearVelocity( velocity, id ); physics->SetLinearVelocity( velocity, id );
} }

View file

@ -669,7 +669,7 @@ bool idThread::Execute( void ) {
if ( waitingUntil > lastExecuteTime ) { if ( waitingUntil > lastExecuteTime ) {
PostEventMS( &EV_Thread_Execute, waitingUntil - lastExecuteTime ); PostEventMS( &EV_Thread_Execute, waitingUntil - lastExecuteTime );
} else if ( interpreter.MultiFrameEventInProgress() ) { } else if ( interpreter.MultiFrameEventInProgress() ) {
PostEventMS( &EV_Thread_Execute, gameLocal.msec ); PostEventMS( &EV_Thread_Execute, USERCMD_MSEC );
} }
} }
@ -910,7 +910,7 @@ void idThread::WaitFrame( void ) {
// manual control threads don't set waitingUntil so that they can be run again // manual control threads don't set waitingUntil so that they can be run again
// that frame if necessary. // that frame if necessary.
if ( !manualControl ) { if ( !manualControl ) {
waitingUntil = gameLocal.time + gameLocal.msec; waitingUntil = gameLocal.time + USERCMD_MSEC;
} }
} }
@ -1760,7 +1760,7 @@ idThread::Event_GetFrameTime
================ ================
*/ */
void idThread::Event_GetFrameTime( void ) { void idThread::Event_GetFrameTime( void ) {
idThread::ReturnFloat( MS2SEC( gameLocal.msec ) ); idThread::ReturnFloat( MS2SEC( USERCMD_MSEC ) );
} }
/* /*
@ -1769,7 +1769,7 @@ idThread::Event_GetTicsPerSecond
================ ================
*/ */
void idThread::Event_GetTicsPerSecond( void ) { void idThread::Event_GetTicsPerSecond( void ) {
idThread::ReturnFloat( USERCMD_HZ ); idThread::ReturnFloat( (float)renderSystem->GetRefresh() );
} }
/* /*

View file

@ -153,6 +153,7 @@ public:
virtual int GetScreenWidth( void ) const = 0; virtual int GetScreenWidth( void ) const = 0;
virtual int GetScreenHeight( void ) const = 0; virtual int GetScreenHeight( void ) const = 0;
virtual float GetFOV() const = 0; virtual float GetFOV() const = 0;
virtual int GetRefresh() const = 0;
// allocate a renderWorld to be used for drawing // allocate a renderWorld to be used for drawing
virtual idRenderWorld * AllocRenderWorld( void ) = 0; virtual idRenderWorld * AllocRenderWorld( void ) = 0;

View file

@ -1793,8 +1793,18 @@ int idRenderSystemLocal::GetScreenHeight( void ) const {
return glConfig.vidHeight; return glConfig.vidHeight;
} }
extern "C" Doom3Quest_GetFOV(); extern "C"
{
float Doom3Quest_GetFOV();
int Doom3Quest_GetRefresh();
}
float idRenderSystemLocal::GetFOV() const float idRenderSystemLocal::GetFOV() const
{ {
return Doom3Quest_GetFOV(); return Doom3Quest_GetFOV();
} }
int idRenderSystemLocal::GetRefresh() const
{
return Doom3Quest_GetRefresh();
}

View file

@ -687,6 +687,7 @@ public:
virtual int GetScreenWidth( void ) const; virtual int GetScreenWidth( void ) const;
virtual int GetScreenHeight( void ) const; virtual int GetScreenHeight( void ) const;
virtual float GetFOV() const; virtual float GetFOV() const;
virtual int GetRefresh() const;
virtual idRenderWorld * AllocRenderWorld( void ); virtual idRenderWorld * AllocRenderWorld( void );
virtual void FreeRenderWorld( idRenderWorld *rw ); virtual void FreeRenderWorld( idRenderWorld *rw );

View file

@ -31,6 +31,8 @@ If you have questions concerning this license or the applicable additional terms
#include "sound/snd_local.h" #include "sound/snd_local.h"
#include "renderer/RenderSystem.h"
#define USE_SOUND_CACHE_ALLOCATOR #define USE_SOUND_CACHE_ALLOCATOR
#ifdef USE_SOUND_CACHE_ALLOCATOR #ifdef USE_SOUND_CACHE_ALLOCATOR

View file

@ -43,6 +43,7 @@ If you have questions concerning this license or the applicable additional terms
#include "framework/UsercmdGen.h" #include "framework/UsercmdGen.h"
#include "sound/efxlib.h" #include "sound/efxlib.h"
#include "sound/sound.h" #include "sound/sound.h"
#include "renderer/RenderSystem.h"
// demo sound commands // demo sound commands
typedef enum { typedef enum {