Esempio n. 1
9
void FUMGViewportClient::Draw(FViewport* InViewport, FCanvas* Canvas)
{
    FViewport* ViewportBackup = Viewport;
    Viewport = InViewport ? InViewport : Viewport;

    // Determine whether we should use world time or real time based on the scene.
    float TimeSeconds;
    float RealTimeSeconds;
    float DeltaTimeSeconds;

    const bool bIsRealTime = true;

    UWorld* World = GWorld;
    if ( ( GetScene() != World->Scene ) || ( bIsRealTime == true ) )
    {
        // Use time relative to start time to avoid issues with float vs double
        TimeSeconds = FApp::GetCurrentTime() - GStartTime;
        RealTimeSeconds = FApp::GetCurrentTime() - GStartTime;
        DeltaTimeSeconds = FApp::GetDeltaTime();
    }
    else
    {
        TimeSeconds = World->GetTimeSeconds();
        RealTimeSeconds = World->GetRealTimeSeconds();
        DeltaTimeSeconds = World->GetDeltaSeconds();
    }

    // Setup a FSceneViewFamily/FSceneView for the viewport.
    FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
                                           Canvas->GetRenderTarget(),
                                           GetScene(),
                                           EngineShowFlags)
                                       .SetWorldTimes(TimeSeconds, DeltaTimeSeconds, RealTimeSeconds)
                                       .SetRealtimeUpdate(bIsRealTime));

    ViewFamily.EngineShowFlags = EngineShowFlags;

    //UpdateLightingShowFlags(ViewFamily.EngineShowFlags);

    //ViewFamily.ExposureSettings = ExposureSettings;

    //ViewFamily.LandscapeLODOverride = LandscapeLODOverride;

    FSceneView* View = CalcSceneView(&ViewFamily);

    //SetupViewForRendering(ViewFamily, *View);

    FSlateRect SafeFrame;
    View->CameraConstrainedViewRect = View->UnscaledViewRect;
    //if ( CalculateEditorConstrainedViewRect(SafeFrame, Viewport) )
    //{
    //	View->CameraConstrainedViewRect = FIntRect(SafeFrame.Left, SafeFrame.Top, SafeFrame.Right, SafeFrame.Bottom);
    //}

    if ( IsAspectRatioConstrained() )
    {
        // Clear the background to black if the aspect ratio is constrained, as the scene view won't write to all pixels.
        Canvas->Clear(FLinearColor::Black);
    }

    Canvas->Clear(BackgroundColor);

    GetRendererModule().BeginRenderingViewFamily(Canvas, &ViewFamily);

    // Remove temporary debug lines.
    // Possibly a hack. Lines may get added without the scene being rendered etc.
    if ( World->LineBatcher != NULL && ( World->LineBatcher->BatchedLines.Num() || World->LineBatcher->BatchedPoints.Num() ) )
    {
        World->LineBatcher->Flush();
    }

    if ( World->ForegroundLineBatcher != NULL && ( World->ForegroundLineBatcher->BatchedLines.Num() || World->ForegroundLineBatcher->BatchedPoints.Num() ) )
    {
        World->ForegroundLineBatcher->Flush();
    }

    //FCanvas* DebugCanvas = Viewport->GetDebugCanvas();

    //UDebugDrawService::Draw(ViewFamily.EngineShowFlags, Viewport, View, DebugCanvas);

    //
    //FlushRenderingCommands();

    Viewport = ViewportBackup;
}
void FJavascriptUMGViewportClient::Draw(FViewport* InViewport, FCanvas* Canvas)
{
	FViewport* ViewportBackup = Viewport;
	Viewport = InViewport ? InViewport : Viewport;

	// Determine whether we should use world time or real time based on the scene.
	float TimeSeconds;
	float RealTimeSeconds;
	float DeltaTimeSeconds;

	const bool bIsRealTime = true;

	UWorld* World = GWorld;
	if ((GetScene() != World->Scene) || (bIsRealTime == true))
	{
		// Use time relative to start time to avoid issues with float vs double
		TimeSeconds = FApp::GetCurrentTime() - GStartTime;
		RealTimeSeconds = FApp::GetCurrentTime() - GStartTime;
		DeltaTimeSeconds = FApp::GetDeltaTime();
	}
	else
	{
		TimeSeconds = World->GetTimeSeconds();
		RealTimeSeconds = World->GetRealTimeSeconds();
		DeltaTimeSeconds = World->GetDeltaSeconds();
	}

	// Setup a FSceneViewFamily/FSceneView for the viewport.
	FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
		Canvas->GetRenderTarget(),
		GetScene(),
		EngineShowFlags)
		.SetWorldTimes(TimeSeconds, DeltaTimeSeconds, RealTimeSeconds)
		.SetRealtimeUpdate(bIsRealTime));

	ViewFamily.EngineShowFlags = EngineShowFlags;

	//UpdateLightingShowFlags(ViewFamily.EngineShowFlags);

	//ViewFamily.ExposureSettings = ExposureSettings;

	//ViewFamily.LandscapeLODOverride = LandscapeLODOverride;

	FSceneView* View = CalcSceneView(&ViewFamily);

	//SetupViewForRendering(ViewFamily, *View);

	FSlateRect SafeFrame;
	View->CameraConstrainedViewRect = View->UnscaledViewRect;
	//if ( CalculateEditorConstrainedViewRect(SafeFrame, Viewport) )
	//{
	//	View->CameraConstrainedViewRect = FIntRect(SafeFrame.Left, SafeFrame.Top, SafeFrame.Right, SafeFrame.Bottom);
	//}

	if (IsAspectRatioConstrained())
	{
		// Clear the background to black if the aspect ratio is constrained, as the scene view won't write to all pixels.
		Canvas->Clear(FLinearColor::Black);
	}

	Canvas->Clear(BackgroundColor);

	// workaround for hacky renderer code that uses GFrameNumber to decide whether to resize render targets
	--GFrameNumber;
	GetRendererModule().BeginRenderingViewFamily(Canvas, &ViewFamily);
	
	Viewport = ViewportBackup;
}
Esempio n. 3
0
void UUserLoginWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
{
	Super::NativeTick(MyGeometry, InDeltaTime);
	UWorld* theWorld = GetWorld();
	float currentTime = theWorld->GetRealTimeSeconds();
	if (m_DisplayError)
	{
		if (currentTime > m_ErrorEndTime)
			m_DisplayError = false;
		else
		{
			float timeAlpha = ((m_ErrorEndTime - currentTime) / m_ErrorLength);
			m_TextColor = FLinearColor(1, 0, 0, timeAlpha);
		}
	}
	else
		m_TextColor = FLinearColor(0, 0, 0, 0);
}