Skip to content
Snippets Groups Projects
Commit 9a3715d0 authored by David Gilbert's avatar David Gilbert :bug:
Browse files

Merge branch 'feature/refactor' into 'develop'

Feature/refactor

See merge request dgilbert/unrealopticalbench!3
parents 2715863d 113ae7df
No related branches found
No related tags found
No related merge requests found
Showing
with 1111 additions and 1454 deletions
......@@ -3,7 +3,7 @@
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Runtime/Engine/Classes/Camera/PlayerCameraManager.h"
#include "OptiXContext.h"
//#include "OptiXContext.h"
#include "Runtime/Engine/Classes/Components/SceneCaptureComponent2D.h"
#include "Runtime/Engine/Classes/Engine/TextureRenderTarget2D.h"
#include "Runtime/Engine/Classes/Components/SceneCaptureComponentCube.h"
......
This diff is collapsed.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/PrimitiveComponent.h"
#include "OptiXContextManager.h"
#include "OptiXCubemapLateUpdateComponent.generated.h"
/**
* Literally only here to update the lenses on applylateupdate, as the scene capture component is a USceneCompoenent and NOT
* a UPrimitiveComponent and can therefore not receive the lateupdate. This is incredibly annoying.
*/
UCLASS(Blueprintable, hidecategories = (Object), meta = (BlueprintSpawnableComponent))
class OPTIX_API UOptiXCubemapLateUpdateComponent : public UPrimitiveComponent
{
GENERATED_BODY()
public:
virtual FPrimitiveSceneProxy* CreateSceneProxy() override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXCubemapLateUpdateComponent")
void LinkOptiXComponent(UOptiXCubemapComponent* OptiXComponent);
//UFUNCTION(BlueprintPure, BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXCubemapLateUpdateComponent")
const uint32* GetOptiXComponentId() const
{
return &OptiXComponentId;
}
uint32 OptiXComponentId;
};
#pragma once
/*
See optix_declarations.h
This defines the same enums as UENUMS to be used in blueprints. I hope this actually works.
*/
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Engine/EngineTypes.h"
//
//
//UENUM()
//enum class URTformat : int32
//{
// RT_FORMAT_UNKNOWN = 0x100, /*!< Format unknown */
// RT_FORMAT_FLOAT, /*!< Float */
// RT_FORMAT_FLOAT2, /*!< sizeof(float)*2 */
// RT_FORMAT_FLOAT3, /*!< sizeof(float)*3 */
// RT_FORMAT_FLOAT4, /*!< sizeof(float)*4 */
// RT_FORMAT_BYTE, /*!< BYTE */
// RT_FORMAT_BYTE2, /*!< sizeof(CHAR)*2 */
// RT_FORMAT_BYTE3, /*!< sizeof(CHAR)*3 */
// RT_FORMAT_BYTE4, /*!< sizeof(CHAR)*4 */
// RT_FORMAT_UNSIGNED_BYTE, /*!< UCHAR */
// RT_FORMAT_UNSIGNED_BYTE2, /*!< sizeof(UCHAR)*2 */
// RT_FORMAT_UNSIGNED_BYTE3, /*!< sizeof(UCHAR)*3 */
// RT_FORMAT_UNSIGNED_BYTE4, /*!< sizeof(UCHAR)*4 */
// RT_FORMAT_SHORT, /*!< SHORT */
// RT_FORMAT_SHORT2, /*!< sizeof(SHORT)*2 */
// RT_FORMAT_SHORT3, /*!< sizeof(SHORT)*3 */
// RT_FORMAT_SHORT4, /*!< sizeof(SHORT)*4 */
// RT_FORMAT_UNSIGNED_SHORT, /*!< USHORT */
// RT_FORMAT_UNSIGNED_SHORT2, /*!< sizeof(USHORT)*2 */
// RT_FORMAT_UNSIGNED_SHORT3, /*!< sizeof(USHORT)*3 */
// RT_FORMAT_UNSIGNED_SHORT4, /*!< sizeof(USHORT)*4 */
// RT_FORMAT_INT, /*!< INT */
// RT_FORMAT_INT2, /*!< sizeof(INT)*2 */
// RT_FORMAT_INT3, /*!< sizeof(INT)*3 */
// RT_FORMAT_INT4, /*!< sizeof(INT)*4 */
// RT_FORMAT_UNSIGNED_INT, /*!< sizeof(UINT) */
// RT_FORMAT_UNSIGNED_INT2, /*!< sizeof(UINT)*2 */
// RT_FORMAT_UNSIGNED_INT3, /*!< sizeof(UINT)*3 */
// RT_FORMAT_UNSIGNED_INT4, /*!< sizeof(UINT)*4 */
// RT_FORMAT_USER, /*!< User Format */
// RT_FORMAT_BUFFER_ID, /*!< Buffer Id */
// RT_FORMAT_PROGRAM_ID, /*!< Program Id */
// RT_FORMAT_HALF, /*!< half float */
// RT_FORMAT_HALF2, /*!< sizeof(half float)*2 */
// RT_FORMAT_HALF3, /*!< sizeof(half float)*3 */
// RT_FORMAT_HALF4 /*!< sizeof(half float)*4 */
//};
\ No newline at end of file
......@@ -3,10 +3,11 @@
#pragma once
#include "CoreMinimal.h"
#include "Components/SceneComponent.h"
#include "Components/PrimitiveComponent.h"
#include "Runtime/Engine/Classes/Engine/Texture2D.h"
#include "PrimitiveSceneProxy.h"
#include "OptiXContext.h"
//#include "OptiXContext.h"
#include "OptiXLaserComponent.generated.h"
......@@ -22,7 +23,7 @@ enum class EPatternTypes : uint8
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class OPTIX_API UOptiXLaserComponent : public USceneComponent
class OPTIX_API UOptiXLaserComponent : public UPrimitiveComponent
{
GENERATED_BODY()
......@@ -43,18 +44,10 @@ public:
virtual void OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport = ETeleportType::None) override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLaserComponent")
void CleanOptiXObjects()
{
//FOptiXModule::Get().GetOptiXContextManager()->bLaserIsInitialized.AtomicSet(true);
UE_LOG(LogTemp, Warning, TEXT("OptiX Laser Component Cleaning up")); // TODO
}
void UpdateOptiXContextVariables();
virtual FPrimitiveSceneProxy* CreateSceneProxy() override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLaserComponent")
void Init();
void CleanOptiXObjects();
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLaserComponent")
void UpdateLaserPosition();
......@@ -100,9 +93,6 @@ public:
public:
UPROPERTY(BlueprintReadOnly, Category = OptiX)
UOptiXContext* OptiXContext;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = OptiX)
int32 LaserMaxDepth;
......@@ -153,8 +143,4 @@ public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, BlueprintGetter = GetLaserPattern, BlueprintSetter = SetLaserPattern) // todo
EPatternTypes CurrentLaserPattern;
private:
FThreadSafeBool bUpdateQueued = true;
FThreadSafeBool bPatternChanged = true;
};
......@@ -4,7 +4,6 @@
#include "CoreMinimal.h"
#include "OptiXObjectComponent.h"
#include "OptiXBuffer.h"
#include "OptiXLaserTargetComponent.generated.h"
/**
......@@ -18,53 +17,25 @@ class OPTIX_API UOptiXLaserTargetComponent : public UOptiXObjectComponent
public:
UOptiXLaserTargetComponent(const FObjectInitializer& ObjectInitializer);
virtual void UpdateOptiXComponentVariables() override;
virtual void BeginPlay() override;
/* OptiXObjectComponent Interface Start */
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void UpdateOptiXComponent() override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXGeometry() override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXMaterial() override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXGroups() override;
virtual void CleanOptiXComponent() override;
/*OptiXObjectComponent Interface End*/
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
float GetMaxFromBuffer();
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
//float GetMaxFromBuffer();
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
//void UpdateBufferData();
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
void UpdateBufferData();
void ClearOptiXBuffer();
/* Standard Component Interface Start */
//virtual void BeginPlay() override;
//virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
//virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
/* Standard Component Interface End */
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OptiX")
bool bIsColorMode;
UPROPERTY(BlueprintReadOnly, Category = "OptiX")
UOptiXTransform* OptiXTransform;
UPROPERTY(BlueprintReadOnly, Category = "OptiX")
UOptiXAcceleration* OptiXAcceleration;
UPROPERTY(BlueprintReadOnly, Category = "OptiX")
UOptiXBuffer* TargetBuffer;
UPROPERTY(BlueprintReadOnly, Category = "OptiX")
UOptiXBuffer* TargetBufferMax;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "OptiX")
float TargetRes;
......
......@@ -41,30 +41,8 @@ public:
virtual void BeginPlay() override;
// UOptiXObjectComponent Interface Start
virtual void UpdateOptiXComponentVariables() override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void UpdateOptiXComponent() override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXGeometry() override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXMaterial() override;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXGroups() override;
virtual void CleanOptiXComponent() override;
// UOptiXObjectComponent Interface End
virtual void InitCubemap(FRHICommandListImmediate & RHICmdList) override;
virtual void UpdateCubemap(FRHICommandListImmediate & RHICmdList) override;
// This sadly only works in the editor itself, leave it for now
//virtual void PostEditChangeProperty(FPropertyChangedEvent & PropertyChangedEvent) override;
......@@ -76,6 +54,9 @@ public:
UFUNCTION(BlueprintPure, BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLensComponent")
float GetThickness() const;
UFUNCTION(BlueprintPure, BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLensComponent")
float GetThicknessForCylinderLength(float Length) const;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLensComponent")
void SetRadius1(float Radius);
UFUNCTION(BlueprintPure, BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLensComponent")
......@@ -112,9 +93,6 @@ public:
UFUNCTION(BlueprintPure, BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLensComponent")
float GetWavelength() const;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLensComponent") // TODO
void MarkDirty();
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXLensComponent") // TODO
TArray<FString> GetGlassDefinitionNames();
......@@ -159,47 +137,7 @@ public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, BlueprintGetter=GetWavelength, BlueprintSetter=SetWavelength)
float CurrentWavelength;
// Helper functions
float GetCylinderLength(float Thickness) const;
private:
// Not sure if we need to even save them here.
UPROPERTY()
UOptiXTransform* OptiXTransform;
UPROPERTY()
UOptiXAcceleration* OptiXAcceleration;
UPROPERTY()
UOptiXBuffer* CubemapBuffer;
UPROPERTY()
UOptiXTextureSampler* CubemapSampler;
void RecalculateBoundingBox();
// Okay, for some crazy reason glass definitions have been originally saved here... TODOOOOO
//struct GlassDefinition
//{
// FVector B;
// FVector C;
// GlassDefinition(FVector b, FVector c) : B(b), C(c)
// {}
//};
//const TArray<GlassDefinition> GlassDefinitions =
//{
// GlassDefinition(FVector(1.03961212f, 0.231792344f, 1.01046945f), FVector(0.00600069867f, 0.0200179144f, 103.560653f)), // BK7
// GlassDefinition(FVector(1.52481889f, 0.187085527f, 1.42729015f), FVector(0.011254756f, 0.0588995392f, 129.141675f)), // SF5
// GlassDefinition(FVector(1.73759695f, 0.313747346f, 1.89878101f), FVector(0.013188707f, 0.0623068142f, 155.23629f)), // SF11
// GlassDefinition(FVector(0.6961663f, 0.4079426f, 0.8974794f), FVector(0.0684043f, 0.1162414f, 9.896161f)), // Fused S.
// GlassDefinition(FVector(1.34317774f, 0.241144399f, 0.994317969f), FVector(0.00704687339f, 0.0229005f, 92.7508526f)), // SK16
// GlassDefinition(FVector(1.34533359f, 0.209073176f, 0.937357162f), FVector(0.00997743871f, 0.0470450767f, 111.886764f)), // F2
//};
};
......@@ -36,11 +36,6 @@ public:
void Init();
UOptiXContext* GetContext()
{
return GetOptiXContextManager()->GetOptiXContext();
}
TMap<FString, FGlassDefinition>& GetGlassDefinitions()
{
return GlassDefinitionsMap;
......
......@@ -5,8 +5,8 @@
#include "Components/PrimitiveComponent.h"
#include "Runtime/Engine/Classes/Components/SceneCaptureComponentCube.h"
#include "OptiXContext.h"
#include "OptiXComponentInterface.h"
//#include "OptiXContext.h"
//#include "OptiXComponentInterface.h"
#include "OptiXObjectComponent.generated.h"
......@@ -14,7 +14,7 @@
// The interface is sadly useless as unreal doesn't let me do what's possible in standard c++.
UCLASS(abstract) //Blueprintable, hidecategories = (Object), meta=(BlueprintSpawnableComponent)) // TODO Many things
class OPTIX_API UOptiXObjectComponent : public USceneComponent, public IOptiXComponentInterface
class OPTIX_API UOptiXObjectComponent : public UPrimitiveComponent
{
GENERATED_BODY()
......@@ -24,10 +24,7 @@ public:
UOptiXObjectComponent(const FObjectInitializer& ObjectInitializer);
virtual void OnUnregister() override;
//virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
virtual FPrimitiveSceneProxy* CreateSceneProxy() override;
// End of UObject interface
......@@ -37,63 +34,16 @@ public:
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
// End UActorComponent interface
// USceneComponent interface
virtual void OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport = ETeleportType::None) override;
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
void InitOptiXComponent(FRHICommandListImmediate & RHICmdList) override;
virtual void RegisterOptiXComponent() override;
virtual void QueueOptiXContextUpdate() override;
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void CleanOptiXComponent() override;
virtual void SetUpdateQueued(bool UpdateQueued) override;
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void UpdateOptiXComponent() override {};
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXGeometry() override {};
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXMaterial() override {};
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXGroups() override {};
void CleanOptiXComponent();
FString OptiXPTXDir;
public:
UPROPERTY(BlueprintReadOnly)
UOptiXContext* OptiXContext;
UPROPERTY(BlueprintReadOnly)
UOptiXGeometryGroup* OptiXGeometryGroup;
UPROPERTY(BlueprintReadOnly)
UOptiXGeometryInstance* OptiXGeometryInstance;
UPROPERTY(BlueprintReadOnly)
UOptiXGeometry* OptiXGeometry;
UPROPERTY(BlueprintReadOnly)
UOptiXMaterial* OptiXMaterial;
protected:
UPROPERTY(BlueprintReadOnly)
bool bIsInitialized = false;
FThreadSafeBool bUpdateQueued = false;
// USceneComponent interface
virtual void OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport = ETeleportType::None) override;
};
UCLASS(abstract) //Blueprintable, hidecategories = (Object), meta=(BlueprintSpawnableComponent)) // TODO Many things
class OPTIX_API UOptiXCubemapComponent : public USceneCaptureComponentCube, public IOptiXComponentInterface
class OPTIX_API UOptiXCubemapComponent : public USceneCaptureComponentCube
{
GENERATED_BODY()
......@@ -103,9 +53,6 @@ public:
UOptiXCubemapComponent(const FObjectInitializer& ObjectInitializer);
virtual void OnUnregister() override;
// End of UObject interface
// Begin UActorComponent interface
......@@ -117,57 +64,13 @@ public:
virtual void OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport = ETeleportType::None) override;
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
void InitOptiXComponent(FRHICommandListImmediate & RHICmdList) override;
virtual void RegisterOptiXComponent() override;
virtual void QueueOptiXContextUpdate() override;
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void CleanOptiXComponent() override;
virtual void SetUpdateQueued(bool UpdateQueued) override;
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void UpdateOptiXComponent() override {};
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXGeometry() override {};
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXMaterial() override {};
//UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
virtual void InitOptiXGroups() override {};
virtual void InitCubemap(FRHICommandListImmediate & RHICmdList) {};
virtual void UpdateCubemap(FRHICommandListImmediate & RHICmdList) {};
void CleanOptiXComponent();
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXComponent")
void RequestCubemapUpdate();
FString OptiXPTXDir;
UFUNCTION(BlueprintCallable, /*meta = (BlueprintProtected)*/ Category = "OptiXCubemapComponent")
virtual void RequestCubemapUpdate();
public:
UPROPERTY(BlueprintReadOnly)
UOptiXContext* OptiXContext;
UPROPERTY(BlueprintReadOnly)
UOptiXGeometryGroup* OptiXGeometryGroup;
UPROPERTY(BlueprintReadOnly)
UOptiXGeometryInstance* OptiXGeometryInstance;
UPROPERTY(BlueprintReadOnly)
UOptiXGeometry* OptiXGeometry;
UPROPERTY(BlueprintReadOnly)
UOptiXMaterial* OptiXMaterial;
UPROPERTY(BlueprintReadOnly)
int32 OptiXCubemapId;
......@@ -177,13 +80,6 @@ public:
UTextureRenderTargetCube* CubeRenderTarget;
FThreadSafeBool bCubemapCaptured = false;
protected:
UPROPERTY(BlueprintReadOnly)
bool bIsInitialized = false;
FThreadSafeBool bUpdateQueued = false;
};
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment