worked on grid-walking
worked on grid-generation added helper library for nav-meshes started working on nav meshes
This commit is contained in:
38
tests/navMesh/TestNavMeshFactory.cpp
Normal file
38
tests/navMesh/TestNavMeshFactory.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
#include "../Tests.h"
|
||||
|
||||
#include "../../navMesh/NavMeshFactory.h"
|
||||
|
||||
TEST(NavMeshFactory, build1) {
|
||||
|
||||
Floorplan::IndoorMap map;
|
||||
Floorplan::Floor floor; map.floors.push_back(&floor); floor.atHeight = 0; floor.height = 3;
|
||||
Floorplan::FloorOutlinePolygon outline; floor.outline.push_back(&outline);
|
||||
outline.poly.points.push_back(Point2(0,0));
|
||||
outline.poly.points.push_back(Point2(10,0));
|
||||
outline.poly.points.push_back(Point2(10,10));
|
||||
outline.poly.points.push_back(Point2(0,10));
|
||||
outline.outdoor = false;
|
||||
outline.method = Floorplan::OutlineMethod::ADD;
|
||||
|
||||
NavMesh<NavMeshTriangle> nm;
|
||||
NavMeshFactory<NavMeshTriangle> fac(&nm);
|
||||
fac.build(&map);
|
||||
|
||||
ASSERT_NEAR(0, nm.getBBox().getMin().x, 0.5);
|
||||
ASSERT_NEAR(0, nm.getBBox().getMin().y, 0.5);
|
||||
ASSERT_NEAR(0, nm.getBBox().getMin().z, 0.5);
|
||||
|
||||
ASSERT_NEAR(10, nm.getBBox().getMax().x, 0.5);
|
||||
ASSERT_NEAR(10, nm.getBBox().getMax().y, 0.5);
|
||||
ASSERT_NEAR( 0, nm.getBBox().getMax().z, 0.5);
|
||||
|
||||
ASSERT_EQ(2, nm.getNumTriangles());
|
||||
|
||||
ASSERT_EQ(nm.getNeighbor(0,0), nm[1]);
|
||||
ASSERT_EQ(nm.getNeighbor(1,0), nm[0]);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
35
tests/navMesh/TestNavMeshTriangle.cpp
Normal file
35
tests/navMesh/TestNavMeshTriangle.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
#include "../Tests.h"
|
||||
|
||||
#include "../../navMesh/NavMeshTriangle.h"
|
||||
|
||||
TEST(NavMeshTriangle, contains) {
|
||||
|
||||
NavMeshTriangle t1(Point3(0,0,0), Point3(1,0,0), Point3(0,1,0));
|
||||
|
||||
ASSERT_TRUE(t1.contains(Point3(0,0,0)));
|
||||
ASSERT_TRUE(t1.contains(Point3(1,0,0)));
|
||||
ASSERT_TRUE(t1.contains(Point3(0,1,0)));
|
||||
ASSERT_TRUE(t1.contains(Point3(0.5,0.5,0)));
|
||||
|
||||
ASSERT_FALSE(t1.contains(Point3(0.501,0.5,0)));
|
||||
ASSERT_FALSE(t1.contains(Point3(0.5,0.501,0)));
|
||||
ASSERT_FALSE(t1.contains(Point3(1,1,0)));
|
||||
|
||||
}
|
||||
|
||||
TEST(NavMeshTriangle, area) {
|
||||
|
||||
NavMeshTriangle t1(Point3(0,0,0), Point3(1,0,0), Point3(0,1,0));
|
||||
ASSERT_NEAR(0.5, t1.getArea(), 0.0001);
|
||||
|
||||
NavMeshTriangle t2(Point3(0,0,9), Point3(1,0,9), Point3(0,1,9));
|
||||
ASSERT_NEAR(0.5, t2.getArea(), 0.0001);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user