CARLA
Loading...
Searching...
No Matches
CustomTerrainPhysicsComponent.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
12#ifdef WITH_PYTORCH
13THIRD_PARTY_INCLUDES_START
15THIRD_PARTY_INCLUDES_END
16#endif
17
18#include <util/ue-header-guard-begin.h>
19#include "Components/ActorComponent.h"
20#include "Components/PrimitiveComponent.h"
21#include "Engine/StaticMeshActor.h"
22#include "Engine/TextureRenderTarget2D.h"
23#include "Engine/DataAsset.h"
24#include "Engine/StreamableManager.h"
25#include "Async/Future.h"
26#include "Misc/ScopeLock.h"
27#include <util/ue-header-guard-end.h>
28
29#include <unordered_map>
30#include <vector>
31#include <string>
32
33#include "CustomTerrainPhysicsComponent.generated.h"
34
35
36UENUM(BlueprintType)
38{
39 E256M = 0 UMETA(DisplayName = "256M"),
40 E512M = 1 UMETA(DisplayName = "512M"),
41 E1K = 2 UMETA(DisplayName = "1K"),
42 E2K = 3 UMETA(DisplayName = "2K"),
43};
44
45UCLASS(BlueprintType)
47{
48 GENERATED_BODY()
49public:
50
51 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = HeightMapDataAsset)
52 int SizeX = 0;
53 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = HeightMapDataAsset)
54 int SizeY = 0;
55 UPROPERTY(BlueprintReadWrite, Category = HeightMapDataAsset)
56 TArray<float> HeightValues;
57};
58
60{
61 FDVector Position; // position in m
62 FVector Velocity;
63 float Radius = 0.02f;
64};
65
67{
69 UHeightMapDataAsset* DataAsset, FDVector Size, FDVector Origin,
70 FDVector Tile0, float ScaleZ);
71 float GetHeight(FDVector Position) const; // get height at a given global 2d position
72 void Clear();
73// private:
76 uint32_t Size_X;
77 uint32_t Size_Y;
78 float MinHeight = 0.0f;
79 float MaxHeight = 10.0f;
80 float Scale_Z = 1;
82 std::vector<float> Pixels;
83};
84
86{
87 FDenseTile();
89 FDenseTile(const FDenseTile& Origin);
90 FDenseTile(FDenseTile&& Origin);
92
93 void InitializeTile(uint32_t TextureSize, float AffectedRadius, float ParticleSize, float Depth,
94 FDVector TileOrigin, FDVector TileEnd, const FString& SavePath, const FHeightMapData &HeightMap);
95 std::vector<FParticle*> GetParticlesInRadius(FDVector Position, float Radius);
96 void GetParticlesInRadius(FDVector Position, float Radius, std::vector<FParticle*> &ParticlesInRadius);
97 void GetParticlesInBox(const FOrientedBox& OBox, std::vector<FParticle*> &ParticlesInRadius);
98 void GetAllParticles(std::vector<FParticle*> &ParticlesInRadius);
100
102 std::vector<FParticle> Particles;
103 std::vector<float> ParticlesHeightMap;
104 std::vector<std::multiset<float,std::greater<float>>> ParticlesZOrdered;
107 FString SavePath;
110 uint32_t TileSize = 0;
111};
112
114{
115public:
116 friend struct FTilesWorker;
117
118 FSparseHighDetailMap(float ParticleDiameter = 0.02f, float Depth = 0.4f)
119 : ParticleSize(ParticleDiameter), TerrainDepth(Depth) {};
120
121 void Init( uint32 NewTextureSize, float NewAffectedRadius, float ParticleDiameter,
122 float Depth, float NewFloorHeight )
123 {
124 ParticleSize = ParticleDiameter;
125 TerrainDepth = Depth;
126 TextureSize = NewTextureSize;
127 AffectedRadius = NewAffectedRadius;
128 FloorHeight = NewFloorHeight;
129 UE_LOG(LogCarla, Warning,
130 TEXT("ParticleSize %f"), ParticleSize);
131 }
132
133 inline float GetTileSize() const {
134 return TileSize;
135 }
136
137 std::vector<FParticle*> GetParticlesInRadius(FDVector Position, float Radius);
138 std::vector<FParticle*> GetParticlesInTileRadius(FDVector Position, float Radius);
139 std::vector<FParticle*> GetParticlesInBox(const FOrientedBox& OBox);
140 std::vector<uint64_t> GetIntersectingTiles(const FOrientedBox& OBox);
141 std::vector<uint64_t> GetLoadedTilesInRange(FDVector Position, float Radius);
142
143
144 FDenseTile& GetTile(uint32_t Tile_X, uint32_t Tile_Y);
146 FDenseTile& GetTile(uint64_t TileId);
147
148 FDenseTile& InitializeRegion(uint32_t Tile_X, uint32_t Tile_Y);
149 FDenseTile& InitializeRegion(uint64_t TileId);
150 FDenseTile& InitializeRegionInCache(uint64_t TileId);
151
152 uint64_t GetTileId(uint32_t Tile_X, uint32_t Tile_Y);
153 uint64_t GetTileId(uint64_t TileId);
154 uint64_t GetTileId(FDVector Position);
156 FIntVector GetVectorTileId(uint64_t TileId);
157 FDVector GetTilePosition(uint64_t TileId);
158 FDVector GetTilePosition(uint32_t Tile_X, uint32_t Tile_Y);
159
163
164 void InitializeMap(UHeightMapDataAsset* DataAsset,
165 FDVector Origin, FDVector MapSize, float Size, float ScaleZ);
166
167 void UpdateHeightMap(UHeightMapDataAsset* DataAsset,
168 FDVector Origin, FDVector MapSize, float Size, float ScaleZ);
169
170 void UpdateMaps(FDVector Position, float RadiusX, float RadiusY, float CacheRadiusX, float CacheRadiusY);
171
172 void Update(FVector Position, float RadiusX, float RadiusY);
173
174 void SaveMap();
175
176 void Clear();
177
179 {
180 Lock_Map.Lock();
181 }
182
184 {
185 Lock_Map.Unlock();
186 }
187
188 std::vector<uint64_t> GetTileIdInMap()
189 {
190 std::vector<uint64_t> Result;
191 for (auto& Iter : Map)
192 {
193 Result.emplace_back(Iter.first);
194 }
195 return Result;
196 }
197 std::vector<uint64_t> GetTileIdInCache()
198 {
199 std::vector<uint64_t> Result;
200 for (auto& Iter : CacheMap)
201 {
202 Result.emplace_back(Iter.first);
203 }
204 return Result;
205 }
206
207 std::unordered_map<uint64_t, FDenseTile> Map;
208 std::unordered_map<uint64_t, FDenseTile> CacheMap;
209 FString SavePath;
210 FCriticalSection Lock_Particles;
211private:
212 std::unordered_map<uint64_t, FDenseTile> TilesToWrite;
215 float TileSize = 1.f; // 1m per tile
217 float ParticleSize = 0.02f;
218 float TerrainDepth = 0.4f;
219 float FloorHeight = 0.0f;
220 uint32 TextureSize = 0;
221 float AffectedRadius = 0.0f;
223 FCriticalSection Lock_Map; // UE4 Mutex
224 FCriticalSection Lock_CacheMap; // UE4 Mutex
225 FCriticalSection Lock_GetTile;
226 FCriticalSection Lock_Position; // UE4 Mutex
227
228};
229
230USTRUCT(BlueprintType)
232{
233 GENERATED_BODY()
234
235 UPROPERTY(EditAnywhere, BlueprintReadWrite)
236 FVector Force = FVector::ZeroVector;
237 UPROPERTY(EditAnywhere, BlueprintReadWrite)
238 FVector Location = FVector::ZeroVector;
239};
240
241UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
242class CARLA_API UCustomTerrainPhysicsComponent : public UActorComponent
243{
244 GENERATED_BODY()
245 friend struct FTilesWorker;
246public:
247
248 UCustomTerrainPhysicsComponent();
249
250 virtual void BeginPlay() override;
251 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
252
253 virtual void TickComponent(float DeltaTime,
254 ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction);
255
256 // UFUNCTION(BlueprintCallable)
257 // TArray<FHitResult> SampleTerrainRayCast(const TArray<FVector> &Locations);
258
259 UFUNCTION(BlueprintCallable)
260 void AddForces(const TArray<FForceAtLocation> &Forces);
261
262 UFUNCTION(BlueprintCallable)
263 static void BuildLandscapeHeightMapDataAasset(ALandscapeProxy* Landscape,
264 int Resolution, FVector MapSize, FString AssetPath, FString AssetName);
265
266 UFUNCTION(BlueprintCallable)
267 float GetHeightAtLocation(ALandscapeProxy * Landscape, FVector Location);
268
269 UFUNCTION(BlueprintCallable)
270 TArray<FVector> GetParticlesInRadius(FVector Position, float Radius);
271
272 UFUNCTION(BlueprintCallable)
273 TArray<FVector> GetParticlesInTileRadius(FVector Position, float Radius);
274
275 UFUNCTION(BlueprintCallable)
276 FVector GetTileCenter(FVector Position);
277
278 UFUNCTION(BlueprintCallable, Category="Tiles")
279 void UpdateMaps(FVector Position, float RadiusX, float RadiusY, float CacheRadiusX, float CacheRadiusY);
280
281 UFUNCTION(BlueprintCallable, Category="Texture")
282 void InitTexture();
283
284 UFUNCTION(BlueprintCallable, Category="Texture")
285 void UpdateTexture();
286
287 UFUNCTION(BlueprintCallable, Category="Texture")
288 void UpdateLoadedTextureDataRegions();
289
290 UPROPERTY(EditAnywhere, BlueprintReadWrite)
291 UHeightMapDataAsset* DataAsset;
292
293 UFUNCTION(BlueprintCallable, Category="Texture")
294 void UpdateLargeTexture();
295
296 UFUNCTION(BlueprintCallable, Category="Texture")
297 void UpdateLargeTextureData();
298
299 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="MaterialParameters")
300 UTexture2D* TextureToUpdate;
301 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="MaterialParameters")
302 float MinDisplacement = -100;
303 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="MaterialParameters")
304 float MaxDisplacement = 100;
305
306 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="MaterialParameters")
307 UTexture2D* LargeTextureToUpdate;
308
309 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="MaterialParameters")
310 UMaterialParameterCollection* MPC;
311
312 UPROPERTY(EditAnywhere, BlueprintReadWrite)
313 FString NeuralModelFile = "";
314
315 UPROPERTY(EditAnywhere, BlueprintReadWrite)
316 FVector NextPositionToUpdate = FVector(0,0,0);
317
318 FVector LastUpdatedPosition;
319 FVector CachePosition;
320
321 FString SavePath;
322
323 UPROPERTY(EditAnywhere, BlueprintReadWrite)
324 float ForceMulFactor = 1.0;
325 UPROPERTY(EditAnywhere, BlueprintReadWrite)
326 float ParticleForceMulFactor = 1.0;
327 UPROPERTY(EditAnywhere, BlueprintReadWrite)
328 int SoilType = 0;
329 UPROPERTY(EditAnywhere, BlueprintReadWrite)
330 bool bUseSoilType = false;
331 UPROPERTY(EditAnywhere)
332 bool NNVerbose = false;
333 UPROPERTY(EditAnywhere, BlueprintReadWrite)
334 bool bUseLocalFrame = false;
335private:
336
337 void RunNNPhysicsSimulation(
338 ACarlaWheeledVehicle *Vehicle, float DeltaTime);
339 // TArray<FParticle*> GetParticlesInRange(...);
340 void SetUpParticleArrays(std::vector<FParticle*>& ParticlesIn,
341 TArray<float>& ParticlePosOut,
342 TArray<float>& ParticleVelOut,
343 const FTransform &WheelTransform);
344 void SetUpWheelArrays(ACarlaWheeledVehicle *Vehicle, int WheelIdx,
345 TArray<float>& WheelPos,
346 TArray<float>& WheelOrientation,
347 TArray<float>& WheelLinearVelocity,
348 TArray<float>& WheelAngularVelocity);
349 void UpdateParticles(
350 std::vector<FParticle*> Particles, std::vector<float> Forces,
351 float DeltaTime, const FTransform& WheelTransform);
352 void ApplyForcesToVehicle(
354 FVector ForceWheel0, FVector ForceWheel1, FVector ForceWheel2, FVector ForceWheel3,
355 FVector TorqueWheel0, FVector TorqueWheel1, FVector TorqueWheel2, FVector TorqueWheel3);
356 void ApplyMeanAccelerationToVehicle(
358 FVector ForceWheel0, FVector ForceWheel1, FVector ForceWheel2, FVector ForceWheel3);
359 void ApplyAccelerationToVehicle(
361 FVector ForceWheel0, FVector ForceWheel1, FVector ForceWheel2, FVector ForceWheel3);
362
363 void ApplyForces();
364 void LimitParticlesPerWheel(std::vector<FParticle*> &Particles);
365 void DrawParticles(UWorld* World, std::vector<FParticle*>& Particles,
366 FLinearColor Color = FLinearColor(1.f, 0.f, 0.f));
367 void DrawParticlesArray(UWorld* World, TArray<float>& ParticlesArray,
368 FLinearColor Color = FLinearColor(1.f, 0.f, 0.f));
369 void DrawOrientedBox(UWorld* World, const TArray<FOrientedBox>& Boxes);
370 void DrawTiles(UWorld* World, const std::vector<uint64_t>& TilesIds, float Height = 0,
371 FLinearColor Color = FLinearColor(0.0,1.0,0.0,1.0));
372 void GenerateBenchmarkParticles(std::vector<FParticle>& BenchParticles,
373 std::vector<FParticle*> &ParticlesWheel0, std::vector<FParticle*> &ParticlesWheel1,
374 std::vector<FParticle*> &ParticlesWheel2, std::vector<FParticle*> &ParticlesWheel3,
375 FOrientedBox &BboxWheel0, FOrientedBox &BboxWheel1,
376 FOrientedBox &BboxWheel2, FOrientedBox &BboxWheel3);
377
378 void UpdateParticlesDebug(std::vector<FParticle*> Particles);
379
380 void OnLevelAddedToWorld(ULevel* InLevel, UWorld* InWorld);
381
382 void UpdateTilesHeightMaps( const std::vector<FParticle*>& Particles);
383 void RemoveParticlesFromOrderedContainer(const std::vector<FParticle*>& Particles);
384 void AddParticlesToOrderedContainer(const std::vector<FParticle*>& Particles);
385 void FlagTilesToRedoOrderedContainer(const std::vector<FParticle*>& Particles);
386 void UpdateTilesHeightMapsInRadius(FDVector Position, uint32 Rad );
387
388 void AddForceToSingleWheel(USkeletalMeshComponent* SkeletalMeshComponent,
389 FVector WheelPosition, FVector WheelNormalForce);
390
391 UPROPERTY(EditAnywhere)
392 TArray<FForceAtLocation> ForcesToApply;
393 UPROPERTY(EditAnywhere)
394 TObjectPtr<UPrimitiveComponent> RootComponent;
395 UPROPERTY(EditAnywhere)
396 float RayCastRange = 10.0f;
397
398public:
399 UPROPERTY(EditAnywhere)
400 FVector WorldSize = FVector(200000,200000,0);
401 UPROPERTY(EditAnywhere)
402 bool DrawDebugInfo = true;
403 UPROPERTY(EditAnywhere)
404 bool bUpdateParticles = false;
405 // Radius of the data loaded in memory
406 UPROPERTY(EditAnywhere, Category="Tiles")
407 FVector TileRadius = FVector( 100, 100, 0 );
408 // Radius of the data loaded in memory
409 UPROPERTY(EditAnywhere, Category="Tiles")
410 FVector CacheRadius = FVector( 50, 50, 0 );
411 UPROPERTY(EditAnywhere, Category="Tiles")
412 bool bDrawLoadedTiles = false;
413 UPROPERTY(EditAnywhere, Category="Tiles")
414 int32 TileSize = 1;
415 UPROPERTY(EditAnywhere, Category="Tiles")
416 bool bRemoveLandscapeColliders = false;
417private:
418 // TimeToTriggerCacheReload In seconds
419 UPROPERTY(EditAnywhere, Category="Tiles")
420 float TimeToTriggerCacheReload = 20.0f;
421 // TimeToTriggerLoadTiles in MS
422 UPROPERTY(EditAnywhere, Category="Tiles")
423 float TimeToTriggerLoadTiles = 1.0f;
424 UPROPERTY(EditAnywhere, Category="Tiles")
425 float TimeToTriggerUnLoadTiles = 5.0f;
426 // Radius of the data collected by the texture in METERS
427 UPROPERTY(EditAnywhere, Category="MaterialParameters")
428 float TextureRadius = 4.0f;
429 // Radius of the data collected by the texture in METERS
430 UPROPERTY(EditAnywhere, Category="MaterialParameters")
431 float LargeTextureRadius = 50.0f;
432 // Scalar Factor of deformation effect applied in the landscape
433 UPROPERTY(EditAnywhere, Category="MaterialParameters")
434 float EffectMultiplayer = 10.0f;
435
436 UPROPERTY(EditAnywhere, Category="MaterialParameters")
437 TEnumAsByte<EDefResolutionType> ChosenRes = EDefResolutionType::E1K;
438 UPROPERTY(EditAnywhere, Category="MaterialParameters")
439 TMap<TEnumAsByte<EDefResolutionType>, UTexture2D*> TexturesRes;
440
441 bool bVisualization = false;
442
443 UPROPERTY(EditAnywhere, Category="DeformationMesh")
444 bool bUseDeformationPlane = false;
445 UPROPERTY(EditAnywhere, Category="DeformationMesh")
446 TObjectPtr<UStaticMesh> DeformationPlaneMesh = nullptr;
447 UPROPERTY(EditAnywhere, Category="DeformationMesh")
448 TObjectPtr<UMaterialInstance> DeformationPlaneMaterial = nullptr;
449 UPROPERTY(VisibleAnywhere, Category="DeformationMesh")
450 TObjectPtr<AStaticMeshActor> DeformationPlaneActor = nullptr;
451
452 UPROPERTY()
453 TObjectPtr<UMaterialParameterCollectionInstance> MPCInstance;
454
455 UPROPERTY(EditAnywhere, Category="Forces")
456 float NormalForceIntensity = 100;
457
458 UPROPERTY(EditAnywhere)
459 float SearchRadius = 100;
460 UPROPERTY(EditAnywhere)
461 float ParticleDiameter = 2;
462 UPROPERTY(EditAnywhere)
463 float TerrainDepth = 40;
464 UPROPERTY(EditAnywhere)
465 TObjectPtr<AActor> FloorActor = nullptr;
466 UPROPERTY(EditAnywhere)
467 bool bUseDynamicModel = false;
468 UPROPERTY(EditAnywhere)
469 bool bUseCUDAModel = false;
470
471 UPROPERTY(EditAnywhere)
472 float TireRadius = 33.0229f;
473 UPROPERTY(EditAnywhere)
474 float TireWidth = 21.21f;
475 UPROPERTY(EditAnywhere)
476 float BoxSearchForwardDistance = 114.39f;
477 UPROPERTY(EditAnywhere)
478 float BoxSearchLateralDistance = 31.815f;
479 UPROPERTY(EditAnywhere)
480 float BoxSearchDepthDistance = 20.f;
481 UPROPERTY(EditAnywhere)
482 bool bDisableVehicleGravity = false;
483 UPROPERTY(EditAnywhere)
484 float MaxForceMagnitude = 1000000.f;
485 UPROPERTY(EditAnywhere)
486 float FloorHeight = 0.f;
487 UPROPERTY(EditAnywhere)
488 bool bUseImpulse = false;
489 UPROPERTY(EditAnywhere)
490 bool bUseMeanAcceleration = false;
491 UPROPERTY(EditAnywhere)
492 bool bShowForces = true;
493 UPROPERTY(EditAnywhere)
494 float MinHeight = 0;
495 UPROPERTY(EditAnywhere)
496 float MaxHeight = 10;
497 UPROPERTY(EditAnywhere)
498 FVector Tile0Origin;
499 UPROPERTY(EditAnywhere)
500 bool bDrawHeightMap = false;
501 UPROPERTY(EditAnywhere)
502 FVector DrawStart = FVector(0);
503 UPROPERTY(EditAnywhere)
504 FVector DrawEnd = FVector(1000, 1000, 0);
505 UPROPERTY(EditAnywhere)
506 FVector DrawInterval = FVector(100,100,0);
507 UPROPERTY(EditAnywhere)
508 int CUDADevice = 0;
509 UPROPERTY(EditAnywhere)
510 FVector HeightMapScaleFactor = FVector(1, 1, 1);
511 UPROPERTY(EditAnywhere)
512 FVector HeightMapOffset = FVector(0, 0, 0);
513 UPROPERTY(EditAnywhere)
514 bool bBenchMark = false;
515 UPROPERTY(EditAnywhere)
516 int MaxParticlesPerWheel = 6000;
517
518 UPROPERTY(EditAnywhere)
519 FVector Radius = FVector(10,10,10);
520
521 UPROPERTY(VisibleAnywhere)
522 FIntVector CurrentLargeMapTileId = FIntVector(-1,-1,0);
523 UPROPERTY(VisibleAnywhere)
524 TObjectPtr<ALargeMapManager> LargeMapManager = nullptr;
525
526 // Async heightmap streaming state.
527 // ActiveHeightMap keeps the most recently applied data asset rooted for GC
528 // while the streaming handle is the primary owner during the in-flight load.
529 UPROPERTY(Transient, DuplicateTransient)
530 TObjectPtr<UHeightMapDataAsset> ActiveHeightMap = nullptr;
531 TSharedPtr<FStreamableHandle> PendingHeightMapHandle;
532 FIntVector PendingHeightMapTileId = FIntVector(-1, -1, 0);
533
534 void OnHeightMapLoaded();
535
536 UPROPERTY()
537 TArray<TObjectPtr<ACarlaWheeledVehicle>> Vehicles;
538 FSparseHighDetailMap SparseMap;
539 TArray<uint8> Data;
540 TArray<uint8> LargeData;
541 #ifdef WITH_PYTORCH
542 carla::learning::NeuralModel TerramechanicsModel;
543 #endif
544
545 TFuture<bool> IterationCompleted;
546
547 class FRunnableThread* Thread;
548 struct FTilesWorker* TilesWorker;
549};
550
551struct FTilesWorker : public FRunnable
552{
553 FTilesWorker(class UCustomTerrainPhysicsComponent* TerrainComp, FVector NewPosition, float NewRadiusX, float NewRadiusY );
554
555 virtual ~FTilesWorker() override;
556
557 virtual uint32 Run() override;
558
559 class UCustomTerrainPhysicsComponent* CustomTerrainComp;
560 FVector Position;
561
562 double RadiusX;
563 double RadiusY;
564
565 volatile bool bShouldContinue = true;
566};
Base class for CARLA wheeled vehicles.
FIntVector GetVectorTileId(FDVector Position)
float GetHeight(FDVector Position)
FDenseTile & GetTile(uint32_t Tile_X, uint32_t Tile_Y)
FDenseTile & InitializeRegionInCache(uint64_t TileId)
FDenseTile & InitializeRegion(uint32_t Tile_X, uint32_t Tile_Y)
void Init(uint32 NewTextureSize, float NewAffectedRadius, float ParticleDiameter, float Depth, float NewFloorHeight)
std::vector< FParticle * > GetParticlesInTileRadius(FDVector Position, float Radius)
void InitializeMap(UHeightMapDataAsset *DataAsset, FDVector Origin, FDVector MapSize, float Size, float ScaleZ)
std::vector< uint64_t > GetTileIdInCache()
uint64_t GetTileId(uint64_t TileId)
std::vector< uint64_t > GetIntersectingTiles(const FOrientedBox &OBox)
void UpdateMaps(FDVector Position, float RadiusX, float RadiusY, float CacheRadiusX, float CacheRadiusY)
std::vector< uint64_t > GetLoadedTilesInRange(FDVector Position, float Radius)
std::unordered_map< uint64_t, FDenseTile > CacheMap
FSparseHighDetailMap(float ParticleDiameter=0.02f, float Depth=0.4f)
FDVector GetTilePosition(uint64_t TileId)
std::vector< FParticle * > GetParticlesInBox(const FOrientedBox &OBox)
std::vector< uint64_t > GetTileIdInMap()
uint64_t GetTileId(uint32_t Tile_X, uint32_t Tile_Y)
void Update(FVector Position, float RadiusX, float RadiusY)
std::vector< FParticle * > GetParticlesInRadius(FDVector Position, float Radius)
void UpdateHeightMap(UHeightMapDataAsset *DataAsset, FDVector Origin, FDVector MapSize, float Size, float ScaleZ)
std::unordered_map< uint64_t, FDenseTile > TilesToWrite
std::unordered_map< uint64_t, FDenseTile > Map
void GetParticlesInBox(const FOrientedBox &OBox, std::vector< FParticle * > &ParticlesInRadius)
std::vector< float > ParticlesHeightMap
std::vector< std::multiset< float, std::greater< float > > > ParticlesZOrdered
std::vector< FParticle > Particles
void InitializeTile(uint32_t TextureSize, float AffectedRadius, float ParticleSize, float Depth, FDVector TileOrigin, FDVector TileEnd, const FString &SavePath, const FHeightMapData &HeightMap)
void GetAllParticles(std::vector< FParticle * > &ParticlesInRadius)
std::vector< FParticle * > GetParticlesInRadius(FDVector Position, float Radius)
FDenseTile & operator=(FDenseTile &&Origin)
float GetHeight(FDVector Position) const
void InitializeHeightmap(UHeightMapDataAsset *DataAsset, FDVector Size, FDVector Origin, FDVector Tile0, float ScaleZ)
std::vector< float > Pixels
class UCustomTerrainPhysicsComponent * CustomTerrainComp
virtual uint32 Run() override