7 #include "PhysicsEngine/BodySetup.h" 8 #include "TessellationRendering.h" 9 #include "PrimitiveSceneProxy.h" 12 : FPrimitiveSceneProxy(Component)
13 , BodySetup(Component->GetBodySetup())
15 bStaticElementsAlwaysUseProxyPrimitiveUniformBuffer =
true;
17 check(Component->GetRuntimeMesh() !=
nullptr);
19 RuntimeMeshProxy = Component->GetRuntimeMesh()->EnsureProxyCreated(GetScene().GetFeatureLevel());
24 for (
auto SectionId : Component->GetRuntimeMesh()->GetSectionIds())
26 UMaterialInterface* Mat = Component->GetMaterial(SectionId);
29 Mat = UMaterial::GetDefaultMaterial(MD_Surface);
53 auto& RenderData = SectionRenderData[Entry.Key];
55 RenderData.bWantsAdjacencyInfo = RequiresAdjacencyInformation(RenderData.Material,
RuntimeMeshProxy->GetSections()[Entry.Key]->GetVertexFactory()->GetType(), GetScene().GetFeatureLevel());
59 FPrimitiveSceneProxy::CreateRenderThreadResources();
64 FPrimitiveViewRelevance Result;
65 Result.bDrawRelevance = IsShown(View);
66 Result.bShadowRelevance = IsShadowCast(View);
68 bool bForceDynamicPath = !IsStatic() || IsRichView(*View->Family) || IsSelected() || View->Family->EngineShowFlags.Wireframe;
72 Result.bRenderInMainPass = ShouldRenderInMainPass();
73 Result.bUsesLightingChannels = GetLightingChannelMask() != GetDefaultLightingChannelMask();
74 Result.bRenderCustomDepth = ShouldRenderCustomDepth();
81 bool bRenderWireframe = WireframeMaterial !=
nullptr;
84 Section->CreateMeshBatch(MeshBatch, bWantsAdjacency);
85 MeshBatch.bWireframe = WireframeMaterial !=
nullptr;
86 MeshBatch.MaterialRenderProxy = MeshBatch.bWireframe ? WireframeMaterial : Material;
88 MeshBatch.ReverseCulling = IsLocalToWorldDeterminantNegative();
89 MeshBatch.bCanApplyViewModeOverrides =
true;
100 if (
SectionRenderData.Contains(SectionEntry.Key) && Section.IsValid() && Section->ShouldRender() && Section->WantsToRenderInStaticPath())
103 FMaterialRenderProxy* Material = RenderData.
Material->GetRenderProxy();
105 FMeshBatch MeshBatch;
107 PDI->DrawMesh(MeshBatch, FLT_MAX);
115 const bool bWireframe = AllowDebugViewmodes() && ViewFamily.EngineShowFlags.Wireframe;
117 FColoredMaterialRenderProxy* WireframeMaterialInstance =
nullptr;
120 WireframeMaterialInstance =
new FColoredMaterialRenderProxy(
121 GEngine->WireframeMaterial ? GEngine->WireframeMaterial->GetRenderProxy() :
nullptr,
122 FLinearColor(0, 0.5
f, 1.
f)
125 Collector.RegisterOneFrameMaterialProxy(WireframeMaterialInstance);
132 if (
SectionRenderData.Contains(SectionEntry.Key) && Section.IsValid() && Section->ShouldRender())
135 for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
137 if (VisibilityMap & (1 << ViewIndex))
139 bool bForceDynamicPath = IsRichView(*Views[ViewIndex]->Family) || Views[ViewIndex]->Family->EngineShowFlags.Wireframe || IsSelected() || !IsStatic();
141 if (bForceDynamicPath || !Section->WantsToRenderInStaticPath())
144 FMaterialRenderProxy* Material = RenderData.
Material->GetRenderProxy();
146 FMeshBatch& MeshBatch = Collector.AllocateMesh();
147 CreateMeshBatch(MeshBatch, Section, RenderData, Material, WireframeMaterialInstance);
149 Collector.AddMesh(ViewIndex, MeshBatch);
157 #if RUNTIMEMESH_ENABLE_DEBUG_RENDERING 158 for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
160 if (VisibilityMap & (1 << ViewIndex))
163 if (ViewFamily.EngineShowFlags.Collision && IsCollisionEnabled() &&
BodySetup &&
BodySetup->GetCollisionTraceFlag() != ECollisionTraceFlag::CTF_UseComplexAsSimple)
165 FTransform GeomTransform(GetLocalToWorld());
166 BodySetup->AggGeom.GetAggGeom(GeomTransform, GetSelectionColor(FColor(157, 149, 223, 255), IsSelected(),
IsHovered()).ToFColor(
true),
NULL,
false,
false,
false , ViewIndex, Collector);
170 RenderBounds(Collector.GetPDI(ViewIndex), ViewFamily.EngineShowFlags, GetBounds(), IsSelected());
FMaterialRelevance MaterialRelevance
virtual void GetDynamicMeshElements(const TArray< const FSceneView * > &Views, const FSceneViewFamily &ViewFamily, uint32 VisibilityMap, FMeshElementCollector &Collector) const override
FRuntimeMeshProxyPtr RuntimeMeshProxy
TSharedPtr< FRuntimeMeshSectionProxy, ESPMode::NotThreadSafe > FRuntimeMeshSectionProxyPtr
virtual ~FRuntimeMeshComponentSceneProxy()
virtual void DrawStaticElements(FStaticPrimitiveDrawInterface *PDI) override
FRuntimeMeshComponentSceneProxy(URuntimeMeshComponent *Component)
static const textual_icon check
void CreateMeshBatch(FMeshBatch &MeshBatch, const FRuntimeMeshSectionProxyPtr &Section, const FRuntimeMeshSectionRenderData &RenderData, FMaterialRenderProxy *Material, FMaterialRenderProxy *WireframeMaterial) const
IMGUI_API bool IsHovered(const ImRect &bb, ImGuiID id, bool flatten_childs=false)
TMap< int32, FRuntimeMeshSectionRenderData > SectionRenderData
virtual FPrimitiveViewRelevance GetViewRelevance(const FSceneView *View) const override
UMaterialInterface * Material
void CreateRenderThreadResources() override
bool bHasShadowableSections