mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-09 00:41:25 +00:00
Shuffle tile positions before adding to queue for processing
This commit is contained in:
parent
12ce82980c
commit
d1d29a2452
1 changed files with 18 additions and 12 deletions
|
@ -35,6 +35,7 @@
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
namespace NavMeshTool
|
namespace NavMeshTool
|
||||||
{
|
{
|
||||||
|
@ -180,26 +181,31 @@ namespace NavMeshTool
|
||||||
SceneUtil::WorkQueue workQueue(threadsNumber);
|
SceneUtil::WorkQueue workQueue(threadsNumber);
|
||||||
auto navMeshTileConsumer = std::make_shared<NavMeshTileConsumer>(std::move(db));
|
auto navMeshTileConsumer = std::make_shared<NavMeshTileConsumer>(std::move(db));
|
||||||
std::size_t tiles = 0;
|
std::size_t tiles = 0;
|
||||||
|
std::mt19937_64 random;
|
||||||
|
|
||||||
for (const std::unique_ptr<WorldspaceNavMeshInput>& input : data.mNavMeshInputs)
|
for (const std::unique_ptr<WorldspaceNavMeshInput>& input : data.mNavMeshInputs)
|
||||||
{
|
{
|
||||||
|
std::vector<TilePosition> worldspaceTiles;
|
||||||
|
|
||||||
DetourNavigator::getTilesPositions(
|
DetourNavigator::getTilesPositions(
|
||||||
Misc::Convert::toOsg(input->mAabb.m_min), Misc::Convert::toOsg(input->mAabb.m_max), settings.mRecast,
|
Misc::Convert::toOsg(input->mAabb.m_min), Misc::Convert::toOsg(input->mAabb.m_max), settings.mRecast,
|
||||||
[&] (const TilePosition& tilePosition)
|
[&] (const TilePosition& tilePosition) { worldspaceTiles.push_back(tilePosition); });
|
||||||
{
|
|
||||||
workQueue.addWorkItem(new GenerateNavMeshTile(
|
|
||||||
input->mWorldspace,
|
|
||||||
tilePosition,
|
|
||||||
RecastMeshProvider(input->mTileCachedRecastMeshManager),
|
|
||||||
agentHalfExtents,
|
|
||||||
settings,
|
|
||||||
navMeshTileConsumer
|
|
||||||
));
|
|
||||||
|
|
||||||
++tiles;
|
tiles += worldspaceTiles.size();
|
||||||
});
|
|
||||||
|
|
||||||
navMeshTileConsumer->mExpected = tiles;
|
navMeshTileConsumer->mExpected = tiles;
|
||||||
|
|
||||||
|
std::shuffle(worldspaceTiles.begin(), worldspaceTiles.end(), random);
|
||||||
|
|
||||||
|
for (const TilePosition& tilePosition : worldspaceTiles)
|
||||||
|
workQueue.addWorkItem(new GenerateNavMeshTile(
|
||||||
|
input->mWorldspace,
|
||||||
|
tilePosition,
|
||||||
|
RecastMeshProvider(input->mTileCachedRecastMeshManager),
|
||||||
|
agentHalfExtents,
|
||||||
|
settings,
|
||||||
|
navMeshTileConsumer
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
navMeshTileConsumer->wait();
|
navMeshTileConsumer->wait();
|
||||||
|
|
Loading…
Reference in a new issue