Skip to content

Commit

Permalink
fix #5943
Browse files Browse the repository at this point in the history
prior to 0cee2e4 the PE's acted as backup for the PF when
a (near-edge) starting position had no expandable neighbors
edge-clamping should not have appreciable side effects, but
time will tell
  • Loading branch information
rt committed Mar 29, 2018
1 parent d7686a0 commit a43bd75
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
32 changes: 23 additions & 9 deletions rts/Sim/MoveTypes/MoveMath/MoveMath.cpp
Expand Up @@ -109,13 +109,17 @@ float CMoveMath::GetPosSpeedMod(const MoveDef& moveDef, unsigned xSquare, unsign
/* Check if a given square-position is accessable by the MoveDef footprint. */
CMoveMath::BlockType CMoveMath::IsBlockedNoSpeedModCheck(const MoveDef& moveDef, int xSquare, int zSquare, const CSolidObject* collider)
{
const int xmin = xSquare - moveDef.xsizeh, xmax = xSquare + moveDef.xsizeh;
const int zmin = zSquare - moveDef.zsizeh, zmax = zSquare + moveDef.zsizeh;
const int xmin = Clamp(xSquare - moveDef.xsizeh, 0, mapDims.mapx - 1);
const int zmin = Clamp(zSquare - moveDef.zsizeh, 0, mapDims.mapy - 1);
const int xmax = Clamp(xSquare + moveDef.xsizeh, 0, mapDims.mapx - 1);
const int zmax = Clamp(zSquare + moveDef.zsizeh, 0, mapDims.mapy - 1);

#if 0
if (xmin < 0 || xmax >= mapDims.mapx)
return BLOCK_IMPASSABLE;
if (zmin < 0 || zmax >= mapDims.mapy)
return BLOCK_IMPASSABLE;
#endif

BlockType ret = BLOCK_NONE;

Expand All @@ -124,13 +128,16 @@ CMoveMath::BlockType CMoveMath::IsBlockedNoSpeedModCheck(const MoveDef& moveDef,
const int zOffset = z * mapDims.mapx;
for (int x = xmin; x <= xmax; x += FOOTPRINT_XSTEP) {
const BlockingMapCell& cell = groundBlockingObjectMap.GetCellUnsafeConst(zOffset + x);

for (const CSolidObject* collidee: cell) {
ret |= ObjectBlockType(moveDef, collidee, collider);
if (ret & BLOCK_STRUCTURE)
return ret;
if (((ret |= ObjectBlockType(moveDef, collidee, collider)) & BLOCK_STRUCTURE) == 0)
continue;

return ret;
}
}
}

return ret;
}

Expand Down Expand Up @@ -265,11 +272,17 @@ CMoveMath::BlockType CMoveMath::SquareIsBlocked(const MoveDef& moveDef, int xSqu

CMoveMath::BlockType CMoveMath::RangeIsBlocked(const MoveDef& moveDef, int xmin, int xmax, int zmin, int zmax, const CSolidObject* collider)
{
#if 0
if (xmin < 0 || xmax >= mapDims.mapx)
return BLOCK_IMPASSABLE;

if (zmin < 0 || zmax >= mapDims.mapy)
return BLOCK_IMPASSABLE;
#else
xmin = Clamp(xmin, 0, mapDims.mapx - 1);
zmin = Clamp(zmin, 0, mapDims.mapy - 1);
xmax = Clamp(xmax, 0, mapDims.mapx - 1);
zmax = Clamp(zmax, 0, mapDims.mapy - 1);
#endif

BlockType ret = BLOCK_NONE;

Expand All @@ -287,10 +300,11 @@ CMoveMath::BlockType CMoveMath::RangeIsBlocked(const MoveDef& moveDef, int xmin,
continue;

collidee->tempNum = tempNum;
ret |= ObjectBlockType(moveDef, collidee, collider);

if (ret & BLOCK_STRUCTURE)
return ret;
if (((ret |= ObjectBlockType(moveDef, collidee, collider)) & BLOCK_STRUCTURE) == 0)
continue;

return ret;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Path/Default/PathConstants.h
Expand Up @@ -26,7 +26,7 @@ static const float MEDRES_SEARCH_DISTANCE_EXT = (MEDRES_SEARCH_DISTANCE * 0.4f)
// how many recursive refinement attempts NextWayPoint should make
static constexpr unsigned int MAX_PATH_REFINEMENT_DEPTH = 4;

static constexpr unsigned int PATHESTIMATOR_VERSION = 90;
static constexpr unsigned int PATHESTIMATOR_VERSION = 91;

static constexpr unsigned int MEDRES_PE_BLOCKSIZE = 16;
static constexpr unsigned int LOWRES_PE_BLOCKSIZE = 32;
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Path/QTPFS/PathDefines.hpp
Expand Up @@ -27,7 +27,7 @@
#define QTPFS_MAX_NETPOINTS_PER_NODE_EDGE 3
#define QTPFS_NETPOINT_EDGE_SPACING_SCALE (1.0f / (QTPFS_MAX_NETPOINTS_PER_NODE_EDGE + 1))

#define QTPFS_CACHE_VERSION 13
#define QTPFS_CACHE_VERSION 14
#define QTPFS_CACHE_XACCESS

#define QTPFS_POSITIVE_INFINITY (std::numeric_limits<float>::infinity())
Expand Down

0 comments on commit a43bd75

Please sign in to comment.