How to enable depth for Canvas Draw?

How to enable depth test for Canvas Draw?



	FCanvas* NativeCanvas = Canvas->Canvas;

        APlayerController* PC = GetOwningPlayerController();
	ULocalPlayer* const LP = PC->GetLocalPlayer();
	if (LP && LP->ViewportClient)
	{
		// get the projection data
		FSceneViewProjectionData ProjectionData;
		FIntPoint ViewportSize = LP->ViewportClient->Viewport->GetSizeXY();
		if (LP->GetProjectionData(LP->ViewportClient->Viewport, eSSP_FULL, /*out*/ ProjectionData))
		{
			FMatrix const InViewProjectionMatrix = ProjectionData.ComputeViewProjectionMatrix();
			FMatrix OldBaseTransform = NativeCanvas->GetBottomTransform();
			NativeCanvas->SetBaseTransform(InViewProjectionMatrix);

			NativeCanvas->PushAbsoluteTransform(FMatrix::Identity);

			FHitProxyId HitProxyId = NativeCanvas->GetHitProxyId();
			FBatchedElements* LineBatcher = NativeCanvas->GetBatchedElements(FCanvas::ET_Line);
			FBatchedElements* TriangleBatcher = NativeCanvas->GetBatchedElements(FCanvas::ET_Triangle);
			LineBatcher->AddLine(FVector(0, 0, 0), GetActorLocation(), FLinearColor::Green, HitProxyId, 10);

			LineBatcher->AddLine(FVector(0, 0, 0), FVector(100, 0, 0), FLinearColor::Red, HitProxyId, 10);

			TriangleBatcher->AddVertex(FVector(0, 0, 0), FVector2D(0, 0), FLinearColor::Blue, HitProxyId);
			TriangleBatcher->AddVertex(FVector(0, 0, 40), FVector2D(0, 1), FLinearColor::Blue, HitProxyId);
			TriangleBatcher->AddVertex(FVector(0, 100, 0), FVector2D(1, 0), FLinearColor::Blue, HitProxyId);

			TriangleBatcher->AddTriangle(0, 1, 2, GWhiteTexture, SE_BLEND_Opaque);

			TriangleBatcher->AddVertex(FVector(0, 0, 0) - FVector(-100, 0, 0), FVector2D(0, 0), FLinearColor::Red, HitProxyId);
			TriangleBatcher->AddVertex(FVector(0, 0, 40) - FVector(-100, 0, 0), FVector2D(0, 1), FLinearColor::Green, HitProxyId);
			TriangleBatcher->AddVertex(FVector(0, 100, 0) - FVector(-100, 0, 0), FVector2D(1, 0), FLinearColor::Blue, HitProxyId);

			TriangleBatcher->AddTriangle(3, 4, 5, GWhiteTexture, SE_BLEND_Opaque);

			NativeCanvas->PopTransform();
			NativeCanvas->SetBaseTransform(OldBaseTransform);
		}
	}


All drawing is ignore depth test, cause some weired effects.

90881-20160517163304.png

I don’t know how to enable depth when drawing with Canvas.
I need this feature to draw gizmo on top of all scene objects.

Thank you.

Just for floating up…

Is anybody here???