This commit is contained in:
aozhiwei 2024-02-19 16:59:34 +08:00
parent eca09cc99a
commit 3c8c2a893b
2 changed files with 19 additions and 0 deletions

View File

@ -89,6 +89,7 @@ public:
void MapInstance::Init()
{
last_raycast_poly_ref_ = INVALID_NAVMESH_POLYREF;
map_meta_ = mt::Map::GetById(map_id);
if (!map_meta_) {
A8_ABORT();
@ -440,6 +441,8 @@ bool MapInstance::FindRandomPointAroundCircle(const glm::vec3& center_pos,
bool MapInstance::Raycast(const glm::vec3& start, const glm::vec3& end,
glm::vec3& hit_point, bool& hit_result)
{
last_raycast_poly_ref_ = INVALID_NAVMESH_POLYREF;
float spos[3];
spos[0] = start.x;
spos[1] = start.y;
@ -480,6 +483,7 @@ bool MapInstance::Raycast(const glm::vec3& start, const glm::vec3& end,
return false;
}
last_raycast_poly_ref_ = polys_[npolys - 1];
if (t > 1) {
// No Hit
hit_pos_[0] = epos[0];
@ -730,6 +734,7 @@ bool MapInstance::RaycastEx(const glm::vec3& start, const glm::vec3& end,
int& same_polys_flags, std::vector<dtPolyRef>& spec_polys,
unsigned short exclude_flags)
{
last_raycast_poly_ref_ = INVALID_NAVMESH_POLYREF;
same_polys_flags = 0;
float spos[3];
@ -772,6 +777,7 @@ bool MapInstance::RaycastEx(const glm::vec3& start, const glm::vec3& end,
return false;
}
last_raycast_poly_ref_ = polys_[npolys - 1];
if (t > 1) {
// No Hit
hit_pos_[0] = epos[0];
@ -1403,3 +1409,14 @@ bool MapInstance::IsValidPos(const glm::vec3& point)
}
return true;
}
unsigned short MapInstance::GetLastRaycastPolyFlags()
{
unsigned short flags = 0;
if (last_raycast_poly_ref_ != INVALID_NAVMESH_POLYREF) {
auto status = navmesh_->getPolyFlags(last_raycast_poly_ref_, &flags);
if (dtStatusSucceed(status)) {
}
}
return flags;
}

View File

@ -64,6 +64,7 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
void AdjustOnLandPoint(glm::vec3& point);
bool IsConnectablePoly(dtPolyRef poly_ref);
bool IsValidPos(const glm::vec3& point);
unsigned short GetLastRaycastPolyFlags();
private:
void LoadHouse();
@ -77,6 +78,7 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
float hit_normal_[3];
float hit_pos_[3];
dtPolyRef polys_[MAX_POLYS];
dtPolyRef last_raycast_poly_ref_ = 0;
std::vector<int> poly_ext_datas_;
std::vector<glm::vec3> grass_pos_hash_;