Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/components/tests/test_Pathfinder.h
Show All 13 Lines | |||||
* You should have received a copy of the GNU General Public License | * 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/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "simulation2/system/ComponentTest.h" | #include "simulation2/system/ComponentTest.h" | ||||
#include "simulation2/components/ICmpObstructionManager.h" | #include "simulation2/components/ICmpObstructionManager.h" | ||||
#include "simulation2/components/ICmpPathfinder.h" | #include "simulation2/components/ICmpPathfinder.h" | ||||
#include "simulation2/components/CCmpPathfinder_Common.h" | |||||
#include "graphics/MapReader.h" | #include "graphics/MapReader.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "graphics/TerrainTextureManager.h" | #include "graphics/TerrainTextureManager.h" | ||||
#include "lib/timer.h" | #include "lib/timer.h" | ||||
#include "lib/tex/tex.h" | #include "lib/tex/tex.h" | ||||
#include "ps/Loader.h" | #include "ps/Loader.h" | ||||
#include "ps/Pyrogenesis.h" | #include "ps/Pyrogenesis.h" | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | void test_performance_short_DISABLED() | ||||
for (size_t i = 0; i < 200; ++i) | for (size_t i = 0; i < 200; ++i) | ||||
{ | { | ||||
fixed x = fixed::FromFloat(1.5f*range.ToFloat() * rand()/(float)RAND_MAX); | fixed x = fixed::FromFloat(1.5f*range.ToFloat() * rand()/(float)RAND_MAX); | ||||
fixed z = fixed::FromFloat(1.5f*range.ToFloat() * rand()/(float)RAND_MAX); | fixed z = fixed::FromFloat(1.5f*range.ToFloat() * rand()/(float)RAND_MAX); | ||||
// printf("# %f %f\n", x.ToFloat(), z.ToFloat()); | // printf("# %f %f\n", x.ToFloat(), z.ToFloat()); | ||||
cmpObstructionMan->AddUnitShape(INVALID_ENTITY, x, z, fixed::FromInt(2), 0, INVALID_ENTITY); | cmpObstructionMan->AddUnitShape(INVALID_ENTITY, x, z, fixed::FromInt(2), 0, INVALID_ENTITY); | ||||
} | } | ||||
NullObstructionFilter filter; | |||||
PathGoal goal = { PathGoal::POINT, range, range }; | PathGoal goal = { PathGoal::POINT, range, range }; | ||||
WaypointPath path; | WaypointPath path = cmpPathfinder->ComputeShortPath(AsyncShortPathRequest{ 0, range/3, range/3, fixed::FromInt(2), range, goal, 0, false, 0, 0 }); | ||||
cmpPathfinder->ComputeShortPath(filter, range/3, range/3, fixed::FromInt(2), range, goal, 0, path); | |||||
for (size_t i = 0; i < path.m_Waypoints.size(); ++i) | for (size_t i = 0; i < path.m_Waypoints.size(); ++i) | ||||
printf("# %d: %f %f\n", (int)i, path.m_Waypoints[i].x.ToFloat(), path.m_Waypoints[i].z.ToFloat()); | printf("# %d: %f %f\n", (int)i, path.m_Waypoints[i].x.ToFloat(), path.m_Waypoints[i].z.ToFloat()); | ||||
} | } | ||||
template<typename T> | template<typename T> | ||||
void DumpGrid(std::ostream& stream, const Grid<T>& grid, int mask) | void DumpGrid(std::ostream& stream, const Grid<T>& grid, int mask) | ||||
{ | { | ||||
for (u16 j = 0; j < grid.m_H; ++j) | for (u16 j = 0; j < grid.m_H; ++j) | ||||
▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator