mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Shuffle tile positions before adding to queue for processing
This commit is contained in:
parent
12ce82980c
commit
d1d29a2452
@ -35,6 +35,7 @@
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
|
||||
namespace NavMeshTool
|
||||
{
|
||||
@ -180,26 +181,31 @@ namespace NavMeshTool
|
||||
SceneUtil::WorkQueue workQueue(threadsNumber);
|
||||
auto navMeshTileConsumer = std::make_shared<NavMeshTileConsumer>(std::move(db));
|
||||
std::size_t tiles = 0;
|
||||
std::mt19937_64 random;
|
||||
|
||||
for (const std::unique_ptr<WorldspaceNavMeshInput>& input : data.mNavMeshInputs)
|
||||
{
|
||||
std::vector<TilePosition> worldspaceTiles;
|
||||
|
||||
DetourNavigator::getTilesPositions(
|
||||
Misc::Convert::toOsg(input->mAabb.m_min), Misc::Convert::toOsg(input->mAabb.m_max), settings.mRecast,
|
||||
[&] (const TilePosition& tilePosition)
|
||||
{
|
||||
workQueue.addWorkItem(new GenerateNavMeshTile(
|
||||
input->mWorldspace,
|
||||
tilePosition,
|
||||
RecastMeshProvider(input->mTileCachedRecastMeshManager),
|
||||
agentHalfExtents,
|
||||
settings,
|
||||
navMeshTileConsumer
|
||||
));
|
||||
[&] (const TilePosition& tilePosition) { worldspaceTiles.push_back(tilePosition); });
|
||||
|
||||
++tiles;
|
||||
});
|
||||
tiles += worldspaceTiles.size();
|
||||
|
||||
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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user