Skip to content
Snippets Groups Projects
Select Git revision
  • ffc532f4c210696b8979562817addaaf644a1c31
  • 5.4 default protected
  • dev/5.6
  • dev/5.5
  • 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
21 results

CalibratioActor.h

Blame
  • CalibratioActor.h 2.18 KiB
    #pragma once
    
    #include "CoreMinimal.h"
    #include "Materials/MaterialInstanceDynamic.h"
    #include "Cluster/IDisplayClusterClusterManager.h"
    #include "Components/DisplayClusterSceneComponent.h"
    
    #include "GameFramework/Actor.h"
    #include "CalibratioActor.generated.h"
    
    UCLASS()
    class CALIBRATIO_API ACalibratioActor : public AActor
    {
    	GENERATED_BODY()
    
    public:
    	ACalibratioActor();
    
    protected:
    	virtual void BeginPlay() override;
    	virtual void PostInitializeComponents() override;
    	virtual void Tick(float DeltaSeconds) override;
    	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
    
    public:
    	UPROPERTY(VisibleAnywhere) UStaticMeshComponent* Mesh;
    	UPROPERTY(EditAnywhere) UMaterialInterface* BaseMaterial;
    	UPROPERTY(BlueprintReadWrite) float Threshold = FMath::DegreesToRadians(1.7f);
    	UPROPERTY(BlueprintReadWrite) float ResetTime = 0.5f;
    	UFUNCTION(Blueprintcallable) void ClusterDespawn();
    
    private:
    	DECLARE_DELEGATE_OneParam(FThresholdDelegate, float);
    	FOnClusterEventJsonListener ClusterEventListenerDelegate;
    
    	void CalibrationRun(float Angle);
    	bool IsTrackerCurrentlyVisible();
    	void LocalSetThreshold(float NewValue);
    	void LocalArmAndSetCalibration(float NewMin, float NewMax);
    	void LocalDespawn();
    	bool IsDeviceMoving(float Angle);
    	void LocalReset();
    
    	// Handling Cluster events
    	UFUNCTION() void ClusterReset();
    	UFUNCTION() void ClusterIncreaseThreshold();
    	UFUNCTION() void ClusterDecreaseThreshold();
    	void ClusterChangeThreshold(float Value);
    	void ClusterArmAndSetCalibration(float MinAngle, float MaxAngle);
    	void HandleClusterEvent(const FDisplayClusterClusterEventJson& Event);
    
    	float MinRotation{0};
    	float MaxRotation{0};
    	int CurrentCalibrationRuns{0};
    	int MaxCalibrationRuns{60};
    	FTimerHandle ResetTimerHandle;
    	TArray<float> LastRotations;
    
    	UPROPERTY() UMaterialInstanceDynamic* DynamicMaterial = nullptr;
    
    	FDateTime LastTimeVisible = FDateTime::MinValue();
    	FVector LastVisiblePosition = FVector(NAN, NAN, NAN);
    	bool FirstPositionSet = false;
    	uint32 AcceptedAbscenceTime = 500u; // in Milliseconds
    	UPROPERTY() USceneComponent* TrackedClusterComponent = nullptr;
    
    	//Overlay
    	TSubclassOf<class UCalibratioOverlay> Overlay_Class;
    	UPROPERTY() UCalibratioOverlay* Overlay;
    };