This commit is contained in:
aozhiwei 2022-11-29 17:33:19 +08:00
parent b411624719
commit f354a90eca
2 changed files with 24 additions and 0 deletions

View File

@ -721,3 +721,26 @@ int MapInstance::Raycast(int layer, const a8::Vec3& start, const a8::Vec3& end,
return 1; return 1;
} }
bool MapInstance::FindNearestPoint(const a8::Vec3& center, float radius, a8::Vec3& nearest_pt)
{
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];
float pos[3];
pos[0] = center.x;
pos[1] = center.y;
pos[2] = center.z;
navmesh_query_->findNearestPoly(pos, extents, &filter, &startRef, nearestPt);
if (!startRef) {
}
return true;
}

View File

@ -50,6 +50,7 @@ class MapInstance
unsigned int max_points, unsigned int max_points,
float max_radius); float max_radius);
int Raycast(int layer, const a8::Vec3& start, const a8::Vec3& end, a8::Vec3& hit_point); int Raycast(int layer, const a8::Vec3& start, const a8::Vec3& end, a8::Vec3& hit_point);
bool FindNearestPoint(const a8::Vec3& center, float radius, a8::Vec3& nearestPt);
private: private:
void CreateThings(); void CreateThings();