Revert "Try to put IA in its own thread"

This reverts commit 2a60a841556a9a6cdd3a259bebd44e95365f8f64.
This commit is contained in:
Vincent Lejeune 2014-09-12 23:22:54 +02:00
parent 2a60a84155
commit d480c52f8c
2 changed files with 8 additions and 17 deletions

View File

@ -36,7 +36,6 @@
#include "race/race_manager.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/profiler.hpp"
#include <thread>
MainLoop* main_loop = 0;
@ -109,9 +108,6 @@ void MainLoop::updateRace(float dt)
World::getWorld()->updateWorld(dt);
} // updateRace
std::thread IAThread;
//-----------------------------------------------------------------------------
/** Run the actual main loop.
*/
@ -177,8 +173,6 @@ void MainLoop::run()
}
PROFILER_POP_CPU_MARKER();
if(IAThread.joinable())
IAThread.join();
PROFILER_SYNC_FRAME();
} // while !m_abort

View File

@ -65,7 +65,7 @@
#include <ctime>
#include <sstream>
#include <stdexcept>
#include <thread>
World* World::m_world = NULL;
@ -763,8 +763,6 @@ void World::scheduleUnpause()
}
} // scheduleUnpause
extern std::thread IAThread;
//-----------------------------------------------------------------------------
/** This is the main interface to update the world. This function calls
* update(), and checks then for the end of the race. Note that race over
@ -928,14 +926,13 @@ void World::update(float dt)
}
PROFILER_PUSH_CPU_MARKER("World::update (AI)", 0x40, 0x7F, 0x00);
IAThread = std::thread([&]() {
const int kart_amount = m_karts.size();
for (int i = 0; i < kart_amount; ++i)
{
// Update all karts that are not eliminated
if (!m_karts[i]->isEliminated()) m_karts[i]->update(dt);
}
});
const int kart_amount = m_karts.size();
#pragma omp parallel for
for (int i = 0 ; i < kart_amount; ++i)
{
// Update all karts that are not eliminated
if(!m_karts[i]->isEliminated()) m_karts[i]->update(dt) ;
}
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("World::update (camera)", 0x60, 0x7F, 0x00);