UE4 编辑器坐标轴绘制和事件处理

首先这不是UE4初学者的教程;是我记录学习的过程的博文;不过有兴趣可以讨论的可以联系我。

1、绘制编辑器的坐标轴。Mesh的两种渲染的方式;

UMeshComponent,PrimitiveDrawInterface绘制的dynamicMesh

二者在渲染线程中的处理不同

在render的不同过程的过程会先后的处理两种Mesh 牵涉到SceneProxy 例如在basepass的过程

for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
{
	SCOPED_CONDITIONAL_DRAW_EVENTF(RHICmdList, EventView, Views.Num() > 1, TEXT("View%d"), ViewIndex);
	FViewInfo& View = Views[ViewIndex];
	if (View.ShouldRenderView())
	{
		RenderBasePassViewParallel(View, RHICmdList);
	}

	RenderEditorPrimitives(RHICmdList, View, bDirty);

}
RenderBasePassViewParallel会把MeshCompoent的Mesh使用StaticMeshDrawList然后使用TBasePassDrawingPolicy进行渲染详见..\Engine\Source\Runtime\Renderer\Private\BasePassRendering.h

而UnrealWidget使用PDI绘制DynamicMesh的方式会现在主线程把Mesh转换成FMeshBatch保存在ViewMeshElementList中如下:

inline int32 FViewElementPDI::DrawMesh(const FMeshBatch& Mesh)
{
	if (ensure(MeshBatchHasPrimitives(Mesh)))
	{
		// Keep track of view mesh elements whether that have translucency.
		ViewInfo->bHasTranslucentViewMeshElements |= true;//Mesh.IsTranslucent() ? 1 : 0;

		uint8 DPGIndex = Mesh.DepthPriorityGroup;
		// Get the correct element list based on dpg index
		// Translucent view mesh elements in the foreground dpg are not supported yet
		TIndirectArray<FMeshBatch>& ViewMeshElementList = ( ( DPGIndex == SDPG_Foreground  ) ? ViewInfo->TopViewMeshElements : ViewInfo->ViewMeshElements );

		FMeshBatch* NewMesh = new(ViewMeshElementList) FMeshBatch(Mesh);
		if( CurrentHitProxy != nullptr )
		{
			NewMesh->BatchHitProxyId = CurrentHitProxy->Id;
		}

		return 1;
	}
	return 0;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值