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

Feat/add unreal engine 5.3 #370

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UE4Project/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Rider IDE
.idea/

# don't check-in generated files
*.sln
*_BuiltData.uasset
Expand Down
7 changes: 7 additions & 0 deletions UE4Project/.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.vscode
/Saved
/Intermediate
/.idea
/Content
/Plugins/AirSim/Intermediate
/Plugins/AirSim/Content
2 changes: 1 addition & 1 deletion UE4Project/FSOnline.uproject
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"FileVersion": 3,
"EngineAssociation": "4.27",
"EngineAssociation": "{39102460-AC08-4665-97C6-39E7243134BA}",
"Category": "",
"Description": "",
"Modules": [
Expand Down
2 changes: 1 addition & 1 deletion UE4Project/Plugins/AirSim/AirSim.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
],
"Plugins": [
{
"Name": "PhysXVehicles",
"Name": "ChaosVehiclesPlugin",
"Enabled": true
}
]
Expand Down
17 changes: 8 additions & 9 deletions UE4Project/Plugins/AirSim/Source/AirBlueprintLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@

#include "AirBlueprintLib.h"
#include "GameFramework/WorldSettings.h"
#include "Components/SceneCaptureComponent2D.h"
#include "Components/SkinnedMeshComponent.h"
#include "GameFramework/RotatingMovementComponent.h"
#include "Components/StaticMeshComponent.h"
#include "EngineUtils.h"
#include "Runtime/Engine/Classes/Engine/StaticMesh.h"
#include "UObject/UObjectIterator.h"
#include "Camera/CameraComponent.h"
//#include "Runtime/Foliage/Public/FoliageType.h"
#include "Misc/MessageDialog.h"
#include "Engine/LocalPlayer.h"
#include "Engine/SkeletalMesh.h"
#include "Slate/SceneViewport.h"
#include "IImageWrapper.h"
#include "Misc/ObjectThumbnail.h"
#include "Engine/Engine.h"
#include <exception>

#include "IImageWrapperModule.h"
#include "common/common_utils/Utils.hpp"

/*
Expand Down Expand Up @@ -398,9 +397,9 @@ std::vector<msr::airlib::MeshPositionVertexBuffersResponse> UAirBlueprintLib::Ge
ENQUEUE_RENDER_COMMAND(GetVertexBuffer)(
[vertex_buffer, data](FRHICommandListImmediate& RHICmdList)
{
FVector* indices = (FVector*)RHILockVertexBuffer(vertex_buffer->VertexBufferRHI, 0, vertex_buffer->VertexBufferRHI->GetSize(), RLM_ReadOnly);
FVector* indices = (FVector*)RHILockBuffer(vertex_buffer->VertexBufferRHI, 0, vertex_buffer->VertexBufferRHI->GetSize(), RLM_ReadOnly);
memcpy(data, indices, vertex_buffer->VertexBufferRHI->GetSize());
RHIUnlockVertexBuffer(vertex_buffer->VertexBufferRHI);
RHIUnlockBuffer(vertex_buffer->VertexBufferRHI);
});

FStaticMeshLODResources& lod = comp->GetStaticMesh()->GetRenderData()->LODResources[0];
Expand All @@ -416,9 +415,9 @@ std::vector<msr::airlib::MeshPositionVertexBuffersResponse> UAirBlueprintLib::Ge
ENQUEUE_RENDER_COMMAND(GetIndexBuffer)(
[IndexBuffer, data_ptr](FRHICommandListImmediate& RHICmdList)
{
uint16_t* indices = (uint16_t*)RHILockIndexBuffer(IndexBuffer->IndexBufferRHI, 0, IndexBuffer->IndexBufferRHI->GetSize(), RLM_ReadOnly);
uint16_t* indices = (uint16_t*)RHILockBuffer(IndexBuffer->IndexBufferRHI, 0, IndexBuffer->IndexBufferRHI->GetSize(), RLM_ReadOnly);
memcpy(data_ptr, indices, IndexBuffer->IndexBufferRHI->GetSize());
RHIUnlockIndexBuffer(IndexBuffer->IndexBufferRHI);
RHIUnlockBuffer(IndexBuffer->IndexBufferRHI);
});

//Need to force the render command to go through cause on the next iteration the buffer no longer exists
Expand All @@ -439,9 +438,9 @@ std::vector<msr::airlib::MeshPositionVertexBuffersResponse> UAirBlueprintLib::Ge
ENQUEUE_RENDER_COMMAND(GetIndexBuffer)(
[IndexBuffer, data_ptr](FRHICommandListImmediate& RHICmdList)
{
uint32_t* indices = (uint32_t*)RHILockIndexBuffer(IndexBuffer->IndexBufferRHI, 0, IndexBuffer->IndexBufferRHI->GetSize(), RLM_ReadOnly);
uint32_t* indices = (uint32_t*)RHILockBuffer(IndexBuffer->IndexBufferRHI, 0, IndexBuffer->IndexBufferRHI->GetSize(), RLM_ReadOnly);
memcpy(data_ptr, indices, IndexBuffer->IndexBufferRHI->GetSize());
RHIUnlockIndexBuffer(IndexBuffer->IndexBufferRHI);
RHIUnlockBuffer(IndexBuffer->IndexBufferRHI);
});

FlushRenderingCommands();
Expand Down
8 changes: 3 additions & 5 deletions UE4Project/Plugins/AirSim/Source/AirBlueprintLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include "Misc/MessageDialog.h"
#include "Components/InputComponent.h"
#include "GameFramework/PlayerInput.h"
#include "IImageWrapperModule.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Kismet/KismetMathLibrary.h"
#include "Components/MeshComponent.h"
#include "LandscapeProxy.h"
#include "Kismet/GameplayStatics.h"
Expand Down Expand Up @@ -123,7 +121,7 @@ class UAirBlueprintLib : public UBlueprintFunctionLibrary

template<class UserClass>
static FInputActionBinding& BindActionToKey(const FName action_name, const FKey in_key, UserClass* actor,
typename FInputActionHandlerSignature::TUObjectMethodDelegate< UserClass >::FMethodPtr func, bool on_press_or_release = false,
FInputActionHandlerSignature::TMethodPtr<UserClass> func, bool on_press_or_release = false,
bool shift_key = false, bool control_key = false, bool alt_key = false, bool command_key = false)
{
FInputActionKeyMapping action(action_name, in_key, shift_key, control_key, alt_key, command_key);
Expand All @@ -137,7 +135,7 @@ class UAirBlueprintLib : public UBlueprintFunctionLibrary

template<class UserClass>
static FInputAxisBinding& BindAxisToKey(const FName axis_name, const FKey in_key, AActor* actor, UserClass* obj,
typename FInputAxisHandlerSignature::TUObjectMethodDelegate<UserClass>::FMethodPtr func)
FInputAxisHandlerSignature::TMethodPtr<UserClass> func)
{
FInputAxisKeyMapping axis(axis_name, in_key);

Expand All @@ -146,7 +144,7 @@ class UAirBlueprintLib : public UBlueprintFunctionLibrary

template<class UserClass>
static FInputAxisBinding& BindAxisToKey(const FInputAxisKeyMapping& axis, AActor* actor, UserClass* obj,
typename FInputAxisHandlerSignature::TUObjectMethodDelegate<UserClass>::FMethodPtr func)
typename FInputAxisHandlerSignature::TMethodPtr<UserClass> func)
{
APlayerController* controller = actor->GetWorld()->GetFirstPlayerController();

Expand Down
15 changes: 13 additions & 2 deletions UE4Project/Plugins/AirSim/Source/AirSim.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,19 @@ public AirSim(ReadOnlyTargetRules Target) : base(Target)

bEnableExceptions = true;

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "HTTP", "InputCore", "ImageWrapper", "RenderCore", "RHI", "PhysXVehicles", "PhysicsCore", "PhysXVehicleLib", "PhysX", "APEX", "Landscape" });
PrivateDependencyModuleNames.AddRange(new string[] { "UMG", "Slate", "SlateCore" });
PublicDependencyModuleNames.AddRange(new string[] {
"Core",
"CoreUObject",
"Engine",
"HTTP",
"InputCore",
"ImageWrapper",
"RenderCore",
"RHI",
"ChaosVehicles",
"Landscape"
});
PrivateDependencyModuleNames.AddRange(new string[] { "UMG", "Slate", "SlateCore", "RenderCore" });

//suppress VC++ proprietary warnings
PublicDefinitions.Add("_SCL_SECURE_NO_WARNINGS=1");
Expand Down
50 changes: 25 additions & 25 deletions UE4Project/Plugins/AirSim/Source/AirSim.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "AirSim.h"
#include "Misc/Paths.h"
#include "Modules/ModuleManager.h"
#include "Modules/ModuleInterface.h"
class FAirSim : public IModuleInterface
{
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};
IMPLEMENT_MODULE(FAirSim, AirSim)
void FAirSim::StartupModule()
{
//plugin startup
UE_LOG(LogTemp, Log, TEXT("StartupModule: AirSim plugin"));
}
void FAirSim::ShutdownModule()
{
//plugin shutdown
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include "AirSim.h"
#include "Misc/Paths.h"
#include "Modules/ModuleManager.h"
#include "Modules/ModuleInterface.h"

class FAirSim : public IModuleInterface
{
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};

IMPLEMENT_MODULE(FAirSim, AirSim)

void FAirSim::StartupModule()
{
//plugin startup
UE_LOG(LogTemp, Log, TEXT("StartupModule: AirSim plugin"));
}

void FAirSim::ShutdownModule()
{
//plugin shutdown
}
158 changes: 79 additions & 79 deletions UE4Project/Plugins/AirSim/Source/Referee.cpp
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
// This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public License as published by the Free Software Foundation
#include "Referee.h"
// Sets default values
AReferee::AReferee()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AReferee::BeginPlay()
{
Super::BeginPlay();
}
msr::airlib::CarApiBase::RefereeState AReferee::getState() {
return this->state;
}
// Called every frame
void AReferee::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
int32 AReferee::ConeHit(FString coneName)
{
return (int32) (++state.doo_counter);
}
int32 AReferee::LapCompleted(float lapTime)
{
state.laps.push_back(lapTime);
return state.laps.size();
}
void AReferee::AppendYellowCone(FTransform transform) {
msr::airlib::CarApiBase::Cone cone;
cone.location.x = transform.GetTranslation().X;
cone.location.y = transform.GetTranslation().Y;
cone.color = msr::airlib::CarApiBase::ConeColor::Yellow;
state.cones.push_back(cone);
}
void AReferee::AppendBlueCone(FTransform transform) {
msr::airlib::CarApiBase::Cone cone;
cone.location.x = transform.GetTranslation().X;
cone.location.y = transform.GetTranslation().Y;
cone.color = msr::airlib::CarApiBase::ConeColor::Blue;
state.cones.push_back(cone);
}
void AReferee::AppendBigOrangeCone(FTransform transform){
msr::airlib::CarApiBase::Cone cone;
cone.location.x = transform.GetTranslation().X;
cone.location.y = transform.GetTranslation().Y;
cone.color = msr::airlib::CarApiBase::ConeColor::OrangeLarge;
state.cones.push_back(cone);
}
void AReferee::AppendSmallOrangeCone(FTransform transform){
msr::airlib::CarApiBase::Cone cone;
cone.location.x = transform.GetTranslation().X;
cone.location.y = transform.GetTranslation().Y;
cone.color = msr::airlib::CarApiBase::ConeColor::OrangeSmall;
state.cones.push_back(cone);
}
void AReferee::LoadStartPos(FVector pos) {
msr::airlib::CarApiBase::Point2D point;
point.x = pos.X;
point.y = pos.Y;
state.car_start_location = point;
// This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public License as published by the Free Software Foundation

#include "Referee.h"


// Sets default values
AReferee::AReferee()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AReferee::BeginPlay()
{
Super::BeginPlay();

}

msr::airlib::CarApiBase::RefereeState AReferee::getState() {
return this->state;
}

// Called every frame
void AReferee::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

}

int32 AReferee::ConeHit(FString coneName)
{
return (int32) (++state.doo_counter);
}

int32 AReferee::LapCompleted(float lapTime)
{
state.laps.push_back(lapTime);
return state.laps.size();
}

void AReferee::AppendYellowCone(FTransform transform) {
msr::airlib::CarApiBase::Cone cone;
cone.location.x = transform.GetTranslation().X;
cone.location.y = transform.GetTranslation().Y;
cone.color = msr::airlib::CarApiBase::ConeColor::Yellow;
state.cones.push_back(cone);
}

void AReferee::AppendBlueCone(FTransform transform) {
msr::airlib::CarApiBase::Cone cone;
cone.location.x = transform.GetTranslation().X;
cone.location.y = transform.GetTranslation().Y;
cone.color = msr::airlib::CarApiBase::ConeColor::Blue;
state.cones.push_back(cone);
}

void AReferee::AppendBigOrangeCone(FTransform transform){
msr::airlib::CarApiBase::Cone cone;
cone.location.x = transform.GetTranslation().X;
cone.location.y = transform.GetTranslation().Y;
cone.color = msr::airlib::CarApiBase::ConeColor::OrangeLarge;
state.cones.push_back(cone);
}

void AReferee::AppendSmallOrangeCone(FTransform transform){
msr::airlib::CarApiBase::Cone cone;
cone.location.x = transform.GetTranslation().X;
cone.location.y = transform.GetTranslation().Y;
cone.color = msr::airlib::CarApiBase::ConeColor::OrangeSmall;
state.cones.push_back(cone);
}

void AReferee::LoadStartPos(FVector pos) {
msr::airlib::CarApiBase::Point2D point;
point.x = pos.X;
point.y = pos.Y;
state.car_start_location = point;
}
Loading