Added check of atalas size texture before created

This commit is contained in:
doterop 2020-07-27 11:48:27 +02:00 committed by bernat
parent 67b9d7d0d2
commit 2430559d8c
1 changed files with 25 additions and 9 deletions

View File

@ -16,6 +16,7 @@
#include <compiler/enable-ue4-macros.h>
#include "Async/ParallelFor.h"
#include "DynamicRHI.h"
#include "DrawDebugHelpers.h"
#include "Kismet/KismetSystemLibrary.h"
@ -205,7 +206,8 @@ void ACarlaGameModeBase::Tick(float DeltaSeconds)
Recorder->Tick(DeltaSeconds);
}
if(!IsAtlasTextureValid) {
if(!IsAtlasTextureValid)
{
CreateAtlasTextures();
}
}
@ -254,7 +256,9 @@ void ACarlaGameModeBase::ParseOpenDrive(const FString &MapName)
Map = carla::opendrive::OpenDriveParser::Load(opendrive_xml);
if (!Map.has_value()) {
UE_LOG(LogCarla, Error, TEXT("Invalid Map"));
} else {
}
else
{
Episode->MapGeoReference = Map->GetGeoReference();
}
}
@ -377,6 +381,8 @@ void ACarlaGameModeBase::DebugShowSignals(bool enable)
}
void ACarlaGameModeBase::CreateAtlasTextures()
{
if(AtlasTextureWidth > 0 && AtlasTextureHeight > 0)
{
UE_LOG(LogCarla, Warning, TEXT("ACarlaGameModeBase::CreateAtlasTextures %d %dx%d"), SceneCaptureSensors.Num(), AtlasTextureWidth, AtlasTextureHeight);
@ -388,6 +394,9 @@ void ACarlaGameModeBase::CreateAtlasTextures()
}
IsAtlasTextureValid = true;
}
}
extern FDynamicRHI* GDynamicRHI;
void ACarlaGameModeBase::CaptureAtlas()
{
@ -422,12 +431,19 @@ void ACarlaGameModeBase::CaptureAtlas()
}
#endif
// GDynamicRHI->RHIReadSurfaceData(AtlasTexture, Rect, CurrentAtlasPixels, FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX));
// FRHICommandBeginRenderPass RHICommandBeginRenderPass;
// FRHICommandBeginParallelRenderPass RHICommandBeginParallelRenderPass;
RHICmdList.ReadSurfaceData(
AtlasTexture,
Rect,
CurrentAtlasPixels,
FReadSurfaceDataFlags(RCM_UNorm, CubeFace_MAX));
// PreviousTexture = CurrentTexture;
// CurrentTexture = (CurrentTexture + 1) & ~MaxNumTextures;
}