From 9a65521fbc6a068e8d7cfef497d3f93747a0ac6e Mon Sep 17 00:00:00 2001 From: Daniel Rupp <daniel.rupp@rwth-aachen.de> Date: Mon, 14 Apr 2025 10:02:42 +0200 Subject: [PATCH] fixed smaller issues, two issues remaining --- .../Private/HMDSimulationManager.cpp | 7 +++++-- Source/HMDSimulatorHMD/Private/SimulatedHMD.cpp | 17 ++++++++++------- Source/HMDSimulatorHMD/Public/SimulatedHMD.h | 6 +++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Source/HMDSimulator/Private/HMDSimulationManager.cpp b/Source/HMDSimulator/Private/HMDSimulationManager.cpp index e552a87..e3f6f0e 100644 --- a/Source/HMDSimulator/Private/HMDSimulationManager.cpp +++ b/Source/HMDSimulator/Private/HMDSimulationManager.cpp @@ -135,7 +135,7 @@ void UHMDSimulationManager::InputXYZ(float DeltaX, float DeltaY, float DeltaZ) if (DeltaY != 0.0f){ FQuat NewRotation = FQuat(HMD.AccumulatedRotation.GetRightVector(), DeltaY * CurrentWorld->GetDeltaSeconds() * Settings->LookAroundSpeedY) * HMD.AccumulatedRotation; - /* Clamp vertical rotation to +- 90� */ + /* Clamp vertical rotation to +- 90° */ if(NewRotation.GetUpVector().Z < 0) { FVector NewUp = NewRotation.GetUpVector(); @@ -246,7 +246,10 @@ bool CheckGameWindowFocus(FSlateApplication& SlateApp) FWidgetPath Path = FSlateApplication::Get().LocateWindowUnderMouse(FSlateApplication::Get().GetCursorPos(), FSlateApplication::Get().GetInteractiveTopLevelWindows(), true); if(!SlateApp.GetGameViewport().IsValid()) return false; - return Path.ContainsWidget(SlateApp.GetGameViewport().ToSharedRef()) && SlateApp.HasUserMouseCapture(0); + TSharedPtr<SViewport> GameViewport = SlateApp.GetGameViewport(); + const SWidget* GameViewportWidget = GameViewport.IsValid() ? &GameViewport->AsShared().Get() : nullptr; + + return Path.ContainsWidget(GameViewportWidget) && SlateApp.HasUserMouseCapture(0); } bool UHMDSimulationManager::HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& InKeyEvent) diff --git a/Source/HMDSimulatorHMD/Private/SimulatedHMD.cpp b/Source/HMDSimulatorHMD/Private/SimulatedHMD.cpp index 8562ed7..5f4304b 100644 --- a/Source/HMDSimulatorHMD/Private/SimulatedHMD.cpp +++ b/Source/HMDSimulatorHMD/Private/SimulatedHMD.cpp @@ -183,14 +183,15 @@ void FSimulatedHMD::OnBeginRendering_RenderThread(FRHICommandListImmediate& RHIC } } -FIntRect FSimulatedHMD::GetFullFlatEyeRect_RenderThread(FTexture2DRHIRef EyeTexture) const +FIntRect FSimulatedHMD::GetFullFlatEyeRect_RenderThread(FTextureRHIRef EyeTexture) const { return FIntRect(0, 0, EyeTexture->GetSizeX(), EyeTexture->GetSizeY()); } -void FSimulatedHMD::CopyTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FRHITexture2D* SrcTexture, FIntRect SrcRect, FRHITexture2D* DstTexture, FIntRect DstRect, bool bClearBlack, bool bNoAlpha) const +void FSimulatedHMD::CopyTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FRHITexture* SrcTexture, FIntRect SrcRect, FRHITexture* DstTexture, FIntRect + DstRect, bool bClearBlack, bool bNoAlpha) const { - /* Mostly copied from OpenXR HMD */ + /* Mostly copied from OpenXR HMD #1#*/ check(IsInRenderingThread()); @@ -241,14 +242,16 @@ void FSimulatedHMD::CopyTexture_RenderThread(FRHICommandListImmediate& RHICmdLis GraphicsPSOInit.BoundShaderState.VertexDeclarationRHI = GFilterVertexDeclaration.VertexDeclarationRHI; GraphicsPSOInit.BoundShaderState.VertexShaderRHI = VertexShader.GetVertexShader(); GraphicsPSOInit.BoundShaderState.PixelShaderRHI = PixelShader.GetPixelShader(); - - SetGraphicsPipelineState(RHICmdList, GraphicsPSOInit); + + SetGraphicsPipelineState(RHICmdList,GraphicsPSOInit,0); // StencilRef 0? RHICmdList.Transition(FRHITransitionInfo(SrcTexture, ERHIAccess::Unknown, ERHIAccess::SRVMask)); const bool bSameSize = DstRect.Size() == SrcRect.Size(); if (bSameSize) { + //FRHIBatchedShaderParameters& BatchedParameters, FRHISamplerState* SamplerStateRHI, FRHITexture* TextureRHI + PixelShader->SetParameters(RHICmdList, TStaticSamplerState<SF_Point>::GetRHI(), SrcTexture); } else @@ -327,7 +330,7 @@ EStereoscopicPass FSimulatedHMD::GetViewPassForIndex(bool bStereoRequested, int3 return EStereoscopicPass::eSSP_PRIMARY; case 1: return EStereoscopicPass::eSSP_SECONDARY; - default: + default: break; } @@ -375,7 +378,7 @@ IStereoRenderTargetManager* FSimulatedHMD::GetRenderTargetManager() return this; } -void FSimulatedHMD::RenderTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FRHITexture2D* BackBuffer, FRHITexture2D* SrcTexture, FVector2D WindowSize) const +void FSimulatedHMD::RenderTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FRHITexture* BackBuffer, FRHITexture* SrcTexture, FVector2D WindowSize) const { if (SpectatorScreenController) { diff --git a/Source/HMDSimulatorHMD/Public/SimulatedHMD.h b/Source/HMDSimulatorHMD/Public/SimulatedHMD.h index e8bcdab..b7f2990 100644 --- a/Source/HMDSimulatorHMD/Public/SimulatedHMD.h +++ b/Source/HMDSimulatorHMD/Public/SimulatedHMD.h @@ -64,9 +64,9 @@ public: virtual void OnBeginRendering_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneViewFamily& ViewFamily) override; // Spectator screen Hooks. - virtual FIntRect GetFullFlatEyeRect_RenderThread(FTexture2DRHIRef EyeTexture) const override; + virtual FIntRect GetFullFlatEyeRect_RenderThread(FTextureRHIRef EyeTexture) const override; // Helper to copy one render target into another for spectator screen display - virtual void CopyTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FRHITexture2D* SrcTexture, FIntRect SrcRect, FRHITexture2D* DstTexture, FIntRect DstRect, bool bClearBlack, bool bNoAlpha) const override; + virtual void CopyTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FRHITexture* SrcTexture, FIntRect SrcRect, FRHITexture* DstTexture, FIntRect DstRect, bool bClearBlack, bool bNoAlpha) const override; protected: /** FXRTrackingSystemBase protected interface */ @@ -95,7 +95,7 @@ public: virtual int32 GetDesiredNumberOfViews(bool bStereoRequested) const override; virtual FMatrix GetStereoProjectionMatrix(const int32 ViewIndex) const override; virtual IStereoRenderTargetManager* GetRenderTargetManager() override; - virtual void RenderTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FRHITexture2D* BackBuffer, FRHITexture2D* SrcTexture, FVector2D WindowSize) const override; + virtual void RenderTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FRHITexture* BackBuffer, FRHITexture* SrcTexture, FVector2D WindowSize) const override; /** IStereoRenderTargetManager */ virtual bool ShouldUseSeparateRenderTarget() const override; -- GitLab