diff --git a/Source/HMDSimulator/Private/HMDSimulationManager.cpp b/Source/HMDSimulator/Private/HMDSimulationManager.cpp index e552a8737be0cb427d5a67dd18a9341d9e21e91b..e3f6f0ea5815b497eb8ca51533490f1b4f19d5ce 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 8562ed78b093f832928b8953098db79b820b9083..5f4304b1cce47c0bb9adc67959ff860f73cee1fb 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 e8bcdab285a416958097fda1915dff1394e1a849..b7f29906bdac1ebd9feca9d99def84238fee58b1 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;