mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-02 23:54:10 +00:00
Update Recastnavigation to 3a619d773deb7e3a15ee215217c825995fe71312
This commit is contained in:
parent
2b3bc4fe61
commit
dbf6780dde
90
extern/recastnavigation/.travis.yml
vendored
90
extern/recastnavigation/.travis.yml
vendored
@ -1,36 +1,72 @@
|
|||||||
sudo: false
|
|
||||||
|
|
||||||
language: cpp
|
language: cpp
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- coverity_scan
|
||||||
|
- /recast-.*$/
|
||||||
|
|
||||||
# Build with gcc and clang.
|
sudo: false
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
- clang
|
|
||||||
|
|
||||||
# Build both debug and release configurations, through use of an environment variable in the build matrix.
|
|
||||||
env:
|
|
||||||
- BUILD_TYPE=debug CMAKE_BUILD_TYPE=Debug
|
|
||||||
- BUILD_TYPE=release CMAKE_BUILD_TYPE=Release
|
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
sources:
|
||||||
- libsdl2-dev
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-xenial-7
|
||||||
|
packages: [ cmake, clang-7, clang-tools-7, gcc-8, g++-8, libsdl2-dev ]
|
||||||
|
|
||||||
install:
|
matrix:
|
||||||
- wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-linux.tar.gz -O premake.tar.gz
|
include:
|
||||||
- tar -xf premake.tar.gz
|
- name: Recastnavigation (all) on MacOS xcode9.4
|
||||||
- rm premake.tar.gz
|
os: osx
|
||||||
|
osx_image: xcode9.4
|
||||||
|
before_install:
|
||||||
|
- brew update
|
||||||
|
- brew install sdl2
|
||||||
|
if: branch != coverity_scan
|
||||||
|
- name: Recastnavigation on Ubuntu Xenial GCC-5
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
sudo: required
|
||||||
|
if: branch != coverity_scan
|
||||||
|
- name: Recastnavigation on Ubuntu Xenial GCC-8
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
sudo: required
|
||||||
|
env:
|
||||||
|
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
|
||||||
|
if: branch != coverity_scan
|
||||||
|
- name: Recastnavigation on Ubuntu Xenial GCC-5 using Premake5
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
sudo: required
|
||||||
|
if: branch != coverity_scan
|
||||||
|
before_install:
|
||||||
|
- wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-linux.tar.gz -O premake.tar.gz
|
||||||
|
- tar -xf premake.tar.gz
|
||||||
|
env:
|
||||||
|
- PREMAKE=1
|
||||||
|
- name: Recastnavigation on Ubuntu Xenial Clang-7 with Static Analysis
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
sudo: required
|
||||||
|
env:
|
||||||
|
- MATRIX_EVAL="CC=clang-7 && CXX=clang++-7"
|
||||||
|
- ANALYZE="scan-build-7 --force-analyze-debug-code --use-cc clang-7 --use-c++ clang++-7"
|
||||||
|
if: branch != coverity_scan
|
||||||
|
compiler: clang
|
||||||
|
- name: Recastnavigation Coverity Scan
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
sudo: required
|
||||||
|
if: branch = coverity_scan
|
||||||
|
|
||||||
# Run premake to generate makefiles.
|
|
||||||
# Have to cd into directory and back out since premake5 doesn't appear to accept a directory argument.
|
|
||||||
before_script:
|
before_script:
|
||||||
- cd RecastDemo && ../premake5 gmake && cd ..
|
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then eval "${MATRIX_EVAL}"; fi
|
||||||
- mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} .. && cd ..
|
- if [ "${PREMAKE}" = "1" ]; then cd RecastDemo && ../premake5 gmake && cd ..; fi
|
||||||
|
- if [ "${PREMAKE}" != "1" ]; then mkdir -p build && cd build && ${ANALYZE} cmake ../ && cd ..; fi
|
||||||
|
|
||||||
# Run make in the directory containing generated makefiles, on the configuration specified by the environment variable.
|
script: # 2 CPUs on Travis-CI + 1 extra for IO bound process
|
||||||
script:
|
- if [ "${PREMAKE}" = "1" ]; then make -C RecastDemo/Build/gmake -j3; fi
|
||||||
- make -C RecastDemo/Build/gmake -j$(nproc) config=${BUILD_TYPE}
|
- if [ "${PREMAKE}" != "1" ]; then make -C build -j3; fi
|
||||||
- RecastDemo/Bin/Tests
|
- if [ "${PREMAKE}" = "1" ]; then RecastDemo/Bin/Tests; fi
|
||||||
- make -C build -j$(nproc)
|
- if [ "${PREMAKE}" != "1" ]; then cd build && ctest; fi
|
||||||
- cd build && ctest
|
|
||||||
|
@ -283,6 +283,28 @@ inline bool dtVequal(const float* p0, const float* p1)
|
|||||||
return d < thr;
|
return d < thr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks that the specified vector's components are all finite.
|
||||||
|
/// @param[in] v A point. [(x, y, z)]
|
||||||
|
/// @return True if all of the point's components are finite, i.e. not NaN
|
||||||
|
/// or any of the infinities.
|
||||||
|
inline bool dtVisfinite(const float* v)
|
||||||
|
{
|
||||||
|
bool result =
|
||||||
|
dtMathIsfinite(v[0]) &&
|
||||||
|
dtMathIsfinite(v[1]) &&
|
||||||
|
dtMathIsfinite(v[2]);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Checks that the specified vector's 2D components are finite.
|
||||||
|
/// @param[in] v A point. [(x, y, z)]
|
||||||
|
inline bool dtVisfinite2D(const float* v)
|
||||||
|
{
|
||||||
|
bool result = dtMathIsfinite(v[0]) && dtMathIsfinite(v[2]);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// Derives the dot product of two vectors on the xz-plane. (@p u . @p v)
|
/// Derives the dot product of two vectors on the xz-plane. (@p u . @p v)
|
||||||
/// @param[in] u A vector [(x, y, z)]
|
/// @param[in] u A vector [(x, y, z)]
|
||||||
/// @param[in] v A vector [(x, y, z)]
|
/// @param[in] v A vector [(x, y, z)]
|
||||||
|
@ -8,6 +8,9 @@ Members in this module are wrappers around the standard math library
|
|||||||
#define DETOURMATH_H
|
#define DETOURMATH_H
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
// This include is required because libstdc++ has problems with isfinite
|
||||||
|
// if cmath is included before math.h.
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
inline float dtMathFabsf(float x) { return fabsf(x); }
|
inline float dtMathFabsf(float x) { return fabsf(x); }
|
||||||
inline float dtMathSqrtf(float x) { return sqrtf(x); }
|
inline float dtMathSqrtf(float x) { return sqrtf(x); }
|
||||||
@ -16,5 +19,6 @@ inline float dtMathCeilf(float x) { return ceilf(x); }
|
|||||||
inline float dtMathCosf(float x) { return cosf(x); }
|
inline float dtMathCosf(float x) { return cosf(x); }
|
||||||
inline float dtMathSinf(float x) { return sinf(x); }
|
inline float dtMathSinf(float x) { return sinf(x); }
|
||||||
inline float dtMathAtan2f(float y, float x) { return atan2f(y, x); }
|
inline float dtMathAtan2f(float y, float x) { return atan2f(y, x); }
|
||||||
|
inline bool dtMathIsfinite(float x) { return std::isfinite(x); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -204,32 +204,31 @@ void dtCalcPolyCenter(float* tc, const unsigned short* idx, int nidx, const floa
|
|||||||
bool dtClosestHeightPointTriangle(const float* p, const float* a, const float* b, const float* c, float& h)
|
bool dtClosestHeightPointTriangle(const float* p, const float* a, const float* b, const float* c, float& h)
|
||||||
{
|
{
|
||||||
float v0[3], v1[3], v2[3];
|
float v0[3], v1[3], v2[3];
|
||||||
|
|
||||||
dtVsub(v0, c,a);
|
dtVsub(v0, c,a);
|
||||||
dtVsub(v1, b,a);
|
dtVsub(v1, b,a);
|
||||||
dtVsub(v2, p,a);
|
dtVsub(v2, p,a);
|
||||||
|
|
||||||
const float dot00 = dtVdot2D(v0, v0);
|
// Compute scaled barycentric coordinates
|
||||||
const float dot01 = dtVdot2D(v0, v1);
|
float denom = v0[0] * v1[2] - v0[2] * v1[0];
|
||||||
const float dot02 = dtVdot2D(v0, v2);
|
float u = v1[2] * v2[0] - v1[0] * v2[2];
|
||||||
const float dot11 = dtVdot2D(v1, v1);
|
float v = v0[0] * v2[2] - v0[2] * v2[0];
|
||||||
const float dot12 = dtVdot2D(v1, v2);
|
|
||||||
|
|
||||||
// Compute barycentric coordinates
|
if (denom < 0) {
|
||||||
const float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01);
|
denom = -denom;
|
||||||
const float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
|
u = -u;
|
||||||
const float v = (dot00 * dot12 - dot01 * dot02) * invDenom;
|
v = -v;
|
||||||
|
}
|
||||||
|
|
||||||
// The (sloppy) epsilon is needed to allow to get height of points which
|
// The (sloppy) epsilon is needed to allow to get height of points which
|
||||||
// are interpolated along the edges of the triangles.
|
// are interpolated along the edges of the triangles.
|
||||||
static const float EPS = 1e-4f;
|
float epsilon = - 1e-4f * denom;
|
||||||
|
|
||||||
// If point lies inside the triangle, return interpolated ycoord.
|
// If point lies inside the triangle, return interpolated ycoord.
|
||||||
if (u >= -EPS && v >= -EPS && (u+v) <= 1+EPS)
|
if (u >= epsilon && v >= epsilon && (u+v) <= denom - epsilon) {
|
||||||
{
|
h = a[1] + (v0[1]*u + v1[1]*v) / denom;
|
||||||
h = a[1] + v0[1]*u + v1[1]*v;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,6 +223,9 @@ dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*fr
|
|||||||
{
|
{
|
||||||
dtAssert(m_nav);
|
dtAssert(m_nav);
|
||||||
|
|
||||||
|
if (!filter || !frand || !randomRef || !randomPt)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
// Randomly pick one tile. Assume that all tiles cover roughly the same area.
|
// Randomly pick one tile. Assume that all tiles cover roughly the same area.
|
||||||
const dtMeshTile* tile = 0;
|
const dtMeshTile* tile = 0;
|
||||||
float tsum = 0.0f;
|
float tsum = 0.0f;
|
||||||
@ -319,8 +322,13 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f
|
|||||||
dtAssert(m_openList);
|
dtAssert(m_openList);
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
if (!m_nav->isValidPolyRef(startRef) ||
|
||||||
|
!centerPos || !dtVisfinite(centerPos) ||
|
||||||
|
maxRadius < 0 || !dtMathIsfinite(maxRadius) ||
|
||||||
|
!filter || !frand || !randomRef || !randomPt)
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
const dtMeshTile* startTile = 0;
|
const dtMeshTile* startTile = 0;
|
||||||
const dtPoly* startPoly = 0;
|
const dtPoly* startPoly = 0;
|
||||||
@ -513,6 +521,9 @@ dtStatus dtNavMeshQuery::closestPointOnPoly(dtPolyRef ref, const float* pos, flo
|
|||||||
if (!tile)
|
if (!tile)
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
|
if (!pos || !dtVisfinite(pos) || !closest)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
// Off-mesh connections don't have detail polygons.
|
// Off-mesh connections don't have detail polygons.
|
||||||
if (poly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (poly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
@ -608,6 +619,9 @@ dtStatus dtNavMeshQuery::closestPointOnPolyBoundary(dtPolyRef ref, const float*
|
|||||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
|
if (!pos || !dtVisfinite(pos) || !closest)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
// Collect vertices.
|
// Collect vertices.
|
||||||
float verts[DT_VERTS_PER_POLYGON*3];
|
float verts[DT_VERTS_PER_POLYGON*3];
|
||||||
float edged[DT_VERTS_PER_POLYGON];
|
float edged[DT_VERTS_PER_POLYGON];
|
||||||
@ -660,6 +674,9 @@ dtStatus dtNavMeshQuery::getPolyHeight(dtPolyRef ref, const float* pos, float* h
|
|||||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
|
if (!pos || !dtVisfinite2D(pos))
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
if (poly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (poly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
const float* v0 = &tile->verts[poly->verts[0]*3];
|
const float* v0 = &tile->verts[poly->verts[0]*3];
|
||||||
@ -768,6 +785,8 @@ dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* halfE
|
|||||||
if (!nearestRef)
|
if (!nearestRef)
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
|
// queryPolygons below will check rest of params
|
||||||
|
|
||||||
dtFindNearestPolyQuery query(this, center);
|
dtFindNearestPolyQuery query(this, center);
|
||||||
|
|
||||||
dtStatus status = queryPolygons(center, halfExtents, filter, &query);
|
dtStatus status = queryPolygons(center, halfExtents, filter, &query);
|
||||||
@ -972,8 +991,12 @@ dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* halfExt
|
|||||||
{
|
{
|
||||||
dtAssert(m_nav);
|
dtAssert(m_nav);
|
||||||
|
|
||||||
if (!center || !halfExtents || !filter || !query)
|
if (!center || !dtVisfinite(center) ||
|
||||||
|
!halfExtents || !dtVisfinite(halfExtents) ||
|
||||||
|
!filter || !query)
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
float bmin[3], bmax[3];
|
float bmin[3], bmax[3];
|
||||||
dtVsub(bmin, center, halfExtents);
|
dtVsub(bmin, center, halfExtents);
|
||||||
@ -1022,13 +1045,19 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
|||||||
dtAssert(m_nodePool);
|
dtAssert(m_nodePool);
|
||||||
dtAssert(m_openList);
|
dtAssert(m_openList);
|
||||||
|
|
||||||
if (pathCount)
|
if (!pathCount)
|
||||||
*pathCount = 0;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
|
*pathCount = 0;
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav->isValidPolyRef(startRef) || !m_nav->isValidPolyRef(endRef) ||
|
if (!m_nav->isValidPolyRef(startRef) || !m_nav->isValidPolyRef(endRef) ||
|
||||||
!startPos || !endPos || !filter || maxPath <= 0 || !path || !pathCount)
|
!startPos || !dtVisfinite(startPos) ||
|
||||||
|
!endPos || !dtVisfinite(endPos) ||
|
||||||
|
!filter || !path || maxPath <= 0)
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
if (startRef == endRef)
|
if (startRef == endRef)
|
||||||
{
|
{
|
||||||
@ -1263,18 +1292,21 @@ dtStatus dtNavMeshQuery::initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef
|
|||||||
m_query.status = DT_FAILURE;
|
m_query.status = DT_FAILURE;
|
||||||
m_query.startRef = startRef;
|
m_query.startRef = startRef;
|
||||||
m_query.endRef = endRef;
|
m_query.endRef = endRef;
|
||||||
dtVcopy(m_query.startPos, startPos);
|
if (startPos)
|
||||||
dtVcopy(m_query.endPos, endPos);
|
dtVcopy(m_query.startPos, startPos);
|
||||||
|
if (endPos)
|
||||||
|
dtVcopy(m_query.endPos, endPos);
|
||||||
m_query.filter = filter;
|
m_query.filter = filter;
|
||||||
m_query.options = options;
|
m_query.options = options;
|
||||||
m_query.raycastLimitSqr = FLT_MAX;
|
m_query.raycastLimitSqr = FLT_MAX;
|
||||||
|
|
||||||
if (!startRef || !endRef)
|
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav->isValidPolyRef(startRef) || !m_nav->isValidPolyRef(endRef))
|
if (!m_nav->isValidPolyRef(startRef) || !m_nav->isValidPolyRef(endRef) ||
|
||||||
|
!startPos || !dtVisfinite(startPos) ||
|
||||||
|
!endPos || !dtVisfinite(endPos) || !filter)
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
// trade quality with performance?
|
// trade quality with performance?
|
||||||
if (options & DT_FINDPATH_ANY_ANGLE)
|
if (options & DT_FINDPATH_ANY_ANGLE)
|
||||||
@ -1530,8 +1562,14 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter, int* doneIters)
|
|||||||
|
|
||||||
dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount, const int maxPath)
|
dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount, const int maxPath)
|
||||||
{
|
{
|
||||||
|
if (!pathCount)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
*pathCount = 0;
|
*pathCount = 0;
|
||||||
|
|
||||||
|
if (!path || maxPath <= 0)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
if (dtStatusFailed(m_query.status))
|
if (dtStatusFailed(m_query.status))
|
||||||
{
|
{
|
||||||
// Reset query.
|
// Reset query.
|
||||||
@ -1615,12 +1653,13 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount,
|
|||||||
dtStatus dtNavMeshQuery::finalizeSlicedFindPathPartial(const dtPolyRef* existing, const int existingSize,
|
dtStatus dtNavMeshQuery::finalizeSlicedFindPathPartial(const dtPolyRef* existing, const int existingSize,
|
||||||
dtPolyRef* path, int* pathCount, const int maxPath)
|
dtPolyRef* path, int* pathCount, const int maxPath)
|
||||||
{
|
{
|
||||||
|
if (!pathCount)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
*pathCount = 0;
|
*pathCount = 0;
|
||||||
|
|
||||||
if (existingSize == 0)
|
if (!existing || existingSize <= 0 || !path || !pathCount || maxPath <= 0)
|
||||||
{
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
return DT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dtStatusFailed(m_query.status))
|
if (dtStatusFailed(m_query.status))
|
||||||
{
|
{
|
||||||
@ -1824,13 +1863,18 @@ dtStatus dtNavMeshQuery::findStraightPath(const float* startPos, const float* en
|
|||||||
{
|
{
|
||||||
dtAssert(m_nav);
|
dtAssert(m_nav);
|
||||||
|
|
||||||
|
if (!straightPathCount)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
*straightPathCount = 0;
|
*straightPathCount = 0;
|
||||||
|
|
||||||
if (!maxStraightPath)
|
if (!startPos || !dtVisfinite(startPos) ||
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
!endPos || !dtVisfinite(endPos) ||
|
||||||
|
!path || pathSize <= 0 || !path[0] ||
|
||||||
if (!path[0])
|
maxStraightPath <= 0)
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
dtStatus stat = 0;
|
dtStatus stat = 0;
|
||||||
|
|
||||||
@ -2070,13 +2114,19 @@ dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* start
|
|||||||
dtAssert(m_nav);
|
dtAssert(m_nav);
|
||||||
dtAssert(m_tinyNodePool);
|
dtAssert(m_tinyNodePool);
|
||||||
|
|
||||||
|
if (!visitedCount)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
*visitedCount = 0;
|
*visitedCount = 0;
|
||||||
|
|
||||||
// Validate input
|
if (!m_nav->isValidPolyRef(startRef) ||
|
||||||
if (!startRef)
|
!startPos || !dtVisfinite(startPos) ||
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
!endPos || !dtVisfinite(endPos) ||
|
||||||
if (!m_nav->isValidPolyRef(startRef))
|
!filter || !resultPos || !visited ||
|
||||||
|
maxVisitedSize <= 0)
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
dtStatus status = DT_SUCCESS;
|
dtStatus status = DT_SUCCESS;
|
||||||
|
|
||||||
@ -2485,15 +2535,22 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
|||||||
{
|
{
|
||||||
dtAssert(m_nav);
|
dtAssert(m_nav);
|
||||||
|
|
||||||
|
if (!hit)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
hit->t = 0;
|
hit->t = 0;
|
||||||
hit->pathCount = 0;
|
hit->pathCount = 0;
|
||||||
hit->pathCost = 0;
|
hit->pathCost = 0;
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
if (!m_nav->isValidPolyRef(startRef) ||
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
!startPos || !dtVisfinite(startPos) ||
|
||||||
if (prevRef && !m_nav->isValidPolyRef(prevRef))
|
!endPos || !dtVisfinite(endPos) ||
|
||||||
|
!filter ||
|
||||||
|
(prevRef && !m_nav->isValidPolyRef(prevRef)))
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
float dir[3], curPos[3], lastPos[3];
|
float dir[3], curPos[3], lastPos[3];
|
||||||
float verts[DT_VERTS_PER_POLYGON*3+3];
|
float verts[DT_VERTS_PER_POLYGON*3+3];
|
||||||
@ -2735,11 +2792,18 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float*
|
|||||||
dtAssert(m_nodePool);
|
dtAssert(m_nodePool);
|
||||||
dtAssert(m_openList);
|
dtAssert(m_openList);
|
||||||
|
|
||||||
|
if (!resultCount)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
*resultCount = 0;
|
*resultCount = 0;
|
||||||
|
|
||||||
// Validate input
|
if (!m_nav->isValidPolyRef(startRef) ||
|
||||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
!centerPos || !dtVisfinite(centerPos) ||
|
||||||
|
radius < 0 || !dtMathIsfinite(radius) ||
|
||||||
|
!filter || maxResult < 0)
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
m_nodePool->clear();
|
m_nodePool->clear();
|
||||||
m_openList->clear();
|
m_openList->clear();
|
||||||
@ -2902,8 +2966,18 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v
|
|||||||
dtAssert(m_nodePool);
|
dtAssert(m_nodePool);
|
||||||
dtAssert(m_openList);
|
dtAssert(m_openList);
|
||||||
|
|
||||||
|
if (!resultCount)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
*resultCount = 0;
|
*resultCount = 0;
|
||||||
|
|
||||||
|
if (!m_nav->isValidPolyRef(startRef) ||
|
||||||
|
!verts || nverts < 3 ||
|
||||||
|
!filter || maxResult < 0)
|
||||||
|
{
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
@ -3089,11 +3163,18 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float*
|
|||||||
dtAssert(m_nav);
|
dtAssert(m_nav);
|
||||||
dtAssert(m_tinyNodePool);
|
dtAssert(m_tinyNodePool);
|
||||||
|
|
||||||
|
if (!resultCount)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
*resultCount = 0;
|
*resultCount = 0;
|
||||||
|
|
||||||
// Validate input
|
if (!m_nav->isValidPolyRef(startRef) ||
|
||||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
!centerPos || !dtVisfinite(centerPos) ||
|
||||||
|
radius < 0 || !dtMathIsfinite(radius) ||
|
||||||
|
!filter || maxResult < 0)
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
static const int MAX_STACK = 48;
|
static const int MAX_STACK = 48;
|
||||||
dtNode* stack[MAX_STACK];
|
dtNode* stack[MAX_STACK];
|
||||||
@ -3302,6 +3383,9 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter*
|
|||||||
{
|
{
|
||||||
dtAssert(m_nav);
|
dtAssert(m_nav);
|
||||||
|
|
||||||
|
if (!segmentCount)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
*segmentCount = 0;
|
*segmentCount = 0;
|
||||||
|
|
||||||
const dtMeshTile* tile = 0;
|
const dtMeshTile* tile = 0;
|
||||||
@ -3309,6 +3393,9 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter*
|
|||||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
|
if (!filter || !segmentVerts || maxSegments < 0)
|
||||||
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
static const int MAX_INTERVAL = 16;
|
static const int MAX_INTERVAL = 16;
|
||||||
dtSegInterval ints[MAX_INTERVAL];
|
dtSegInterval ints[MAX_INTERVAL];
|
||||||
@ -3455,8 +3542,13 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
|||||||
dtAssert(m_openList);
|
dtAssert(m_openList);
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
if (!m_nav->isValidPolyRef(startRef) ||
|
||||||
|
!centerPos || !dtVisfinite(centerPos) ||
|
||||||
|
maxRadius < 0 || !dtMathIsfinite(maxRadius) ||
|
||||||
|
!filter || !hitDist || !hitPos || !hitNormal)
|
||||||
|
{
|
||||||
return DT_FAILURE | DT_INVALID_PARAM;
|
return DT_FAILURE | DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
m_nodePool->clear();
|
m_nodePool->clear();
|
||||||
m_openList->clear();
|
m_openList->clear();
|
||||||
|
@ -38,7 +38,9 @@ endif()
|
|||||||
add_dependencies(RecastDemo DebugUtils Detour DetourCrowd DetourTileCache Recast)
|
add_dependencies(RecastDemo DebugUtils Detour DetourCrowd DetourTileCache Recast)
|
||||||
target_link_libraries(RecastDemo ${OPENGL_LIBRARIES} SDL2::SDL2main DebugUtils Detour DetourCrowd DetourTileCache Recast)
|
target_link_libraries(RecastDemo ${OPENGL_LIBRARIES} SDL2::SDL2main DebugUtils Detour DetourCrowd DetourTileCache Recast)
|
||||||
|
|
||||||
install(TARGETS RecastDemo RUNTIME DESTINATION bin)
|
install(TARGETS RecastDemo
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
BUNDLE DESTINATION bin)
|
||||||
install(DIRECTORY Bin/Meshes DESTINATION bin)
|
install(DIRECTORY Bin/Meshes DESTINATION bin)
|
||||||
install(DIRECTORY Bin/TestCases DESTINATION bin)
|
install(DIRECTORY Bin/TestCases DESTINATION bin)
|
||||||
install(FILES Bin/DroidSans.ttf DESTINATION bin)
|
install(FILES Bin/DroidSans.ttf DESTINATION bin)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user