Skip to content

Commit

Permalink
Fixes weird FOV, black screen play & some crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Panakotta00 committed Dec 18, 2021
1 parent 56f1735 commit 67cce68
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Source/FicsItCam/FICAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ class AFICAnimation : public AActor, public IFGSaveInterface {
GENERATED_BODY()

public:
UPROPERTY(SaveGame)
FString Name;

UPROPERTY(SaveGame)
FFICFloatAttribute PosX;
UPROPERTY(SaveGame)
Expand Down
4 changes: 1 addition & 3 deletions Source/FicsItCam/FICCameraCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void AFICCameraCharacter::Tick(float DeltaSeconds) {
FString FSP;
// TODO: Get UFGSaveSystem::GetSaveDirectoryPath() working
if (FSP.IsEmpty()) {
FSP = FPaths::Combine(FPlatformProcess::UserSettingsDir(), FApp::GetProjectName(), TEXT("Saved/") TEXT("SaveGames/") TEXT("FicsItCam/"), Animation->GetName());
FSP = FPaths::Combine(FPlatformProcess::UserSettingsDir(), FApp::GetProjectName(), TEXT("Saved/") TEXT("SaveGames/") TEXT("FicsItCam/"), Animation->Name);
}

IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
Expand Down Expand Up @@ -163,13 +163,11 @@ void AFICCameraCharacter::StartAnimation(AFICAnimation* inAnimation, bool bInDoR
if (Animation->bUseCinematic) {
UCineCameraComponent* CineCamera = NewObject<UCineCameraComponent>(this);
CineCamera->FocusSettings.FocusMethod = ECameraFocusMethod::Manual;
CineCamera->bConstrainAspectRatio = true;
CineCamera->Filmback.SensorWidth = Animation->SensorWidth;
CineCamera->Filmback.SensorHeight = Animation->SensorHeight;
Camera = CineCamera;
} else {
Camera = NewObject<UCameraComponent>(this);
Camera->bConstrainAspectRatio = true;
Camera->SetAspectRatio(Animation->ResolutionHeight / Animation->ResolutionWidth);
}
Camera->AttachToComponent(GetCapsuleComponent(), FAttachmentTransformRules::KeepRelativeTransform);
Expand Down
10 changes: 4 additions & 6 deletions Source/FicsItCam/FICCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ EExecutionStatus AFICCommand::ExecuteCommand_Implementation(UCommandSender* Send
FVector Pos = Sender->GetPlayer()->PlayerCameraManager->GetCameraLocation();
FRotator Rot = Sender->GetPlayer()->PlayerCameraManager->GetCameraRotation();
float FOV = Sender->GetPlayer()->PlayerCameraManager->GetFOVAngle();
FActorSpawnParameters Params;
Params.Name = FName(Arguments[1]);
AFICAnimation* Anim = GetWorld()->SpawnActor<AFICAnimation>(Params);
AFICAnimation* Anim = GetWorld()->SpawnActor<AFICAnimation>();
Anim->Name = Arguments[1];
Anim->PosX.SetDefaultValue(Pos.X);
Anim->PosY.SetDefaultValue(Pos.Y);
Anim->PosZ.SetDefaultValue(Pos.Z);
Expand Down Expand Up @@ -139,9 +138,8 @@ EExecutionStatus AFICCommand::ExecuteCommand_Implementation(UCommandSender* Send
if (!FDefaultValueHelper::ParseFloat(Arguments[3], Frequency)) return EExecutionStatus::BAD_ARGUMENTS;
FVector Pos = Sender->GetPlayer()->PlayerCameraManager->GetCameraLocation();
FRotator Rot = Sender->GetPlayer()->PlayerCameraManager->GetCameraRotation();
FActorSpawnParameters Params;
Params.Name = FName(CameraName);
AFICTimelapseCamera* Camera = GetWorld()->SpawnActor<AFICTimelapseCamera>(Pos, Rot, Params);
AFICTimelapseCamera* Camera = GetWorld()->SpawnActor<AFICTimelapseCamera>(Pos, Rot);
Camera->Name = Arguments[3];
Camera->Frequency = Frequency;
SubSys->TimelapseCameras.Add(CameraName, Camera);
Sender->SendChatMessage("Timelapse-Camera '" + CameraName + "' created.");
Expand Down
8 changes: 8 additions & 0 deletions Source/FicsItCam/FICSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ AFICSubsystem::AFICSubsystem() {

void AFICSubsystem::BeginPlay() {
Super::BeginPlay();

for (TTuple<FString, AFICAnimation*> Anim : StoredAnimations) {
Anim.Value->Name = Anim.Key;
}

for (TTuple<FString, AFICTimelapseCamera*> Cam : TimelapseCameras) {
Cam.Value->Name = Cam.Key;
}
}

void AFICSubsystem::Tick(float DeltaSeconds) {
Expand Down
2 changes: 1 addition & 1 deletion Source/FicsItCam/FICTimelapseCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void AFICTimelapseCamera::CaptureTick() {
FSP = FPaths::Combine(FPlatformProcess::UserSettingsDir(), FApp::GetProjectName(), TEXT("Saved/") TEXT("SaveGames/"));
}

FSP = FPaths::Combine(FSP, TEXT("FicsItCam/"), GetName());
FSP = FPaths::Combine(FSP, TEXT("FicsItCam/"), Name);

IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
if (!PlatformFile.DirectoryExists(*FSP)) PlatformFile.CreateDirectoryTree(*FSP);
Expand Down
3 changes: 3 additions & 0 deletions Source/FicsItCam/FICTimelapseCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ UCLASS()
class FICSITCAM_API AFICTimelapseCamera : public AActor, public IFGSaveInterface {
GENERATED_BODY()
public:
UPROPERTY(SaveGame)
FString Name;

UPROPERTY()
UTextureRenderTarget2D* RenderTarget;

Expand Down
3 changes: 2 additions & 1 deletion Source/FicsItCam/UI/FICEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ void SFICEditor::Tick(const FGeometry& AllottedGeometry, const double InCurrentT
FVector2D GameSize = FVector2D(Context->GetAnimation()->ResolutionWidth, Context->GetAnimation()->ResolutionHeight);
FVector2D Size = Context->GetWorld()->GetGameViewport()->GetGameViewport()->GetSizeXY();
Size *= Scalability::GetResolutionScreenPercentage() / 100.0;
Size *= IConsoleManager::Get().FindConsoleVariable(TEXT("r.SecondaryScreenPercentage.GameViewport"), false)->GetFloat() / 100.0;
float SecondaryPercentage = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SecondaryScreenPercentage.GameViewport"))->GetFloat();
if (SecondaryPercentage) Size *= SecondaryPercentage / 100.0;
Context->SensorWidthAdjust = GameSize.X / Size.X;
}

Expand Down

0 comments on commit 67cce68

Please sign in to comment.