Make OpenDrive static functions available in blueprints

This commit is contained in:
nsubiron 2019-05-21 16:02:26 +02:00
parent 8febd66739
commit f026ead7f2
4 changed files with 17 additions and 7 deletions

View File

@ -136,7 +136,7 @@ void AOpenDriveActor::BuildRoutes(FString MapName)
// As the OpenDrive file has the same name as level, build the path to the
// xodr file using the lavel name and the game content directory.
const FString XodrContent = FOpenDrive::Load(MapName);
const FString XodrContent = UOpenDrive::LoadXODR(MapName);
auto map = carla::opendrive::OpenDriveParser::Load(carla::rpc::FromFString(XodrContent));

View File

@ -195,7 +195,7 @@ void FCarlaServer::FPimpl::BindActions()
BIND_SYNC(get_map_info) << [this]() -> R<cr::MapInfo>
{
REQUIRE_CARLA_EPISODE();
auto FileContents = FOpenDrive::Load(Episode->GetMapName());
auto FileContents = UOpenDrive::LoadXODR(Episode->GetMapName());
const auto &SpawnPoints = Episode->GetRecommendedSpawnPoints();
return cr::MapInfo{
cr::FromFString(Episode->GetMapName()),

View File

@ -9,7 +9,7 @@
#include "Runtime/Core/Public/HAL/FileManagerGeneric.h"
static FString FOpenDrive_FindPathToXODRFile(const FString &InMapName)
FString UOpenDrive::FindPathToXODRFile(const FString &InMapName)
{
FString MapName = InMapName;
#if WITH_EDITOR
@ -50,9 +50,9 @@ static FString FOpenDrive_FindPathToXODRFile(const FString &InMapName)
return FilesFound.Num() > 0 ? FilesFound[0u] : FString{};
}
FString FOpenDrive::Load(const FString &MapName)
FString UOpenDrive::LoadXODR(const FString &MapName)
{
const auto FilePath = FOpenDrive_FindPathToXODRFile(MapName);
const auto FilePath = FindPathToXODRFile(MapName);
FString Content;

View File

@ -6,11 +6,21 @@
#pragma once
class FOpenDrive
#include "Kismet/BlueprintFunctionLibrary.h"
#include "OpenDrive.generated.h"
UCLASS()
class CARLA_API UOpenDrive : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
static FString FindPathToXODRFile(const FString &MapName);
/// Return the OpenDrive XML associated to @a MapName, or empty if the file
/// is not found.
static FString Load(const FString &MapName);
UFUNCTION(BlueprintCallable, Category="CARLA|OpenDrive")
static FString LoadXODR(const FString &MapName);
};