808 virtual void GetDynamicMeshElements(
const TArray<const FSceneView*>& Views,
const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector)
const override
814 const bool bWireframe = AllowDebugViewmodes() && ViewFamily.EngineShowFlags.Wireframe;
816 auto WireframeMaterialInstance =
new FColoredMaterialRenderProxy(
817 GEngine->WireframeMaterial ? GEngine->WireframeMaterial->GetRenderProxy() :
nullptr,
818 FLinearColor(0, 0.5f, 1.f)
821 Collector.RegisterOneFrameMaterialProxy(WireframeMaterialInstance);
823 FMaterialRenderProxy* ParentMaterialProxy =
nullptr;
826 ParentMaterialProxy = WireframeMaterialInstance;
833 FMaterialRenderProxy* ParentMaterialProxy =
MaterialInstance->GetRenderProxy();
838 const FMatrix& ViewportLocalToWorld = GetLocalToWorld();
840 FMatrix PreviousLocalToWorld;
842 if (!GetScene().GetPreviousLocalToWorld(GetPrimitiveSceneInfo(), PreviousLocalToWorld))
844 PreviousLocalToWorld = GetLocalToWorld();
849 FTextureResource* TextureResource =
RenderTarget->Resource;
859 int32 VertexIndices[4];
861 for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
863 FDynamicMeshBuilder MeshBuilder(Views[ViewIndex]->GetFeatureLevel());
865 if (VisibilityMap & (1 << ViewIndex))
867 VertexIndices[0] = MeshBuilder.AddVertex(-FVector(0, U, V), FVector2D(0, 0), FVector(0, -1, 0), FVector(0, 0, -1), FVector(1, 0, 0), FColor::White);
868 VertexIndices[1] = MeshBuilder.AddVertex(-FVector(0, U, VL), FVector2D(0, 1), FVector(0, -1, 0), FVector(0, 0, -1), FVector(1, 0, 0), FColor::White);
869 VertexIndices[2] = MeshBuilder.AddVertex(-FVector(0, UL, VL), FVector2D(1, 1), FVector(0, -1, 0), FVector(0, 0, -1), FVector(1, 0, 0), FColor::White);
870 VertexIndices[3] = MeshBuilder.AddVertex(-FVector(0, UL, V), FVector2D(1, 0), FVector(0, -1, 0), FVector(0, 0, -1), FVector(1, 0, 0), FColor::White);
872 MeshBuilder.AddTriangle(VertexIndices[0], VertexIndices[1], VertexIndices[2]);
873 MeshBuilder.AddTriangle(VertexIndices[0], VertexIndices[2], VertexIndices[3]);
875 FDynamicMeshBuilderSettings Settings;
876 Settings.bDisableBackfaceCulling =
false;
877 Settings.bReceivesDecals =
true;
878 Settings.bUseSelectionOutline =
true;
879 MeshBuilder.GetMesh(ViewportLocalToWorld, PreviousLocalToWorld, ParentMaterialProxy, SDPG_World, Settings,
nullptr, ViewIndex, Collector, FHitProxyId());
887 const int32 NumSegments = FMath::Lerp(4, 32,
ArcAngle / PI);
891 const float Apothem = Radius * FMath::Cos(0.5f*
ArcAngle);
892 const float ChordLength = 2.0f * Radius * FMath::Sin(0.5f*
ArcAngle);
894 const float PivotOffsetX = ChordLength * (0.5 -
Pivot.X);
898 int32 VertexIndices[4];
900 for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
902 FDynamicMeshBuilder MeshBuilder(Views[ViewIndex]->GetFeatureLevel());
904 if (VisibilityMap & (1 << ViewIndex))
906 const float RadiansPerStep =
ArcAngle / NumSegments;
908 FVector LastTangentX;
909 FVector LastTangentY;
910 FVector LastTangentZ;
912 for (int32 Segment = 0; Segment < NumSegments; Segment++)
914 const float Angle = -
ArcAngle / 2 + Segment * RadiansPerStep;
915 const float NextAngle = Angle + RadiansPerStep;
918 const float X0 = Radius * FMath::Cos(Angle) - Apothem;
919 const float Y0 = Radius * FMath::Sin(Angle);
920 const float X1 = Radius * FMath::Cos(NextAngle) - Apothem;
921 const float Y1 = Radius * FMath::Sin(NextAngle);
923 const float U0 =
static_cast<float>(Segment) / NumSegments;
924 const float U1 =
static_cast<float>(Segment + 1) / NumSegments;
926 const FVector Vertex0 = -FVector(X0, PivotOffsetX + Y0, V);
927 const FVector Vertex1 = -FVector(X0, PivotOffsetX + Y0, VL);
928 const FVector Vertex2 = -FVector(X1, PivotOffsetX + Y1, VL);
929 const FVector Vertex3 = -FVector(X1, PivotOffsetX + Y1, V);
931 FVector TangentX = Vertex3 - Vertex0;
932 TangentX.Normalize();
933 FVector TangentY = Vertex1 - Vertex0;
934 TangentY.Normalize();
935 FVector TangentZ = FVector::CrossProduct(TangentX, TangentY);
939 LastTangentX = TangentX;
940 LastTangentY = TangentY;
941 LastTangentZ = TangentZ;
944 VertexIndices[0] = MeshBuilder.AddVertex(Vertex0, FVector2D(U0, 0), LastTangentX, LastTangentY, LastTangentZ, FColor::White);
945 VertexIndices[1] = MeshBuilder.AddVertex(Vertex1, FVector2D(U0, 1), LastTangentX, LastTangentY, LastTangentZ, FColor::White);
946 VertexIndices[2] = MeshBuilder.AddVertex(Vertex2, FVector2D(U1, 1), TangentX, TangentY, TangentZ, FColor::White);
947 VertexIndices[3] = MeshBuilder.AddVertex(Vertex3, FVector2D(U1, 0), TangentX, TangentY, TangentZ, FColor::White);
949 MeshBuilder.AddTriangle(VertexIndices[0], VertexIndices[1], VertexIndices[2]);
950 MeshBuilder.AddTriangle(VertexIndices[0], VertexIndices[2], VertexIndices[3]);
952 LastTangentX = TangentX;
953 LastTangentY = TangentY;
954 LastTangentZ = TangentZ;
957 FDynamicMeshBuilderSettings Settings;
958 Settings.bDisableBackfaceCulling =
false;
959 Settings.bReceivesDecals =
true;
960 Settings.bUseSelectionOutline =
true;
961 MeshBuilder.GetMesh(ViewportLocalToWorld, PreviousLocalToWorld, ParentMaterialProxy, SDPG_World, Settings,
nullptr, ViewIndex, Collector, FHitProxyId());
968#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
969 for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
971 if (VisibilityMap & (1 << ViewIndex))
974 RenderBounds(Collector.GetPDI(ViewIndex), ViewFamily.EngineShowFlags, GetBounds(), IsSelected());
980 void RenderCollision(UBodySetup* InBodySetup, FMeshElementCollector& Collector, int32 ViewIndex,
const FEngineShowFlags& EngineShowFlags,
const FBoxSphereBounds& InBounds,
bool bRenderInEditor)
const
984 bool bDrawCollision = EngineShowFlags.Collision && IsCollisionEnabled();
986 if (bDrawCollision && AllowDebugViewmodes())
989 const bool bDrawSimpleWireframeCollision = InBodySetup->CollisionTraceFlag != ECollisionTraceFlag::CTF_UseComplexAsSimple;
991 if (FMath::Abs(GetLocalToWorld().Determinant()) < SMALL_NUMBER)
999 const bool bDrawSolid = !bDrawSimpleWireframeCollision;
1000 const bool bProxyIsSelected = IsSelected();
1005 auto SolidMaterialInstance =
new FColoredMaterialRenderProxy(
1006 GEngine->ShadedLevelColorationUnlitMaterial->GetRenderProxy(),
1010 Collector.RegisterOneFrameMaterialProxy(SolidMaterialInstance);
1012 FTransform GeomTransform(GetLocalToWorld());
1013 InBodySetup->AggGeom.GetAggGeom(GeomTransform, GetWireframeColor().ToFColor(
true), SolidMaterialInstance,
false,
true, DrawsVelocity(), ViewIndex, Collector);
1018 FColor CollisionColor = FColor(157, 149, 223, 255);
1019 FTransform GeomTransform(GetLocalToWorld());
1020 InBodySetup->AggGeom.GetAggGeom(GeomTransform, GetSelectionColor(CollisionColor, bProxyIsSelected, IsHovered()).ToFColor(
true),
nullptr,
false,
false, DrawsVelocity(), ViewIndex, Collector);