2020-01-10 20:54:35 +01:00
|
|
|
/* Copyright (C) 2020 Wildfire Games.
|
2010-09-03 11:32:12 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_CCMPPATHFINDER_COMMON
|
|
|
|
#define INCLUDED_CCMPPATHFINDER_COMMON
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
* Declares CCmpPathfinder. Its implementation is mainly done in CCmpPathfinder.cpp,
|
|
|
|
* but the short-range (vertex) pathfinding is done in CCmpPathfinder_Vertex.cpp.
|
|
|
|
* This file provides common code needed for both files.
|
|
|
|
*
|
|
|
|
* The long-range pathfinding is done by a LongPathfinder object.
|
2010-09-03 11:32:12 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "simulation2/system/Component.h"
|
|
|
|
|
|
|
|
#include "ICmpPathfinder.h"
|
|
|
|
|
|
|
|
#include "graphics/Overlay.h"
|
|
|
|
#include "graphics/Terrain.h"
|
|
|
|
#include "maths/MathUtil.h"
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
#include "ps/CLogger.h"
|
2019-05-08 13:53:02 +02:00
|
|
|
#include "renderer/TerrainOverlay.h"
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
#include "simulation2/components/ICmpObstructionManager.h"
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2019-05-13 18:58:00 +02:00
|
|
|
|
|
|
|
class HierarchicalPathfinder;
|
|
|
|
class LongPathfinder;
|
2019-05-08 13:53:02 +02:00
|
|
|
class VertexPathfinder;
|
|
|
|
|
2010-09-03 11:32:12 +02:00
|
|
|
class SceneCollector;
|
2015-06-29 21:59:41 +02:00
|
|
|
class AtlasOverlay;
|
2010-09-03 11:32:12 +02:00
|
|
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
#define PATHFIND_DEBUG 0
|
|
|
|
#else
|
|
|
|
#define PATHFIND_DEBUG 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of ICmpPathfinder
|
|
|
|
*/
|
2019-05-08 13:53:02 +02:00
|
|
|
class CCmpPathfinder final : public ICmpPathfinder
|
2010-09-03 11:32:12 +02:00
|
|
|
{
|
2019-09-15 11:27:10 +02:00
|
|
|
protected:
|
|
|
|
|
|
|
|
class PathfinderWorker
|
|
|
|
{
|
|
|
|
friend CCmpPathfinder;
|
|
|
|
public:
|
|
|
|
PathfinderWorker();
|
|
|
|
|
|
|
|
// Process path requests, checking if we should stop before each new one.
|
|
|
|
void Work(const CCmpPathfinder& pathfinder);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Insert requests in m_[Long/Short]Requests depending on from.
|
|
|
|
// This could be removed when we may use if-constexpr in CCmpPathfinder::PushRequestsToWorkers
|
|
|
|
template<typename T>
|
|
|
|
void PushRequests(std::vector<T>& from, ssize_t amount);
|
|
|
|
|
|
|
|
// Stores our results, the main thread will fetch this.
|
|
|
|
std::vector<PathResult> m_Results;
|
|
|
|
|
|
|
|
std::vector<LongPathRequest> m_LongRequests;
|
|
|
|
std::vector<ShortPathRequest> m_ShortRequests;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Allow the workers to access our private variables
|
|
|
|
friend class PathfinderWorker;
|
|
|
|
|
2010-09-03 11:32:12 +02:00
|
|
|
public:
|
|
|
|
static void ClassInit(CComponentManager& componentManager)
|
|
|
|
{
|
2019-09-23 08:38:16 +02:00
|
|
|
componentManager.SubscribeToMessageType(MT_Deserialized);
|
2010-09-03 11:55:14 +02:00
|
|
|
componentManager.SubscribeToMessageType(MT_Update);
|
2010-09-03 11:32:12 +02:00
|
|
|
componentManager.SubscribeToMessageType(MT_RenderSubmit); // for debug overlays
|
|
|
|
componentManager.SubscribeToMessageType(MT_TerrainChanged);
|
2014-05-26 15:45:10 +02:00
|
|
|
componentManager.SubscribeToMessageType(MT_WaterChanged);
|
2014-06-04 00:35:40 +02:00
|
|
|
componentManager.SubscribeToMessageType(MT_ObstructionMapShapeChanged);
|
2011-06-26 09:03:08 +02:00
|
|
|
componentManager.SubscribeToMessageType(MT_TurnStart);
|
2010-09-03 11:32:12 +02:00
|
|
|
}
|
|
|
|
|
2019-05-08 13:53:02 +02:00
|
|
|
~CCmpPathfinder();
|
|
|
|
|
2010-09-03 11:32:12 +02:00
|
|
|
DEFAULT_COMPONENT_ALLOCATOR(Pathfinder)
|
|
|
|
|
2010-10-23 21:59:40 +02:00
|
|
|
// Template state:
|
|
|
|
|
2011-02-10 17:06:28 +01:00
|
|
|
std::map<std::string, pass_class_t> m_PassClassMasks;
|
2010-09-03 11:32:12 +02:00
|
|
|
std::vector<PathfinderPassability> m_PassClasses;
|
|
|
|
|
2010-10-23 21:59:40 +02:00
|
|
|
// Dynamic state:
|
|
|
|
|
2019-05-26 15:47:41 +02:00
|
|
|
std::vector<LongPathRequest> m_LongPathRequests;
|
|
|
|
std::vector<ShortPathRequest> m_ShortPathRequests;
|
2019-09-15 11:27:10 +02:00
|
|
|
u32 m_NextAsyncTicket; // Unique IDs for asynchronous path requests.
|
|
|
|
u16 m_MaxSameTurnMoves; // Compute only this many paths when useMax is true in StartProcessingMoves.
|
2010-09-03 11:55:14 +02:00
|
|
|
|
2010-10-23 21:59:40 +02:00
|
|
|
// Lazily-constructed dynamic state (not serialized):
|
|
|
|
|
2010-09-03 11:32:12 +02:00
|
|
|
u16 m_MapSize; // tiles per side
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
Grid<NavcellData>* m_Grid; // terrain/passability information
|
2015-06-14 21:22:07 +02:00
|
|
|
Grid<NavcellData>* m_TerrainOnlyGrid; // same as m_Grid, but only with terrain, to avoid some recomputations
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
|
2017-07-14 12:09:32 +02:00
|
|
|
// Keep clever updates in memory to avoid memory fragmentation from the grid.
|
|
|
|
// This should be used only in UpdateGrid(), there is no guarantee the data is properly initialized anywhere else.
|
|
|
|
GridUpdateInformation m_DirtinessInformation;
|
|
|
|
// The data from clever updates is stored for the AI manager
|
|
|
|
GridUpdateInformation m_AIPathfinderDirtinessInformation;
|
2015-06-14 21:22:07 +02:00
|
|
|
bool m_TerrainDirty;
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
|
2019-05-08 13:53:02 +02:00
|
|
|
std::unique_ptr<VertexPathfinder> m_VertexPathfinder;
|
2019-05-13 18:58:00 +02:00
|
|
|
std::unique_ptr<HierarchicalPathfinder> m_PathfinderHier;
|
|
|
|
std::unique_ptr<LongPathfinder> m_LongPathfinder;
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
|
2019-09-15 11:27:10 +02:00
|
|
|
// Workers process pathing requests.
|
|
|
|
std::vector<PathfinderWorker> m_Workers;
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2015-06-29 21:59:41 +02:00
|
|
|
AtlasOverlay* m_AtlasOverlay;
|
2010-09-03 11:32:12 +02:00
|
|
|
|
|
|
|
static std::string GetSchema()
|
|
|
|
{
|
|
|
|
return "<a:component type='system'/><empty/>";
|
|
|
|
}
|
|
|
|
|
2011-01-16 15:08:38 +01:00
|
|
|
virtual void Init(const CParamNode& paramNode);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2011-01-16 15:08:38 +01:00
|
|
|
virtual void Deinit();
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2016-10-28 17:34:24 +02:00
|
|
|
template<typename S>
|
|
|
|
void SerializeCommon(S& serialize);
|
|
|
|
|
2010-09-17 19:53:26 +02:00
|
|
|
virtual void Serialize(ISerializer& serialize);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2011-01-16 15:08:38 +01:00
|
|
|
virtual void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2011-01-16 15:08:38 +01:00
|
|
|
virtual void HandleMessage(const CMessage& msg, bool global);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2017-01-20 03:25:19 +01:00
|
|
|
virtual pass_class_t GetPassabilityClass(const std::string& name) const;
|
2011-02-10 17:06:28 +01:00
|
|
|
|
2015-07-05 21:14:52 +02:00
|
|
|
virtual void GetPassabilityClasses(std::map<std::string, pass_class_t>& passClasses) const;
|
|
|
|
virtual void GetPassabilityClasses(
|
|
|
|
std::map<std::string, pass_class_t>& nonPathfindingPassClasses,
|
|
|
|
std::map<std::string, pass_class_t>& pathfindingPassClasses) const;
|
2015-06-17 22:19:53 +02:00
|
|
|
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
const PathfinderPassability* GetPassabilityFromMask(pass_class_t passClass) const;
|
|
|
|
|
|
|
|
virtual entity_pos_t GetClearance(pass_class_t passClass) const
|
|
|
|
{
|
|
|
|
const PathfinderPassability* passability = GetPassabilityFromMask(passClass);
|
2015-06-17 22:19:53 +02:00
|
|
|
if (!passability)
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
return fixed::Zero();
|
|
|
|
|
|
|
|
return passability->m_Clearance;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual entity_pos_t GetMaximumClearance() const
|
|
|
|
{
|
|
|
|
entity_pos_t max = fixed::Zero();
|
|
|
|
|
|
|
|
for (const PathfinderPassability& passability : m_PassClasses)
|
2015-06-17 22:19:53 +02:00
|
|
|
if (passability.m_Clearance > max)
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
max = passability.m_Clearance;
|
|
|
|
|
2015-11-16 23:03:10 +01:00
|
|
|
return max + Pathfinding::CLEARANCE_EXTENSION_RADIUS;
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
}
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2015-10-03 10:27:19 +02:00
|
|
|
virtual const Grid<NavcellData>& GetPassabilityGrid();
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2017-07-14 12:09:32 +02:00
|
|
|
virtual const GridUpdateInformation& GetAIPathfinderDirtinessInformation() const
|
|
|
|
{
|
|
|
|
return m_AIPathfinderDirtinessInformation;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void FlushAIPathfinderDirtinessInformation()
|
|
|
|
{
|
|
|
|
m_AIPathfinderDirtinessInformation.Clean();
|
|
|
|
}
|
2015-05-06 20:47:02 +02:00
|
|
|
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
virtual Grid<u16> ComputeShoreGrid(bool expandOnWater = false);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2019-09-15 11:27:10 +02:00
|
|
|
virtual void ComputePathImmediate(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass, WaypointPath& ret) const;
|
2010-09-03 11:55:14 +02:00
|
|
|
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
virtual u32 ComputePathAsync(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass, entity_id_t notify);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2019-09-15 11:27:10 +02:00
|
|
|
virtual WaypointPath ComputeShortPathImmediate(const ShortPathRequest& request) const;
|
2010-09-03 11:55:14 +02:00
|
|
|
|
2015-07-18 10:37:49 +02:00
|
|
|
virtual u32 ComputeShortPathAsync(entity_pos_t x0, entity_pos_t z0, entity_pos_t clearance, entity_pos_t range, const PathGoal& goal, pass_class_t passClass, bool avoidMovingUnits, entity_id_t controller, entity_id_t notify);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2019-05-08 13:53:02 +02:00
|
|
|
virtual void SetDebugPath(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2019-05-08 13:53:02 +02:00
|
|
|
virtual void SetDebugOverlay(bool enabled);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2019-05-08 13:53:02 +02:00
|
|
|
virtual void SetHierDebugOverlay(bool enabled);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2019-05-08 13:53:02 +02:00
|
|
|
virtual void GetDebugData(u32& steps, double& time, Grid<u8>& grid) const;
|
2010-11-30 13:31:54 +01:00
|
|
|
|
2015-06-29 21:59:41 +02:00
|
|
|
virtual void SetAtlasOverlay(bool enable, pass_class_t passClass = 0);
|
|
|
|
|
2017-01-20 03:25:19 +01:00
|
|
|
virtual bool CheckMovement(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, pass_class_t passClass) const;
|
2010-09-03 11:55:14 +02:00
|
|
|
|
2017-01-20 03:25:19 +01:00
|
|
|
virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool onlyCenterPoint) const;
|
2013-07-08 00:44:47 +02:00
|
|
|
|
2017-01-20 03:25:19 +01:00
|
|
|
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass) const;
|
2011-08-06 10:11:05 +02:00
|
|
|
|
2017-01-20 03:25:19 +01:00
|
|
|
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint) const;
|
2013-07-08 00:44:47 +02:00
|
|
|
|
2019-09-15 11:27:10 +02:00
|
|
|
virtual void FetchAsyncResultsAndSendMessages();
|
2010-09-03 11:55:14 +02:00
|
|
|
|
2019-09-15 11:27:10 +02:00
|
|
|
virtual void StartProcessingMoves(bool useMax);
|
2016-11-23 12:18:37 +01:00
|
|
|
|
2019-09-15 11:27:10 +02:00
|
|
|
template <typename T>
|
2019-09-23 08:38:16 +02:00
|
|
|
std::vector<T> GetMovesToProcess(std::vector<T>& requests, bool useMax = false, size_t maxMoves = 0);
|
2011-06-26 09:03:08 +02:00
|
|
|
|
2019-09-15 11:27:10 +02:00
|
|
|
template <typename T>
|
|
|
|
void PushRequestsToWorkers(std::vector<T>& from);
|
2011-06-26 09:03:08 +02:00
|
|
|
|
2010-09-03 11:32:12 +02:00
|
|
|
/**
|
|
|
|
* Regenerates the grid based on the current obstruction list, if necessary
|
|
|
|
*/
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 20:58:24 +02:00
|
|
|
virtual void UpdateGrid();
|
|
|
|
|
2015-06-29 21:59:41 +02:00
|
|
|
/**
|
|
|
|
* Updates the terrain-only grid without updating the dirtiness informations.
|
|
|
|
* Useful for fast passability updates in Atlas.
|
|
|
|
*/
|
2020-01-10 20:54:35 +01:00
|
|
|
void MinimalTerrainUpdate(int itile0, int jtile0, int itile1, int jtile1);
|
2015-06-29 21:59:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Regenerates the terrain-only grid.
|
2015-07-01 21:13:56 +02:00
|
|
|
* Atlas doesn't need to have passability cells expanded.
|
2015-06-29 21:59:41 +02:00
|
|
|
*/
|
2020-01-10 20:54:35 +01:00
|
|
|
void TerrainUpdateHelper(bool expandPassability = true, int itile0 = -1, int jtile0 = -1, int itile1 = -1, int jtile1 = -1);
|
2010-09-03 11:32:12 +02:00
|
|
|
|
2011-01-16 15:08:38 +01:00
|
|
|
void RenderSubmit(SceneCollector& collector);
|
2010-09-03 11:32:12 +02:00
|
|
|
};
|
|
|
|
|
2015-06-29 21:59:41 +02:00
|
|
|
class AtlasOverlay : public TerrainTextureOverlay
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const CCmpPathfinder* m_Pathfinder;
|
|
|
|
pass_class_t m_PassClass;
|
|
|
|
|
|
|
|
AtlasOverlay(const CCmpPathfinder* pathfinder, pass_class_t passClass) :
|
|
|
|
TerrainTextureOverlay(Pathfinding::NAVCELLS_PER_TILE), m_Pathfinder(pathfinder), m_PassClass(passClass)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void BuildTextureRGBA(u8* data, size_t w, size_t h)
|
|
|
|
{
|
|
|
|
// Render navcell passability, based on the terrain-only grid
|
|
|
|
u8* p = data;
|
|
|
|
for (size_t j = 0; j < h; ++j)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < w; ++i)
|
|
|
|
{
|
|
|
|
SColor4ub color(0, 0, 0, 0);
|
|
|
|
if (!IS_PASSABLE(m_Pathfinder->m_TerrainOnlyGrid->get((int)i, (int)j), m_PassClass))
|
|
|
|
color = SColor4ub(255, 0, 0, 127);
|
|
|
|
|
|
|
|
*p++ = color.R;
|
|
|
|
*p++ = color.G;
|
|
|
|
*p++ = color.B;
|
|
|
|
*p++ = color.A;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-09-03 11:32:12 +02:00
|
|
|
#endif // INCLUDED_CCMPPATHFINDER_COMMON
|