31 : Super(ObjectInitializer)
33 PrimaryActorTick.bCanEverTick =
false;
36 static struct FConstructorStatics
39 ConstructorHelpers::FObjectFinderOptional<UTexture2D> TextureObject;
44 : TextureObject(TEXT(
"/Carla/Icons/OpenDriveActorIcon")),
45 Category(TEXT(
"OpenDriveActor")),
46 Name(NSLOCTEXT(
"SpriteCategory",
"OpenDriveActor",
"OpenDriveActor"))
51 USceneComponent *SceneComponent =
52 ObjectInitializer.CreateDefaultSubobject<USceneComponent>(
this, TEXT(
"SceneComp"));
53 RootComponent = SceneComponent;
54 RootComponent->Mobility = EComponentMobility::Static;
56#if WITH_EDITORONLY_DATA
58 ObjectInitializer.CreateEditorOnlyDefaultSubobject<UBillboardComponent>(
this, TEXT(
"Sprite"));
167 if (!map.has_value())
169 UE_LOG(LogCarla, Error, TEXT(
"Failed to parse OpenDrive file."));
174 const std::vector<Waypoint> LaneWaypoints =
175 map->GenerateWaypointsOnRoadEntries();
177 std::unordered_map<Waypoint, std::vector<Waypoint>> PredecessorMap;
179 for (
auto &Wp : LaneWaypoints)
181 const auto PredecessorsList = map->GetPredecessors(Wp);
182 if (PredecessorsList.empty())
186 const auto MinRoadId = *std::min_element(
187 PredecessorsList.begin(),
188 PredecessorsList.end(),
189 [](
const auto &WaypointA,
const auto &WaypointB) {
190 return WaypointA.road_id < WaypointB.road_id;
192 PredecessorMap[MinRoadId].emplace_back(Wp);
195 for (
auto &&PredecessorWp : PredecessorMap)
199 for (
auto &&Wp : PredecessorWp.second)
201 std::vector<Waypoint> Waypoints;
206 Waypoints.emplace_back(CurrentWp);
207 const auto Successors = map->GetNext(CurrentWp,
RoadAccuracy);
208 if (Successors.empty())
212 if (Successors.front().road_id != Wp.road_id)
216 CurrentWp = Successors.front();
217 }
while (CurrentWp.road_id == Wp.road_id);
220 const auto FollowingWp = map->GetSuccessors(CurrentWp);
221 if (!FollowingWp.empty())
223 Waypoints.emplace_back(FollowingWp.front());
226 if (Waypoints.size() >= 2)
228 TArray<FVector> Positions;
229 Positions.Reserve(Waypoints.size());
230 for (
int i = 0; i < Waypoints.size(); ++i)
233 Positions.Add(map->ComputeTransform(Waypoints[i]).location +
238 if (RoutePlanner ==
nullptr )
240 const auto WpTransform = map->ComputeTransform(Wp);
244 RoutePlanner->SetActorRotation(WpTransform.rotation);
245 RoutePlanner->SetActorLocation(WpTransform.location +
249 if (RoutePlanner !=
nullptr)
251 RoutePlanner->
AddRoute(1.f, Positions);
UE_LOG(LogCarla, Log, TEXT("UActorDispatcher::Destroying actor: '%s' %x"), *Id, Actor)