Skip to content

Commit

Permalink
Fix timing issues. Fixes issue KozGit#113 and KozGit#27.
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlKenner committed Mar 9, 2017
1 parent 88c8327 commit 25b82b5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
22 changes: 19 additions & 3 deletions neo/framework/common_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ which should also be nicely contained.
*/
#define DEFAULT_FIXED_TIC "0"
#define DEFAULT_NO_SLEEP "0"
#define DEFAULT_NO_SLEEP "1"

idCVar com_deltaTimeClamp( "com_deltaTimeClamp", "50", CVAR_INTEGER, "don't process more than this time in a single frame" );

Expand Down Expand Up @@ -771,7 +771,7 @@ void idCommonLocal::Frame()


// debug cvar to force multiple game tics
if( com_fixedTic.GetInteger() > 0 )
if( com_fixedTic.GetInteger() > 0 && timescale.GetFloat() == 1.0f ) // Carl: Don't fix tics if we're in slow motion mode
{
numGameFrames = com_fixedTic.GetInteger();
gameFrame += numGameFrames;
Expand Down Expand Up @@ -806,11 +806,14 @@ void idCommonLocal::Frame()

if( numGameFrames > 0 )
{
// Leyland's debt forgiveness code. For me, it just makes things worse.
#if 0
// debt forgiveness
if( gameTimeResidual < frameDelay/4.0f )
{
gameTimeResidual = 0;
}
#endif

// ready to actually run them
break;
Expand All @@ -819,14 +822,27 @@ void idCommonLocal::Frame()
// if we are vsyncing, we always want to run at least one game
// frame and never sleep, which might happen due to scheduling issues
// if we were just looking at real time.
if( com_noSleep.GetBool() )
// Carl: Unless we're in slow-motion mode (timescale).
if( com_noSleep.GetBool() && timescale.GetFloat() == 1.0f )
{
numGameFrames = 1;
gameFrame += numGameFrames;
gameTimeResidual = 0;
break;
}

// Carl: if we're in slow motion mode (timescale)
// always run at least one drawing frame even if there's no game frame
// Unfortunately, these frames have bad headtracking, so I disabled it.
#if 0
if( com_noSleep.GetBool() && timescale.GetFloat() < 1.0f )
{
numGameFrames = 0;
gameFrame++;
break;
}
#endif

// not enough time has passed to run a frame, as might happen if
// we don't have vsync on, or the monitor is running at 120hz while
// com_engineHz is 60, so sleep a bit and check again
Expand Down
4 changes: 2 additions & 2 deletions neo/vr/Vr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ bool iVr::OculusInit( void )
ovr_RecenterTrackingOrigin( hmdSession );
hmdWidth = hmdDesc.Resolution.w;
hmdHeight = hmdDesc.Resolution.h;
hmdHz = hmdDesc.DisplayRefreshRate;
hmdHz = hmdDesc.DisplayRefreshRate + 0.5f; // Carl: This was 89 because we were rounding down when converting to int
com_engineHz.SetInteger( hmdHz );
common->Printf( "Hmd: %s .\n", hmdDesc.ProductName );
common->Printf( "Hmd HZ %d, width %d, height %d\n", hmdHz, hmdWidth, hmdHeight );
Expand Down Expand Up @@ -670,7 +670,7 @@ bool iVr::OpenVRInit(void)
// get this here so we have a resolution starting point for gl initialization.
m_pHMD->GetRecommendedRenderTargetSize( &hmdWidth, &hmdHeight );

commonVr->hmdHz = (int)m_pHMD->GetFloatTrackedDeviceProperty( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_DisplayFrequency_Float );
commonVr->hmdHz = (int)(m_pHMD->GetFloatTrackedDeviceProperty( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_DisplayFrequency_Float ) + 0.5f);

officialIPD = m_pHMD->GetFloatTrackedDeviceProperty( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_UserIpdMeters_Float ) * 100;

Expand Down
2 changes: 2 additions & 0 deletions vr_assets/Fully Possessed/vr_oculus_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ bind "SAY_SOUL_CUBE" "_impulse12"
bind "SAY_ARTIFACT" "_impulse12"
bind "SAY_RESET_VIEW" "_impulse32"
set com_skipIntroVideos "1"
set com_fixedTic "0"
set com_noSleep "1"
set com_engineHz "90"
set net_inviteOnly "1"
set vr_showWIP "0"
Expand Down
2 changes: 2 additions & 0 deletions vr_assets/Fully Possessed/vr_openvr_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ bind "SAY_SOUL_CUBE" "_impulse12"
bind "SAY_ARTIFACT" "_impulse12"
bind "SAY_RESET_VIEW" "_impulse32"
set com_skipIntroVideos "1"
set com_fixedTic "0"
set com_noSleep "1"
set com_engineHz "90"
set net_inviteOnly "1"
set vr_showWIP "0"
Expand Down

0 comments on commit 25b82b5

Please sign in to comment.