void ULevelThumbnailRenderer::GetView(ULevel* Level, FSceneViewFamily* ViewFamily, int32 X, int32 Y, uint32 SizeX, uint32 SizeY) const { check(ViewFamily); FIntRect ViewRect( FMath::Max<int32>(X,0), FMath::Max<int32>(Y,0), FMath::Max<int32>(X+SizeX,0), FMath::Max<int32>(Y+SizeY,0)); FBox LevelBox(0); if (Level->LevelBoundsActor.IsValid()) { LevelBox = Level->LevelBoundsActor.Get()->GetComponentsBoundingBox(); } else { LevelBox = ALevelBounds::CalculateLevelBounds(Level); } if (ViewRect.Width() > 0 && ViewRect.Height() > 0) { FSceneViewInitOptions ViewInitOptions; ViewInitOptions.SetViewRectangle(ViewRect); ViewInitOptions.ViewFamily = ViewFamily; const FVector ViewPoint = LevelBox.GetCenter(); ViewInitOptions.ViewMatrix = FMatrix( FPlane(1, 0, 0, 0), FPlane(0, -1, 0, 0), FPlane(0, 0, -1, 0), FPlane(-ViewPoint.X, ViewPoint.Y, 0, 1)); const float ZOffset = WORLD_MAX; ViewInitOptions.ProjectionMatrix = FReversedZOrthoMatrix( LevelBox.GetSize().X/2.f, LevelBox.GetSize().Y/2.f, 0.5f / ZOffset, ZOffset ); FSceneView* NewView = new FSceneView(ViewInitOptions); ViewFamily->Views.Add(NewView); } }
void FRendererModule::GPUBenchmark(FSynthBenchmarkResults& InOut, float WorkScale) { check(IsInGameThread()); FSceneViewInitOptions ViewInitOptions; FIntRect ViewRect(0, 0, 1, 1); FBox LevelBox(FVector(-WORLD_MAX), FVector(+WORLD_MAX)); ViewInitOptions.SetViewRectangle(ViewRect); // Initialize Projection Matrix and ViewMatrix since FSceneView initialization is doing some math on them. // Otherwise it trips NaN checks. const FVector ViewPoint = LevelBox.GetCenter(); ViewInitOptions.ViewOrigin = FVector(ViewPoint.X, ViewPoint.Y, 0.0f); ViewInitOptions.ViewRotationMatrix = FMatrix( FPlane(1, 0, 0, 0), FPlane(0, -1, 0, 0), FPlane(0, 0, -1, 0), FPlane(0, 0, 0, 1)); const float ZOffset = WORLD_MAX; ViewInitOptions.ProjectionMatrix = FReversedZOrthoMatrix( LevelBox.GetSize().X / 2.f, LevelBox.GetSize().Y / 2.f, 0.5f / ZOffset, ZOffset ); FSceneView DummyView(ViewInitOptions); ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER( RendererGPUBenchmarkCommand, FSceneView, DummyView, DummyView, float, WorkScale, WorkScale, FSynthBenchmarkResults&, InOut, InOut, { RendererGPUBenchmark(RHICmdList, InOut, DummyView, WorkScale); });