*
*/
+#include <dali-test-suite-utils.h>
#include "dali-scene3d/public-api/algorithm/navigation-mesh.h"
#include "dali-scene3d/public-api/algorithm/path-finder.h"
#include "dali-scene3d/public-api/loader/navigation-mesh-factory.h"
-#include <dali-test-suite-utils.h>
using namespace Dali;
using namespace Dali::Scene3D::Algorithm;
using namespace Dali::Scene3D::Loader;
-bool CompareResults( const std::vector<uint32_t>& nodes, const WayPointList& waypoints )
+bool CompareResults(const std::vector<FaceIndex>& nodes, const WayPointList& waypoints)
{
if(nodes.size() != waypoints.size())
{
oss << waypoint.GetNavigationMeshFaceIndex() << ", ";
}
oss << "]\n";
- tet_printf("%s\n",oss.str().c_str());
+ tet_printf("%s\n", oss.str().c_str());
return false;
}
- for(auto i = 0u; i < nodes.size(); ++i )
+ for(auto i = 0u; i < nodes.size(); ++i)
{
if(nodes[i] != waypoints[i].GetNavigationMeshFaceIndex())
{
oss << waypoint.GetNavigationMeshFaceIndex() << ", ";
}
oss << "]\n";
- tet_printf("%s\n",oss.str().c_str());
+ tet_printf("%s\n", oss.str().c_str());
return false;
}
}
int UtcDaliPathFinderNewP(void)
{
- auto navmesh = NavigationMeshFactory::CreateFromFile( "resources/navmesh-test.bin");
+ auto navmesh = NavigationMeshFactory::CreateFromFile("resources/navmesh-test.bin");
- auto pathfinder = PathFinder::New( *navmesh, PathFinderAlgorithm::DEFAULT );
+ auto pathfinder = PathFinder::New(*navmesh, PathFinderAlgorithm::DEFAULT);
DALI_TEST_CHECK(navmesh);
DALI_TEST_CHECK(pathfinder);
int UtcDaliPathFinderNewFail(void)
{
- auto navmesh = NavigationMeshFactory::CreateFromFile( "resources/navmesh-test.bin");
+ auto navmesh = NavigationMeshFactory::CreateFromFile("resources/navmesh-test.bin");
- auto pathfinder = PathFinder::New( *navmesh, static_cast<PathFinderAlgorithm>(-1) );
+ auto pathfinder = PathFinder::New(*navmesh, static_cast<PathFinderAlgorithm>(-1));
DALI_TEST_CHECK(navmesh);
DALI_TEST_CHECK(!pathfinder);
END_TEST;
}
-void printWaypointForPython( WayPointList& waypoints)
+void printWaypointForPython(WayPointList& waypoints)
{
- tet_printf( "size: %d\n", waypoints.size());
- tet_printf( "[");
+ tet_printf("size: %d\n", waypoints.size());
+ tet_printf("[");
for(auto& wp : waypoints)
{
auto index = wp.GetNavigationMeshFaceIndex();
tet_printf("%d, ", index);
}
- tet_printf( "]");
+ tet_printf("]");
}
int UtcDaliPathFinderFindShortestPath0(void)
{
- auto navmesh = NavigationMeshFactory::CreateFromFile( "resources/navmesh-test.bin");
+ auto navmesh = NavigationMeshFactory::CreateFromFile("resources/navmesh-test.bin");
std::vector<PathFinderAlgorithm> testAlgorithms = {
- PathFinderAlgorithm::DJIKSTRA_SHORTEST_PATH,
+ PathFinderAlgorithm::DIJKSTRA_SHORTEST_PATH,
PathFinderAlgorithm::SPFA,
};
for(const auto& algorithm : testAlgorithms)
{
tet_printf("Test algorithm type : %d\n", static_cast<int>(algorithm));
- auto pathfinder = PathFinder::New( *navmesh, algorithm );
+ auto pathfinder = PathFinder::New(*navmesh, algorithm);
DALI_TEST_CHECK(navmesh);
DALI_TEST_CHECK(pathfinder);
DALI_TEST_NOT_EQUALS(int(waypoints.size()), 0, 0, TEST_LOCATION);
// Results are verified in the Blender
- std::vector<uint32_t> expectedResults =
+ std::vector<FaceIndex> expectedResults =
{18, 97, 106, 82, 50, 139};
DALI_TEST_EQUALS(CompareResults(expectedResults, waypoints), true, TEST_LOCATION);
//printWaypointForPython(waypoints);
// Results are verified in the Blender
- std::vector<uint32_t> expectedResults =
+ std::vector<FaceIndex> expectedResults =
{18, 97, 106, 82, 50, 6, 89, 33, 157};
DALI_TEST_EQUALS(CompareResults(expectedResults, waypoints), true, TEST_LOCATION);
-
}
}
int UtcDaliPathFinderFindShortestPath1(void)
{
- auto navmesh = NavigationMeshFactory::CreateFromFile( "resources/navmesh-test.bin");
+ auto navmesh = NavigationMeshFactory::CreateFromFile("resources/navmesh-test.bin");
// All coordinates in navmesh local space
- navmesh->SetSceneTransform( Matrix(Matrix::IDENTITY));
+ navmesh->SetSceneTransform(Matrix(Matrix::IDENTITY));
std::vector<PathFinderAlgorithm> testAlgorithms = {
- PathFinderAlgorithm::DJIKSTRA_SHORTEST_PATH,
+ PathFinderAlgorithm::DIJKSTRA_SHORTEST_PATH,
PathFinderAlgorithm::SPFA,
PathFinderAlgorithm::SPFA_DOUBLE_WAY, /* Note : Even this algorithm doesn't found shortest path, UTC will pass. */
};
for(const auto& algorithm : testAlgorithms)
{
tet_printf("Test algorithm type : %d\n", static_cast<int>(algorithm));
- auto pathfinder = PathFinder::New( *navmesh, algorithm );
+ auto pathfinder = PathFinder::New(*navmesh, algorithm);
DALI_TEST_CHECK(navmesh);
DALI_TEST_CHECK(pathfinder);
{
Vector3 from(-6.0767, -1.7268, 0.1438); // ground floor
- Vector3 to(-6.0767, -1.7268, 4.287); // first floor
+ Vector3 to(-6.0767, -1.7268, 4.287); // first floor
auto waypoints = pathfinder->FindPath(from, to);
DALI_TEST_NOT_EQUALS(int(waypoints.size()), 0, 0, TEST_LOCATION);
// Results are verified in the Blender
- std::vector<uint32_t> expectedResults =
- {154, 58, 85, 106, 128, 132, 137};
+ std::vector<FaceIndex> expectedResults =
+ {154, 58, 85, 106, 128, 132, 137};
DALI_TEST_EQUALS(CompareResults(expectedResults, waypoints), true, TEST_LOCATION);
// Verify last and first points by finding floor points
{
- Vector3 verifyPos = Vector3::ZERO;
- uint32_t verifyIndex = NavigationMesh::NULL_FACE;
- auto result = navmesh->FindFloor(from, verifyPos, verifyIndex);
+ Vector3 verifyPos = Vector3::ZERO;
+ FaceIndex verifyIndex = NavigationMesh::NULL_FACE;
+ auto result = navmesh->FindFloor(from, verifyPos, verifyIndex);
DALI_TEST_EQUALS(result, true, TEST_LOCATION);
DALI_TEST_EQUALS(verifyPos, waypoints[0].GetScenePosition(), TEST_LOCATION);
}
{
- Vector3 verifyPos = Vector3::ZERO;
- uint32_t verifyIndex = NavigationMesh::NULL_FACE;
- auto result = navmesh->FindFloor(to, verifyPos, verifyIndex);
+ Vector3 verifyPos = Vector3::ZERO;
+ FaceIndex verifyIndex = NavigationMesh::NULL_FACE;
+ auto result = navmesh->FindFloor(to, verifyPos, verifyIndex);
DALI_TEST_EQUALS(result, true, TEST_LOCATION);
DALI_TEST_EQUALS(verifyPos, waypoints.back().GetScenePosition(), TEST_LOCATION);