mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-25 07:56:37 +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 <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…
	
		Reference in a new issue