Files
UnrealEngineUWP/Engine/Source/Runtime/NavigationSystem/Public/NavMesh/RecastNavMeshDataChunk.h
Aris Theophanidis e2dab4ca3d [WP navmesh] Limit tile building to the loaded space when using a WP dynamic navmesh
- Update and use active tiles when using URecastNavMeshDataChunk
- Keep track of dirty areas origin
- Fix some logs TileRef
#rb Mieszko.Zielinski
#jira UE-150793
#preflight 6286493e9016c6dd8982744e

[CL 20279641 by Aris Theophanidis in ue5-main branch]
2022-05-19 09:59:18 -04:00

115 lines
3.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "AI/Navigation/NavigationTypes.h"
#include "AI/Navigation/NavigationDataChunk.h"
#include "RecastNavMeshDataChunk.generated.h"
class FPImplRecastNavMesh;
struct FRecastTileData
{
struct FRawData
{
FRawData(uint8* InData);
~FRawData();
uint8* RawData;
};
FRecastTileData();
FRecastTileData(int32 TileDataSize, uint8* TileRawData, int32 TileCacheDataSize, uint8* TileCacheRawData);
// Location of attached tile
int32 OriginalX; // Tile X coordinates when gathered
int32 OriginalY; // Tile Y coordinates when gathered
int32 X;
int32 Y;
int32 Layer;
// Tile data
int32 TileDataSize;
TSharedPtr<FRawData> TileRawData;
// Compressed tile cache layer
int32 TileCacheDataSize;
TSharedPtr<FRawData> TileCacheRawData;
// Whether this tile is attached to NavMesh
bool bAttached;
};
class dtNavMesh;
class FPImplRecastNavMesh;
enum EGatherTilesCopyMode
{
NoCopy = 0,
CopyData = 1 << 0,
CopyCacheData = 1 << 1,
CopyDataAndCacheData = (CopyData | CopyCacheData)
};
/**
*
*/
UCLASS()
class NAVIGATIONSYSTEM_API URecastNavMeshDataChunk : public UNavigationDataChunk
{
GENERATED_UCLASS_BODY()
//~ Begin UObject Interface
virtual void Serialize(FArchive& Ar) override;
//~ End UObject Interface
/** Attaches tiles to specified navmesh, transferring tile ownership to navmesh */
TArray<uint32> AttachTiles(FPImplRecastNavMesh& NavMeshImpl);
/** Attaches tiles to specified navmesh */
TArray<uint32> AttachTiles(FPImplRecastNavMesh& NavMeshImpl, const bool bKeepCopyOfData, const bool bKeepCopyOfCacheData);
/** Detaches tiles from specified navmesh, taking tile ownership */
TArray<uint32> DetachTiles(FPImplRecastNavMesh& NavMeshImpl);
/** Detaches tiles from specified navmesh */
TArray<uint32> DetachTiles(FPImplRecastNavMesh& NavMeshImpl, const bool bTakeDataOwnership, const bool bTakeCacheDataOwnership);
/**
* Experimental: Moves tiles data on the xy plane by the offset (in tile coordinates) and rotation (in degree).
* @param NavMeshImpl Recast navmesh implementation.
* @param Offset Offset in tile coordinates.
* @param RotationDeg Rotation in degrees.
* @param RotationCenter World position
*/
void MoveTiles(FPImplRecastNavMesh& NavMeshImpl, const FIntPoint& Offset, const FVector::FReal RotationDeg, const FVector2D& RotationCenter);
/** Number of tiles in this chunk */
int32 GetNumTiles() const;
/** Const accessor to the list of tiles in the data chunk. */
const TArray<FRecastTileData>& GetTiles() const { return Tiles; }
/** Returns the AABB for the given tiles. */
void GetTilesBounds(const FPImplRecastNavMesh& NavMeshImpl, const TArray<int32>& TileIndices, FBox& OutBounds) const;
/** Mutable accessor to the list of tiles in the data chunk. */
TArray<FRecastTileData>& GetMutableTiles() { return Tiles; }
/** Releases all tiles that this chunk holds */
void ReleaseTiles();
/** Collect tiles with data and/or cache data from the provided TileIndices. */
void GetTiles(const FPImplRecastNavMesh* NavMeshImpl, const TArray<int32>& TileIndices, const EGatherTilesCopyMode CopyMode, const bool bMarkAsAttached = true);
private:
#if WITH_RECAST
void SerializeRecastData(FArchive& Ar, int32 NavMeshVersion);
#endif//WITH_RECAST
private:
TArray<FRecastTileData> Tiles;
};