Add EditorCameraUtils (#6469)

* Add EditorCamera utility class.

* Rename and reparent UEditorCameraUtils to AEditorCameraUtils (AActor).

* Add copyright and fix indentation.

* Fix copyright.
This commit is contained in:
Marcel Pi 2023-05-12 16:35:39 +02:00 committed by GitHub
parent 14f6ea1f79
commit 78476f6b37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma
// de Barcelona (UAB).
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#include "EditorCamera.h"
#include "UnrealClient.h"
#include "Editor/EditorEngine.h"
#include "EditorViewportClient.h"
void AEditorCameraUtils::Get()
{
auto ViewportClient = dynamic_cast<FEditorViewportClient*>(GEditor->GetActiveViewport()->GetClient());
CameraTransform = FTransform();
CameraTransform.SetLocation(ViewportClient->GetViewLocation());
CameraTransform.SetRotation(FQuat(ViewportClient->GetViewRotation()));
}
void AEditorCameraUtils::Set()
{
auto ViewportClient = dynamic_cast<FEditorViewportClient*>(GEditor->GetActiveViewport()->GetClient());
ViewportClient->SetViewLocation(CameraTransform.GetLocation());
ViewportClient->SetViewRotation(FRotator(CameraTransform.GetRotation()));
}

View File

@ -0,0 +1,32 @@
// Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma
// de Barcelona (UAB).
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#pragma once
#include "CoreMinimal.h"
#include "EditorCamera.generated.h"
UCLASS(BlueprintType)
class CARLATOOLS_API AEditorCameraUtils :
public AActor
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, CallInEditor)
void Get();
UFUNCTION(BlueprintCallable, CallInEditor)
void Set();
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FTransform CameraTransform;
};