Removed OldTransform workaround

This commit is contained in:
Marc Garcia Puig 2020-12-02 11:07:42 +01:00 committed by bernat
parent d6f44df7c9
commit bb635add57
8 changed files with 50 additions and 27 deletions

View File

@ -110,9 +110,10 @@ void FCarlaEngine::NotifyEndEpisode()
void FCarlaEngine::OnPreTick(UWorld *, ELevelTick TickType, float DeltaSeconds)
{
if (TickType == ELevelTick::LEVELTICK_All)
{
{
// update frame counter
UpdateFrameCounter();
// UE_LOG(LogCarla, Warning, TEXT("-- UpdateFrameCounter() -> %d ---------------"), GetFrameCounter());
// process RPC commands
do
@ -131,6 +132,7 @@ void FCarlaEngine::OnPreTick(UWorld *, ELevelTick TickType, float DeltaSeconds)
void FCarlaEngine::OnPostTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
{
// tick the recorder/replayer system
// UE_LOG(LogCarla, Warning, TEXT("CarlaEngine - PostPhysTick - frame counter: %d"), FCarlaEngine::GetFrameCounter());
if (GetCurrentEpisode())
{
auto* EpisodeRecorder = GetCurrentEpisode()->GetRecorder();

View File

@ -32,7 +32,6 @@ AInertialMeasurementUnit::AInertialMeasurementUnit(
// Initialized to something hight to minimize the artifacts
// when the initial values are unknown
PrevDeltaTime = std::numeric_limits<float>::max();
OldTransform = GetActorTransform();
}
FActorDefinition AInertialMeasurementUnit::GetSensorDefinition()
@ -40,10 +39,6 @@ FActorDefinition AInertialMeasurementUnit::GetSensorDefinition()
return UActorBlueprintFunctionLibrary::MakeIMUDefinition();
}
const FTransform &AInertialMeasurementUnit::GetSyncActorTransform() const {
return OldTransform;
}
void AInertialMeasurementUnit::Set(const FActorDescription &ActorDescription)
{
Super::Set(ActorDescription);
@ -150,6 +145,7 @@ carla::geom::Vector3D AInertialMeasurementUnit::ComputeAccelerometer(
carla::geom::Vector3D AInertialMeasurementUnit::ComputeGyroscope()
{
check(GetOwner() != nullptr);
const FVector AngularVelocity =
FIMU_GetActorAngularVelocityInRadians(*GetOwner());
@ -184,15 +180,13 @@ float AInertialMeasurementUnit::ComputeCompass()
void AInertialMeasurementUnit::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTime)
{
// UE_LOG(LogCarla, Warning, TEXT("IMU - PostPhysTick - frame counter: %d"), FCarlaEngine::GetFrameCounter());
auto Stream = GetDataStream(*this);
Stream.Send(
*this,
ComputeAccelerometer(DeltaTime),
ComputeGyroscope(),
ComputeCompass());
// TODO: delete once the new tick pipeline is done
OldTransform = GetActorTransform();
}
void AInertialMeasurementUnit::SetAccelerationStandardDeviation(const FVector &Vec)

View File

@ -30,9 +30,6 @@ public:
static FActorDefinition GetSensorDefinition();
/// @TODO: delete once the new tick pipeline is done
const FTransform &GetSyncActorTransform() const override;
void Set(const FActorDescription &ActorDescription) override;
void SetOwner(AActor *Owner) override;
@ -72,9 +69,6 @@ public:
private:
/// @TODO: delete once the new tick pipeline is done
FTransform OldTransform;
void BeginPlay() override;
/// Standard deviation for acceleration settings.

View File

@ -91,6 +91,9 @@ void FPixelReader::SendPixelsInRenderThread(TSensor &Sensor)
return;
}
// FlushRenderingCommands();
// Sensor.CaptureRenderTarget->UpdateResourceImmediate(true);
// Enqueue a command in the render-thread that will write the image buffer to
// the data stream. The stream is created in the capture thus executed in the
// game-thread.
@ -107,7 +110,6 @@ void FPixelReader::SendPixelsInRenderThread(TSensor &Sensor)
Buffer,
carla::sensor::SensorRegistry::get<TSensor *>::type::header_offset,
InRHICmdList);
if(Buffer.data())
{
SCOPE_CYCLE_COUNTER(STAT_CarlaSensorStreamSend);

View File

@ -7,6 +7,9 @@
#include "Carla.h"
#include "Carla/Sensor/SceneCaptureCamera.h"
#include "Runtime/RenderCore/Public/RenderingThread.h"
// #include "Runtime/Engine/Public/UnrealEngine.h"
FActorDefinition ASceneCaptureCamera::GetSensorDefinition()
{
constexpr bool bEnableModifyingPostProcessEffects = true;
@ -22,11 +25,32 @@ ASceneCaptureCamera::ASceneCaptureCamera(const FObjectInitializer &ObjectInitial
TEXT("Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
}
void ASceneCaptureCamera::Tick(const float DeltaTime)
{
Super::Tick(DeltaTime);
// FlushRenderingCommands(true);
// UE_LOG(LogCarla, Warning, TEXT("FlushRenderingCommands()"));
// FPixelReader::SendPixelsInRenderThread(*this);
// RenderFence.BeginFence();
// UE_LOG(LogCarla, Warning, TEXT("RenderFence.BeginFence()"));
}
void ASceneCaptureCamera::SendPixels(UWorld *World, ELevelTick TickType, float DeltaSeconds)
{
if(ReadyToCapture)
{
UE_LOG(LogCarla, Warning, TEXT("FlushRenderingCommands()"));
FlushRenderingCommands(true);
// UE_LOG(LogCarla, Warning, TEXT("RenderFence.Wait() (waiting...)"));
// RenderFence.Wait();
// FFrameEndSync::Sync(false);
// UE_LOG(LogCarla, Warning, TEXT("Fence done! Sending Pixels..."));
FPixelReader::SendPixelsInRenderThread(*this);
// UE_LOG(LogCarla, Warning, TEXT("Pixels sended!"));
ReadyToCapture = false;
}
}

View File

@ -24,6 +24,8 @@ public:
ASceneCaptureCamera(const FObjectInitializer &ObjectInitializer);
virtual void Tick(const float DeltaTime);
protected:
void SendPixels(UWorld *World, ELevelTick TickType, float DeltaSeconds) override;

View File

@ -72,9 +72,9 @@ ASceneCaptureSensor::ASceneCaptureSensor(const FObjectInitializer &ObjectInitial
++SCENE_CAPTURE_COUNTER;
}
const FTransform &ASceneCaptureSensor::GetSyncActorTransform() const {
return OldTransform;
}
// const FTransform &ASceneCaptureSensor::GetSyncActorTransform() const {
// return OldTransform;
// }
void ASceneCaptureSensor::Set(const FActorDescription &Description)
{
@ -489,18 +489,19 @@ void ASceneCaptureSensor::BeginPlay()
SceneCaptureSensor_local_ns::ConfigureShowFlags(CaptureComponent2D->ShowFlags,
bEnablePostProcessingEffects);
// This ensures the camera is always spawning the rain drops in case the
// weather was previously set to has rain
// This ensures the camera is always spawning the raindrops in case the
// weather was previously set to have rain.
GetEpisode().GetWeather()->NotifyWeather();
Super::BeginPlay();
SendPixelsDelegate = FWorldDelegates::OnWorldPostActorTick.AddUObject(this, &ASceneCaptureSensor::SendPixels);
SendPixelsDelegate = FWorldDelegates::OnWorldPreActorTick.AddUObject(this, &ASceneCaptureSensor::SendPixels);
// SendPixelsDelegate = FWorldDelegates::OnWorldPostActorTick.AddUObject(this, &ASceneCaptureSensor::SendPixels);
}
void ASceneCaptureSensor::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTime)
{
// Add the view information every tick. Its only used for one tick and then
// Add the view information every tick. It's only used for one tick and then
// removed by the streamer.
IStreamingManager::Get().AddViewInformation(
CaptureComponent2D->GetComponentLocation(),
@ -510,7 +511,7 @@ void ASceneCaptureSensor::PostPhysTick(UWorld *World, ELevelTick TickType, float
ReadyToCapture = true;
// TODO: delete once the new tick pipeline is done
OldTransform = GetActorTransform();
// OldTransform = GetActorTransform();
}
void ASceneCaptureSensor::EndPlay(const EEndPlayReason::Type EndPlayReason)
@ -518,7 +519,8 @@ void ASceneCaptureSensor::EndPlay(const EEndPlayReason::Type EndPlayReason)
Super::EndPlay(EndPlayReason);
SCENE_CAPTURE_COUNTER = 0u;
FWorldDelegates::OnWorldPostActorTick.Remove(SendPixelsDelegate);
FWorldDelegates::OnWorldPreActorTick.Remove(SendPixelsDelegate);
// FWorldDelegates::OnWorldPostActorTick.Remove(SendPixelsDelegate);
}
// =============================================================================

View File

@ -9,6 +9,7 @@
#include "Carla/Sensor/PixelReader.h"
#include "Carla/Sensor/Sensor.h"
#include "Runtime/RenderCore/Public/RenderCommandFence.h"
#include "SceneCaptureSensor.generated.h"
class UDrawFrustumComponent;
@ -42,7 +43,7 @@ public:
ASceneCaptureSensor(const FObjectInitializer &ObjectInitializer);
/// @TODO: delete once the new tick pipeline is done
const FTransform &GetSyncActorTransform() const override;
// const FTransform &GetSyncActorTransform() const override;
void Set(const FActorDescription &ActorDescription) override;
@ -315,6 +316,8 @@ protected:
UPROPERTY(EditAnywhere)
bool bEnablePostProcessingEffects = true;
bool ReadyToCapture = false;
FRenderCommandFence RenderFence;
bool ReadyToCapture = true;
};