diff --git a/Source/URoboVision/Private/PacketBuffer.cpp b/Source/URoboVision/Private/PacketBuffer.cpp index 9fccf76..9c77cf4 100644 --- a/Source/URoboVision/Private/PacketBuffer.cpp +++ b/Source/URoboVision/Private/PacketBuffer.cpp @@ -74,7 +74,9 @@ void PacketBuffer::StartWriting(const TMap &ObjectToColor, cons Entry->B = ObjectColor.B; // Convert name to ANSI and copy it to the packet (no trailing '\0', length is indirectly given by the entry size) - const char *Name = TCHAR_TO_ANSI(*Elem.Key); + + auto NamePtr = StringCast(*Elem.Key); + const char *Name = NamePtr.Get(); memcpy(&Entry->FirstChar, Name, NameSize); It += ElemSize; diff --git a/Source/URoboVision/Private/RGBDCamera.cpp b/Source/URoboVision/Private/RGBDCamera.cpp index 702c165..877032f 100644 --- a/Source/URoboVision/Private/RGBDCamera.cpp +++ b/Source/URoboVision/Private/RGBDCamera.cpp @@ -3,7 +3,12 @@ #include "RGBDCamera.h" #include "Components/SceneCaptureComponent2D.h" #include "Camera/CameraComponent.h" + +#if ENGINE_MINOR_VERSION > 23 || ENGINE_MAJOR_VERSION >4 #include "UObject/ConstructorHelpers.h" +#else +#include "ConstructorHelpers.h" +#endif #include "EngineUtils.h" #include "StopTime.h" #include "Server.h" @@ -79,7 +84,7 @@ ARGBDCamera::ARGBDCamera() /*: ACameraActor(), Width(960), Height(540), Framerat bCaptureColorImage = true; bCaptureDepthImage = true; bCaptureObjectMaskImage = true; - + // TCP IP communication server port ServerPort = 10000; bBindToAnyIP = true; @@ -230,8 +235,7 @@ void ARGBDCamera::EndPlay(const EEndPlayReason::Type EndPlayReason) void ARGBDCamera::Tick(float DeltaTime) { Super::Tick(DeltaTime); - - // Check if paused + // Check if paused if(Paused) { return; @@ -245,7 +249,7 @@ void ARGBDCamera::Tick(float DeltaTime) } TimePassed -= 1.0f / Framerate; //MEASURE_TIME("Tick"); - //OUT_INFO(TEXT("FRAME_RATE: %f"),Framerate) + // OUT_INFO(TEXT("FRAME_RATE: %f"),Framerate) if(bColorAllObjectsOnEveryTick) { @@ -326,11 +330,11 @@ void ARGBDCamera::Pause(const bool _Pause) DepthImgCaptureComp->Deactivate(); ObjectMaskImgCaptureComp->SetHiddenInGame(true); ObjectMaskImgCaptureComp->Deactivate(); - bCompActive = false; + bCompActive = false; } else { - // Enable capture + // Enable capture if (bCaptureColorImage) { ColorImgCaptureComp->SetHiddenInGame(false); @@ -628,7 +632,7 @@ bool ARGBDCamera::ColorObject(AActor *Actor, const FString &name) USegmentationComponent* SegmentationComponent = NewObject(MeshComponent); SegmentationComponent->SetupAttachment(MeshComponent); SegmentationComponent->RegisterComponent(); - SegmentationComponent->SetSegmentationColor(SegmentationColor); + SegmentationComponent->SetSegmentationColor(SegmentationColor); SegmentationComponent->MarkRenderStateDirty(); } return true; @@ -649,7 +653,7 @@ bool ARGBDCamera::ColorAllObjects() if(bColoringObjectsIsVerbose) OUT_INFO(TEXT("Actor with name: %s."), *ActorName); } - + if(bColoringObjectsIsVerbose) { OUT_INFO(TEXT("Found %d Actors."), NumberOfActors); @@ -767,7 +771,7 @@ void ARGBDCamera::ProcessObject() Priv->CVObject.wait(WaitLock, [this] {return Priv->DoObject; }); Priv->DoObject = false; if(!this->Running) break; - ToColorImage(ImageObject, Priv->Buffer->Object); + ToColorImage(ImageObject, Priv->Buffer->Object); Priv->DoneObject = true; Priv->CVDone.notify_one(); } diff --git a/Source/URoboVision/Private/SegmentationComponent.cpp b/Source/URoboVision/Private/SegmentationComponent.cpp index 8abde48..c698a54 100644 --- a/Source/URoboVision/Private/SegmentationComponent.cpp +++ b/Source/URoboVision/Private/SegmentationComponent.cpp @@ -7,7 +7,12 @@ #include #include "Components/SceneCaptureComponent2D.h" #include "Camera/CameraComponent.h" + +#if ENGINE_MINOR_VERSION > 23 || ENGINE_MAJOR_VERSION >4 #include "UObject/ConstructorHelpers.h" +#else +#include "ConstructorHelpers.h" +#endif #include "EngineUtils.h" #include "StopTime.h" #include "Server.h" @@ -20,6 +25,10 @@ #include #include +#if ENGINE_MINOR_VERSION >= 2 && ENGINE_MAJOR_VERSION == 5 +#include "SkeletalMeshSceneProxy.h" +#endif + USegmentationComponent::USegmentationComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { @@ -76,8 +85,13 @@ FPrimitiveSceneProxy* USegmentationComponent::CreateSceneProxy(UStaticMeshCompon UMaterialInterface* ProxyMaterial = SegmentationMID; UStaticMesh* ParentStaticMesh = StaticMeshComponent->GetStaticMesh(); if(ParentStaticMesh == NULL + #if ENGINE_MINOR_VERSION < 27 && ENGINE_MAJOR_VERSION < 5 + || ParentStaticMesh->RenderData == NULL + || ParentStaticMesh->RenderData->LODResources.Num() == 0) + #else || ParentStaticMesh->GetRenderData() == NULL || ParentStaticMesh->GetRenderData()->LODResources.Num() == 0) + #endif //Version { OUT_INFO(TEXT("ParentStaticMesh is invalid.")); return NULL; @@ -94,7 +108,7 @@ FPrimitiveSceneProxy* USegmentationComponent::CreateSceneProxy(USkeletalMeshComp FSkeletalMeshRenderData* SkelMeshRenderData = SkeletalMeshComponent->GetSkeletalMeshRenderData(); if (SkelMeshRenderData && SkelMeshRenderData->LODRenderData.IsValidIndex(SkeletalMeshComponent->GetPredictedLODLevel()) && - SkeletalMeshComponent->MeshObject) + SkeletalMeshComponent->MeshObject) { return new FSkeletalSegmentationSceneProxy(SkeletalMeshComponent, SkelMeshRenderData, ProxyMaterial); } diff --git a/Source/URoboVision/Private/StaticSegmentationSceneProxy.cpp b/Source/URoboVision/Private/StaticSegmentationSceneProxy.cpp index 0b15b6d..4e0efe7 100644 --- a/Source/URoboVision/Private/StaticSegmentationSceneProxy.cpp +++ b/Source/URoboVision/Private/StaticSegmentationSceneProxy.cpp @@ -5,7 +5,7 @@ FStaticSegmentationSceneProxy::FStaticSegmentationSceneProxy(UStaticMeshComponent* Component, bool bForceLODsShareStaticLighting, UMaterialInterface* SegmentationMID) : FStaticMeshSceneProxy(Component, bForceLODsShareStaticLighting) { - #if (ENGINE_MINOR_VERSION >= 22 || ENGINE_MAJOR_VERSION == 5) + #if (ENGINE_MINOR_VERSION >= 22 || ENGINE_MAJOR_VERSION >= 5) MaterialRenderProxy = SegmentationMID->GetRenderProxy(); #else MaterialRenderProxy = SegmentationMID->GetRenderProxy(false, false); @@ -44,7 +44,7 @@ bool FStaticSegmentationSceneProxy::GetMeshElement( int32 BatchIndex, int32 ElementIndex, uint8 InDepthPriorityGroup, -#if (ENGINE_MINOR_VERSION >= 22 || ENGINE_MAJOR_VERSION == 5) +#if (ENGINE_MINOR_VERSION >= 22 || ENGINE_MAJOR_VERSION >= 5) bool bUseSelectionOutline, #else bool bUseSelectedMaterial, @@ -54,7 +54,7 @@ bool FStaticSegmentationSceneProxy::GetMeshElement( FMeshBatch & OutMeshBatch) const { bool Ret = FStaticMeshSceneProxy::GetMeshElement(LODIndex, BatchIndex, ElementIndex, InDepthPriorityGroup, -#if (ENGINE_MINOR_VERSION >= 22 || ENGINE_MAJOR_VERSION == 5) +#if (ENGINE_MINOR_VERSION >= 22 || ENGINE_MAJOR_VERSION >= 5) bUseSelectionOutline, #else bUseSelectedMaterial, diff --git a/Source/URoboVision/Public/SkeletalSegmentationSceneProxy.h b/Source/URoboVision/Public/SkeletalSegmentationSceneProxy.h index 3d91957..423a89d 100644 --- a/Source/URoboVision/Public/SkeletalSegmentationSceneProxy.h +++ b/Source/URoboVision/Public/SkeletalSegmentationSceneProxy.h @@ -9,8 +9,15 @@ #include "Runtime/Engine/Public/MaterialShared.h" #include "Runtime/Engine/Classes/Engine/Engine.h" #include "Runtime/Engine/Public/Rendering/SkeletalMeshRenderData.h" +#if ENGINE_MINOR_VERSION > 23 || ENGINE_MAJOR_VERSION >4 #include "UObject/ConstructorHelpers.h" +#else +#include "ConstructorHelpers.h" +#endif #include "EngineUtils.h" +#if ENGINE_MINOR_VERSION >= 2 && ENGINE_MAJOR_VERSION == 5 +#include "SkeletalMeshSceneProxy.h" +#endif class FSkeletalSegmentationSceneProxy : public FSkeletalMeshSceneProxy { diff --git a/Source/URoboVision/Public/StaticSegmentationSceneProxy.h b/Source/URoboVision/Public/StaticSegmentationSceneProxy.h index 0701002..0d6ad66 100644 --- a/Source/URoboVision/Public/StaticSegmentationSceneProxy.h +++ b/Source/URoboVision/Public/StaticSegmentationSceneProxy.h @@ -8,10 +8,18 @@ #include "Runtime/Engine/Public/MaterialShared.h" #include "Runtime/Engine/Classes/Engine/Engine.h" #include "Runtime/Engine/Public/Rendering/SkeletalMeshRenderData.h" + +#if ENGINE_MINOR_VERSION > 23 || ENGINE_MAJOR_VERSION >4 #include "UObject/ConstructorHelpers.h" -#include "EngineUtils.h" +#else +#include "ConstructorHelpers.h" +#endif +#include "EngineUtils.h" +#if ENGINE_MINOR_VERSION >= 2 && ENGINE_MAJOR_VERSION == 5 +#include "StaticMeshSceneProxy.h" +#endif class FStaticSegmentationSceneProxy : public FStaticMeshSceneProxy { @@ -30,7 +38,7 @@ class FStaticSegmentationSceneProxy : public FStaticMeshSceneProxy int32 BatchIndex, int32 ElementIndex, uint8 InDepthPriorityGroup, - #if (ENGINE_MINOR_VERSION >= 22 || ENGINE_MAJOR_VERSION == 5) + #if (ENGINE_MINOR_VERSION >= 22 || ENGINE_MAJOR_VERSION >= 5) bool bUseSelectionOutline, #else bool bUseSelectedMaterial, diff --git a/Source/URoboVision/Public/URoboVision.h b/Source/URoboVision/Public/URoboVision.h index 83cc2b1..a8a798b 100644 --- a/Source/URoboVision/Public/URoboVision.h +++ b/Source/URoboVision/Public/URoboVision.h @@ -3,7 +3,11 @@ #pragma once #include "CoreMinimal.h" +#if ENGINE_MINOR_VERSION > 23 || ENGINE_MAJOR_VERSION >4 #include "Modules/ModuleManager.h" +#else +#include "ModuleManager.h" +#endif class FURoboVisionModule : public IModuleInterface {