1
This commit is contained in:
parent
838e078e0f
commit
e9aa79fa00
@ -612,3 +612,34 @@ glm::vec3 MapInstance::UnScaleEx(const glm::vec3& v)
|
||||
UnScale(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
dtPoly* MapInstance::GetPoly(glm::vec3 pos)
|
||||
{
|
||||
dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
|
||||
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
|
||||
const float extents[3] = {2.f, 4.f, 2.f};
|
||||
float nearestPt[3];
|
||||
|
||||
Scale(pos);
|
||||
|
||||
float pos1[3];
|
||||
pos1[0] = pos.x;
|
||||
pos1[1] = pos.y;
|
||||
pos1[2] = pos.z;
|
||||
|
||||
const dtMeshTile* tile = navmesh_->getTileAt(0, 0, 0);
|
||||
assert(tile);
|
||||
navmesh_query_->findNearestPoly(pos1, extents, &filter, &startRef, nearestPt);
|
||||
if (startRef) {
|
||||
unsigned int slat = 0;
|
||||
unsigned int it = 0;
|
||||
unsigned int ip = 0;
|
||||
navmesh_->decodePolyId(startRef, slat, it, ip);
|
||||
return &tile->polys[ip];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
|
||||
glm::vec3& hit_point, bool& hit_result);
|
||||
bool FindNearestPoint(const glm::vec3& center, float radius, glm::vec3& nearestPt);
|
||||
bool GetPosHeight(const Position& pos, float& out_height);
|
||||
dtPoly* GetPoly(glm::vec3 pos);
|
||||
void Scale(glm::vec3& v);
|
||||
void UnScale(glm::vec3& v);
|
||||
glm::vec3 UnScaleEx(const glm::vec3& v);
|
||||
|
Loading…
x
Reference in New Issue
Block a user