13 #include "DrawDebugHelpers.h" 14 #include "Components/LineBatchComponent.h" 27 FShapeVisitor(UWorld &InWorld, FColor InColor,
float InLifeTime,
bool bInPersistentLines)
33 World->PersistentLineBatcher->SetCollisionEnabled(ECollisionEnabled::NoCollision);
44 World->PersistentLineBatcher->DrawPoint(
54 FVector Begin = FVector(Line.
begin);
55 FVector End = FVector(Line.
end);
62 World->PersistentLineBatcher->DrawLine(
73 FVector Begin = FVector(Arrow.
line.
begin);
74 FVector End = FVector(Arrow.
line.
end);
81 const auto Diff = End - Begin;
82 const FRotator LookAt = FRotationMatrix::MakeFromX(Diff).Rotator();
83 const FTransform
Transform = {LookAt, Begin};
86 const auto Dist = Diff.Size();
87 const auto ArrowSize = 1e2f * Arrow.
arrow_size;
88 const auto ArrowTipDist = Dist - ArrowSize;
91 World->PersistentLineBatcher->DrawLines(TArray<FBatchedLine>({
100 Transform.TransformPosition(FVector(ArrowTipDist, +ArrowSize, +ArrowSize)),
107 Transform.TransformPosition(FVector(ArrowTipDist, +ArrowSize, -ArrowSize)),
114 Transform.TransformPosition(FVector(ArrowTipDist, -ArrowSize, +ArrowSize)),
121 Transform.TransformPosition(FVector(ArrowTipDist, -ArrowSize, -ArrowSize)),
133 const auto Thickness = 1e2f * Box.
thickness;
145 for(int32 i = 0; i < 2; ++i)
147 for(int32 j = 0; j < 2; ++j)
155 World->PersistentLineBatcher->DrawLine(
156 Transform.TransformPosition(P),
157 Transform.TransformPosition(Q),
169 World->PersistentLineBatcher->DrawLine(
170 Transform.TransformPosition(P),
171 Transform.TransformPosition(Q),
183 World->PersistentLineBatcher->DrawLine(
184 Transform.TransformPosition(P),
185 Transform.TransformPosition(Q),
196 auto PlayerController = UGameplayStatics::GetPlayerController(
World, 0);
197 if (PlayerController ==
nullptr)
199 UE_LOG(LogCarla, Error, TEXT(
"Can't find player controller!"));
208 ACarlaHUD *Hud = Cast<ACarlaHUD>(PlayerController->GetHUD());
226 #if UE_BUILD_SHIPPING 231 static constexpr
double BrightMultiplier = 1.0;
239 boost::variant2::visit(Visitor, Shape.
primitive);
static constexpr double BrightMultiplier
void operator()(const Shape::Line &Line) const
void AddHUDString(const FString Str, const FVector Location, const FColor Color, double LifeTime)
void operator()(const Shape::Arrow &Arrow) const
FShapeVisitor(UWorld &InWorld, FColor InColor, float InLifeTime, bool bInPersistentLines)
carla::rpc::DebugShape Shape
void operator()(const Shape::Box &Box) const
Location location
Center of the BoundingBox in local space.
FVector GlobalToLocalLocation(const FVector &InLocation) const
Vector3D extent
Half the size of the BoundingBox in local space.
void operator()(const Shape::Point &Point) const
bg::model::box< Point3D > Box
void Draw(const carla::rpc::DebugShape &Shape)
void operator()(const Shape::String &Str) const
FTransform GlobalToLocalTransform(const FTransform &InTransform) const
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
boost::variant2::variant< Point, Line, Arrow, Box, String > primitive
geom::Transform Transform