mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 01:34:07 +00:00
fix: Falling Off Edge in Pet Puzzle (#1584)
* FloatFix * game activity setting * Update dNavMesh.cpp --------- Co-authored-by: David Markowitz <EmosewaMC@gmail.com>
This commit is contained in:
@@ -112,6 +112,31 @@ void dNavMesh::LoadNavmesh() {
|
||||
m_NavMesh = mesh;
|
||||
}
|
||||
|
||||
NiPoint3 dNavMesh::NearestPoint(const NiPoint3& location, const float halfExtent) const {
|
||||
NiPoint3 toReturn = location;
|
||||
if (m_NavMesh != nullptr) {
|
||||
float pos[3];
|
||||
pos[0] = location.x;
|
||||
pos[1] = location.y;
|
||||
pos[2] = location.z;
|
||||
|
||||
dtPolyRef nearestRef = 0;
|
||||
float polyPickExt[3] = { halfExtent, halfExtent, halfExtent };
|
||||
float nearestPoint[3] = { 0.0f, 0.0f, 0.0f };
|
||||
dtQueryFilter filter{};
|
||||
|
||||
auto hasPoly = m_NavQuery->findNearestPoly(pos, polyPickExt, &filter, &nearestRef, nearestPoint);
|
||||
if (hasPoly != DT_SUCCESS) {
|
||||
toReturn = location;
|
||||
} else {
|
||||
toReturn.x = nearestPoint[0];
|
||||
toReturn.y = nearestPoint[1];
|
||||
toReturn.z = nearestPoint[2];
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
float dNavMesh::GetHeightAtPoint(const NiPoint3& location, const float halfExtentsHeight) const {
|
||||
if (m_NavMesh == nullptr) {
|
||||
return location.y;
|
||||
|
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
/**
|
||||
* Get the height at a point
|
||||
*
|
||||
*
|
||||
* @param location The location to check for height at. This is the center of the search area.
|
||||
* @param halfExtentsHeight The half extents height of the search area. This is the distance from the center to the top and bottom of the search area.
|
||||
* The larger the value of halfExtentsHeight is, the larger the performance cost of the query.
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
*/
|
||||
float GetHeightAtPoint(const NiPoint3& location, const float halfExtentsHeight = 32.0f) const;
|
||||
std::vector<NiPoint3> GetPath(const NiPoint3& startPos, const NiPoint3& endPos, float speed = 10.0f);
|
||||
|
||||
NiPoint3 NearestPoint(const NiPoint3& location, const float halfExtent = 32.0f) const;
|
||||
bool IsNavmeshLoaded() { return m_NavMesh != nullptr; }
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user