From 7e736696e38205f47ee80316e2bc09cdaa49b5a2 Mon Sep 17 00:00:00 2001 From: doterop Date: Tue, 6 Oct 2020 16:10:06 +0200 Subject: [PATCH] Fixed sensor_tick on cameras --- .../Plugins/Carla/Source/Carla/Sensor/DepthCamera.cpp | 6 +++++- .../Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp | 6 +++++- .../Carla/Source/Carla/Sensor/SceneCaptureSensor.cpp | 1 + .../Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.h | 2 ++ .../Source/Carla/Sensor/SemanticSegmentationCamera.cpp | 6 +++++- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/DepthCamera.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/DepthCamera.cpp index 27cdbd327..2b6241e1e 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/DepthCamera.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/DepthCamera.cpp @@ -30,5 +30,9 @@ ADepthCamera::ADepthCamera(const FObjectInitializer &ObjectInitializer) void ADepthCamera::SendPixels(UWorld *World, ELevelTick TickType, float DeltaSeconds) { - FPixelReader::SendPixelsInRenderThread(*this); + if(ReadyToCapture) + { + FPixelReader::SendPixelsInRenderThread(*this); + ReadyToCapture = false; + } } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp index 4e01ecd08..8ab03a307 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp @@ -24,5 +24,9 @@ ASceneCaptureCamera::ASceneCaptureCamera(const FObjectInitializer &ObjectInitial void ASceneCaptureCamera::SendPixels(UWorld *World, ELevelTick TickType, float DeltaSeconds) { - FPixelReader::SendPixelsInRenderThread(*this); + if(ReadyToCapture) + { + FPixelReader::SendPixelsInRenderThread(*this); + ReadyToCapture = false; + } } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.cpp index 88d5e6a6f..1a0be897a 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.cpp @@ -505,6 +505,7 @@ void ASceneCaptureSensor::Tick(float DeltaTime) ImageWidth, ImageWidth / FMath::Tan(CaptureComponent2D->FOVAngle)); + ReadyToCapture = true; } void ASceneCaptureSensor::EndPlay(const EEndPlayReason::Type EndPlayReason) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.h index 60421eec6..88c0b8953 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.h @@ -307,4 +307,6 @@ protected: UPROPERTY(EditAnywhere) bool bEnablePostProcessingEffects = true; + bool ReadyToCapture = false; + }; diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SemanticSegmentationCamera.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SemanticSegmentationCamera.cpp index bd673170a..2d371e3f4 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SemanticSegmentationCamera.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SemanticSegmentationCamera.cpp @@ -26,5 +26,9 @@ ASemanticSegmentationCamera::ASemanticSegmentationCamera( void ASemanticSegmentationCamera::SendPixels(UWorld *World, ELevelTick TickType, float DeltaSeconds) { - FPixelReader::SendPixelsInRenderThread(*this); + if(ReadyToCapture) + { + FPixelReader::SendPixelsInRenderThread(*this); + ReadyToCapture = false; + } }