CARLA
 
载入中...
搜索中...
未找到
SceneCaptureCamera.cpp
浏览该文件的文档.
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
24ASceneCaptureCamera::ASceneCaptureCamera(const FObjectInitializer& ObjectInitializer)
25 : Super(ObjectInitializer)
26{
28 TEXT("Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
29}
30
32{
33 Super::BeginPlay();
34}
35
39
43
44void ASceneCaptureCamera::EndPlay(const EEndPlayReason::Type EndPlayReason)
45{
46 Super::EndPlay(EndPlayReason);
47}
48
49void 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
68void ASceneCaptureCamera::SendGBufferTextures(FGBufferRequest& GBuffer)
69{
70 SendGBufferTexturesInternal(*this, GBuffer);
71}
static FActorDefinition GetSensorDefinition()
virtual void SendGBufferTextures(FGBufferRequest &GBuffer) override
void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
virtual void OnLastClientDisconnected() override
void EndPlay(const EEndPlayReason::Type EndPlayReason) override
virtual void OnFirstClientConnected() override
ASceneCaptureCamera(const FObjectInitializer &ObjectInitializer)
void SendGBufferTexturesInternal(T &Self, FGBufferRequest &GBufferData)
bool AddPostProcessingMaterial(const FString &Path)
Load the UMaterialInstanceDynamic at the given Path and append it to the list of shaders with Weight.
static uint64_t GetFrameCounter()
Definition CarlaEngine.h:65
static FActorDefinition MakeCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
A definition of a Carla Actor with all the variation and attributes.