minor changes to floorplan
fixed some compile issues worked on nav-meshes added some tests
This commit is contained in:
@@ -28,6 +28,14 @@ namespace NM {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** does this submesh contain the given point? */
|
||||
bool contains(const Point3 p3) const {
|
||||
for (const Tria* t : toVisit) {
|
||||
if (t->contains(p3)) {return true;}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** get the triangle that contains the given point (if any) */
|
||||
const Tria* getContainingTriangle(const Point2 p2) const {
|
||||
for (const Tria* t : toVisit) {
|
||||
@@ -37,24 +45,36 @@ namespace NM {
|
||||
}
|
||||
|
||||
/** perform random operations on the submesh */
|
||||
NavMeshRandom<Tria> getRandom() {
|
||||
NavMeshRandom<Tria> getRandom() const {
|
||||
return NavMeshRandom<Tria>(toVisit);
|
||||
}
|
||||
|
||||
|
||||
/** allows for-each iteration over all included triangles */
|
||||
decltype(toVisit.begin()) begin() {return toVisit.begin();}
|
||||
|
||||
/** allows for-each iteration over all included triangles */
|
||||
decltype(toVisit.end()) end() {return toVisit.end();}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void build(const NavMeshLocation<Tria>& loc, float radius_m) {
|
||||
|
||||
PERF_REGION(6, "NavMeshSub::build()");
|
||||
|
||||
std::unordered_set<const Tria*> visited;
|
||||
|
||||
// starting-triangle + all its (max 3) neighbors
|
||||
toVisit.push_back(loc.tria);
|
||||
visited.insert(loc.tria);
|
||||
for (const auto* n : *loc.tria) {
|
||||
toVisit.push_back( (const Tria*)n );
|
||||
}
|
||||
// for (const auto* n : *loc.tria) {
|
||||
// toVisit.push_back( (const Tria*)n );
|
||||
// }
|
||||
// size_t next = 1; // start with the first neighbor (skip starting triangle itself)
|
||||
|
||||
size_t next = 1; // start with the first neighbor (skip starting triangle itself)
|
||||
size_t next = 0;
|
||||
while (next < toVisit.size()) {
|
||||
|
||||
// next triangle
|
||||
@@ -63,7 +83,8 @@ namespace NM {
|
||||
// neighbors
|
||||
for (const auto* n : *cur) {
|
||||
const Tria* t = (const Tria*) n;
|
||||
const float dist = loc.pos.getDistance(n->getCenter());
|
||||
//const float dist = loc.pos.getDistance(n->getCenter());
|
||||
const float dist = n->getDistanceApx(loc.pos);
|
||||
if (dist > radius_m) {continue;}
|
||||
if (visited.find(t) != visited.end()) {continue;}
|
||||
toVisit.push_back(t);
|
||||
|
||||
Reference in New Issue
Block a user