From a0c2c215818ec503b19a85d972112f945891b68b Mon Sep 17 00:00:00 2001 From: nsubiron Date: Mon, 11 Feb 2019 17:33:39 +0100 Subject: [PATCH] Add movable static meshes to the actor registry --- CHANGELOG.md | 1 + .../Carla/Source/Carla/Game/CarlaEpisode.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index df7485a40..d7327a4f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Latest Changes * Fixed `manual_control.py` and `no_rendering_mode.py` to prevent crashes when used in "no rendering mode" + * Added movable props present in the map (e.g. chairs and tables) as actors so they can be controlled from Python * Refactored `no_rendering_mode.py` to improve performance and interface ## CARLA 0.9.3 diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaEpisode.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaEpisode.cpp index 367b0c32d..6a50fa242 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaEpisode.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaEpisode.cpp @@ -12,6 +12,7 @@ #include "Carla/Vehicle/VehicleSpawnPoint.h" #include "EngineUtils.h" +#include "Engine/StaticMeshActor.h" #include "GameFramework/SpectatorPawn.h" static FString UCarlaEpisode_GetTrafficSignId(ETrafficSignState State) @@ -108,4 +109,19 @@ void UCarlaEpisode::InitializeAtBeginPlay() Description.Class = Actor->GetClass(); ActorDispatcher->RegisterActor(*Actor, Description); } + + for (TActorIterator It(World); It; ++It) + { + auto Actor = *It; + check(Actor != nullptr); + auto MeshComponent = Actor->GetStaticMeshComponent(); + check(MeshComponent != nullptr); + if (MeshComponent->Mobility == EComponentMobility::Movable) + { + FActorDescription Description; + Description.Id = TEXT("static.prop"); + Description.Class = Actor->GetClass(); + ActorDispatcher->RegisterActor(*Actor, Description); + } + } }