Select Git revision
mem_usage.c
PointCloud.h 2.99 KiB
#pragma once
#include "CoreMinimal.h"
#include "GPUPointCloudRendererComponent.h"
#include "KdtreeCommon.h"
#include "UndoRedoManager.h"
#include "GameFramework/Actor.h"
#include "MetaCastBachelor/PointStorage/DensityField.h"
#include "PointCloud.generated.h"
class UGPUPointCloudRendererComponent;
UCLASS()
class APointCloud : public AActor
{
GENERATED_BODY()
mutable FCriticalSection DataGuard;
FVector MinBounds;
FVector MaxBounds;
FKdtree MyKdTree;
UPROPERTY()
TArray<FVector> PositionVectors;
UPROPERTY()
TArray<bool> DefaultFlags;
UPROPERTY()
TArray<bool> SelectionFlags;
UPROPERTY()
TArray<FColor> PointColors;
UPROPERTY()
UGPUPointCloudRendererComponent* PointCloudVisualizer;
FUndoRedoManager MyUndoRedoManager;
public:
FDensityField* MyDensityField;
UPROPERTY(EditAnywhere)
float InfluenceRadius = 3.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Visualization")
float SplatSize = 1.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Files")
FFilePath PointInputData;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Files")
FFilePath FlagInputData;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Materials")
UMaterialInterface* SelectedMaterial;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Materials")
UMaterialInterface* UnselectedMaterial;
APointCloud();
void InitPointCloudVisualizer();
void UpdateBounds();
void SetupDensityFieldFromPointCloud() const;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
void UpdateSelection();
virtual void Tick(float DeltaTime) override;
public:
void DrawVoxel(const int Index, float Time) const;
void SelectAllPointsInVoxels(const TArray<int32> VoxelIndices);
void AddToSelection(const TArray<bool>& NewSelection);
void SubtractFromSelection(const TArray<bool>& NewSelection);
void SetSelection(const TArray<bool>& NewSelection);
void Undo();
void Redo();
const TArray<FVector>& GetPositionVectors() const
{
return PositionVectors;
}
const FVector& GetMinBounds() const
{
return MinBounds;
}
const FVector& GetMaxBounds() const
{
return MaxBounds;
}
UGPUPointCloudRendererComponent* GetPointCloudVisualizer() const
{
return PointCloudVisualizer;
}
void SetSelectionFlag(const int32 Index, const bool bValue)
{
if (SelectionFlags.IsValidIndex(Index))
{
SelectionFlags[Index] = bValue;
}
else
{
UE_LOG(LogTemp, Warning, TEXT("SetSelectionFlag: Invalid index %d"), Index);
}
}
bool GetSelectionFlag(const int32 Index) const
{
if (SelectionFlags.IsValidIndex(Index))
{
return SelectionFlags[Index];
}
UE_LOG(LogTemp, Warning, TEXT("GetSelectionFlag: Invalid index %d"), Index);
return false;
}
void SaveStateAndUpdate()
{
MyUndoRedoManager.AddState(SelectionFlags);
UpdateSelection();
}
int32 GetNumberOfPoints() const
{
return SelectionFlags.Num();
}
UFUNCTION(BlueprintCallable)
void ReadPointCloudFromFile(FFilePath FileNamePoints, FFilePath FileNameFlags);
};