CARLA
SceneCaptureCamera.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #include "Carla.h"
10 #include <chrono>
11 
13 
14 #include "Runtime/RenderCore/Public/RenderingThread.h"
15 
17 {
18  constexpr bool bEnableModifyingPostProcessEffects = true;
20  TEXT("rgb"),
21  bEnableModifyingPostProcessEffects);
22 }
23 
24 ASceneCaptureCamera::ASceneCaptureCamera(const FObjectInitializer& ObjectInitializer)
25  : Super(ObjectInitializer)
26 {
28  TEXT("Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
29 }
30 
32 {
33  Super::BeginPlay();
34 }
35 
37 {
38 }
39 
41 {
42 }
43 
44 void ASceneCaptureCamera::EndPlay(const EEndPlayReason::Type EndPlayReason)
45 {
46  Super::EndPlay(EndPlayReason);
47 }
48 
49 void ASceneCaptureCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
50 {
51  TRACE_CPUPROFILER_EVENT_SCOPE(ASceneCaptureCamera::PostPhysTick);
52  ENQUEUE_RENDER_COMMAND(MeasureTime)
53  (
54  [](auto &InRHICmdList)
55  {
56  std::chrono::time_point<std::chrono::high_resolution_clock> Time =
57  std::chrono::high_resolution_clock::now();
58  auto Duration = std::chrono::duration_cast< std::chrono::milliseconds >(Time.time_since_epoch());
59  uint64_t Milliseconds = Duration.count();
60  FString ProfilerText = FString("(Render)Frame: ") + FString::FromInt(FCarlaEngine::GetFrameCounter()) +
61  FString(" Time: ") + FString::FromInt(Milliseconds);
62  TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(*ProfilerText);
63  }
64  );
65  FPixelReader::SendPixelsInRenderThread<ASceneCaptureCamera, FColor>(*this);
66 }
67 
68 void ASceneCaptureCamera::SendGBufferTextures(FGBufferRequest& GBuffer)
69 {
70  SendGBufferTexturesInternal(*this, GBuffer);
71 }
void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
ASceneCaptureCamera(const FObjectInitializer &ObjectInitializer)
bool AddPostProcessingMaterial(const FString &Path)
Load the UMaterialInstanceDynamic at the given Path and append it to the list of shaders with Weight...
A definition of a Carla Actor with all the variation and attributes.
static uint64_t GetFrameCounter()
Definition: CarlaEngine.h:65
static FActorDefinition GetSensorDefinition()
virtual void SendGBufferTextures(FGBufferRequest &GBuffer) override
virtual void OnFirstClientConnected() override
void SendGBufferTexturesInternal(T &Self, FGBufferRequest &GBufferData)
void EndPlay(const EEndPlayReason::Type EndPlayReason) override
static FActorDefinition MakeCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
void BeginPlay() override
virtual void OnLastClientDisconnected() override