#pragma once #include "CoreMinimal.h" #include "ProceduralMeshComponent.h" #include "Core/Tuning/DescentTune_Terrain.h" class UProceduralMeshComponent; namespace Descent::World { /** Where a chunk is in its life (DESIGN_UE.md section 2.3). */ enum class EChunkState : uint8 { Uniform, // classified: all rock or all water, no data (UniformValue = +-4) Candidate, // may hold a surface; not filled yet (or its data was freed) Mixed, // filled: Data / Cut hold P^3 samples Empty, // filled once, no surface; data freed (queries use the analytic field) }; /** * One 20 m chunk. Owned and touched by the game thread only; a worker never sees one (jobs get copies). * Sample (i, j, k) of chunk C sits at ((C * CoreN - Pad) + (i, j, k)) * VoxelM metres. */ struct FTerrainChunk { FIntVector Key = FIntVector::ZeroValue; EChunkState State = EChunkState::Candidate; float UniformValue = 4.f; TArray Data; TArray Cut; TArray> Deposits; bool bDepositsKnown = false; bool bModified = false; // carved at least once: its data is kept for ever bool bDirty = false; // edited since the last mesh bool bJobInFlight = false; bool bMeshed = false; // has been given its mesh (Comp may still be null when there is no terrain actor) uint32 Version = 0; // incremented by every edit: a job result with another version is stale int32 Triangles = 0; int64 LastRemeshFrame = -100; UProceduralMeshComponent* Comp = nullptr; bool HasData() const { return Data.Num() == Descent::Tune::Terrain::P3; } FVector OriginM() const { return FVector(Key) * Descent::Tune::Terrain::ChunkM; } FVector CentreM() const { return (FVector(Key) + FVector(0.5)) * Descent::Tune::Terrain::ChunkM; } }; }