diff --git a/build/premake/premake.lua b/build/premake/premake.lua index 433b2ca251..3bdc4ecbcc 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -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 diff --git a/source/simulation/AStarEngine.h b/source/simulation/AStarEngine.h index 60cdfdcf9b..259a6cb270 100644 --- a/source/simulation/AStarEngine.h +++ b/source/simulation/AStarEngine.h @@ -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 diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index ce1ebe1203..b4d7627936 100644 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -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) diff --git a/source/simulation/EntityManager.cpp b/source/simulation/EntityManager.cpp index b40417962f..77613b73d7 100644 --- a/source/simulation/EntityManager.cpp +++ b/source/simulation/EntityManager.cpp @@ -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 } diff --git a/source/simulation/EntityStateProcessing.cpp b/source/simulation/EntityStateProcessing.cpp index dcd12a89dc..cc2db8ff64 100644 --- a/source/simulation/EntityStateProcessing.cpp +++ b/source/simulation/EntityStateProcessing.cpp @@ -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 ); } diff --git a/source/simulation/PathfindEngine.cpp b/source/simulation/PathfindEngine.cpp index 72e963f8ae..f85d780baf 100644 --- a/source/simulation/PathfindEngine.cpp +++ b/source/simulation/PathfindEngine.cpp @@ -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 ) diff --git a/source/simulation/PathfindEngine.h b/source/simulation/PathfindEngine.h index fc31e287ef..f220fa5e97 100644 --- a/source/simulation/PathfindEngine.h +++ b/source/simulation/PathfindEngine.h @@ -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 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 diff --git a/source/simulation/TRAStarEngine.cpp b/source/simulation/TRAStarEngine.cpp index 93f873579d..c2d7c4fdf0 100644 --- a/source/simulation/TRAStarEngine.cpp +++ b/source/simulation/TRAStarEngine.cpp @@ -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 diff --git a/source/simulation/TRAStarEngine.h b/source/simulation/TRAStarEngine.h index 20b51817f6..928fa62bf5 100644 --- a/source/simulation/TRAStarEngine.h +++ b/source/simulation/TRAStarEngine.h @@ -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 \ No newline at end of file +#endif