Skip to content

Commit 10984be

Browse files
committed
1 parent d0cb2eb commit 10984be

18 files changed

+104
-84
lines changed

Unreal/Environments/Blocks/Blocks.uproject

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"FileVersion": 3,
3-
"EngineAssociation": "5.2",
3+
"EngineAssociation": "5.3",
44
"Category": "",
55
"Description": "",
66
"Modules": [

Unreal/Environments/Blocks/Source/Blocks.Target.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public BlocksTarget(TargetInfo Target) : base(Target)
99
{
1010
Type = TargetType.Game;
1111
ExtraModuleNames.AddRange(new string[] { "Blocks" });
12-
12+
DefaultBuildSettings = BuildSettingsVersion.V4;
1313
//bUseUnityBuild = false;
1414
if (Target.Platform == UnrealTargetPlatform.Linux)
1515
bUsePCHFiles = false;

Unreal/Environments/Blocks/Source/BlocksEditor.Target.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public BlocksEditorTarget(TargetInfo Target) : base(Target)
99
{
1010
Type = TargetType.Editor;
1111
ExtraModuleNames.AddRange(new string[] { "Blocks" });
12-
DefaultBuildSettings = BuildSettingsVersion.V2;
12+
DefaultBuildSettings = BuildSettingsVersion.V4;
1313
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_2;
1414
//bUseUnityBuild = false;
1515
//bUsePCHFiles = false;

Unreal/Environments/Blocks/package.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set OutPath=%1
77
set ToolPath=%2
88
set UEVer=%3
99

10-
if "%UEVer%"=="" set "UEVer=5.2.1"
10+
if "%UEVer%"=="" set "UEVer=5.3.2"
1111

1212
set "_ToolPath=%PROGRAMFILES%\Epic Games\UE_%UEVer%\Engine\Build\BatchFiles"
1313
if "%ToolPath%"=="" set ToolPath=%_ToolPath%

Unreal/Plugins/AirSim/Source/AirBlueprintLib.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ EAppReturnType::Type UAirBlueprintLib::ShowMessage(EAppMsgType::Type message_typ
5353

5454
return FMessageDialog::Open(message_type,
5555
FText::FromString(message.c_str()),
56-
&title_text);
56+
title_text);
5757
}
5858

5959
ULineBatchComponent* GetLineBatcher(const UWorld* InWorld, bool bPersistentLines, float LifeTime, bool bDepthIsForeground)
@@ -732,9 +732,9 @@ std::vector<msr::airlib::MeshPositionVertexBuffersResponse> UAirBlueprintLib::Ge
732732
ENQUEUE_RENDER_COMMAND(GetVertexBuffer)
733733
(
734734
[vertex_buffer, data](FRHICommandListImmediate& RHICmdList) {
735-
FVector* indices = (FVector*)RHILockBuffer(vertex_buffer->VertexBufferRHI, 0, vertex_buffer->VertexBufferRHI->GetSize(), RLM_ReadOnly);
735+
FVector* indices = (FVector*)RHICmdList.LockBuffer(vertex_buffer->VertexBufferRHI, 0, vertex_buffer->VertexBufferRHI->GetSize(), RLM_ReadOnly);
736736
memcpy(data, indices, vertex_buffer->VertexBufferRHI->GetSize());
737-
RHIUnlockBuffer(vertex_buffer->VertexBufferRHI);
737+
RHICmdList.UnlockBuffer(vertex_buffer->VertexBufferRHI);
738738
});
739739

740740
#if ((ENGINE_MAJOR_VERSION > 4) || (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 27))
@@ -754,9 +754,9 @@ std::vector<msr::airlib::MeshPositionVertexBuffersResponse> UAirBlueprintLib::Ge
754754
ENQUEUE_RENDER_COMMAND(GetIndexBuffer)
755755
(
756756
[IndexBuffer, data_ptr](FRHICommandListImmediate& RHICmdList) {
757-
uint16_t* indices = (uint16_t*)RHILockBuffer(IndexBuffer->IndexBufferRHI, 0, IndexBuffer->IndexBufferRHI->GetSize(), RLM_ReadOnly);
757+
uint16_t* indices = (uint16_t*)RHICmdList.LockBuffer(IndexBuffer->IndexBufferRHI, 0, IndexBuffer->IndexBufferRHI->GetSize(), RLM_ReadOnly);
758758
memcpy(data_ptr, indices, IndexBuffer->IndexBufferRHI->GetSize());
759-
RHIUnlockBuffer(IndexBuffer->IndexBufferRHI);
759+
RHICmdList.UnlockBuffer(IndexBuffer->IndexBufferRHI);
760760
});
761761

762762
//Need to force the render command to go through cause on the next iteration the buffer no longer exists
@@ -777,9 +777,9 @@ std::vector<msr::airlib::MeshPositionVertexBuffersResponse> UAirBlueprintLib::Ge
777777
ENQUEUE_RENDER_COMMAND(GetIndexBuffer)
778778
(
779779
[IndexBuffer, data_ptr](FRHICommandListImmediate& RHICmdList) {
780-
uint32_t* indices = (uint32_t*)RHILockBuffer(IndexBuffer->IndexBufferRHI, 0, IndexBuffer->IndexBufferRHI->GetSize(), RLM_ReadOnly);
780+
uint32_t* indices = (uint32_t*)RHICmdList.LockBuffer(IndexBuffer->IndexBufferRHI, 0, IndexBuffer->IndexBufferRHI->GetSize(), RLM_ReadOnly);
781781
memcpy(data_ptr, indices, IndexBuffer->IndexBufferRHI->GetSize());
782-
RHIUnlockBuffer(IndexBuffer->IndexBufferRHI);
782+
RHICmdList.UnlockBuffer(IndexBuffer->IndexBufferRHI);
783783
});
784784

785785
FlushRenderingCommands();
@@ -814,7 +814,8 @@ std::vector<msr::airlib::MeshPositionVertexBuffersResponse> UAirBlueprintLib::Ge
814814
TArray<FName> UAirBlueprintLib::ListWorldsInRegistry()
815815
{
816816
FARFilter Filter;
817-
Filter.ClassNames.Add(UWorld::StaticClass()->GetFName());
817+
FTopLevelAssetPath UPath(UWorld::StaticClass()->GetPathName());
818+
Filter.ClassPaths.Add(UPath);
818819
Filter.bRecursivePaths = true;
819820

820821
TArray<FAssetData> AssetData;
@@ -830,7 +831,8 @@ TArray<FName> UAirBlueprintLib::ListWorldsInRegistry()
830831
UObject* UAirBlueprintLib::GetMeshFromRegistry(const std::string& load_object)
831832
{
832833
FARFilter Filter;
833-
Filter.ClassNames.Add(UStaticMesh::StaticClass()->GetFName());
834+
FTopLevelAssetPath MPath(UStaticMesh::StaticClass()->GetPathName());
835+
Filter.ClassPaths.Add(MPath);
834836
Filter.bRecursivePaths = true;
835837

836838
TArray<FAssetData> AssetData;

Unreal/Plugins/AirSim/Source/AirBlueprintLib.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class UAirBlueprintLib : public UBlueprintFunctionLibrary
5858
FName name_n = FName(*name);
5959
for (TActorIterator<AActor> It(context->GetWorld(), T::StaticClass()); It; ++It) {
6060
AActor* Actor = *It;
61-
if (!Actor->IsPendingKill() && (Actor->ActorHasTag(name_n) || Actor->GetName().Compare(name) == 0)) {
61+
if (IsValid(Actor) && (Actor->ActorHasTag(name_n) || Actor->GetName().Compare(name) == 0)) {
6262
return static_cast<T*>(Actor);
6363
}
6464
}

Unreal/Plugins/AirSim/Source/AirSim.Build.cs

+14-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ private string AirSimPluginPath
2222
}
2323
private string ProjectBinariesPath
2424
{
25-
get { return Path.Combine(
25+
get
26+
{
27+
return Path.Combine(
2628
Directory.GetParent(AirSimPluginPath).Parent.FullName, "Binaries");
2729
}
2830
}
@@ -91,7 +93,7 @@ public AirSim(ReadOnlyTargetRules Target) : base(Target)
9193
PublicIncludePaths.Add(Path.Combine(AirLibPath, "deps", "eigen3"));
9294
AddOSLibDependencies(Target);
9395

94-
SetupCompileMode(CompileMode.HeaderOnlyWithRpc, Target);
96+
SetupCompileMode(CompileMode.CppCompileWithRpc, Target);
9597
}
9698

9799
private void AddOSLibDependencies(ReadOnlyTargetRules Target)
@@ -106,12 +108,12 @@ private void AddOSLibDependencies(ReadOnlyTargetRules Target)
106108
PublicAdditionalLibraries.Add("dxguid.lib");
107109
}
108110

109-
if (Target.Platform == UnrealTargetPlatform.Linux)
110-
{
111-
// needed when packaging
112-
PublicAdditionalLibraries.Add("stdc++");
113-
PublicAdditionalLibraries.Add("supc++");
114-
}
111+
if (Target.Platform == UnrealTargetPlatform.Linux)
112+
{
113+
// needed when packaging
114+
PublicAdditionalLibraries.Add("stdc++");
115+
PublicAdditionalLibraries.Add("supc++");
116+
}
115117
}
116118

117119
static void CopyFileIfNewer(string srcFilePath, string destFolder)
@@ -143,7 +145,9 @@ private bool AddLibDependency(string LibName, string LibPath, string LibFileName
143145
isLibrarySupported = true;
144146

145147
PublicAdditionalLibraries.Add(Path.Combine(LibPath, PlatformString, ConfigurationString, LibFileName + ".lib"));
146-
} else if (Target.Platform == UnrealTargetPlatform.Linux || Target.Platform == UnrealTargetPlatform.Mac) {
148+
}
149+
else if (Target.Platform == UnrealTargetPlatform.Linux || Target.Platform == UnrealTargetPlatform.Mac)
150+
{
147151
isLibrarySupported = true;
148152
PublicAdditionalLibraries.Add(Path.Combine(LibPath, "lib" + LibFileName + ".a"));
149153
}
@@ -157,4 +161,4 @@ private bool AddLibDependency(string LibName, string LibPath, string LibFileName
157161

158162
return isLibrarySupported;
159163
}
160-
}
164+
}

Unreal/Plugins/AirSim/Source/CameraDirector.cpp Unreal/Plugins/AirSim/Source/AirSimCameraDirector.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "CameraDirector.h"
1+
#include "AirSimCameraDirector.h"
22
#include "GameFramework/PlayerController.h"
33
#include "AirBlueprintLib.h"
44

@@ -321,7 +321,7 @@ void ACameraDirector::inputEventFpvView()
321321
if (fpv_camera_) {
322322
setMode(ECameraDirectorMode::CAMERA_DIRECTOR_MODE_FPV);
323323
fpv_camera_->showToScreen();
324-
disableCameras(false, true, true);
324+
disableCameras(false, true, true, true);
325325
}
326326
else
327327
UAirBlueprintLib::LogMessageString("Camera is not available: ", "fpv_camera", LogDebugLevel::Failure);
@@ -346,4 +346,4 @@ void ACameraDirector::notifyViewModeChanged()
346346
UWorld* world = GetWorld();
347347
UGameViewportClient* gameViewport = world->GetGameViewport();
348348
gameViewport->bDisableWorldRendering = nodisplay;
349-
}
349+
}

Unreal/Plugins/AirSim/Source/CameraDirector.h Unreal/Plugins/AirSim/Source/AirSimCameraDirector.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "ManualPoseController.h"
88
#include "common/common_utils/Utils.hpp"
99
#include "GameFramework/SpringArmComponent.h"
10-
#include "CameraDirector.generated.h"
10+
#include "AirSimCameraDirector.generated.h"
1111

1212
UENUM(BlueprintType)
1313
enum class ECameraDirectorMode : uint8
@@ -30,10 +30,10 @@ class AIRSIM_API ACameraDirector : public AActor
3030
public:
3131
/** Spring arm that will offset the camera */
3232
UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
33-
USpringArmComponent* SpringArm;
33+
USpringArmComponent *SpringArm;
3434

3535
UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
36-
APIPCamera* ExternalCamera;
36+
APIPCamera *ExternalCamera;
3737

3838
public:
3939
void inputEventFpvView();
@@ -57,11 +57,11 @@ class AIRSIM_API ACameraDirector : public AActor
5757
void setMode(ECameraDirectorMode mode);
5858

5959
void initializeForBeginPlay(ECameraDirectorMode view_mode,
60-
AActor* follow_actor, APIPCamera* fpv_camera, APIPCamera* front_camera, APIPCamera* back_camera);
60+
AActor *follow_actor, APIPCamera *fpv_camera, APIPCamera *front_camera, APIPCamera *back_camera);
6161

62-
APIPCamera* getFpvCamera() const;
63-
APIPCamera* getExternalCamera() const;
64-
APIPCamera* getBackupCamera() const;
62+
APIPCamera *getFpvCamera() const;
63+
APIPCamera *getExternalCamera() const;
64+
APIPCamera *getBackupCamera() const;
6565
void setFollowDistance(const int follow_distance) { this->follow_distance_ = follow_distance; }
6666
void setCameraRotationLagEnabled(const bool lag_enabled) { this->camera_rotation_lag_enabled_ = lag_enabled; }
6767

@@ -74,16 +74,16 @@ class AIRSIM_API ACameraDirector : public AActor
7474
private:
7575
typedef common_utils::Utils Utils;
7676

77-
APIPCamera* fpv_camera_;
78-
APIPCamera* backup_camera_;
79-
APIPCamera* front_camera_;
80-
AActor* follow_actor_;
77+
APIPCamera *fpv_camera_;
78+
APIPCamera *backup_camera_;
79+
APIPCamera *front_camera_;
80+
AActor *follow_actor_;
8181

82-
USceneComponent* last_parent_ = nullptr;
82+
USceneComponent *last_parent_ = nullptr;
8383

8484
ECameraDirectorMode mode_;
8585
UPROPERTY()
86-
UManualPoseController* manual_pose_controller_;
86+
UManualPoseController *manual_pose_controller_;
8787

8888
FVector camera_start_location_;
8989
FVector initial_ground_obs_offset_;

Unreal/Plugins/AirSim/Source/DetectionComponent.cpp

+45-24
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,34 @@ UDetectionComponent::UDetectionComponent()
2626
void UDetectionComponent::BeginPlay()
2727
{
2828
Super::BeginPlay();
29-
scene_capture_component_2D_ = CastChecked<USceneCaptureComponent2D>(GetAttachParent());
29+
scene_capture_component_2D_ = Cast<USceneCaptureComponent2D>(GetAttachParent());
30+
if (!scene_capture_component_2D_)
31+
{
32+
// we get re-parented to USceneComponent when saving Take Recorder videos
33+
this->Deactivate();
34+
}
3035
object_filter_ = FObjectFilter();
3136
}
3237

33-
void UDetectionComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
38+
void UDetectionComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
3439
{
3540
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
3641
}
3742

38-
const TArray<FDetectionInfo>& UDetectionComponent::getDetections()
43+
const TArray<FDetectionInfo> &UDetectionComponent::getDetections()
3944
{
4045
cached_detections_.Empty();
4146

42-
for (TActorIterator<AActor> actor_itr(GetWorld()); actor_itr; ++actor_itr) {
43-
AActor* actor = *actor_itr;
44-
if (object_filter_.matchesActor(actor)) {
45-
if (FVector::Distance(actor->GetActorLocation(), GetComponentLocation()) <= max_distance_to_camera_) {
47+
for (TActorIterator<AActor> actor_itr(GetWorld()); actor_itr; ++actor_itr)
48+
{
49+
AActor *actor = *actor_itr;
50+
if (object_filter_.matchesActor(actor))
51+
{
52+
if (FVector::Distance(actor->GetActorLocation(), GetComponentLocation()) <= max_distance_to_camera_)
53+
{
4654
FBox2D box_2D_out;
47-
if (texture_target_ && calcBoundingFromViewInfo(actor, box_2D_out)) {
55+
if (texture_target_ && calcBoundingFromViewInfo(actor, box_2D_out))
56+
{
4857
FDetectionInfo detection;
4958
detection.Actor = actor;
5059
detection.Box2D = box_2D_out;
@@ -63,7 +72,7 @@ const TArray<FDetectionInfo>& UDetectionComponent::getDetections()
6372
return cached_detections_;
6473
}
6574

66-
bool UDetectionComponent::calcBoundingFromViewInfo(AActor* actor, FBox2D& box_out)
75+
bool UDetectionComponent::calcBoundingFromViewInfo(AActor *actor, FBox2D &box_out)
6776
{
6877
FVector origin;
6978
FVector extend;
@@ -74,7 +83,7 @@ bool UDetectionComponent::calcBoundingFromViewInfo(AActor* actor, FBox2D& box_ou
7483
bool is_in_camera_view = false;
7584

7685
// get render target for texture size
77-
FRenderTarget* render_target = texture_target_->GameThread_GetRenderTargetResource();
86+
FRenderTarget *render_target = texture_target_->GameThread_GetRenderTargetResource();
7887

7988
// initialize viewinfo for projection matrix
8089
FMinimalViewInfo info;
@@ -113,16 +122,19 @@ bool UDetectionComponent::calcBoundingFromViewInfo(AActor* actor, FBox2D& box_ou
113122
FPlane(0, 1, 0, 0),
114123
FPlane(0, 0, 0, 1));
115124

116-
if (scene_capture_component_2D_->bUseCustomProjectionMatrix) {
125+
if (scene_capture_component_2D_->bUseCustomProjectionMatrix)
126+
{
117127
projection_data.ProjectionMatrix = scene_capture_component_2D_->CustomProjectionMatrix;
118128
}
119-
else {
129+
else
130+
{
120131
projection_data.ProjectionMatrix = info.CalculateProjectionMatrix();
121132
}
122133
projection_data.SetConstrainedViewRectangle(screen_rect);
123134

124135
// Project Points to pixels and get the corner pixels
125-
for (FVector& point : points) {
136+
for (FVector &point : points)
137+
{
126138
FVector2D Pixel(0, 0);
127139
FSceneView::ProjectWorldToScreen((point), screen_rect, projection_data.ComputeViewProjectionMatrix(), Pixel);
128140
is_in_camera_view |= (Pixel != screen_rect.Min) && (Pixel != screen_rect.Max) && screen_rect.Contains(FIntPoint(Pixel.X, Pixel.Y));
@@ -136,13 +148,17 @@ bool UDetectionComponent::calcBoundingFromViewInfo(AActor* actor, FBox2D& box_ou
136148
// If actor in camera view - check if it's actually visible or hidden
137149
// Check against 8 extend points
138150
bool is_visible = false;
139-
if (is_in_camera_view) {
151+
if (is_in_camera_view)
152+
{
140153
FHitResult result;
141154
bool is_world_hit;
142-
for (FVector& point : points) {
155+
for (FVector &point : points)
156+
{
143157
is_world_hit = GetWorld()->LineTraceSingleByChannel(result, GetComponentLocation(), point, ECC_WorldStatic);
144-
if (is_world_hit) {
145-
if (result.GetActor() == actor) {
158+
if (is_world_hit)
159+
{
160+
if (result.GetActor() == actor)
161+
{
146162
is_visible = true;
147163
break;
148164
}
@@ -151,12 +167,16 @@ bool UDetectionComponent::calcBoundingFromViewInfo(AActor* actor, FBox2D& box_ou
151167

152168
// If actor in camera view but didn't hit any point out of 8 extend points,
153169
// check against 10 random points
154-
if (!is_visible) {
155-
for (int i = 0; i < 10; i++) {
170+
if (!is_visible)
171+
{
172+
for (int i = 0; i < 10; i++)
173+
{
156174
FVector point = UKismetMathLibrary::RandomPointInBoundingBox(origin, extend);
157175
is_world_hit = GetWorld()->LineTraceSingleByChannel(result, GetComponentLocation(), point, ECC_WorldStatic);
158-
if (is_world_hit) {
159-
if (result.GetActor() == actor) {
176+
if (is_world_hit)
177+
{
178+
if (result.GetActor() == actor)
179+
{
160180
is_visible = true;
161181
break;
162182
}
@@ -187,11 +207,12 @@ FRotator UDetectionComponent::getRelativeRotation(FVector in_location, FRotator
187207
return relative_object_transform.Rotator();
188208
}
189209

190-
void UDetectionComponent::addMeshName(const std::string& mesh_name)
210+
void UDetectionComponent::addMeshName(const std::string &mesh_name)
191211
{
192212
FString name(mesh_name.c_str());
193213

194-
if (!object_filter_.wildcard_mesh_names_.Contains(name)) {
214+
if (!object_filter_.wildcard_mesh_names_.Contains(name))
215+
{
195216
object_filter_.wildcard_mesh_names_.Add(name);
196217
}
197218
}
@@ -204,4 +225,4 @@ void UDetectionComponent::setFilterRadius(const float radius_cm)
204225
void UDetectionComponent::clearMeshNames()
205226
{
206227
object_filter_.wildcard_mesh_names_.Empty();
207-
}
228+
}

0 commit comments

Comments
 (0)