So, here’s what my 2 functions now look like, and the path finder is still failing exactly the same as before O_o
TArray<FDonNavigationVoxel*> ADonNavigationManager::FindOrSetupNeighborsForVolume(FDonNavigationVoxel* Volume)
{
// if (NavGraphCache.Contains(Volume))
// {
// auto neighbors = *NavGraphCache.Find(Volume); // copy by value so we don't pollute the cache implicit DOFs
//
// AppendImplictDOFNeighborsForVolume(Volume->X, Volume->Y, Volume->Z, neighbors);
//
// return neighbors;
// }
// else
{
// Neighbors not found, Lazy loading of NAV Graph for given volume commences...
TArray<FDonNavigationVoxel*> neighbors;
DiscoverNeighborsForVolume(Volume->X, Volume->Y, Volume->Z, neighbors);
NavGraphCache.Add(Volume, neighbors);
AppendImplictDOFNeighborsForVolume(Volume->X, Volume->Y, Volume->Z, neighbors);
return neighbors;
}
}
void ADonNavigationManager::AppendImplictDOFNeighborsForVolume(int32 x, int32 y, int32 z, TArray<FDonNavigationVoxel*>& Neighbors)
{
bool bNeedsValidaion = x == 0 || y == 0 || z == 0 || x == XGridSize - 1 || y == YGridSize - 1 || z == ZGridSize - 1;
// if (!bNeedsValidaion || (IsValidVolume(x + 1, y, z + 1) && IsValidVolume(x - 1, y, z + 1) && IsValidVolume(x + 1, y, z - 1) && IsValidVolume(x - 1, y, z - 1) &&
// IsValidVolume(x, y + 1, z + 1) && IsValidVolume(x, y - 1, z + 1) && IsValidVolume(x, y + 1, z - 1) && IsValidVolume(x, y - 1, z - 1) &&
// IsValidVolume(x + 1, y + 1, z) && IsValidVolume(x - 1, y + 1, z) && IsValidVolume(x + 1, y - 1, z - 1) && IsValidVolume(x - 1, y - 1, z))
// )
{
// X
//if (CanNavigate(&VolumeAtUnsafe(x + 1, y, z)) && CanNavigate(&VolumeAtUnsafe(x, y, z + 1)))
Neighbors.Add(&VolumeAtUnsafe(x + 1, y, z + 1));
//if (CanNavigate(&VolumeAtUnsafe(x - 1, y, z)) && CanNavigate(&VolumeAtUnsafe(x, y, z + 1)))
Neighbors.Add(&VolumeAtUnsafe(x - 1, y, z + 1));
//if (CanNavigate(&VolumeAtUnsafe(x + 1, y, z)) && CanNavigate(&VolumeAtUnsafe(x, y, z - 1)))
Neighbors.Add(&VolumeAtUnsafe(x + 1, y, z - 1));
//if (CanNavigate(&VolumeAtUnsafe(x - 1, y, z)) && CanNavigate(&VolumeAtUnsafe(x, y, z - 1)))
Neighbors.Add(&VolumeAtUnsafe(x - 1, y, z - 1));
//Y
//if (CanNavigate(&VolumeAtUnsafe(x, y + 1, z)) && CanNavigate(&VolumeAtUnsafe(x, y, z + 1)))
Neighbors.Add(&VolumeAtUnsafe(x, y + 1, z + 1));
//if (CanNavigate(&VolumeAtUnsafe(x, y - 1, z)) && CanNavigate(&VolumeAtUnsafe(x, y, z + 1)))
Neighbors.Add(&VolumeAtUnsafe(x, y - 1, z + 1));
//if (CanNavigate(&VolumeAtUnsafe(x, y + 1, z)) && CanNavigate(&VolumeAtUnsafe(x, y, z - 1)))
Neighbors.Add(&VolumeAtUnsafe(x, y + 1, z - 1));
//if (CanNavigate(&VolumeAtUnsafe(x, y - 1, z)) && CanNavigate(&VolumeAtUnsafe(x, y, z - 1)))
Neighbors.Add(&VolumeAtUnsafe(x, y - 1, z - 1));
//Z
//if (CanNavigate(&VolumeAtUnsafe(x + 1, y, z)) && CanNavigate(&VolumeAtUnsafe(x, y + 1, z)))
Neighbors.Add(&VolumeAtUnsafe(x + 1, y + 1, z));
//if (CanNavigate(&VolumeAtUnsafe(x - 1, y, z)) && CanNavigate(&VolumeAtUnsafe(x, y + 1, z)))
Neighbors.Add(&VolumeAtUnsafe(x - 1, y + 1, z));
//if (CanNavigate(&VolumeAtUnsafe(x + 1, y, z)) && CanNavigate(&VolumeAtUnsafe(x, y - 1, z)))
Neighbors.Add(&VolumeAtUnsafe(x + 1, y - 1, z));
//if (CanNavigate(&VolumeAtUnsafe(x - 1, y, z)) && CanNavigate(&VolumeAtUnsafe(x, y - 1, z)))
Neighbors.Add(&VolumeAtUnsafe(x - 1, y - 1, z));
}
}
To make things even weirder, here’s a screen grab of 2 use cases; one succeeds and one fails. The one that succeeds is a copy of the AI unit that I duped and slightly nudged over a bit towards the goal. It seems like distance from origin to goal is playing a factor, though I have no idea why.
I don’t have time to look into it further tonight, but will try tomorrow. Just wanted to send the new info out in case it triggered something for you