/** Loc is an anchor point in the world to guide which part of the infinite plane to draw. */ void DrawDebugSolidPlane(const UWorld* InWorld, FPlane const& P, FVector const& Loc, float Size, FColor const& Color, bool bPersistent, float LifeTime, uint8 DepthPriority) { // no debug line drawing on dedicated server if (GEngine->GetNetMode(InWorld) != NM_DedicatedServer) { FVector const ClosestPtOnPlane = Loc - P.PlaneDot(Loc) * P; FVector U, V; P.FindBestAxisVectors(U, V); U *= Size; V *= Size; TArray<FVector> Verts; Verts.AddUninitialized(4); Verts[0] = ClosestPtOnPlane + U + V; Verts[1] = ClosestPtOnPlane - U + V; Verts[2] = ClosestPtOnPlane + U - V; Verts[3] = ClosestPtOnPlane - U - V; TArray<int32> Indices; Indices.AddUninitialized(6); Indices[0] = 0; Indices[1] = 2; Indices[2] = 1; Indices[3] = 1; Indices[4] = 2; Indices[5] = 3; // plane quad DrawDebugMesh(InWorld, Verts, Indices, Color, bPersistent, LifeTime, DepthPriority); // arrow indicating normal DrawDebugDirectionalArrow(InWorld, ClosestPtOnPlane, ClosestPtOnPlane + P * 16.f, 8.f, FColor::White, bPersistent, LifeTime, DepthPriority); } }
FPoly FPoly::BuildInfiniteFPoly(const FPlane& InPlane) { FVector Axis1, Axis2; // Find two non-problematic axis vectors. InPlane.FindBestAxisVectors( Axis1, Axis2 ); // Set up the FPoly. FPoly EdPoly; EdPoly.Init(); EdPoly.Normal.X = InPlane.X; EdPoly.Normal.Y = InPlane.Y; EdPoly.Normal.Z = InPlane.Z; EdPoly.Base = EdPoly.Normal * InPlane.W; EdPoly.Vertices.Add( EdPoly.Base + Axis1*HALF_WORLD_MAX + Axis2*HALF_WORLD_MAX ); EdPoly.Vertices.Add( EdPoly.Base - Axis1*HALF_WORLD_MAX + Axis2*HALF_WORLD_MAX ); EdPoly.Vertices.Add( EdPoly.Base - Axis1*HALF_WORLD_MAX - Axis2*HALF_WORLD_MAX ); EdPoly.Vertices.Add( EdPoly.Base + Axis1*HALF_WORLD_MAX - Axis2*HALF_WORLD_MAX ); return EdPoly; }