Skip to content

Instantly share code, notes, and snippets.

@Busata
Created October 8, 2017 12:35
Show Gist options
  • Save Busata/489ceff8589c699a90f7b6f1281f8a84 to your computer and use it in GitHub Desktop.
Save Busata/489ceff8589c699a90f7b6f1281f8a84 to your computer and use it in GitHub Desktop.
FAerialNavigationVoxel* AAerialNavigationManager::GetVoxel(int32 X, int32 Y, int32 Z)
{
auto Plane = NavigationData.Planes[Z];
int32 i = X + GetGridSize().X * Y;
FAerialNavigationVoxel Vox = Plane.Voxels[i]; //UStruct, TArray<FAerialNavigationVoxel> Voxels;
UE_LOG(LogTemp, Warning, TEXT("GetVoxelAt: %s"), *Vox.WorldLocation.ToString());
return &Plane.Voxels[i];
}
FAerialNavigationVoxel* AAerialNavigationManager::GetVoxelAt(FVector Location)
{
if (!IsLocationInBounds(Location)) { return nullptr; }
auto GridStart = GetGridStart();
int32 X = (Location.X - GridStart.X) / VoxelSize;
int32 Y = (Location.Y - GridStart.Y) / VoxelSize;
int32 Z = (Location.Z - GridStart.Z) / VoxelSize;
FAerialNavigationVoxel* VoxelPtr = GetVoxel(X, Y, Z);
UE_LOG(LogTemp, Warning, TEXT("GetVoxelAt: %s"), *VoxelPtr->WorldLocation.ToString());
return VoxelPtr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment