diff --git a/Minecraft.Client/Common/App_Defines.h b/Minecraft.Client/Common/App_Defines.h index 28b02191..48c4ab79 100644 --- a/Minecraft.Client/Common/App_Defines.h +++ b/Minecraft.Client/Common/App_Defines.h @@ -100,6 +100,7 @@ enum EGameHostOptionWorldSize #define GAMESETTING_DISPLAYHAND 0x00000100 #define GAMESETTING_CUSTOMSKINANIM 0x00000200 #define GAMESETTING_DEATHMESSAGES 0x00000400 +#define GAMESETTING_PASSIVECHUNKLOADING 0x00040000 #define GAMESETTING_UISIZE 0x00001800 #define GAMESETTING_UISIZE_SPLITSCREEN 0x00006000 #define GAMESETTING_ANIMATEDCHARACTER 0x00008000 diff --git a/Minecraft.Client/Common/App_enums.h b/Minecraft.Client/Common/App_enums.h index 50ff0da0..77a324a6 100644 --- a/Minecraft.Client/Common/App_enums.h +++ b/Minecraft.Client/Common/App_enums.h @@ -193,6 +193,9 @@ enum eGameSetting eGameSetting_SafeCam, //safe cam is safe sprint eGameSetting_Swap, eGameSetting_GameChat, + + // custom + eGameSetting_PassiveChunkLoading, }; diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 890fd4c2..40310d75 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -1051,6 +1051,9 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con //TU34 SetGameSettings(iPad, eGameSetting_MinecartSounds, 1); + // custom + SetGameSettings(iPad, eGameSetting_PassiveChunkLoading, 0); + // 4J-PB - leave these in, or remove from everywhere they are referenced! // Although probably best to leave in unless we split the profile settings into platform specific classes - having different meaning per platform for the same bitmask could get confusing //#ifdef __PS3__ @@ -1516,6 +1519,9 @@ void CMinecraftApp::ApplyGameSettingsChanged(int iPad) ActionGameSettings(iPad, eGameSetting_HideSaveSizeBar); ActionGameSettings(iPad, eGameSetting_SafeCam); ActionGameSettings(iPad, eGameSetting_Swap); + + // custom + ActionGameSettings(iPad, eGameSetting_PassiveChunkLoading); } void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) @@ -1735,6 +1741,9 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) case eGameSetting_DeathMessages: //nothing to do here break; + case eGameSetting_PassiveChunkLoading: + //nothing to do here + break; case eGameSetting_UISize: //nothing to do here break; @@ -2449,6 +2458,21 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV GameSettingsA[iPad]->bSettingsChanged=true; } break; + case eGameSetting_PassiveChunkLoading: + if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PASSIVECHUNKLOADING)!=(ucVal&0x01)<<18) + { + if(ucVal==1) + { + GameSettingsA[iPad]->uiBitmaskValues|=GAMESETTING_PASSIVECHUNKLOADING; + } + else + { + GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_PASSIVECHUNKLOADING; + } + ActionGameSettings(iPad,eVal); + GameSettingsA[iPad]->bSettingsChanged=true; + } + break; case eGameSetting_UISize: if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE)!=((ucVal&0x03)<<11)) { @@ -2759,6 +2783,9 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal) case eGameSetting_DeathMessages: return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DEATHMESSAGES)>>10; break; + case eGameSetting_PassiveChunkLoading: + return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PASSIVECHUNKLOADING)>>18; + break; case eGameSetting_UISize: { unsigned char ucVal=(GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE)>>11; diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenu1080.swf deleted file mode 100644 index 7e731522..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenu1080.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenu720.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenu720.swf deleted file mode 100644 index 7e731522..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenu720.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenuSplit1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenuSplit1080.swf deleted file mode 100644 index 99d2251b..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenuSplit1080.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenuSplit720.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenuSplit720.swf deleted file mode 100644 index 99d2251b..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsAudioMenuSplit720.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenu1080.swf deleted file mode 100644 index 39fc0dd4..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenu1080.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenu720.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenu720.swf deleted file mode 100644 index 39fc0dd4..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenu720.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenuSplit1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenuSplit1080.swf deleted file mode 100644 index 0b3713ae..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenuSplit1080.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenuSplit720.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenuSplit720.swf deleted file mode 100644 index 0b3713ae..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsGraphicsMenuSplit720.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenu1080.swf deleted file mode 100644 index dfefaf46..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenu1080.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenu720.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenu720.swf deleted file mode 100644 index dfefaf46..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenu720.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenuSplit1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenuSplit1080.swf deleted file mode 100644 index cfceefcf..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenuSplit1080.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenuSplit720.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenuSplit720.swf deleted file mode 100644 index cfceefcf..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsOptionsMenuSplit720.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenu1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenu1080.swf deleted file mode 100644 index 78b8aa2c..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenu1080.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenu720.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenu720.swf deleted file mode 100644 index 78b8aa2c..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenu720.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenuSplit1080.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenuSplit1080.swf deleted file mode 100644 index 055f36e8..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenuSplit1080.swf and /dev/null differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenuSplit720.swf b/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenuSplit720.swf deleted file mode 100644 index 055f36e8..00000000 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/SettingsUIMenuSplit720.swf and /dev/null differ diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp index 97183a2d..d8a7c482 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.cpp @@ -84,6 +84,7 @@ void UIScene_SettingsOptionsMenu::tick() m_multiList.AddNewCheckbox(app.GetString(IDS_VIEW_BOBBING), eControl_ViewBob, (app.GetGameSettings(m_iPad,eGameSetting_ViewBob)!=0)); m_multiList.AddNewCheckbox(app.GetString(IDS_HINTS), eControl_Hints, (app.GetGameSettings(m_iPad,eGameSetting_Hints)!=0)); m_multiList.AddNewCheckbox(app.GetString(IDS_CHECKBOX_DEATH_MESSAGES), eControl_DeathMessages, (app.GetGameSettings(m_iPad,eGameSetting_DeathMessages)!=0)); + m_multiList.AddNewCheckbox(L"Passive chunk loading", eControl_PassiveChunkLoading, (app.GetGameSettings(m_iPad,eGameSetting_PassiveChunkLoading)!=0)); if(m_bNotInGame) { @@ -246,6 +247,7 @@ void UIScene_SettingsOptionsMenu::setGameSettings() app.SetGameSettings(m_iPad,eGameSetting_ViewBob,m_multiList.GetCheckboxValue(eControl_ViewBob)?1:0); app.SetGameSettings(m_iPad,eGameSetting_Hints,m_multiList.GetCheckboxValue(eControl_Hints)?1:0); app.SetGameSettings(m_iPad,eGameSetting_DeathMessages,m_multiList.GetCheckboxValue(eControl_DeathMessages)?1:0); + app.SetGameSettings(m_iPad,eGameSetting_PassiveChunkLoading,m_multiList.GetCheckboxValue(eControl_PassiveChunkLoading)?1:0); app.SetGameSettings(m_iPad,eGameSetting_Autosave,m_multiList.GetSliderValue(eControl_Autosave)); app.SetGameSettings(m_iPad,eGameSetting_Sensitivity_InGame,m_multiList.GetSliderValue(eControl_Sensitivity_InGame)); app.SetGameSettings(m_iPad,eGameSetting_Difficulty,m_multiList.GetSliderValue(eControl_Difficulty)); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.h b/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.h index 1b18fc4f..91779f56 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_SettingsOptionsMenu.h @@ -13,10 +13,11 @@ private: eControl_ViewBob = 2, eControl_Hints = 3, eControl_DeathMessages = 4, - eControl_Languages = 5, - eControl_Autosave = 6, - eControl_Sensitivity_InGame = 7, - eControl_Difficulty = 8, + eControl_PassiveChunkLoading = 5, + eControl_Languages = 6, + eControl_Autosave = 7, + eControl_Sensitivity_InGame = 8, + eControl_Difficulty = 9, }; UIControl_MultiList m_multiList; diff --git a/Minecraft.Client/Extrax64Stubs.cpp b/Minecraft.Client/Extrax64Stubs.cpp index db2da718..2fd6cfcc 100644 --- a/Minecraft.Client/Extrax64Stubs.cpp +++ b/Minecraft.Client/Extrax64Stubs.cpp @@ -673,6 +673,7 @@ static void Win64_ApplyDefaultProfileGameSettings(void* profileBytes) pGameSettings->uiBitmaskValues |= GAMESETTING_DISPLAYHAND; //eGameSetting_DisplayHand - on pGameSettings->uiBitmaskValues |= GAMESETTING_CUSTOMSKINANIM; //eGameSetting_CustomSkinAnim - on pGameSettings->uiBitmaskValues |= GAMESETTING_DEATHMESSAGES; //eGameSetting_DeathMessages - on + pGameSettings->uiBitmaskValues &= ~GAMESETTING_PASSIVECHUNKLOADING; //eGameSetting_PassiveChunkLoading - off pGameSettings->uiBitmaskValues |= (GAMESETTING_UISIZE & 0x00000800); // uisize 2 pGameSettings->uiBitmaskValues |= (GAMESETTING_UISIZE_SPLITSCREEN & 0x00004000); // splitscreen ui size 3 pGameSettings->uiBitmaskValues |= GAMESETTING_ANIMATEDCHARACTER; //eGameSetting_AnimatedCharacter - on diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index 849e6a0d..645b740d 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -1956,6 +1956,7 @@ void LevelRenderer::renderAdvancedClouds(float alpha) bool LevelRenderer::updateDirtyChunks() { + bool passiveChunkLoading = app.GetGameSettings(ProfileManager.GetPrimaryPad(), eGameSetting_PassiveChunkLoading); #ifdef _LARGE_WORLDS std::list< std::pair > nearestClipChunks; #endif @@ -2182,13 +2183,90 @@ bool LevelRenderer::updateDirtyChunks() Chunk *chunk = nullptr; -#ifdef _LARGE_WORLDS - if(!nearestClipChunks.empty()) + bool bHasRebuildWork = false; + + if( passiveChunkLoading == 0 ) { - int index = 0; - for(auto & it : nearestClipChunks) + if(!nearestClipChunks.empty()) { - chunk = it.first->chunk; + int index = 0; + for(auto & it : nearestClipChunks) + { + chunk = it.first->chunk; + // If this chunk is very near, then move the renderer into a deferred mode. This won't commit any command buffers + // for rendering until we call CBuffDeferredModeEnd(), allowing us to group any near changes into an atomic unit. This + // is essential so we don't temporarily create any holes in the environment whilst updating one chunk and not the neighbours. + // The "ver near" aspect of this is just a cosmetic nicety - exactly the same thing would happen further away, but we just don't + // care about it so much from terms of visual impact. + if( veryNearCount > 0 ) + { + RenderManager.CBuffDeferredModeStart(); + } + // Build this chunk & return false to continue processing + chunk->clearDirty(); + // Take a copy of the details that are required for chunk rebuilding, and rebuild That instead of the original chunk data. This is done within + // the m_csDirtyChunks critical section, which means that any chunks can't be repositioned whilst we are doing this copy. The copy will then + // be guaranteed to be consistent whilst rebuilding takes place outside of that critical section. + permaChunk[index].makeCopyForRebuild(chunk); + ++index; + } + LeaveCriticalSection(&m_csDirtyChunks); + + --index; // Bring it back into 0 counted range + + for(int i = MAX_CHUNK_REBUILD_THREADS - 1; i >= 0; --i) + { + // Set the events that won't run + if( (i+1) > index) s_rebuildCompleteEvents->Set(i); + else break; + } + + for(; index >=0; --index) + { + bool bAtomic = false; + if((veryNearCount > 0)) + bAtomic = true; //MGH - if veryNearCount, then we're trying to rebuild atomically, so do it all on the main thread + + if( bAtomic || (index == 0) ) + { + //PIXBeginNamedEvent(0,"Rebuilding near chunk %d %d %d",chunk->x, chunk->y, chunk->z); + // static int64_t totalTime = 0; + // static int64_t countTime = 0; + // int64_t startTime = System::currentTimeMillis(); + + //app.DebugPrintf("Rebuilding permaChunk %d\n", index); + + permaChunk[index].rebuild(); + + if(index !=0) + s_rebuildCompleteEvents->Set(index-1); // MGH - this rebuild happening on the main thread instead, mark the thread it should have been running on as complete + + // int64_t endTime = System::currentTimeMillis(); + // totalTime += (endTime - startTime); + // countTime++; + // printf("%d : %f\n", countTime, (float)totalTime / (float)countTime); + //PIXEndNamedEvent(); + } + // 4J Stu - Ignore this path when in constrained mode on Xbox One + else + { + // Activate thread to rebuild this chunk + s_activationEventA[index - 1]->Set(); + } + } + + // Wait for the other threads to be done as well + s_rebuildCompleteEvents->WaitForAll(INFINITE); + + bHasRebuildWork = true; + } + } + else + { + if( nearChunk ) + { + chunk = nearChunk->chunk; + PIXBeginNamedEvent(0,"Rebuilding near chunk %d %d %d",chunk->x, chunk->y, chunk->z); // If this chunk is very near, then move the renderer into a deferred mode. This won't commit any command buffers // for rendering until we call CBuffDeferredModeEnd(), allowing us to group any near changes into an atomic unit. This // is essential so we don't temporarily create any holes in the environment whilst updating one chunk and not the neighbours. @@ -2203,91 +2281,24 @@ bool LevelRenderer::updateDirtyChunks() // Take a copy of the details that are required for chunk rebuilding, and rebuild That instead of the original chunk data. This is done within // the m_csDirtyChunks critical section, which means that any chunks can't be repositioned whilst we are doing this copy. The copy will then // be guaranteed to be consistent whilst rebuilding takes place outside of that critical section. - permaChunk[index].makeCopyForRebuild(chunk); - ++index; + static Chunk permaChunk; + permaChunk.makeCopyForRebuild(chunk); + LeaveCriticalSection(&m_csDirtyChunks); + // static int64_t totalTime = 0; + // static int64_t countTime = 0; + // int64_t startTime = System::currentTimeMillis(); + permaChunk.rebuild(); + // int64_t endTime = System::currentTimeMillis(); + // totalTime += (endTime - startTime); + // countTime++; + // printf("%d : %f\n", countTime, (float)totalTime / (float)countTime); + PIXEndNamedEvent(); + + bHasRebuildWork = true; } - LeaveCriticalSection(&m_csDirtyChunks); - - --index; // Bring it back into 0 counted range - - for(int i = MAX_CHUNK_REBUILD_THREADS - 1; i >= 0; --i) - { - // Set the events that won't run - if( (i+1) > index) s_rebuildCompleteEvents->Set(i); - else break; - } - - for(; index >=0; --index) - { - bool bAtomic = false; - if((veryNearCount > 0)) - bAtomic = true; //MGH - if veryNearCount, then we're trying to rebuild atomically, so do it all on the main thread - - if( bAtomic || (index == 0) ) - { - //PIXBeginNamedEvent(0,"Rebuilding near chunk %d %d %d",chunk->x, chunk->y, chunk->z); - // static int64_t totalTime = 0; - // static int64_t countTime = 0; - // int64_t startTime = System::currentTimeMillis(); - - //app.DebugPrintf("Rebuilding permaChunk %d\n", index); - - permaChunk[index].rebuild(); - - if(index !=0) - s_rebuildCompleteEvents->Set(index-1); // MGH - this rebuild happening on the main thread instead, mark the thread it should have been running on as complete - - // int64_t endTime = System::currentTimeMillis(); - // totalTime += (endTime - startTime); - // countTime++; - // printf("%d : %f\n", countTime, (float)totalTime / (float)countTime); - //PIXEndNamedEvent(); - } - // 4J Stu - Ignore this path when in constrained mode on Xbox One - else - { - // Activate thread to rebuild this chunk - s_activationEventA[index - 1]->Set(); - } - } - - // Wait for the other threads to be done as well - s_rebuildCompleteEvents->WaitForAll(INFINITE); } -#else - if( nearChunk ) - { - chunk = nearChunk->chunk; - PIXBeginNamedEvent(0,"Rebuilding near chunk %d %d %d",chunk->x, chunk->y, chunk->z); - // If this chunk is very near, then move the renderer into a deferred mode. This won't commit any command buffers - // for rendering until we call CBuffDeferredModeEnd(), allowing us to group any near changes into an atomic unit. This - // is essential so we don't temporarily create any holes in the environment whilst updating one chunk and not the neighbours. - // The "ver near" aspect of this is just a cosmetic nicety - exactly the same thing would happen further away, but we just don't - // care about it so much from terms of visual impact. - if( veryNearCount > 0 ) - { - RenderManager.CBuffDeferredModeStart(); - } - // Build this chunk & return false to continue processing - chunk->clearDirty(); - // Take a copy of the details that are required for chunk rebuilding, and rebuild That instead of the original chunk data. This is done within - // the m_csDirtyChunks critical section, which means that any chunks can't be repositioned whilst we are doing this copy. The copy will then - // be guaranteed to be consistent whilst rebuilding takes place outside of that critical section. - static Chunk permaChunk; - permaChunk.makeCopyForRebuild(chunk); - LeaveCriticalSection(&m_csDirtyChunks); - // static int64_t totalTime = 0; - // static int64_t countTime = 0; - // int64_t startTime = System::currentTimeMillis(); - permaChunk.rebuild(); - // int64_t endTime = System::currentTimeMillis(); - // totalTime += (endTime - startTime); - // countTime++; - // printf("%d : %f\n", countTime, (float)totalTime / (float)countTime); - PIXEndNamedEvent(); - } -#endif - else + + if( !bHasRebuildWork ) { // Nothing to do - clear flags that there are things to process, unless it's been a while since we found any dirty chunks in which case force a check next time through // Scale recheck period with render distance to reduce wasted full-scans at high distances