163 float distToStartPoly, distToEndPoly;
164 float startPoint[
VERTEX_SIZE] = {startPos.y, startPos.z, startPos.x};
165 float endPoint[
VERTEX_SIZE] = {endPos.y, endPos.z, endPos.x};
175 TC_LOG_DEBUG(
"maps",
"++ BuildPolyPath :: (startPoly == 0 || endPoly == 0)\n");
200 bool farFromPoly = (distToStartPoly > 7.0f || distToEndPoly > 7.0f);
203 TC_LOG_DEBUG(
"maps",
"++ BuildPolyPath :: farFromPoly distToStartPoly=%.3f distToEndPoly=%.3f\n", distToStartPoly, distToEndPoly);
205 bool buildShotrcut =
false;
210 G3D::Vector3 const& p = (distToStartPoly > 7.0f) ? startPos : endPos;
213 TC_LOG_DEBUG(
"maps",
"++ BuildPolyPath :: underWater case\n");
215 buildShotrcut =
true;
219 TC_LOG_DEBUG(
"maps",
"++ BuildPolyPath :: flying case\n");
221 buildShotrcut =
true;
237 dtVcopy(endPoint, closestPoint);
249 if (startPoly == endPoly)
251 TC_LOG_DEBUG(
"maps",
"++ BuildPolyPath :: (startPoly == endPoly)\n");
265 bool startPolyFound =
false;
266 bool endPolyFound =
false;
267 uint32 pathStartIndex = 0;
272 for (; pathStartIndex <
_polyLength; ++pathStartIndex)
277 TC_LOG_ERROR(
"maps",
"Invalid poly ref in BuildPolyPath. _polyLength: %u, pathStartIndex: %u,"
278 " startPos: %s, endPos: %s, mapid: %u",
279 _polyLength, pathStartIndex, startPos.toString().c_str(), endPos.toString().c_str(),
287 startPolyFound =
true;
292 for (pathEndIndex = _polyLength-1; pathEndIndex > pathStartIndex; --pathEndIndex)
300 if (startPolyFound && endPolyFound)
302 TC_LOG_DEBUG(
"maps",
"++ BuildPolyPath :: (startPolyFound && endPolyFound)\n");
308 _polyLength = pathEndIndex - pathStartIndex + 1;
311 else if (startPolyFound && !endPolyFound)
313 TC_LOG_DEBUG(
"maps",
"++ BuildPolyPath :: (startPolyFound && !endPolyFound)\n");
318 _polyLength -= pathStartIndex;
327 uint32 prefixPolyLength =
uint32(_polyLength * 0.8f + 0.5f);
350 uint32 suffixPolyLength = 0;
357 memset(hitNormal, 0,
sizeof(hitNormal));
367 (
int*)&suffixPolyLength,
387 (
int*)&suffixPolyLength,
399 TC_LOG_DEBUG(
"maps",
"++ m_polyLength=%u prefixPolyLength=%u suffixPolyLength=%u \n", _polyLength, prefixPolyLength, suffixPolyLength);
402 _polyLength = prefixPolyLength + suffixPolyLength - 1;
406 TC_LOG_DEBUG(
"maps",
"++ BuildPolyPath :: (!startPolyFound && !endPolyFound)\n");
420 memset(hitNormal, 0,
sizeof(hitNormal));
uint32 _polyLength
Definition: PathGenerator.h:80
float x
Definition: Vector3.h:62
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
PathType
Definition: PathGenerator.h:41
Definition: PathGenerator.h:47
Definition: PathGenerator.h:44
void SetActualEndPosition(G3D::Vector3 const &point)
Definition: PathGenerator.h:102
dtPolyRef GetPolyByLocation(float const *Point, float *Distance) const
Definition: PathGenerator.cpp:125
bool _straightLine
Definition: PathGenerator.h:88
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
dtStatus raycast(dtPolyRef startRef, const float *startPos, const float *endPos, const dtQueryFilter *filter, float *t, float *hitNormal, dtPolyRef *path, int *pathCount, const int maxPath) const
Definition: DetourNavMeshQuery.cpp:2306
Unit const *const _sourceUnit
Definition: PathGenerator.h:94
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
bool CanSwim() const
Definition: Creature.h:499
unsigned int dtStatus
Definition: DetourStatus.h:22
float y
Definition: Vector3.h:62
dtStatus findPath(dtPolyRef startRef, dtPolyRef endRef, const float *startPos, const float *endPos, const dtQueryFilter *filter, dtPolyRef *path, int *pathCount, const int maxPath) const
Definition: DetourNavMeshQuery.cpp:923
TypeID GetTypeId() const
Definition: Object.h:113
#define INVALID_POLYREF
Definition: PathGenerator.h:39
bool dtStatusSucceed(dtStatus status)
Definition: DetourStatus.h:41
G3D::int16 z
Definition: Vector3int16.h:46
#define MAP_ALL_LIQUIDS
Definition: Map.h:146
uint32_t uint32
Definition: Define.h:150
Movement::PointsArray _pathPoints
Definition: PathGenerator.h:82
G3D::int16 y
Definition: Vector2int16.h:38
bool dtStatusFailed(dtStatus status)
Definition: DetourStatus.h:47
ZLiquidStatus
Definition: Map.h:131
dtQueryFilter _filter
Definition: PathGenerator.h:98
uint32 GetMapId() const
Definition: Position.h:254
bool IsUnderWater(float x, float y, float z) const
Definition: Map.cpp:2622
Definition: PathGenerator.h:46
bool CanFly() const override
Definition: Creature.h:500
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
ObjectGuid const & GetGUID() const
Definition: Object.h:105
float z
Definition: Vector3.h:62
Definition: PathGenerator.h:48
Map const * GetBaseMap() const
Definition: Object.cpp:2199
Creature * ToCreature()
Definition: Object.h:194
dtNavMeshQuery const * _navMeshQuery
Definition: PathGenerator.h:96
PathType _type
Definition: PathGenerator.h:83
void BuildShortcut()
Definition: PathGenerator.cpp:585
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
#define VERTEX_SIZE
Definition: PathGenerator.h:38
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
#define MAX_PATH_LENGTH
Definition: PathGenerator.h:32
dtPolyRef _pathPolyRefs[MAX_PATH_LENGTH]
Definition: PathGenerator.h:79
void Clear()
Definition: PathGenerator.h:105
void BuildPointPath(float const *startPoint, float const *endPoint)
Definition: PathGenerator.cpp:474
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=nullptr) const
Definition: Map.cpp:2497
std::string ToString() const
Definition: ObjectGuid.cpp:99
dtStatus closestPointOnPoly(dtPolyRef ref, const float *pos, float *closest, bool *posOverPoly) const
Definition: DetourNavMeshQuery.cpp:505