mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
Cleanup Operator padding
This commit is contained in:
parent
9141299127
commit
e32b9953a1
264 changed files with 6715 additions and 6715 deletions
|
|
@ -224,7 +224,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
if (DT_SUCCESS == m_navMeshQuery->closestPointOnPoly(endPoly, endPoint, closestPoint))
|
||||
{
|
||||
dtVcopy(endPoint, closestPoint);
|
||||
setActualEndPosition(Vector3(endPoint[2],endPoint[0],endPoint[1]));
|
||||
setActualEndPosition(Vector3(endPoint[2], endPoint[0], endPoint[1]));
|
||||
}
|
||||
|
||||
m_type = PATHFIND_INCOMPLETE;
|
||||
|
|
@ -269,7 +269,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
}
|
||||
}
|
||||
|
||||
for (pathEndIndex = m_polyLength-1; pathEndIndex > pathStartIndex; --pathEndIndex)
|
||||
for (pathEndIndex = m_polyLength - 1; pathEndIndex > pathStartIndex; --pathEndIndex)
|
||||
if (m_pathPolyRefs[pathEndIndex] == endPoly)
|
||||
{
|
||||
endPolyFound = true;
|
||||
|
|
@ -286,7 +286,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
// just "cut" it out
|
||||
|
||||
m_polyLength = pathEndIndex - pathStartIndex + 1;
|
||||
memmove(m_pathPolyRefs, m_pathPolyRefs+pathStartIndex, m_polyLength*sizeof(dtPolyRef));
|
||||
memmove(m_pathPolyRefs, m_pathPolyRefs + pathStartIndex, m_polyLength * sizeof(dtPolyRef));
|
||||
}
|
||||
else if (startPolyFound && !endPolyFound)
|
||||
{
|
||||
|
|
@ -304,10 +304,10 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
|
||||
// take ~80% of the original length
|
||||
// TODO : play with the values here
|
||||
uint32 prefixPolyLength = uint32(m_polyLength*0.8f + 0.5f);
|
||||
memmove(m_pathPolyRefs, m_pathPolyRefs+pathStartIndex, prefixPolyLength*sizeof(dtPolyRef));
|
||||
uint32 prefixPolyLength = uint32(m_polyLength * 0.8f + 0.5f);
|
||||
memmove(m_pathPolyRefs, m_pathPolyRefs + pathStartIndex, prefixPolyLength * sizeof(dtPolyRef));
|
||||
|
||||
dtPolyRef suffixStartPoly = m_pathPolyRefs[prefixPolyLength-1];
|
||||
dtPolyRef suffixStartPoly = m_pathPolyRefs[prefixPolyLength - 1];
|
||||
|
||||
// we need any point on our suffix start poly to generate poly-path, so we need last poly in prefix data
|
||||
float suffixEndPoint[VERTEX_SIZE];
|
||||
|
|
@ -316,7 +316,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
// we can hit offmesh connection as last poly - closestPointOnPoly() don't like that
|
||||
// try to recover by using prev polyref
|
||||
--prefixPolyLength;
|
||||
suffixStartPoly = m_pathPolyRefs[prefixPolyLength-1];
|
||||
suffixStartPoly = m_pathPolyRefs[prefixPolyLength - 1];
|
||||
if (DT_SUCCESS != m_navMeshQuery->closestPointOnPoly(suffixStartPoly, endPoint, suffixEndPoint))
|
||||
{
|
||||
// suffixStartPoly is still invalid, error state
|
||||
|
|
@ -336,7 +336,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
&m_filter, // polygon search filter
|
||||
m_pathPolyRefs + prefixPolyLength - 1, // [out] path
|
||||
(int*)&suffixPolyLength,
|
||||
MAX_PATH_LENGTH-prefixPolyLength); // max number of polygons in output path
|
||||
MAX_PATH_LENGTH - prefixPolyLength); // max number of polygons in output path
|
||||
|
||||
if (!suffixPolyLength || dtResult != DT_SUCCESS)
|
||||
{
|
||||
|
|
@ -346,7 +346,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
sLog.outError("%u's Path Build failed: 0 length path", m_sourceUnit->GetGUIDLow());
|
||||
}
|
||||
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ m_polyLength=%u prefixPolyLength=%u suffixPolyLength=%u \n",m_polyLength, prefixPolyLength, suffixPolyLength);
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ m_polyLength=%u prefixPolyLength=%u suffixPolyLength=%u \n", m_polyLength, prefixPolyLength, suffixPolyLength);
|
||||
|
||||
// new path = prefix + suffix - overlap
|
||||
m_polyLength = prefixPolyLength + suffixPolyLength - 1;
|
||||
|
|
@ -394,7 +394,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
|
||||
void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint)
|
||||
{
|
||||
float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE];
|
||||
float pathPoints[MAX_POINT_PATH_LENGTH * VERTEX_SIZE];
|
||||
uint32 pointCount = 0;
|
||||
dtStatus dtResult = DT_FAILURE;
|
||||
if (m_useStraightPath)
|
||||
|
|
@ -435,10 +435,10 @@ void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint)
|
|||
|
||||
m_pathPoints.resize(pointCount);
|
||||
for (uint32 i = 0; i < pointCount; ++i)
|
||||
m_pathPoints[i] = Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]);
|
||||
m_pathPoints[i] = Vector3(pathPoints[i * VERTEX_SIZE + 2], pathPoints[i * VERTEX_SIZE], pathPoints[i * VERTEX_SIZE + 1]);
|
||||
|
||||
// first point is always our current location - we need the next one
|
||||
setActualEndPosition(m_pathPoints[pointCount-1]);
|
||||
setActualEndPosition(m_pathPoints[pointCount - 1]);
|
||||
|
||||
// force the given destination, if needed
|
||||
if (m_forceDestination &&
|
||||
|
|
@ -449,7 +449,7 @@ void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint)
|
|||
0.3f * dist3DSqr(getStartPosition(), getEndPosition()))
|
||||
{
|
||||
setActualEndPosition(getEndPosition());
|
||||
m_pathPoints[m_pathPoints.size()-1] = getEndPosition();
|
||||
m_pathPoints[m_pathPoints.size() - 1] = getEndPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -556,10 +556,10 @@ uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath,
|
|||
int32 furthestVisited = -1;
|
||||
|
||||
// Find furthest common polygon.
|
||||
for (int32 i = npath-1; i >= 0; --i)
|
||||
for (int32 i = npath - 1; i >= 0; --i)
|
||||
{
|
||||
bool found = false;
|
||||
for (int32 j = nvisited-1; j >= 0; --j)
|
||||
for (int32 j = nvisited - 1; j >= 0; --j)
|
||||
{
|
||||
if (path[i] == visited[j])
|
||||
{
|
||||
|
|
@ -580,19 +580,19 @@ uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath,
|
|||
|
||||
// Adjust beginning of the buffer to include the visited.
|
||||
uint32 req = nvisited - furthestVisited;
|
||||
uint32 orig = uint32(furthestPath+1) < npath ? furthestPath+1 : npath;
|
||||
uint32 size = npath-orig > 0 ? npath-orig : 0;
|
||||
if (req+size > maxPath)
|
||||
size = maxPath-req;
|
||||
uint32 orig = uint32(furthestPath + 1) < npath ? furthestPath + 1 : npath;
|
||||
uint32 size = npath - orig > 0 ? npath - orig : 0;
|
||||
if (req + size > maxPath)
|
||||
size = maxPath - req;
|
||||
|
||||
if (size)
|
||||
memmove(path+req, path+orig, size*sizeof(dtPolyRef));
|
||||
memmove(path + req, path + orig, size * sizeof(dtPolyRef));
|
||||
|
||||
// Store visited
|
||||
for (uint32 i = 0; i < req; ++i)
|
||||
path[i] = visited[(nvisited-1)-i];
|
||||
path[i] = visited[(nvisited - 1) - i];
|
||||
|
||||
return req+size;
|
||||
return req + size;
|
||||
}
|
||||
|
||||
bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
||||
|
|
@ -601,7 +601,7 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
|||
{
|
||||
// Find steer target.
|
||||
static const uint32 MAX_STEER_POINTS = 3;
|
||||
float steerPath[MAX_STEER_POINTS*VERTEX_SIZE];
|
||||
float steerPath[MAX_STEER_POINTS * VERTEX_SIZE];
|
||||
unsigned char steerPathFlags[MAX_STEER_POINTS];
|
||||
dtPolyRef steerPathPolys[MAX_STEER_POINTS];
|
||||
uint32 nsteerPath = 0;
|
||||
|
|
@ -616,7 +616,7 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
|||
{
|
||||
// Stop at Off-Mesh link or when point is further than slop away.
|
||||
if ((steerPathFlags[ns] & DT_STRAIGHTPATH_OFFMESH_CONNECTION) ||
|
||||
!inRangeYZX(&steerPath[ns*VERTEX_SIZE], startPos, minTargetDist, 1000.0f))
|
||||
!inRangeYZX(&steerPath[ns * VERTEX_SIZE], startPos, minTargetDist, 1000.0f))
|
||||
break;
|
||||
ns++;
|
||||
}
|
||||
|
|
@ -624,7 +624,7 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
|||
if (ns >= nsteerPath)
|
||||
return false;
|
||||
|
||||
dtVcopy(steerPos, &steerPath[ns*VERTEX_SIZE]);
|
||||
dtVcopy(steerPos, &steerPath[ns * VERTEX_SIZE]);
|
||||
steerPos[1] = startPos[1]; // keep Z value
|
||||
steerPosFlag = steerPathFlags[ns];
|
||||
steerPosRef = steerPathPolys[ns];
|
||||
|
|
@ -647,10 +647,10 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
|||
if (DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[0], startPos, iterPos))
|
||||
return DT_FAILURE;
|
||||
|
||||
if (DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[npolys-1], endPos, targetPos))
|
||||
if (DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[npolys - 1], endPos, targetPos))
|
||||
return DT_FAILURE;
|
||||
|
||||
dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos);
|
||||
dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], iterPos);
|
||||
nsmoothPath++;
|
||||
|
||||
// Move towards target a small advancement at a time until target reached or
|
||||
|
|
@ -671,7 +671,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
|||
// Find movement delta.
|
||||
float delta[VERTEX_SIZE];
|
||||
dtVsub(delta, steerPos, iterPos);
|
||||
float len = dtSqrt(dtVdot(delta,delta));
|
||||
float len = dtSqrt(dtVdot(delta, delta));
|
||||
// If the steer target is end of path or off-mesh link, do not move past the location.
|
||||
if ((endOfPath || offMeshConnection) && len < SMOOTH_PATH_STEP_SIZE)
|
||||
len = 1.0f;
|
||||
|
|
@ -701,7 +701,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
|||
dtVcopy(iterPos, targetPos);
|
||||
if (nsmoothPath < maxSmoothPathSize)
|
||||
{
|
||||
dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos);
|
||||
dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], iterPos);
|
||||
nsmoothPath++;
|
||||
}
|
||||
break;
|
||||
|
|
@ -720,7 +720,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
|||
}
|
||||
|
||||
for (uint32 i = npos; i < npolys; ++i)
|
||||
polys[i-npos] = polys[i];
|
||||
polys[i - npos] = polys[i];
|
||||
|
||||
npolys -= npos;
|
||||
|
||||
|
|
@ -730,7 +730,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
|||
{
|
||||
if (nsmoothPath < maxSmoothPathSize)
|
||||
{
|
||||
dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], startPos);
|
||||
dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], startPos);
|
||||
nsmoothPath++;
|
||||
}
|
||||
// Move position at the other side of the off-mesh link.
|
||||
|
|
@ -744,7 +744,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
|||
// Store results.
|
||||
if (nsmoothPath < maxSmoothPathSize)
|
||||
{
|
||||
dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos);
|
||||
dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], iterPos);
|
||||
nsmoothPath++;
|
||||
}
|
||||
}
|
||||
|
|
@ -760,16 +760,16 @@ bool PathFinder::inRangeYZX(const float* v1, const float* v2, float r, float h)
|
|||
const float dx = v2[0] - v1[0];
|
||||
const float dy = v2[1] - v1[1]; // elevation
|
||||
const float dz = v2[2] - v1[2];
|
||||
return (dx*dx + dz*dz) < r*r && fabsf(dy) < h;
|
||||
return (dx * dx + dz * dz) < r * r && fabsf(dy) < h;
|
||||
}
|
||||
|
||||
bool PathFinder::inRange(const Vector3& p1, const Vector3& p2, float r, float h) const
|
||||
{
|
||||
Vector3 d = p1-p2;
|
||||
return (d.x*d.x + d.y*d.y) < r*r && fabsf(d.z) < h;
|
||||
Vector3 d = p1 - p2;
|
||||
return (d.x * d.x + d.y * d.y) < r * r && fabsf(d.z) < h;
|
||||
}
|
||||
|
||||
float PathFinder::dist3DSqr(const Vector3& p1, const Vector3& p2) const
|
||||
{
|
||||
return (p1-p2).squaredLength();
|
||||
return (p1 - p2).squaredLength();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue