Projekt for SPIE - Avatar for safety briefing / managment event
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

141 lines
4.7 KiB

// Copyright Voulz 2021-2025. All Rights Reserved.
#include "ArchVisCineCameraComponent.h"
#include "DrawDebugHelpers.h"
#include "UnrealClient.h"
#include "Engine/Engine.h"
#include "Engine/GameViewportClient.h"
#include "Misc/ConfigCacheIni.h"
#if WITH_EDITOR
#include "LevelEditorViewport.h"
#include "Math/Vector.h"
#include "Misc/AssertionMacros.h"
#endif
#define CURRENT_LOG_CATEGORY LogArchVisTools
/** Set to true to print debug logs in the console */
#define U_ARCH_VIS_CINE_CAMERA_COMPONENT_DEBUG 0
#undef HERE_D
#if U_ARCH_VIS_CINE_CAMERA_COMPONENT_DEBUG
/** Prints the current function name in the Output if U_ARCH_VIS_CINE_CAMERA_COMPONENT_DEBUG is set */
#define HERE_D LOGV(" ==== [%s] ==== [ %s ]", __FUNCTIONW__, GetOwner() ? *GetOwner()->GetName() : *FString(""));
#define LOG_D(Format, ...) LOG(Format,__VA_ARGS__);
#define WARN_D(Format, ...) WARN(Format,__VA_ARGS__);
#else
/** Prints the current function name in the Output if U_ARCH_VIS_CINE_CAMERA_COMPONENT_DEBUG is set */
#define HERE_D {}
#define LOG_D(Format, ...) {}
#define WARN_D(Format, ...) {}
#endif
void UArchVisCineCameraComponent::InitFromCameraComponent(const UCameraComponent* CameraComponent, const bool bCopyTransform)
{
if (!IsValid(CameraComponent))
{
return;
}
// -- UActorComponent
ComponentTags = TArray<FName>(CameraComponent->ComponentTags);
// -- USceneComponent
if (bCopyTransform)
{
SetWorldLocationAndRotationNoPhysics(CameraComponent->GetComponentLocation(), CameraComponent->GetComponentRotation());
SetWorldScale3D(CameraComponent->GetComponentScale());
}
// -- UCameraComponent
FieldOfView = CameraComponent->FieldOfView;
OrthoWidth = CameraComponent->OrthoWidth;
OrthoNearClipPlane = CameraComponent->OrthoNearClipPlane;
OrthoFarClipPlane = CameraComponent->OrthoFarClipPlane;
AspectRatio = CameraComponent->AspectRatio;
bConstrainAspectRatio = CameraComponent->bConstrainAspectRatio;
bUseFieldOfViewForLOD = CameraComponent->bUseFieldOfViewForLOD;
#if WITH_EDITORONLY_DATA
bCameraMeshHiddenInGame = CameraComponent->bCameraMeshHiddenInGame;
#endif
bLockToHmd = CameraComponent->bLockToHmd;
bUsePawnControlRotation = CameraComponent->bUsePawnControlRotation;
ProjectionMode = CameraComponent->ProjectionMode;
PostProcessBlendWeight = CameraComponent->PostProcessBlendWeight;
ClearAdditiveOffset();
FTransform OutAdditiveOffset;
float OutAdditiveFOVOffset;
CameraComponent->GetAdditiveOffset(OutAdditiveOffset, OutAdditiveFOVOffset);
AddAdditiveOffset(OutAdditiveOffset, OutAdditiveFOVOffset);
ClearExtraPostProcessBlends();
TArray<FPostProcessSettings> OutSettings;
TArray<float> OutWeights;
CameraComponent->GetExtraPostProcessBlends(OutSettings, OutWeights);
for (int i = 0; i < FMath::Min(OutSettings.Num(), OutWeights.Num()); ++i)
{
AddExtraPostProcessBlend(OutSettings[i], OutWeights[i]);
}
PostProcessSettings = CameraComponent->PostProcessSettings;
// -- UCineCameraComponent
if (const UCineCameraComponent* CineCameraComponent = Cast<UCineCameraComponent>(CameraComponent))
{
Filmback = CineCameraComponent->Filmback;
LensSettings = CineCameraComponent->LensSettings;
FocusSettings = CineCameraComponent->FocusSettings;
SetCurrentFocalLength(CineCameraComponent->CurrentFocalLength);
CurrentAperture = CineCameraComponent->CurrentAperture;
CurrentFocusDistance = CineCameraComponent->CurrentFocusDistance;
CustomNearClippingPlane = CineCameraComponent->CustomNearClippingPlane;
}
// -- UArchVisCineCameraComponent
if (const UArchVisCineCameraComponent* ArchVisCineCameraComponent = Cast<UArchVisCineCameraComponent>(CameraComponent))
{
ProjectionOffset = ArchVisCineCameraComponent->ProjectionOffset;
bCorrectPerspective = ArchVisCineCameraComponent->bCorrectPerspective;
CorrectionStrength = ArchVisCineCameraComponent->CorrectionStrength;
MaxPitch = ArchVisCineCameraComponent->MaxPitch;
bAllowRoll = ArchVisCineCameraComponent->bAllowRoll;
PRAGMA_DISABLE_DEPRECATION_WARNINGS
bAutomaticNearClipPlaneHandling = false; // deactivate the automatic near clipping plane handling first
PRAGMA_ENABLE_DEPRECATION_WARNINGS
}
}
void UArchVisCineCameraComponent::GetCameraView(float DeltaTime, FMinimalViewInfo& DesiredView)
{
Super::GetCameraView(DeltaTime, DesiredView);
if (!bAllowRoll)
{
DesiredView.Rotation.Roll = 0;
}
DesiredView.OffCenterProjectionOffset += ProjectionOffset;
}
#if WITH_EDITOR
void UArchVisCineCameraComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
HERE_D
const FName PropertyChangedName = PropertyChangedEvent.GetPropertyName();
LOG_D("PostEditChangeProperty: [ %s ]", *PropertyChangedName.ToString());
Super::PostEditChangeProperty(PropertyChangedEvent);
}
#endif
#undef CURRENT_LOG_CATEGORY
#undef U_ARCH_VIS_CINE_CAMERA_COMPONENT_DEBUG