From 70c4e8193801bb79a1f7e47288e9924e5e733a67 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 16 Oct 2020 20:45:26 +0100 Subject: [PATCH] Allow headset to dictate refresh rate for game --- .../jni/Doom3Quest/Doom3Quest_SurfaceView.c | 16 +++- Projects/Android/jni/Doom3Quest/VrCommon.h | 2 + .../Android/jni/Doom3Quest/VrInputDefault.c | 3 +- .../neo/framework/UsercmdGen.cpp | 2 + .../neo/framework/UsercmdGen.h | 6 +- .../neo/game/AFEntity.cpp | 6 +- .../neo/game/Camera.cpp | 12 +-- .../neo/game/Entity.cpp | 2 +- .../neo/game/Game_local.cpp | 6 +- .../neo/game/Game_local.h | 4 +- .../neo/game/Game_network.cpp | 4 +- .../neo/game/Moveable.cpp | 4 +- .../neo/game/Player.cpp | 6 +- .../neo/game/Projectile.cpp | 2 +- .../neo/game/Target.cpp | 2 +- .../neo/game/ai/AI.cpp | 96 +++++++++---------- .../neo/game/ai/AI_events.cpp | 20 ++-- .../neo/game/gamesys/DebugGraph.cpp | 2 +- .../neo/game/physics/Force_Drag.cpp | 6 +- .../neo/game/script/Script_Thread.cpp | 8 +- .../neo/renderer/RenderSystem.h | 1 + .../neo/renderer/RenderSystem_init.cpp | 12 ++- .../neo/renderer/tr_local.h | 1 + .../neo/sound/snd_cache.cpp | 2 + .../neo/sound/snd_local.h | 1 + 25 files changed, 127 insertions(+), 99 deletions(-) diff --git a/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c b/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c index ed20a41..bd472a0 100644 --- a/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c +++ b/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c @@ -1051,13 +1051,16 @@ static bool destroyed = false; 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; } +int Doom3Quest_GetRefresh() +{ + return Doom3Quest_initialised ? vrapi_GetSystemPropertyInt(&gAppState.Java, VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE) : 60; +} + static void ovrApp_HandleVrModeChanges( ovrApp * app ) { if ( app->Resumed != false && app->NativeWindow != NULL ) @@ -1585,8 +1588,11 @@ void * AppThreadFunction(void * parm ) { // Create the scene if not yet created. ovrScene_Create( m_width, m_height, &gAppState.Scene, &java ); - //Set the screen refresh - vrapi_SetDisplayRefreshRate(gAppState.Ovr, DISPLAY_REFRESH); + //Set the screen refresh - only for Quest 1 + bool quest1 = false; + if (quest1) { + vrapi_SetDisplayRefreshRate(gAppState.Ovr, DISPLAY_REFRESH); + } //Run loading loop until we are ready to start QzDoom while (!destroyed && !Doom3Quest_initialised) { diff --git a/Projects/Android/jni/Doom3Quest/VrCommon.h b/Projects/Android/jni/Doom3Quest/VrCommon.h index 4395960..5412007 100644 --- a/Projects/Android/jni/Doom3Quest/VrCommon.h +++ b/Projects/Android/jni/Doom3Quest/VrCommon.h @@ -66,6 +66,8 @@ void controlMouse(ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemo //Called from engine code +int Doom3Quest_GetRefresh(); + bool Doom3Quest_useScreenLayer(); void Doom3Quest_GetScreenRes(int *width, int *height); diff --git a/Projects/Android/jni/Doom3Quest/VrInputDefault.c b/Projects/Android/jni/Doom3Quest/VrInputDefault.c index 0b99988..8e40c79 100644 --- a/Projects/Android/jni/Doom3Quest/VrInputDefault.c +++ b/Projects/Android/jni/Doom3Quest/VrInputDefault.c @@ -59,7 +59,6 @@ extern bool inMenu; extern bool inGameGuiActive; extern bool objectiveSystemActive; extern bool inCinematic; -const int USERCMD_HZ = 60; 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) static float lastSampleTime = 0; 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; //This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the diff --git a/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.cpp b/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.cpp index 5d264e9..24c820e 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.cpp @@ -35,6 +35,8 @@ If you have questions concerning this license or the applicable additional terms #include "framework/UsercmdGen.h" +#include "renderer/RenderSystem.h" + /* ================ usercmd_t::ByteSwap diff --git a/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.h b/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.h index ef650a2..6b5495b 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.h @@ -37,8 +37,10 @@ If you have questions concerning this license or the applicable additional terms =============================================================================== */ -const int USERCMD_HZ = 60; -const int USERCMD_MSEC = 1000 / USERCMD_HZ; +//const int USERCMD_HZ = 60; +//const int USERCMD_MSEC = 1000 / USERCMD_HZ; + +#define USERCMD_MSEC (1000 / (renderSystem ? renderSystem->GetRefresh() : 60)) // usercmd_t->button bits const int BUTTON_ATTACK = BIT(0); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/AFEntity.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/AFEntity.cpp index 17e507b..141138b 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/AFEntity.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/AFEntity.cpp @@ -1860,7 +1860,7 @@ void idAFEntity_VehicleSimple::Think( void ) { origin = suspension[i]->GetWheelOrigin(); 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 wheelRotation.SetAngle( RAD2DEG( wheelAngles[i] ) ); @@ -2052,7 +2052,7 @@ void idAFEntity_VehicleFourWheels::Think( void ) { if ( force == 0.0f ) { 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 rotation.SetAngle( RAD2DEG( wheelAngles[i] ) ); axis = af.GetPhysics()->GetAxis( 0 ); @@ -2242,7 +2242,7 @@ void idAFEntity_VehicleSixWheels::Think( void ) { if ( force == 0.0f ) { 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 rotation.SetAngle( RAD2DEG( wheelAngles[i] ) ); axis = af.GetPhysics()->GetAxis( 0 ); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Camera.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Camera.cpp index eddef37..982d4fa 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Camera.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Camera.cpp @@ -514,9 +514,9 @@ void idCameraAnim::Think( void ) { return; } - if ( frameRate == USERCMD_HZ ) { + if ( frameRate == renderSystem->GetRefresh() ) { frameTime = gameLocal.time - starttime; - frame = frameTime / gameLocal.msec; + frame = frameTime / USERCMD_MSEC; } else { frameTime = ( gameLocal.time - starttime ) * frameRate; frame = frameTime / 1000; @@ -564,9 +564,9 @@ void idCameraAnim::GetViewParms( renderView_t *view ) { return; } - if ( frameRate == USERCMD_HZ ) { + if ( frameRate == renderSystem->GetRefresh() ) { frameTime = gameLocal.time - starttime; - frame = frameTime / gameLocal.msec; + frame = frameTime / USERCMD_MSEC; lerp = 0.0f; } else { frameTime = ( gameLocal.time - starttime ) * frameRate; @@ -586,7 +586,7 @@ void idCameraAnim::GetViewParms( renderView_t *view ) { } 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 prevCut; @@ -659,7 +659,7 @@ void idCameraAnim::GetViewParms( renderView_t *view ) { static int lastFrame = 0; static idVec3 lastFrameVec( 0.0f, 0.0f, 0.0f ); 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( 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 ); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Entity.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Entity.cpp index 8ae5f13..af9b548 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Entity.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Entity.cpp @@ -481,7 +481,7 @@ void idEntity::Spawn( void ) { renderEntity.entityNum = entityNumber; // 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; axis = renderEntity.axis; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Game_local.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Game_local.cpp index dd018b9..f72576a 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Game_local.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Game_local.cpp @@ -2218,7 +2218,7 @@ gameReturn_t idGameLocal::RunFrame( const usercmd_t *clientCmds ) { // update the game time framenum++; previousTime = time; - time += msec; + time += USERCMD_MSEC; realClientTime = time; #ifdef GAME_DLL @@ -3553,7 +3553,7 @@ idGameLocal::AlertAI void idGameLocal::AlertAI( idEntity *ent ) { if ( ent && ent->IsType( idActor::Type ) ) { // alert them for the next frame - lastAIAlertTime = time + msec; + lastAIAlertTime = time + USERCMD_MSEC; lastAIAlertEntity = static_cast( ent ); } } @@ -3958,7 +3958,7 @@ void idGameLocal::SetCamera( idCamera *cam ) { } else { inCinematic = false; - cinematicStopTime = time + msec; + cinematicStopTime = time + USERCMD_MSEC; // restore r_znear cvarSystem->SetCVarFloat( "r_znear", 3.0f ); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Game_local.h b/Projects/Android/jni/d3es-multithread-master/neo/game/Game_local.h index 6c6d4e0..8472d97 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Game_local.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Game_local.h @@ -274,7 +274,7 @@ public: int framenum; int previousTime; // time in msec of last frame 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 @@ -426,7 +426,7 @@ public: // added the following to assist licensees with merge issues int GetFrameNum() const { return framenum; }; int GetTime() const { return time; }; - int GetMSec() const { return msec; }; + int GetMSec() const { return USERCMD_MSEC; }; int GetNextClientNum( int current ) const; idPlayer * GetClientByNum( int current ) const; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Game_network.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Game_network.cpp index c26d906..a4e2d53 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Game_network.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Game_network.cpp @@ -994,7 +994,7 @@ void idGameLocal::ClientReadSnapshot( int clientNum, int sequence, const int gam // update the game time framenum = gameFrame; time = gameTime; - previousTime = time - msec; + previousTime = time - USERCMD_MSEC; // so that StartSound/StopSound doesn't risk skipping isNewFrame = true; @@ -1492,7 +1492,7 @@ gameReturn_t idGameLocal::ClientPrediction( int clientNum, const usercmd_t *clie // update the game time framenum++; previousTime = time; - time += msec; + time += USERCMD_MSEC; // update the real client time and the new frame flag if ( time > realClientTime ) { diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Moveable.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Moveable.cpp index e13ecd6..e3f7eb5 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Moveable.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Moveable.cpp @@ -392,14 +392,14 @@ bool idMoveable::FollowInitialSplinePath( void ) { if ( initialSpline != NULL ) { if ( gameLocal.time < initialSpline->GetTime( initialSpline->GetNumValues() - 1 ) ) { idVec3 splinePos = initialSpline->GetCurrentValue( gameLocal.time ); - idVec3 linearVelocity = ( splinePos - physicsObj.GetOrigin() ) * USERCMD_HZ; + idVec3 linearVelocity = ( splinePos - physicsObj.GetOrigin() ) * renderSystem->GetRefresh(); physicsObj.SetLinearVelocity( linearVelocity ); idVec3 splineDir = initialSpline->GetCurrentFirstDerivative( gameLocal.time ); idVec3 dir = initialSplineDir * physicsObj.GetAxis(); idVec3 angularVelocity = dir.Cross( splineDir ); angularVelocity.Normalize(); - angularVelocity *= idMath::ACos16( dir * splineDir / splineDir.Length() ) * USERCMD_HZ; + angularVelocity *= idMath::ACos16( dir * splineDir / splineDir.Length() ) * renderSystem->GetRefresh(); physicsObj.SetAngularVelocity( angularVelocity ); return true; } else { diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp index 2efa27e..b8f5a3a 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp @@ -4930,7 +4930,7 @@ void idPlayer::BobCycle( const idVec3 &pushVelocity ) { // check for footstep / splash sounds old = bobCycle; - bobCycle = (int)( old + bobmove * gameLocal.msec ) & 255; + bobCycle = (int)( old + bobmove * USERCMD_MSEC ) & 255; bobFoot = ( bobCycle & 128 ) >> 7; bobfracsin = idMath::Fabs( sin( ( bobCycle & 127 ) / 127.0 * idMath::PI ) ); }*/ @@ -5883,7 +5883,7 @@ void idPlayer::AdjustSpeed( void ) { bobFrac = 0.0f; } else if ( !physicsObj.OnLadder() && ( usercmd.buttons & BUTTON_RUN ) && ( usercmd.forwardmove || usercmd.rightmove ) && ( usercmd.upmove >= 0 ) ) { if ( !gameLocal.isMultiplayer && !physicsObj.IsCrouching() && !PowerUpActive( ADRENALINE ) ) { - stamina -= MS2SEC( gameLocal.msec ); + stamina -= MS2SEC( USERCMD_MSEC ); } if ( stamina < 0 ) { stamina = 0; @@ -5904,7 +5904,7 @@ void idPlayer::AdjustSpeed( void ) { rate *= 1.25f; } - stamina += rate * MS2SEC( gameLocal.msec ); + stamina += rate * MS2SEC( USERCMD_MSEC ); if ( stamina > pm_stamina.GetFloat() ) { stamina = pm_stamina.GetFloat(); } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Projectile.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Projectile.cpp index c353ca0..b5680f3 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Projectile.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Projectile.cpp @@ -1430,7 +1430,7 @@ void idGuidedProjectile::Launch( const idVec3 &start, const idVec3 &dir, const i angles = vel.ToAngles(); speed = vel.Length(); 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" ); burstMode = spawnArgs.GetBool( "burstMode" ); unGuided = false; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Target.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Target.cpp index 1912a78..084ae29 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Target.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Target.cpp @@ -1330,7 +1330,7 @@ void idTarget_SetFov::Event_Activate( idEntity *activator ) { cinematic = true; 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 ); } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/ai/AI.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/ai/AI.cpp index 2ac9948..0f63e4b 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/ai/AI.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/ai/AI.cpp @@ -1143,7 +1143,7 @@ void idAI::Think( void ) { } /* this still draws in retail builds.. not sure why.. don't care at this point. 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(); 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() ); } @@ -1463,7 +1463,7 @@ float idAI::TravelDistance( const idVec3 &start, const idVec3 &end ) const { dist = delta.LengthFast(); 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() ); } @@ -2276,7 +2276,7 @@ bool idAI::GetMovePos( idVec3 &seekPos ) { seekPos = org + move.moveDir * 2048.0f; if ( ai_debugMove.GetBool() ) { - gameRenderWorld->DebugLine( colorYellow, org, seekPos, gameLocal.msec, true ); + gameRenderWorld->DebugLine( colorYellow, org, seekPos, USERCMD_MSEC, true ); } } else { AI_DEST_UNREACHABLE = false; @@ -2400,18 +2400,18 @@ void idAI::Turn( void ) { current_yaw = idMath::AngleNormalize180( anim_turn_yaw + rotateAxis[ 0 ].ToYaw() ); } else { 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 ) { turnVel = turnRate; } else if ( turnVel < -turnRate ) { turnVel = -turnRate; } - turnAmount = turnVel * MS2SEC( gameLocal.msec ); + turnAmount = turnVel * MS2SEC( USERCMD_MSEC ); if ( ( diff >= 0.0f ) && ( turnAmount >= diff ) ) { - turnVel = diff / MS2SEC( gameLocal.msec ); + turnVel = diff / MS2SEC( USERCMD_MSEC ); turnAmount = diff; } else if ( ( diff <= 0.0f ) && ( turnAmount <= diff ) ) { - turnVel = diff / MS2SEC( gameLocal.msec ); + turnVel = diff / MS2SEC( USERCMD_MSEC ); turnAmount = diff; } current_yaw += turnAmount; @@ -2426,9 +2426,9 @@ void idAI::Turn( void ) { if ( ai_debugMove.GetBool() ) { const idVec3 &org = physicsObj.GetOrigin(); - gameRenderWorld->DebugLine( colorRed, org, org + idAngles( 0, ideal_yaw, 0 ).ToForward() * 64, gameLocal.msec ); - gameRenderWorld->DebugLine( colorGreen, org, org + idAngles( 0, current_yaw, 0 ).ToForward() * 48, gameLocal.msec ); - gameRenderWorld->DebugLine( colorYellow, org, org + idAngles( 0, current_yaw + turnVel, 0 ).ToForward() * 32, 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, USERCMD_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 modelOrigin; - animator.GetDelta( gameLocal.time - gameLocal.msec, gameLocal.time, delta ); + animator.GetDelta( gameLocal.time - USERCMD_MSEC, gameLocal.time, delta ); delta = axis * delta; if ( modelOffset != vec3_zero ) { @@ -2555,8 +2555,8 @@ void idAI::CheckObstacleAvoidance( const idVec3 &goalPos, idVec3 &newPos ) { AI_OBSTACLE_IN_PATH = false; foundPath = FindPathAroundObstacles( &physicsObj, aas, enemy.GetEntity(), origin, goalPos, path ); 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( foundPath ? colorYellow : colorRed, path.seekPos, path.seekPos + idVec3( 0.0f, 0.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 ), USERCMD_MSEC ); } if ( !foundPath ) { @@ -2730,9 +2730,9 @@ void idAI::AnimMove( void ) { } if ( ai_debugMove.GetBool() ) { - gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, gameLocal.msec ); - gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, gameLocal.msec ); - gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, gameLocal.msec, true ); + gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, USERCMD_MSEC ); + gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, USERCMD_MSEC ); + gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, USERCMD_MSEC, true ); DrawRoute(); } } @@ -2750,7 +2750,7 @@ idVec3 Seek( idVec3 &vel, const idVec3 &org, const idVec3 &goal, float predictio // predict our position predictedPos = org + vel * prediction; goalDelta = goal - predictedPos; - seekVel = goalDelta * MS2SEC( gameLocal.msec ); + seekVel = goalDelta * MS2SEC( USERCMD_MSEC ); return seekVel; } @@ -2812,8 +2812,8 @@ void idAI::SlideMove( void ) { // seek the goal position goalDelta = goalPos - predictedPos; - vel -= vel * AI_FLY_DAMPENING * MS2SEC( gameLocal.msec ); - vel += goalDelta * MS2SEC( gameLocal.msec ); + vel -= vel * AI_FLY_DAMPENING * MS2SEC( USERCMD_MSEC ); + vel += goalDelta * MS2SEC( USERCMD_MSEC ); // cap our speed vel.Truncate( fly_speed ); @@ -2856,9 +2856,9 @@ void idAI::SlideMove( void ) { } if ( ai_debugMove.GetBool() ) { - gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, gameLocal.msec ); - gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, gameLocal.msec ); - gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, gameLocal.msec, true ); + gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, USERCMD_MSEC ); + gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, USERCMD_MSEC ); + gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, USERCMD_MSEC, true ); DrawRoute(); } } @@ -2918,7 +2918,7 @@ void idAI::AddFlyBob( idVec3 &vel ) { if ( fly_bob_strength ) { 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; - vel += fly_bob_add * MS2SEC( gameLocal.msec ); + vel += fly_bob_add * MS2SEC( USERCMD_MSEC ); if ( ai_debugMove.GetBool() ) { const idVec3 &origin = physicsObj.GetOrigin(); 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() ) { - 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; // 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 speed = vel.Normalize(); - speed += ( move.speed - speed ) * MS2SEC( gameLocal.msec ); + speed += ( move.speed - speed ) * MS2SEC( USERCMD_MSEC ); if ( speed < 0.0f ) { speed = 0.0f; } else if ( move.speed && ( speed > move.speed ) ) { @@ -3104,11 +3104,11 @@ void idAI::FlyMove( void ) { if ( ai_debugMove.GetBool() ) { gameRenderWorld->DebugLine( colorCyan, oldorigin, physicsObj.GetOrigin(), 4000 ); - gameRenderWorld->DebugBounds( colorOrange, physicsObj.GetBounds(), org, gameLocal.msec ); - gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, gameLocal.msec ); - gameRenderWorld->DebugLine( colorRed, org, org + physicsObj.GetLinearVelocity(), gameLocal.msec, true ); - gameRenderWorld->DebugLine( colorBlue, org, goalPos, gameLocal.msec, true ); - gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, gameLocal.msec, true ); + gameRenderWorld->DebugBounds( colorOrange, physicsObj.GetBounds(), org, USERCMD_MSEC ); + gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), move.moveDest, USERCMD_MSEC ); + gameRenderWorld->DebugLine( colorRed, org, org + physicsObj.GetLinearVelocity(), USERCMD_MSEC, true ); + gameRenderWorld->DebugLine( colorBlue, org, goalPos, USERCMD_MSEC, true ); + gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, USERCMD_MSEC, true ); DrawRoute(); } } @@ -3145,9 +3145,9 @@ void idAI::StaticMove( void ) { if ( ai_debugMove.GetBool() ) { const idVec3 &org = physicsObj.GetOrigin(); - gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, gameLocal.msec ); - gameRenderWorld->DebugLine( colorBlue, org, move.moveDest, gameLocal.msec, true ); - gameRenderWorld->DebugLine( colorYellow, org + EyeOffset(), org + EyeOffset() + viewAxis[ 0 ] * physicsObj.GetGravityAxis() * 16.0f, gameLocal.msec, true ); + gameRenderWorld->DebugBounds( colorMagenta, physicsObj.GetBounds(), org, USERCMD_MSEC ); + gameRenderWorld->DebugLine( colorBlue, org, move.moveDest, USERCMD_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() ) { - gameRenderWorld->DebugBounds( colorLtGrey, enemyEnt->GetPhysics()->GetBounds(), lastReachableEnemyPos, gameLocal.msec ); - gameRenderWorld->DebugBounds( colorWhite, enemyEnt->GetPhysics()->GetBounds(), lastVisibleReachableEnemyPos, gameLocal.msec ); + gameRenderWorld->DebugBounds( colorLtGrey, enemyEnt->GetPhysics()->GetBounds(), lastReachableEnemyPos, USERCMD_MSEC ); + gameRenderWorld->DebugBounds( colorWhite, enemyEnt->GetPhysics()->GetBounds(), lastVisibleReachableEnemyPos, USERCMD_MSEC ); } } @@ -4294,7 +4294,7 @@ bool idAI::TestMelee( void ) const { enemyBounds.TranslateSelf( enemyOrg ); if ( ai_debugMove.GetBool() ) { - gameRenderWorld->DebugBounds( colorYellow, bounds, vec3_zero, gameLocal.msec ); + gameRenderWorld->DebugBounds( colorYellow, bounds, vec3_zero, USERCMD_MSEC ); } if ( !bounds.IntersectsBounds( enemyBounds ) ) { @@ -4746,7 +4746,7 @@ bool idAI::UpdateAnimationControllers( void ) { } eyeOffset.z = eyepos.z - physicsObj.GetOrigin().z; 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 { eyepos = GetEyePosition(); @@ -4788,9 +4788,9 @@ bool idAI::UpdateAnimationControllers( void ) { newLookAng.pitch = 0.0f; #if 0 - gameRenderWorld->DebugLine( colorRed, orientationJointPos, focusPos, gameLocal.msec ); - gameRenderWorld->DebugLine( colorYellow, orientationJointPos, orientationJointPos + orientationJointAxis[ 0 ] * 32.0f, gameLocal.msec ); - gameRenderWorld->DebugLine( colorGreen, orientationJointPos, orientationJointPos + newLookAng.ToForward() * 48.0f, gameLocal.msec ); + gameRenderWorld->DebugLine( colorRed, orientationJointPos, focusPos, USERCMD_MSEC ); + gameRenderWorld->DebugLine( colorYellow, orientationJointPos, orientationJointPos + orientationJointAxis[ 0 ] * 32.0f, USERCMD_MSEC ); + gameRenderWorld->DebugLine( colorGreen, orientationJointPos, orientationJointPos + newLookAng.ToForward() * 48.0f, USERCMD_MSEC ); #endif // determine pitch from joint position @@ -5031,12 +5031,12 @@ void idCombatNode::DrawDebugInfo( void ) { idVec3 pos3 = org + rightDir * node->min_dist; idVec3 pos4 = org + rightDir * cone_dist; - gameRenderWorld->DebugLine( color, node->GetPhysics()->GetOrigin(), ( pos1 + pos3 ) * 0.5f, gameLocal.msec ); - gameRenderWorld->DebugLine( color, pos1, pos2, gameLocal.msec ); - gameRenderWorld->DebugLine( color, pos1, pos3, gameLocal.msec ); - gameRenderWorld->DebugLine( color, pos3, pos4, gameLocal.msec ); - gameRenderWorld->DebugLine( color, pos2, pos4, gameLocal.msec ); - gameRenderWorld->DebugBounds( color, bounds, org, gameLocal.msec ); + gameRenderWorld->DebugLine( color, node->GetPhysics()->GetOrigin(), ( pos1 + pos3 ) * 0.5f, USERCMD_MSEC ); + gameRenderWorld->DebugLine( color, pos1, pos2, USERCMD_MSEC ); + gameRenderWorld->DebugLine( color, pos1, pos3, USERCMD_MSEC ); + gameRenderWorld->DebugLine( color, pos3, pos4, USERCMD_MSEC ); + gameRenderWorld->DebugLine( color, pos2, pos4, USERCMD_MSEC ); + gameRenderWorld->DebugBounds( color, bounds, org, USERCMD_MSEC ); } } } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/ai/AI_events.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/ai/AI_events.cpp index 04d6687..3308086 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/ai/AI_events.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/ai/AI_events.cpp @@ -750,7 +750,7 @@ void idAI::Event_MeleeAttackToJoint( const char *jointname, const char *meleeDef start = GetEyePosition(); 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 ); @@ -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 ); if ( ai_debugMove.GetBool() ) { - gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), end, gameLocal.msec ); - gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), end, gameLocal.msec ); + gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), end, USERCMD_MSEC ); + gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), end, USERCMD_MSEC ); } 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 ); if ( ai_debugMove.GetBool() ) { - gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), physicsObj.GetOrigin() + moveVec, gameLocal.msec ); - gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), 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, USERCMD_MSEC ); } 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 ); if ( ai_debugMove.GetBool() ) { - gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), physicsObj.GetOrigin() + moveVec, gameLocal.msec ); - gameRenderWorld->DebugBounds( path.endEvent == 0 ? colorYellow : colorRed, physicsObj.GetBounds(), 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, USERCMD_MSEC ); } 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 ); if ( ai_debugMove.GetBool() ) { - gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), position, gameLocal.msec ); - gameRenderWorld->DebugBounds( colorYellow, physicsObj.GetBounds(), position, gameLocal.msec ); + gameRenderWorld->DebugLine( colorGreen, physicsObj.GetOrigin(), position, USERCMD_MSEC ); + gameRenderWorld->DebugBounds( colorYellow, physicsObj.GetBounds(), position, USERCMD_MSEC ); if ( path.endEvent ) { - gameRenderWorld->DebugBounds( colorRed, physicsObj.GetBounds(), path.endPos, gameLocal.msec ); + gameRenderWorld->DebugBounds( colorRed, physicsObj.GetBounds(), path.endPos, USERCMD_MSEC ); } } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/DebugGraph.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/DebugGraph.cpp index 4f98662..1b9e2cc 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/DebugGraph.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/DebugGraph.cpp @@ -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(); 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; } } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/physics/Force_Drag.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/physics/Force_Drag.cpp index f8682a1..f4d7164 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/physics/Force_Drag.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/physics/Force_Drag.cpp @@ -33,6 +33,8 @@ If you have questions concerning this license or the applicable additional terms #include "physics/Force_Drag.h" +#include "renderer/RenderSystem.h" + CLASS_DECLARATION( idForce, idForce_Drag ) END_CLASS @@ -139,9 +141,9 @@ void idForce_Drag::Evaluate( int time ) { l2 = dir2.Normalize(); 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 ); } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/script/Script_Thread.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/script/Script_Thread.cpp index 58daa5d..0e10685 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/script/Script_Thread.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/script/Script_Thread.cpp @@ -669,7 +669,7 @@ bool idThread::Execute( void ) { if ( waitingUntil > lastExecuteTime ) { PostEventMS( &EV_Thread_Execute, waitingUntil - lastExecuteTime ); } 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 // that frame if necessary. if ( !manualControl ) { - waitingUntil = gameLocal.time + gameLocal.msec; + waitingUntil = gameLocal.time + USERCMD_MSEC; } } @@ -1760,7 +1760,7 @@ idThread::Event_GetFrameTime ================ */ 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 ) { - idThread::ReturnFloat( USERCMD_HZ ); + idThread::ReturnFloat( (float)renderSystem->GetRefresh() ); } /* diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.h b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.h index c30c82c..71e3226 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.h @@ -153,6 +153,7 @@ public: virtual int GetScreenWidth( void ) const = 0; virtual int GetScreenHeight( void ) const = 0; virtual float GetFOV() const = 0; + virtual int GetRefresh() const = 0; // allocate a renderWorld to be used for drawing virtual idRenderWorld * AllocRenderWorld( void ) = 0; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem_init.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem_init.cpp index ad8f1d6..a60a28b 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem_init.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem_init.cpp @@ -1793,8 +1793,18 @@ int idRenderSystemLocal::GetScreenHeight( void ) const { return glConfig.vidHeight; } -extern "C" Doom3Quest_GetFOV(); +extern "C" +{ + float Doom3Quest_GetFOV(); + int Doom3Quest_GetRefresh(); +} + float idRenderSystemLocal::GetFOV() const { return Doom3Quest_GetFOV(); } + +int idRenderSystemLocal::GetRefresh() const +{ + return Doom3Quest_GetRefresh(); +} diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h index f99c7eb..ec56e5a 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h @@ -687,6 +687,7 @@ public: virtual int GetScreenWidth( void ) const; virtual int GetScreenHeight( void ) const; virtual float GetFOV() const; + virtual int GetRefresh() const; virtual idRenderWorld * AllocRenderWorld( void ); virtual void FreeRenderWorld( idRenderWorld *rw ); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/sound/snd_cache.cpp b/Projects/Android/jni/d3es-multithread-master/neo/sound/snd_cache.cpp index 1e44bfc..ed5d30c 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/sound/snd_cache.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/sound/snd_cache.cpp @@ -31,6 +31,8 @@ If you have questions concerning this license or the applicable additional terms #include "sound/snd_local.h" +#include "renderer/RenderSystem.h" + #define USE_SOUND_CACHE_ALLOCATOR #ifdef USE_SOUND_CACHE_ALLOCATOR diff --git a/Projects/Android/jni/d3es-multithread-master/neo/sound/snd_local.h b/Projects/Android/jni/d3es-multithread-master/neo/sound/snd_local.h index 3f80e86..b3c85ae 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/sound/snd_local.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/sound/snd_local.h @@ -43,6 +43,7 @@ If you have questions concerning this license or the applicable additional terms #include "framework/UsercmdGen.h" #include "sound/efxlib.h" #include "sound/sound.h" +#include "renderer/RenderSystem.h" // demo sound commands typedef enum {