1
This commit is contained in:
parent
fd14c02ac6
commit
bf9f59807a
@ -178,6 +178,7 @@ void MapInstance::Init()
|
||||
navmesh_query_ = new dtNavMeshQuery();
|
||||
navmesh_query_->init(navmesh_, 1024);
|
||||
MarkMapAreaPolys();
|
||||
MarkConnectablePolys();
|
||||
LoadHouse();
|
||||
}
|
||||
|
||||
@ -1156,7 +1157,7 @@ void MapInstance::AdjustOnLandPoint(glm::vec3& point)
|
||||
const dtPoly* poly = &tile->polys[ip];
|
||||
for (int ii = 2; ii < poly->vertCount; ++ii) {
|
||||
const float* va = &tile->verts[poly->verts[0]*3];
|
||||
const float* vb = &tile->verts[poly->verts[ii-1]*3];
|
||||
const float* vb = &tile->verts[poly->verts[ii-1]*3];
|
||||
const float* vc = &tile->verts[poly->verts[ii]*3];
|
||||
|
||||
glm::vec3 v0 = glm::vec3(va[0], va[1], va[2]);
|
||||
@ -1194,3 +1195,29 @@ void MapInstance::AdjustOnLandPoint(glm::vec3& point)
|
||||
glm::vec3 nearest_pt = orig + dir * nearest_distance;
|
||||
point.y = nearest_pt.y;
|
||||
}
|
||||
|
||||
void MapInstance::MarkConnectablePolys()
|
||||
{
|
||||
std::list<dtPolyRef> queue;
|
||||
while (!queue.empty()) {
|
||||
dtPolyRef poly_ref = queue.front();
|
||||
queue.pop_front();
|
||||
|
||||
const dtPoly* poly = nullptr;
|
||||
const dtMeshTile* tile = 0;
|
||||
navmesh_->getTileAndPolyByRefUnsafe(poly_ref, &tile, &poly);
|
||||
for (unsigned int i = poly->firstLink; i != DT_NULL_LINK; i = tile->links[i].next) {
|
||||
dtPolyRef neighbour_ref = tile->links[i].ref;
|
||||
if (!neighbour_ref) {
|
||||
continue;
|
||||
}
|
||||
if (connectable_polys_.find(neighbour_ref) !=
|
||||
connectable_polys_.end()) {
|
||||
continue;
|
||||
}
|
||||
queue.push_back(neighbour_ref);
|
||||
connectable_polys_.insert(neighbour_ref);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
|
||||
private:
|
||||
void LoadHouse();
|
||||
void MarkMapAreaPolys();
|
||||
void MarkConnectablePolys();
|
||||
|
||||
private:
|
||||
dtNavMesh* navmesh_ = nullptr;
|
||||
@ -79,6 +80,7 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
|
||||
std::list<HouseInfo> houses_;
|
||||
|
||||
std::vector<mc::ColliderNode*> things_;
|
||||
std::set<dtPolyRef> connectable_polys_;
|
||||
|
||||
std::string map_tpl_name_;
|
||||
const mt::Map* map_meta_ = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user