3#include "Serialization/ArchiveSaveCompressedProxy.h"
4#include "Serialization/ArchiveLoadCompressedProxy.h"
9#include "Engine/TextureRenderTarget2D.h"
10#include "Kismet/KismetMathLibrary.h"
11#include "Kismet/KismetRenderingLibrary.h"
12#include "Engine/CanvasRenderTarget2D.h"
14#include "TimerManager.h"
15#include "GameFramework/PlayerController.h"
16#include "Engine/Canvas.h"
17#include "Materials/Material.h"
21#include "VRRenderTargetManager.generated.h"
28USTRUCT(BlueprintType, Category =
"VRExpansionLibrary")
39 TArray<uint8> PackedData;
42 TArray<uint16> UnpackedData;
56 EPixelFormat PixelFormat;
71 PixelFormat = (EPixelFormat)0;
82 bool NetSerialize(FArchive& Ar,
class UPackageMap* Map,
bool& bOutSuccess);
91 WithNetSerializer =
true,
92 WithNetSharedSerialization =
true,
101 TArray<FColor> ColorData;
102 FRenderCommandFence RenderFence;
104 EPixelFormat PixelFormat;
155 TSoftObjectPtr<UTexture2D> Texture;
164 Color = FColor::White;
165 P1 = FVector2D::ZeroVector;
166 P2 = FVector2D::ZeroVector;
170 bool NetSerialize(FArchive& Ar,
class UPackageMap* Map,
bool& bOutSuccess);
177 WithNetSerializer =
true,
178 WithNetSharedSerialization =
true,
193 UPROPERTY(Replicated, ReplicatedUsing = OnRep_Manager)
194 TWeakObjectPtr<UVRRenderTargetManager> OwningManager;
196 UPROPERTY(Replicated)
200 void OnRep_Manager();
208 bool bWaitingForManager;
210 void SendInitMessage();
213 void SendNextDataBlob();
215 FTimerHandle SendTimer_Handle;
216 FTimerHandle CheckManager_Handle;
220 int32 TextureBlobSize;
227 int32 MaxBytesPerSecondRate;
229 virtual
void EndPlay(const EEndPlayReason::Type EndPlayReason)
override
231 if(SendTimer_Handle.IsValid())
232 GetWorld()->GetTimerManager().ClearTimer(SendTimer_Handle);
234 Super::EndPlay(EndPlayReason);
238 UFUNCTION(Reliable, Server, WithValidation)
239 void SendLocalDrawOperations(
const TArray<FRenderManagerOperation>& LocalRenderOperationStoreList);
241 UFUNCTION(Reliable, Client)
242 void InitTextureSend(int32 Width, int32 Height, int32 TotalDataCount, int32 BlobCount, EPixelFormat PixelFormat,
bool bIsZipped);
244 UFUNCTION(Reliable, Server, WithValidation)
245 void Ack_InitTextureSend(int32 TotalDataCount);
247 UFUNCTION(Reliable, Client)
248 void ReceiveTextureBlob(
const TArray<uint8>& TextureBlob, int32 LocationInData, int32 BlobCount);
250 UFUNCTION(Reliable, Server, WithValidation)
251 void Ack_ReceiveTextureBlob(int32 BlobCount);
253 UFUNCTION(Reliable, Client)
265 TWeakObjectPtr<APlayerController> PC;
289UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (
VRExpansionPlugin))
298 uint32 OwnerIDCounter;
307 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
310 UFUNCTION(Reliable, NetMultiCast, WithValidation)
313 UFUNCTION(BlueprintCallable, Category = "VRRenderTargetManager|DrawingFunctions")
314 void AddLineDrawOperation(FVector2D Point1, FVector2D Point2, FColor Color, int32 Thickness);
316 UFUNCTION(BlueprintCallable, Category = "VRRenderTargetManager|DrawingFunctions")
317 void AddTextureDrawOperation(FVector2D Position, UTexture2D* TextureToDisplay);
320 UFUNCTION(BlueprintCallable, Category = "VRRenderTargetManager|DrawingFunctions")
321 void AddMaterialTrianglesDrawOperation(TArray<FCanvasUVTri> Tris,
UMaterial* Material);
328 void DrawOperations();
331 FTimerHandle DrawHandle;
334 bool bIsStoringImage;
336 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
337 bool bInitiallyReplicateTexture;
340 bool bIsLoadingTextureBuffer;
343 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
344 int32 TextureBlobSize;
350 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
351 int32 MaxBytesPerSecondRate;
353 UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "RenderTargetManager")
354 UCanvasRenderTarget2D* RenderTarget;
356 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
357 int32 RenderTargetWidth;
359 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
360 int32 RenderTargetHeight;
362 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
369 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
370 float PollRelevancyTime;
372 FTimerHandle NetRelevancyTimer_Handle;
377 UFUNCTION(BlueprintCallable, Category = "VRRenderTargetManager|UtilityFunctions")
378 bool GenerateTrisFromBoxPlaneIntersection(UPrimitiveComponent* PrimToBoxCheck, FTransform WorldTransformOfPlane, const FPlane& LocalProjectionPlane, FVector2D PlaneSize, FColor UVColor, TArray<FCanvasUVTri>& OutTris);
381 void InitRenderTarget();
384 void UpdateRelevancyMap();
387 bool DeCompressRenderTarget2D();
390 void QueueImageStore();
392 virtual
void TickComponent(
float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
393 virtual
void BeginPlay() override;
394 virtual
void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
ERenderManagerOperationType
UENUM(BlueprintType)
UCLASS(ClassGroup = (VRExpansionPlugin))
FTimerHandle SendTimer_Handle
int32 MaxBytesPerSecondRate
UPROPERTY()
void InitTextureSend(int32 Width, int32 Height, int32 TotalDataCount, int32 BlobCount, EPixelFormat PixelFormat, bool bIsZipped)
UFUNCTION(Reliable, Client)
FTimerHandle CheckManager_Handle
int32 BlobNum
UPROPERTY(Transient)
FBPVRReplicatedTextureStore TextureStore
UPROPERTY(Transient)
void ReceiveTexture(const FBPVRReplicatedTextureStore &TextureData)
UFUNCTION(Reliable, Client)
int32 TextureBlobSize
UPROPERTY()
TWeakObjectPtr< UVRRenderTargetManager > OwningManager
UPROPERTY(Replicated, ReplicatedUsing = OnRep_Manager)
void ReceiveTextureBlob(const TArray< uint8 > &TextureBlob, int32 LocationInData, int32 BlobCount)
UFUNCTION(Reliable, Client)
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
void Ack_InitTextureSend(int32 TotalDataCount)
UFUNCTION(Reliable, Server, WithValidation)
void SendLocalDrawOperations(const TArray< FRenderManagerOperation > &LocalRenderOperationStoreList)
UFUNCTION(Reliable, Server, WithValidation)
uint32 OwnersID
UPROPERTY(Replicated)
void Ack_ReceiveTextureBlob(int32 BlobCount)
UFUNCTION(Reliable, Server, WithValidation)
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (VRExpansionPlugin))
float DrawRate
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
bool bIsLoadingTextureBuffer
UPROPERTY(Transient)
UCanvasRenderTarget2D * RenderTarget
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "RenderTargetManager")
TArray< FRenderManagerOperation > LocalRenderOperationStore
int32 TextureBlobSize
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
bool bIsStoringImage
UPROPERTY(Transient)
int32 MaxBytesPerSecondRate
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
FBPVRReplicatedTextureStore RenderTargetStore
UPROPERTY(Transient)
FTimerHandle DrawHandle
UPROPERTY()
TArray< FClientRepData > NetRelevancyLog
UPROPERTY(Transient)
TWeakObjectPtr< ARenderTargetReplicationProxy > LocalProxy
UPROPERTY(Transient)
FColor ClearColor
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
int32 RenderTargetHeight
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
TArray< FRenderManagerOperation > RenderOperationStore
bool bInitiallyReplicateTexture
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
float PollRelevancyTime
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
void SendDrawOperations(const TArray< FRenderManagerOperation > &RenderOperationStoreList)
UFUNCTION(Reliable, NetMultiCast, WithValidation)
TQueue< FRenderDataStore * > RenderDataQueue
FTimerHandle NetRelevancyTimer_Handle
int32 RenderTargetWidth
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RenderTargetManager")
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
TArray< uint16 > UnpackedData
UPROPERTY(Transient)
TArray< uint8 > PackedData
UPROPERTY(Transient)
bool bIsZipped
UPROPERTY(Transient)
FBPVRReplicatedTextureStore()
uint32 Width
UPROPERTY(Transient)
bool bIsRelevant
UPROPERTY()
TWeakObjectPtr< APlayerController > PC
UPROPERTY()
TWeakObjectPtr< ARenderTargetReplicationProxy > ReplicationProxy
UPROPERTY()
FRenderCommandFence RenderFence
TArray< FColor > ColorData
ERenderManagerOperationType OperationType
UPROPERTY()
TSoftObjectPtr< UTexture2D > Texture
UPROPERTY()
FRenderManagerOperation()
TSoftObjectPtr< UMaterial > Material
UPROPERTY()
uint32 Thickness
UPROPERTY()
uint32 OwnerID
UPROPERTY()
bool NetSerialize(FArchive &Ar, class UPackageMap *Map, bool &bOutSuccess)
TArray< FRenderManagerTri > Tris
UPROPERTY()