diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 722d2eafb..65d5e87dd 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -726,7 +726,6 @@ void Minecraft::run() { // try { // 4J - removed try/catch // if (minecraftApplet != null && !minecraftApplet.isActive()) break; // 4J - removed - AABB::resetPool(); // if (parent == NULL && Display.isCloseRequested()) { // 4J - removed // stop(); @@ -1282,7 +1281,6 @@ void Minecraft::run_middle() { // try { // 4J - removed try/catch // if (minecraftApplet != null && // !minecraftApplet.isActive()) break; // 4J - removed - AABB::resetPool(); // if (parent == NULL && Display.isCloseRequested()) { // // 4J - removed @@ -2226,7 +2224,6 @@ void Minecraft::run_end() { destroy(); } void Minecraft::emergencySave() { // 4J - lots of try/catches removed here, and garbage collector things levelRenderer->clear(); - AABB::clearPool(); setLevel(NULL); } @@ -2402,7 +2399,6 @@ void Minecraft::levelTickUpdateFunc(void* pParam) { } void Minecraft::levelTickThreadInitFunc() { - AABB::CreateNewThreadStorage(); Compression::UseDefaultThreadStorage(); } diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp index 23cd23251..7009e71ef 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -316,7 +316,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) { MinecraftServer* server = (MinecraftServer*)lpParam; Entity::useSmallIds(); // This thread can end up spawning entities as // resources - AABB::CreateNewThreadStorage(); Compression::UseDefaultThreadStorage(); Level::enableLightingCache(); Tile::CreateNewThreadStorage(); @@ -365,7 +364,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) { LeaveCriticalSection(&server->m_postProcessCS); // #endif //__PS3__ Tile::ReleaseThreadStorage(); - AABB::ReleaseThreadStorage(); Level::destroyLightingCache(); ShutdownManager::HasFinished(ShutdownManager::ePostProcessThread); @@ -1650,8 +1648,6 @@ void MinecraftServer::tick() { ironTimers.erase(toRemove[i]); } - AABB::resetPool(); - tickCount++; // 4J We need to update client difficulty levels based on the servers diff --git a/Minecraft.Client/Platform/Common/Consoles_App.cpp b/Minecraft.Client/Platform/Common/Consoles_App.cpp index a1cdfa0d3..24b4c72a5 100644 --- a/Minecraft.Client/Platform/Common/Consoles_App.cpp +++ b/Minecraft.Client/Platform/Common/Consoles_App.cpp @@ -4707,7 +4707,6 @@ int CMinecraftApp::EthernetDisconnectReturned( int CMinecraftApp::SignoutExitWorldThreadProc(void* lpParameter) { // Share AABB & Vec3 pools with default (main thread) - should be ok as long // as we don't tick the main thread whilst this thread is running - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); // app.SetGameStarted(false); @@ -7698,7 +7697,6 @@ void CMinecraftApp::LeaveSaveNotificationSection() { int CMinecraftApp::RemoteSaveThreadProc(void* lpParameter) { // The game should be stopped while we are doing this, but the connections // ticks may try to create some AABB's or Vec3's - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); // 4J-PB - Xbox 360 - 163153 - [CRASH] TU17: Code: Multiplayer: During the diff --git a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp index 180049628..06bf5ffec 100644 --- a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp @@ -950,7 +950,6 @@ bool CGameNetworkManager::IsNetworkThreadRunning() { int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) { // Share AABB & Vec3 pools with default (main thread) - should be ok as long // as we don't tick the main thread whilst this thread is running - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); Tile::CreateNewThreadStorage(); @@ -1009,7 +1008,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) { } SetThreadName(-1, "Minecraft Server thread"); - AABB::CreateNewThreadStorage(); Compression::UseDefaultThreadStorage(); OldChunkStorage::UseDefaultThreadStorage(); Entity::useSmallIds(); @@ -1022,7 +1020,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) { lpParameter); // saveData, app.GetGameHostOption(eGameHostOption_All)); Tile::ReleaseThreadStorage(); - AABB::ReleaseThreadStorage(); Level::destroyLightingCache(); if (lpParameter != NULL) delete (NetworkGameInitData*)lpParameter; @@ -1033,7 +1030,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) { int CGameNetworkManager::ExitAndJoinFromInviteThreadProc(void* lpParam) { // Share AABB & Vec3 pools with default (main thread) - should be ok as long // as we don't tick the main thread whilst this thread is running - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); // app.SetGameStarted(false); @@ -1185,7 +1181,6 @@ void CGameNetworkManager::_LeaveGame() { int CGameNetworkManager::ChangeSessionTypeThreadProc(void* lpParam) { // Share AABB & Vec3 pools with default (main thread) - should be ok as long // as we don't tick the main thread whilst this thread is running - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); Minecraft* pMinecraft = Minecraft::GetInstance(); diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp index f748a6343..e815d7a5c 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp @@ -383,7 +383,6 @@ int IUIScene_PauseMenu::SaveWorldThreadProc(void* lpParameter) { // Share AABB & Vec3 pools with default (main thread) - should be ok as long // as we don't tick the main thread whilst this thread is running - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -420,7 +419,6 @@ int IUIScene_PauseMenu::SaveWorldThreadProc(void* lpParameter) { int IUIScene_PauseMenu::ExitWorldThreadProc(void* lpParameter) { // Share AABB & Vec3 pools with default (main thread) - should be ok as long // as we don't tick the main thread whilst this thread is running - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); // app.SetGameStarted(false); diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_Death.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_Death.cpp index df7adb806..738499468 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_Death.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_Death.cpp @@ -222,7 +222,6 @@ HRESULT CScene_Death::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) { } int CScene_Death::RespawnThreadProc(void* lpParameter) { - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); size_t iPad = (size_t)lpParameter; diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_PauseMenu.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_PauseMenu.cpp index 01b8b4405..a0c633adb 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_PauseMenu.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_PauseMenu.cpp @@ -1075,7 +1075,6 @@ int UIScene_PauseMenu::SaveWorldThreadProc(LPVOID lpParameter) { // Share AABB & Vec3 pools with default (main thread) - should be ok as long // as we don't tick the main thread whilst this thread is running - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); Minecraft* pMinecraft = Minecraft::GetInstance(); @@ -1107,7 +1106,6 @@ int UIScene_PauseMenu::SaveWorldThreadProc(LPVOID lpParameter) { int UIScene_PauseMenu::ExitWorldThreadProc(void* lpParameter) { // Share AABB & Vec3 pools with default (main thread) - should be ok as long // as we don't tick the main thread whilst this thread is running - AABB::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); // app.SetGameStarted(false); diff --git a/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp b/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp index e7f5179c4..30b9c8eb7 100644 --- a/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp +++ b/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp @@ -794,7 +794,6 @@ void oldWinMainInit() { // Initialise TLS for tesselator, for this main thread Tesselator::CreateNewThreadStorage(1024 * 1024); // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); OldChunkStorage::CreateNewThreadStorage(); Level::enableLightingCache(); Tile::CreateNewThreadStorage(); diff --git a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp index 290b4626e..f7cb7d184 100644 --- a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp @@ -856,7 +856,6 @@ return -1; // Initialise TLS for tesselator, for this main thread Tesselator::CreateNewThreadStorage(1024 * 1024); // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); Compression::CreateNewThreadStorage(); OldChunkStorage::CreateNewThreadStorage(); Level::enableLightingCache(); diff --git a/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp b/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp index 84e6fbf12..5744dc9d9 100644 --- a/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp +++ b/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp @@ -1040,7 +1040,6 @@ void RegisterAwardsWithProfileManager() { } int StartMinecraftThreadProc(void* lpParameter) { - AABB::UseDefaultThreadStorage(); Tesselator::CreateNewThreadStorage(1024 * 1024); RenderManager.InitialiseContext(); Minecraft::start(std::wstring(), std::wstring()); @@ -1376,7 +1375,6 @@ int main(int argc, const char* argv[]) { // Initialise TLS for tesselator, for this main thread Tesselator::CreateNewThreadStorage(1024 * 1024); // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); Compression::CreateNewThreadStorage(); OldChunkStorage::CreateNewThreadStorage(); Level::enableLightingCache(); diff --git a/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp b/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp index e2200c8a8..6aaced5fd 100644 --- a/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp +++ b/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp @@ -1210,7 +1210,6 @@ int main() { // Initialise TLS for tesselator, for this main thread Tesselator::CreateNewThreadStorage(1024 * 1024); // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); OldChunkStorage::CreateNewThreadStorage(); Level::enableLightingCache(); Tile::CreateNewThreadStorage(); diff --git a/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp b/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp index 90c153b8d..968ab073a 100644 --- a/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp +++ b/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp @@ -660,7 +660,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // Initialise TLS for tesselator, for this main thread Tesselator::CreateNewThreadStorage(1024 * 1024); // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); Level::enableLightingCache(); Minecraft::main(); diff --git a/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp b/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp index 9065eccb7..4849f15a1 100644 --- a/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp +++ b/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp @@ -895,7 +895,6 @@ int main() { // Initialise TLS for tesselator, for this main thread Tesselator::CreateNewThreadStorage(1024 * 1024); // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); Compression::CreateNewThreadStorage(); OldChunkStorage::CreateNewThreadStorage(); Level::enableLightingCache(); diff --git a/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp index 0e009e4ce..4fc3b34db 100644 --- a/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Platform/Windows64/Windows64_Minecraft.cpp @@ -940,7 +940,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // Initialise TLS for tesselator, for this main thread Tesselator::CreateNewThreadStorage(1024 * 1024); // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); Compression::CreateNewThreadStorage(); OldChunkStorage::CreateNewThreadStorage(); Level::enableLightingCache(); diff --git a/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp b/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp index 1b2cdd997..9a1530c85 100644 --- a/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp +++ b/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp @@ -699,7 +699,6 @@ int __cdecl main() { // Initialise TLS for tesselator, for this main thread Tesselator::CreateNewThreadStorage(1024 * 1024); // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); Compression::CreateNewThreadStorage(); OldChunkStorage::CreateNewThreadStorage(); Level::enableLightingCache(); diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index e405931b0..7b1ac303b 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -1121,7 +1121,6 @@ void GameRenderer::FinishedReassigning() { int GameRenderer::runUpdate(void* lpParam) { Minecraft* minecraft = Minecraft::GetInstance(); - AABB::CreateNewThreadStorage(); Tesselator::CreateNewThreadStorage(1024 * 1024); Compression::UseDefaultThreadStorage(); RenderManager.InitialiseContext(); @@ -1200,7 +1199,6 @@ int GameRenderer::runUpdate(void* lpParam) { // PIXEndNamedEvent(); - AABB::resetPool(); m_updateEvents->Set(eUpdateEventIsFinished); } diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index 556d83ec7..0d5e9afa7 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -4030,7 +4030,6 @@ void LevelRenderer::staticCtor() { } int LevelRenderer::rebuildChunkThreadProc(void* lpParam) { - AABB::CreateNewThreadStorage(); Tesselator::CreateNewThreadStorage(1024 * 1024); RenderManager.InitialiseContext(); Chunk::CreateNewThreadStorage(); diff --git a/Minecraft.World/Util/AABB.cpp b/Minecraft.World/Util/AABB.cpp index 2cf5236e5..a31d27728 100644 --- a/Minecraft.World/Util/AABB.cpp +++ b/Minecraft.World/Util/AABB.cpp @@ -12,47 +12,6 @@ #include "HitResult.h" #include "Util/Vec3.h" -thread_local AABB::ThreadStorage* AABB::m_tlsPool = nullptr; -AABB::ThreadStorage* AABB::m_tlsPoolDefault = nullptr; - -AABB::ThreadStorage::ThreadStorage() { - pool = new AABB[POOL_SIZE]; // 4jcraft, needs to be deleted with delete[] - poolPointer = 0; -} - -AABB::ThreadStorage::~ThreadStorage() { - delete[] pool; // 4jcraft, changed to [] -} - -void AABB::CreateNewThreadStorage() { - ThreadStorage* tls = new ThreadStorage(); - if (m_tlsPoolDefault == nullptr) { - m_tlsPoolDefault = tls; - } - m_tlsPool = tls; -} - -void AABB::UseDefaultThreadStorage() { m_tlsPool = m_tlsPoolDefault; } - -void AABB::ReleaseThreadStorage() { - if (m_tlsPool != m_tlsPoolDefault) { - delete m_tlsPool; - } -} - -void AABB::clearPool() {} - -void AABB::resetPool() {} - -AABB* AABB::newTemp(double x0, double y0, double z0, double x1, double y1, - double z1) { - ThreadStorage* tls = m_tlsPool; - AABB* thisAABB = &tls->pool[tls->poolPointer]; - *thisAABB = {x0, y0, z0, x1, y1, z1}; - tls->poolPointer = (tls->poolPointer + 1) % ThreadStorage::POOL_SIZE; - return thisAABB; -} - AABB::AABB(double x0, double y0, double z0, double x1, double y1, double z1) { this->x0 = x0; this->y0 = y0; diff --git a/Minecraft.World/Util/AABB.h b/Minecraft.World/Util/AABB.h index 61d8446cd..fb62056d8 100644 --- a/Minecraft.World/Util/AABB.h +++ b/Minecraft.World/Util/AABB.h @@ -6,38 +6,13 @@ class HitResult; class AABB { - // 4J added so we can have separate pools for different threads - class ThreadStorage { - public: - static const int POOL_SIZE = 1024; - AABB* pool; - unsigned int poolPointer; - ThreadStorage(); - ~ThreadStorage(); - }; - static thread_local ThreadStorage* m_tlsPool; - static ThreadStorage* m_tlsPoolDefault; - public: - // Each new thread that needs to use Vec3 pools will need to call one of the - // following 2 functions, to either create its own local storage, or share - // the default storage already allocated by the main thread - static void CreateNewThreadStorage(); - static void UseDefaultThreadStorage(); - static void ReleaseThreadStorage(); - - static void clearPool(); - static void resetPool(); - static AABB* newTemp(double x0, double y0, double z0, double x1, double y1, - double z1); - double x0, y0, z0; double x1, y1, z1; AABB() {} AABB(double x0, double y0, double z0, double x1, double y1, double z1); -public: AABB expand(double xa, double ya, double za) const; AABB grow(double xa, double ya, double za) const; AABB minmax(const AABB& other) const;