CARLA
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ARoutePlanner Class Reference

Assign a random route to every ACarlaWheeledVehicle entering the trigger volume. More...

#include <RoutePlanner.h>

+ Inheritance diagram for ARoutePlanner:

Public Member Functions

void AddRoute (float probability, const TArray< FVector > &routePoints)
 
 ARoutePlanner (const FObjectInitializer &ObjectInitializer)
 
void AssignRandomRoute (AWheeledVehicleAIController &Controller) const
 
virtual void BeginDestroy () override
 
void CleanRoute ()
 
void DrawRoutes ()
 
void Init ()
 
void SetBoxExtent (const FVector &Extent)
 

Static Public Member Functions

static bool FindRoadFlowRotationAtLocation (const UObject *WorldContextObject, const FVector &Location, float SearchRadius, FRotator &OutRotation)
 Searches every ARoutePlanner in the world for the route spline point closest to Location, and returns the road direction there (as a rotator built from the spline tangent).
 

Public Attributes

bool bIsIntersection = false
 
TArray< float > Probabilities
 
TArray< TObjectPtr< USplineComponent > > Routes
 
TObjectPtr< UBoxComponent > TriggerVolume
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void EndPlay (EEndPlayReason::Type EndPlayReason) override
 
void OnTriggerBeginOverlap (UPrimitiveComponent *OverlappedComp, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
 

Detailed Description

Assign a random route to every ACarlaWheeledVehicle entering the trigger volume.

Routes must be added in editor after placing this actor into the world. Spline tangents are ignored, only locations are taken into account for making the route.

Definition at line 24 of file RoutePlanner.h.

Constructor & Destructor Documentation

◆ ARoutePlanner()

ARoutePlanner::ARoutePlanner ( const FObjectInitializer &  ObjectInitializer)

Definition at line 51 of file RoutePlanner.cpp.

References TriggerVolume.

Member Function Documentation

◆ AddRoute()

void ARoutePlanner::AddRoute ( float  probability,
const TArray< FVector > &  routePoints 
)

Definition at line 99 of file RoutePlanner.cpp.

References Probabilities, and Routes.

Referenced by AOpenDriveActor::BuildRoutes().

◆ AssignRandomRoute()

void ARoutePlanner::AssignRandomRoute ( AWheeledVehicleAIController &  Controller) const

◆ BeginDestroy()

void ARoutePlanner::BeginDestroy ( )
overridevirtual

Definition at line 69 of file RoutePlanner.cpp.

References CleanRoute().

◆ BeginPlay()

void ARoutePlanner::BeginPlay ( )
overrideprotectedvirtual

Definition at line 221 of file RoutePlanner.cpp.

References Init().

◆ CleanRoute()

void ARoutePlanner::CleanRoute ( )

Definition at line 120 of file RoutePlanner.cpp.

References Probabilities, and Routes.

Referenced by BeginDestroy().

◆ DrawRoutes()

void ARoutePlanner::DrawRoutes ( )

Definition at line 253 of file RoutePlanner.cpp.

References bIsIntersection, and Routes.

◆ EndPlay()

void ARoutePlanner::EndPlay ( EEndPlayReason::Type  EndPlayReason)
overrideprotectedvirtual

Definition at line 227 of file RoutePlanner.cpp.

References OnTriggerBeginOverlap(), and TriggerVolume.

◆ FindRoadFlowRotationAtLocation()

bool ARoutePlanner::FindRoadFlowRotationAtLocation ( const UObject *  WorldContextObject,
const FVector &  Location,
float  SearchRadius,
FRotator &  OutRotation 
)
static

Searches every ARoutePlanner in the world for the route spline point closest to Location, and returns the road direction there (as a rotator built from the spline tangent).

Used by editor tools that want to align spawned props (e.g. road decals) to the flow of traffic. Returns false, leaving OutRotation untouched, if no route spline point is found within SearchRadius.

Definition at line 153 of file RoutePlanner.cpp.

References IsSplineValid().

◆ Init()

void ARoutePlanner::Init ( )

Definition at line 197 of file RoutePlanner.cpp.

References IsSplineValid(), OnTriggerBeginOverlap(), Routes, and TriggerVolume.

Referenced by BeginPlay().

◆ OnTriggerBeginOverlap()

void ARoutePlanner::OnTriggerBeginOverlap ( UPrimitiveComponent *  OverlappedComp,
AActor *  OtherActor,
UPrimitiveComponent *  OtherComp,
int32  OtherBodyIndex,
bool  bFromSweep,
const FHitResult &  SweepResult 
)
protected

Definition at line 238 of file RoutePlanner.cpp.

References AssignRandomRoute(), and GetVehicleController().

Referenced by EndPlay(), and Init().

◆ SetBoxExtent()

void ARoutePlanner::SetBoxExtent ( const FVector &  Extent)
inline

Definition at line 36 of file RoutePlanner.h.

References TriggerVolume.

Referenced by AOpenDriveActor::BuildRoutes().

Member Data Documentation

◆ bIsIntersection

bool ARoutePlanner::bIsIntersection = false

Definition at line 94 of file RoutePlanner.h.

Referenced by AOpenDriveActor::BuildRoutes(), and DrawRoutes().

◆ Probabilities

TArray<float> ARoutePlanner::Probabilities

Definition at line 91 of file RoutePlanner.h.

Referenced by AddRoute(), AssignRandomRoute(), and CleanRoute().

◆ Routes

TArray<TObjectPtr<USplineComponent> > ARoutePlanner::Routes

Definition at line 88 of file RoutePlanner.h.

Referenced by AddRoute(), AssignRandomRoute(), CleanRoute(), DrawRoutes(), and Init().

◆ TriggerVolume

TObjectPtr<UBoxComponent> ARoutePlanner::TriggerVolume

Definition at line 85 of file RoutePlanner.h.

Referenced by ARoutePlanner(), EndPlay(), and Init().


The documentation for this class was generated from the following files: