Skip to content
Snippets Groups Projects
Select Git revision
  • 470a1f35f4e82ad3fa3ce48f6cefc983b9a7d8ce
  • 5.4 default protected
  • 5.5
  • dev/5.5
  • dev/5.4
  • dev/5.3_downgrade
  • feature/experimenttime_hack
  • 5.3 protected
  • _IntenSelect5.3
  • IntenSelect5.3
  • 4.27 protected
  • 4.26 protected
  • 5.0 protected
  • 4.22 protected
  • 4.21 protected
  • UE5.4-2024.1
  • UE5.4-2024.1-rc1
  • UE5.3-2023.1-rc3
  • UE5.3-2023.1-rc2
  • UE5.3-2023.1-rc
20 results

BP_RWTHVRContentExamplesGameModeBase.uasset

Blame
  • 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);
    };