2015-05-06 20:47:02 +02:00
|
|
|
/* Copyright (C) 2015 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"
|
|
|
|
#include "simulation2/components/ICmpObstructionManager.h"
|
2010-09-03 11:32:12 +02:00
|
|
|
#include "simulation2/helpers/Geometry.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/helpers/LongPathfinder.h"
|
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
|
|
|
|
|
2011-02-28 01:35:53 +01:00
|
|
|
|
2010-09-03 11:55:14 +02:00
|
|
|
struct AsyncLongPathRequest
|
|
|
|
{
|
|
|
|
u32 ticket;
|
|
|
|
entity_pos_t x0;
|
|
|
|
entity_pos_t z0;
|
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
|
|
|
PathGoal goal;
|
|
|
|
pass_class_t passClass;
|
2010-09-03 11:55:14 +02:00
|
|
|
entity_id_t notify;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AsyncShortPathRequest
|
|
|
|
{
|
|
|
|
u32 ticket;
|
|
|
|
entity_pos_t x0;
|
|
|
|
entity_pos_t z0;
|
2015-07-18 10:37:49 +02:00
|
|
|
entity_pos_t clearance;
|
2010-09-03 11:55:14 +02:00
|
|
|
entity_pos_t range;
|
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
|
|
|
PathGoal goal;
|
|
|
|
pass_class_t passClass;
|
2010-09-03 11:55:14 +02:00
|
|
|
bool avoidMovingUnits;
|
|
|
|
entity_id_t group;
|
|
|
|
entity_id_t notify;
|
|
|
|
};
|
|
|
|
|
2010-09-03 11:32:12 +02:00
|
|
|
/**
|
|
|
|
* Implementation of ICmpPathfinder
|
|
|
|
*/
|
|
|
|
class CCmpPathfinder : public ICmpPathfinder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void ClassInit(CComponentManager& componentManager)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
2010-09-03 11:55:14 +02:00
|
|
|
std::vector<AsyncLongPathRequest> m_AsyncLongPathRequests;
|
|
|
|
std::vector<AsyncShortPathRequest> m_AsyncShortPathRequests;
|
2010-09-17 19:53:26 +02:00
|
|
|
u32 m_NextAsyncTicket; // unique IDs for asynchronous path requests
|
2011-06-26 09:47:03 +02:00
|
|
|
u16 m_SameTurnMovesCount; // current number of same turn moves we have processed this turn
|
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
|
|
|
|
2015-06-14 21:22:07 +02:00
|
|
|
// Update data, used for clever updates and then stored for the AI manager
|
|
|
|
GridUpdateInformation m_ObstructionsDirty;
|
|
|
|
bool m_TerrainDirty;
|
2015-06-24 22:15:06 +02:00
|
|
|
// When other components request the passability grid and trigger an update,
|
|
|
|
// the following regular update should not clean the dirtiness state.
|
|
|
|
bool m_PreserveUpdateInformations;
|
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
|
|
|
|
|
|
|
// Interface to the long-range pathfinder.
|
|
|
|
LongPathfinder m_LongPathfinder;
|
|
|
|
|
2011-06-26 09:47:03 +02:00
|
|
|
// For responsiveness we will process some moves in the same turn they were generated in
|
2011-06-26 09:03:08 +02:00
|
|
|
|
|
|
|
u16 m_MaxSameTurnMoves; // max number of moves that can be created and processed in the same turn
|
2010-09-03 11:32:12 +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
|
|
|
bool m_DebugOverlay;
|
2010-09-03 11:32:12 +02:00
|
|
|
std::vector<SOverlayLine> m_DebugOverlayShortPathLines;
|
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
|
|
|
|
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
|
|
|
|
2011-02-10 17:06:28 +01:00
|
|
|
virtual pass_class_t GetPassabilityClass(const std::string& name);
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
return max;
|
|
|
|
}
|
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
|
|
|
|
2015-06-14 21:22:07 +02:00
|
|
|
virtual const GridUpdateInformation& GetDirtinessData() const;
|
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
|
|
|
|
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 ComputePath(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass, WaypointPath& ret)
|
|
|
|
{
|
|
|
|
m_LongPathfinder.ComputePath(x0, z0, goal, passClass, ret);
|
|
|
|
}
|
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
|
|
|
|
2015-07-18 10:37:49 +02:00
|
|
|
virtual void ComputeShortPath(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t clearance, entity_pos_t range, const PathGoal& goal, pass_class_t passClass, WaypointPath& ret);
|
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
|
|
|
|
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 SetDebugPath(entity_pos_t x0, entity_pos_t z0, const PathGoal& goal, pass_class_t passClass)
|
|
|
|
{
|
|
|
|
m_LongPathfinder.SetDebugPath(x0, z0, goal, passClass);
|
|
|
|
}
|
2010-09-03 11:32:12 +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 void SetDebugOverlay(bool enabled)
|
|
|
|
{
|
|
|
|
m_DebugOverlay = enabled;
|
|
|
|
m_LongPathfinder.SetDebugOverlay(enabled);
|
|
|
|
}
|
2010-09-03 11:32:12 +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 void SetHierDebugOverlay(bool enabled)
|
|
|
|
{
|
|
|
|
m_LongPathfinder.SetHierDebugOverlay(enabled, &GetSimContext());
|
|
|
|
}
|
2010-09-03 11:32:12 +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 void GetDebugData(u32& steps, double& time, Grid<u8>& grid)
|
|
|
|
{
|
|
|
|
m_LongPathfinder.GetDebugData(steps, time, grid);
|
|
|
|
}
|
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);
|
|
|
|
|
2011-02-10 17:06:28 +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);
|
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 ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool onlyCenterPoint);
|
2013-07-08 00:44:47 +02:00
|
|
|
|
2013-02-24 01:12:41 +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);
|
2011-08-06 10:11:05 +02:00
|
|
|
|
2013-07-08 00:44:47 +02: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);
|
|
|
|
|
2010-09-03 11:55:14 +02:00
|
|
|
virtual void FinishAsyncRequests();
|
|
|
|
|
2011-06-26 09:47:03 +02:00
|
|
|
void ProcessLongRequests(const std::vector<AsyncLongPathRequest>& longRequests);
|
2011-06-26 09:03:08 +02:00
|
|
|
|
2011-06-26 09:47:03 +02:00
|
|
|
void ProcessShortRequests(const std::vector<AsyncShortPathRequest>& shortRequests);
|
2011-06-26 09:03:08 +02:00
|
|
|
|
|
|
|
virtual void ProcessSameTurnMoves();
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
void MinimalTerrainUpdate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
2015-07-01 21:13:56 +02:00
|
|
|
void TerrainUpdateHelper(bool expandPassability = true);
|
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
|