From 756b3e887732fdc318176c2e375a3f81c71c80d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henri=20Hyyryl=C3=A4inen?= Date: Sun, 24 Feb 2019 12:18:09 +0200 Subject: [PATCH] Fix for texture loading (#639) (#741) * Revert "Deleted my badly formatted comment, and added one more check, because in the createbackground we only checked one of the backgrounds before editing it." This reverts commit c01247b3fb0a39c605fcc115f1bda4960db43a9b. * Revert "The microbe editor now uses its own background mesh, as a result it always uses the same texture (ocean, we can change that later very easily so i can fix that), but at least it seems to have stopped the banana background from happening." This reverts commit 3223dcfd9a422e540145883c0bd7e02fbc2a6ef9. * Removed some comments and one log The bandaids should now all be gone * This automates hitting suicide every 15 seconds and other stuff For testing banana bug * Added a potential fix for texture loading, increased max open file count * Revert "This automates hitting suicide every 15 seconds and other stuff" This reverts commit c24a714d2536aac9a71d0cdbfd209266cab4cc5e. A bunch of debugging stuff * Updated engine to invalidate precompiled cAudio version Now everyone should get the changes by crodnu --- SetupThrive.rb | 2 +- src/ThriveGame.cpp | 44 +++++++++++++++----------------------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/SetupThrive.rb b/SetupThrive.rb index 1b14beaadf3..5c7cfe2f95b 100755 --- a/SetupThrive.rb +++ b/SetupThrive.rb @@ -78,7 +78,7 @@ def parseExtraArgs leviathan = Leviathan.new( # Use this if you always want the latest commit # version: "develop", - version: "02599f1c44a37d6d84bf9cdd1051b8debdd4815c", + version: "ff0b85fa6fafe9d1161910524775eb2c1e6a486d", # Doesn't actually work, but leviathan doesn't install with sudo by # default, or install at all for that matter noInstallSudo: true diff --git a/src/ThriveGame.cpp b/src/ThriveGame.cpp index 5edfd828ff9..0565ce0fab1 100644 --- a/src/ThriveGame.cpp +++ b/src/ThriveGame.cpp @@ -62,14 +62,6 @@ class ThriveGame::Implementation { m_microbeBackgroundMesh.reset(); m_microbeBackgroundSubMesh = nullptr; } - - if(m_microbeEditorBackgroundMesh) { - - Ogre::MeshManager::getSingleton().remove( - m_microbeEditorBackgroundMesh); - m_microbeEditorBackgroundMesh.reset(); - m_microbeEditorBackgroundSubMesh = nullptr; - } } void @@ -98,8 +90,6 @@ class ThriveGame::Implementation { { destroyBackgroundItem(); - LOG_INFO("Creating background item"); - LEVIATHAN_ASSERT( m_cellStage, "Trying to create background item before world"); @@ -117,7 +107,7 @@ class ThriveGame::Implementation { if(!m_microbeEditorBackgroundItem) { m_microbeEditorBackgroundItem = m_microbeEditor->GetScene()->createItem( - m_microbeEditorBackgroundMesh, Ogre::SCENE_STATIC); + m_microbeBackgroundMesh, Ogre::SCENE_STATIC); m_microbeEditorBackgroundItem->setCastShadows(false); // Need to edit the render queue and add it to an early one @@ -145,8 +135,6 @@ class ThriveGame::Implementation { //! This is the background object of the cell stage Ogre::MeshPtr m_microbeBackgroundMesh; Ogre::SubMesh* m_microbeBackgroundSubMesh; - Ogre::MeshPtr m_microbeEditorBackgroundMesh; - Ogre::SubMesh* m_microbeEditorBackgroundSubMesh; Ogre::Item* m_microbeBackgroundItem = nullptr; Ogre::SceneNode* m_backgroundRenderNode = nullptr; @@ -167,6 +155,17 @@ ThriveGame::ThriveGame() m_cheatsEnabled = true; #endif // MAKE_RELEASE +#ifdef _WIN32 + // This should fix the texture loading error. It is likely caused by running + // out of file descriptors, so here we set our limit to the max Not sure why + // it was able to happen on linux. Perhaps the launcher could do "ulimit" to + // increase the file limit when running the game, but it is very rare to + // happen on Linux + if(_setmaxstdio(2048) != 2048) { + LOG_ERROR("Max open file increase failed! _setmaxstdio"); + } +#endif //_WIN32 + StaticGame = this; } @@ -375,17 +374,7 @@ void m_impl->m_microbeBackgroundSubMesh->setMaterialName("Background"); } - // This also needs to be manually destroyed later. - if(!m_impl->m_microbeEditorBackgroundMesh) { - m_impl->m_microbeEditorBackgroundMesh = - Leviathan::GeometryHelpers::CreateScreenSpaceQuad( - "Editor_background", -1, -1, 2, 2); - - m_impl->m_microbeEditorBackgroundSubMesh = - m_impl->m_microbeEditorBackgroundMesh->getSubMesh(0); - m_impl->m_microbeEditorBackgroundSubMesh->setMaterialName("Background"); - } // Setup render queue for it m_impl->m_cellStage->GetScene()->getRenderQueue()->setRenderQueueMode( 1, Ogre::RenderQueue::FAST); @@ -546,17 +535,17 @@ void m_impl->m_microbeEditor->SetCamera(camera); - // Background - // Ill add an if statement here and see what happens if(!m_impl->m_editorBackgroundRenderNode) { m_impl->m_editorBackgroundRenderNode = m_impl->m_microbeEditor->GetScene()->createSceneNode( Ogre::SCENE_STATIC); + // Setup render queue for it m_impl->m_microbeEditor->GetScene() ->getRenderQueue() ->setRenderQueueMode(1, Ogre::RenderQueue::FAST); - // This also attaches it + + // This creates and attaches the item m_impl->createBackgroundItem(); } @@ -984,9 +973,6 @@ void LOG_INFO("Setting microbe background to: " + material); m_impl->m_microbeBackgroundSubMesh->setMaterialName(material); - // If the banana background re-appears after this change, we will make it - // just use the default blue background. SO just comment this out then. - m_impl->m_microbeEditorBackgroundSubMesh->setMaterialName(material); m_impl->createBackgroundItem(); }