From 3c8c2a893bfc85c9cb8335f4f763547489b3f69c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Feb 2024 16:59:34 +0800 Subject: [PATCH] 1 --- server/gameserver/mapinstance.cc | 17 +++++++++++++++++ server/gameserver/mapinstance.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/server/gameserver/mapinstance.cc b/server/gameserver/mapinstance.cc index 46d8d302..ee1e7d17 100644 --- a/server/gameserver/mapinstance.cc +++ b/server/gameserver/mapinstance.cc @@ -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& 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; +} diff --git a/server/gameserver/mapinstance.h b/server/gameserver/mapinstance.h index 8edd9ec6..2aa07927 100644 --- a/server/gameserver/mapinstance.h +++ b/server/gameserver/mapinstance.h @@ -64,6 +64,7 @@ class MapInstance : public std::enable_shared_from_this 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 float hit_normal_[3]; float hit_pos_[3]; dtPolyRef polys_[MAX_POLYS]; + dtPolyRef last_raycast_poly_ref_ = 0; std::vector poly_ext_datas_; std::vector grass_pos_hash_;