1
0
forked from 0ad/0ad

# Disable non-Free pathfinding library

(All the code is still there, it's just #ifdef'd out by default)

This was SVN commit r6775.
This commit is contained in:
Ykkrosh 2009-03-24 21:40:10 +00:00
parent f69c5fc25e
commit 6426777e61
9 changed files with 58 additions and 15 deletions

View File

@ -6,6 +6,8 @@ addoption("outpath", "Location for generated project files")
addoption("without-tests", "Disable generation of test projects")
addoption("without-pch", "Disable generation and usage of precompiled headers")
use_dcdt = false -- disable it since it's a non-Free library
dofile("functions.lua")
dofile("extern_libs.lua")
@ -185,6 +187,9 @@ function package_set_build_flags()
package.defines = {
-- "CONFIG_USE_MMGR",
}
if use_dcdt then
tinsert(package.defines, "USE_DCDT")
end
end
end
@ -339,7 +344,6 @@ function setup_all_libs ()
setup_static_lib_package("network", source_dirs, extern_libs, {})
source_dirs = {
"dcdt/se",
"ps",
"ps/scripting",
"ps/Network",
@ -352,6 +356,9 @@ function setup_all_libs ()
"maths",
"maths/scripting",
}
if use_dcdt then
tinsert(source_dirs, "dcdt/se")
end
extern_libs = {
"spidermonkey",
"sdl", -- key definitions

View File

@ -10,7 +10,9 @@
#include "ps/World.h"
#include "EntityManager.h"
#include "dcdt/se/se_dcdt.h"
#ifdef USE_DCDT
# include "dcdt/se/se_dcdt.h"
#endif // USE_DCDT
class AStarNode
{
@ -81,9 +83,10 @@ public:
//Kai:added tile overlay for pathfinding
PathFindingTerrainOverlay* pathfindingOverlay;
#ifdef USE_DCDT
SrPolygon pol;
//void TAStarTest();
#endif // USE_DCDT

View File

@ -227,6 +227,7 @@ void CEntity::initAuraData()
void CEntity::removeObstacle()
{
#ifdef USE_DCDT
if(g_Pathfinder.dcdtInitialized)
{
g_Pathfinder.dcdtPathfinder.remove_polygon(m_dcdtId);
@ -238,7 +239,7 @@ void CEntity::removeObstacle()
g_Pathfinder.drawTriangulation();
}
}
#endif // USE_DCDT
}
void CEntity::Kill(bool keepActor)

View File

@ -13,7 +13,10 @@
#include "Entity.h"
#include "lib/timer.h"
#include "dcdt/se/se_dcdt.h"
#ifdef USE_DCDT
# include "dcdt/se/se_dcdt.h"
#endif // USE_DCDT
#include "PathfindEngine.h"
#include "ps/GameSetup/Config.h"
@ -88,6 +91,7 @@ void CEntityManager::DeleteAll()
void CEntityManager::updateObstacle( CEntity* tempHandle )
{
#ifdef USE_DCDT
if(g_Pathfinder.dcdtInitialized)
{
SrPolygon poly;
@ -183,7 +187,7 @@ void CEntityManager::updateObstacle( CEntity* tempHandle )
g_Pathfinder.drawTriangulation();
}
}
#endif // USE_DCDT
}

View File

@ -703,12 +703,14 @@ bool CEntity::ProcessGotoWaypoint( CEntityOrder* current, int UNUSED(timestep_mi
ChooseMovementSpeed( Distance );
#ifdef USE_DCDT
//Kai: invoking triangulation or original A* pathfinding
if(g_TriPathfind)
{
g_Pathfinder.RequestTriangulationPath( me, path_to, contact, pathfinder_radius, source );
}
else
#endif // USE_DCDT
{
g_Pathfinder.RequestLowLevelPath( me, path_to, contact, pathfinder_radius, source );
}

View File

@ -16,6 +16,8 @@
#ifdef USE_DCDT
#define EPSILON 0.00001f
@ -151,8 +153,10 @@ public:
RenderCurrentPath();
}
};
#endif // USE_DCDT
#ifdef USE_DCDT
CPathfindEngine::CPathfindEngine() : triangulationOverlay(0),
OABBBOUNDREDUCTION(0.8f),
CIRCLEBOUNDREDUCTION(0.5f),
@ -172,7 +176,13 @@ CPathfindEngine::~CPathfindEngine()
triangulationOverlay = 0;
}
}
#else // USE_DCDT
CPathfindEngine::CPathfindEngine() { }
CPathfindEngine::~CPathfindEngine() { }
#endif // USE_DCDT
#ifdef USE_DCDT
//Todo:
// 1; the bouncing problem with the fortress
// 2; update obstacles when things vanishes. done
@ -324,6 +334,7 @@ void CPathfindEngine::drawTriangulation()
}
#endif // USE_DCDT
void CPathfindEngine::RequestPath( HEntity entity, const CVector2D& destination,
CEntityOrder::EOrderSource orderSource )
@ -338,18 +349,19 @@ void CPathfindEngine::RequestPath( HEntity entity, const CVector2D& destination,
waypoint.m_type = CEntityOrder::ORDER_GOTO_WAYPOINT;
waypoint.m_source = orderSource;
waypoint.m_target_location = destination;
waypoint.m_pathfinder_radius = 0.0f;
#ifdef USE_DCDT
//Kai: adding radius for pathfinding
CBoundingObject* m_bounds = entity->m_bounds;
waypoint.m_pathfinder_radius = m_bounds->m_radius + RADIUSINCREMENT;
#endif // USE_DCDT
//waypoint.m_pathfinder_radius = 0.0f;
entity->m_orderQueue.push_front( waypoint );
}
#ifdef USE_DCDT
void CPathfindEngine::RequestTriangulationPath( HEntity entity, const CVector2D& destination, bool contact,
float radius, CEntityOrder::EOrderSource orderSource )
{
@ -486,6 +498,7 @@ void CPathfindEngine::RequestTriangulationPath( HEntity entity, const CVector2D&
PROFILE_END("Pathfinding");
}
#endif // USE_DCDT
void CPathfindEngine::RequestLowLevelPath( HEntity entity, const CVector2D& destination, bool contact,
float radius, CEntityOrder::EOrderSource orderSource )

View File

@ -12,12 +12,13 @@
#include "ps/Singleton.h"
#include "EntityHandles.h"
#include "ps/Vector2D.h"
//#include "AStarEngine.h"
#include "dcdt/se/se_dcdt.h"
#include "TRAStarEngine.h"
#include "AStarEngine.h"
#ifdef USE_DCDT
# include "dcdt/se/se_dcdt.h"
# include "TRAStarEngine.h"
class TriangulationTerrainOverlay;
#endif // USE_DCDT
#define g_Pathfinder CPathfindEngine::GetSingleton()
@ -35,6 +36,7 @@ class CPathfindEngine : public Singleton<CPathfindEngine>
NONCOPYABLE(CPathfindEngine);
public:
#ifdef USE_DCDT
//Kai: added for dcdt
const float OABBBOUNDREDUCTION ;
const float CIRCLEBOUNDREDUCTION ;
@ -52,7 +54,7 @@ public:
//Kai:added tile overlay for pathfinding
TriangulationTerrainOverlay* triangulationOverlay;
#endif
CPathfindEngine();
~CPathfindEngine();
@ -66,13 +68,17 @@ public:
void RequestContactPath( HEntity entity, CEntityOrder* current, float range );
bool RequestAvoidPath( HEntity entity, CEntityOrder* current, float avoidRange );
#ifdef USE_DCDT
void RequestTriangulationPath( HEntity entity, const CVector2D& destination, bool contact,
float radius, CEntityOrder::EOrderSource orderSource );
#endif
private:
CAStarEngineLowLevel mLowPathfinder;
#ifdef USE_DCDT
CTRAStarEngine mTriangulationPathfinder;
#endif
};
#endif

View File

@ -1,6 +1,8 @@
#include "precompiled.h"
#include "TRAStarEngine.h"
#ifdef USE_DCDT
CTRAStarEngine::CTRAStarEngine(void)
{
@ -17,3 +19,5 @@ bool CTRAStarEngine::FindPath(const CVector2D &src, const CVector2D &dest, HEnti
bool found = dcdtPathfinder.SearchPathFast(src.x, src.y, dest.x, dest.y, radius);
return found;
}
#endif // USE_DCDT

View File

@ -1,6 +1,8 @@
#ifndef INCLUDED_TRASTARENGINE
#define INCLUDED_TRASTARENGINE
#ifdef USE_DCDT
#include "AStarEngine.h"
class CTRAStarEngine :
@ -15,5 +17,6 @@ public:
bool FindPath( const CVector2D& src, const CVector2D& dest, HEntity entity, SeDcdt& dcdtPathfinder,float radius=0.0f );
};
#endif // USE_DCDT
#endif
#endif