Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch5.3 #20

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 3 additions & 1 deletion Source/URoboVision/Private/PacketBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void PacketBuffer::StartWriting(const TMap<FString, uint32> &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<ANSICHAR>(*Elem.Key);
const char *Name = NamePtr.Get();
memcpy(&Entry->FirstChar, Name, NameSize);

It += ElemSize;
Expand Down
22 changes: 13 additions & 9 deletions Source/URoboVision/Private/RGBDCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -628,7 +632,7 @@ bool ARGBDCamera::ColorObject(AActor *Actor, const FString &name)
USegmentationComponent* SegmentationComponent = NewObject<USegmentationComponent>(MeshComponent);
SegmentationComponent->SetupAttachment(MeshComponent);
SegmentationComponent->RegisterComponent();
SegmentationComponent->SetSegmentationColor(SegmentationColor);
SegmentationComponent->SetSegmentationColor(SegmentationColor);
SegmentationComponent->MarkRenderStateDirty();
}
return true;
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down
16 changes: 15 additions & 1 deletion Source/URoboVision/Private/SegmentationComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
#include <sstream>
#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"
Expand All @@ -20,6 +25,10 @@
#include <cmath>
#include <condition_variable>

#if ENGINE_MINOR_VERSION >= 2 && ENGINE_MAJOR_VERSION == 5
#include "SkeletalMeshSceneProxy.h"
#endif

USegmentationComponent::USegmentationComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions Source/URoboVision/Private/StaticSegmentationSceneProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions Source/URoboVision/Public/SkeletalSegmentationSceneProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
12 changes: 10 additions & 2 deletions Source/URoboVision/Public/StaticSegmentationSceneProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions Source/URoboVision/Public/URoboVision.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down