Skip to content

Commit

Permalink
added Honour Pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto De Ioris committed Aug 25, 2018
1 parent 285e6f0 commit d906da9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
42 changes: 27 additions & 15 deletions Source/AnselCapture/Private/Ansel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ class FNVAnselCaptureCameraPhotographyPrivate : public ICameraPhotography
FConsoleVariableSinkHandle CVarDelegateHandle;
};

static void* AnselSDKDLLHandle = 0;
static bool bAnselDLLLoaded = false;
static bool bAnselHonourRoll = false;
namespace AnselCapture
{
void* AnselSDKDLLHandle = 0;
bool bAnselDLLLoaded = false;
bool bAnselHonourRoll = false;
bool bAnselHonourPitch = false;
}

FNVAnselCaptureCameraPhotographyPrivate::FNVAnselCaptureCameraPhotographyPrivate()
: ICameraPhotography()
Expand All @@ -101,7 +105,7 @@ FNVAnselCaptureCameraPhotographyPrivate::FNVAnselCaptureCameraPhotographyPrivate
{


if (bAnselDLLLoaded)
if (AnselCapture::bAnselDLLLoaded)
{
AnselConfig = new ansel::Configuration();

Expand Down Expand Up @@ -136,7 +140,7 @@ FNVAnselCaptureCameraPhotographyPrivate::FNVAnselCaptureCameraPhotographyPrivate

FNVAnselCaptureCameraPhotographyPrivate::~FNVAnselCaptureCameraPhotographyPrivate()
{
if (bAnselDLLLoaded)
if (AnselCapture::bAnselDLLLoaded)
{
IConsoleManager::Get().UnregisterConsoleVariableSink_Handle(CVarDelegateHandle);
DeconfigureAnsel();
Expand All @@ -146,7 +150,7 @@ FNVAnselCaptureCameraPhotographyPrivate::~FNVAnselCaptureCameraPhotographyPrivat

bool FNVAnselCaptureCameraPhotographyPrivate::IsSupported()
{
return bAnselDLLLoaded && ansel::isAnselAvailable();
return AnselCapture::bAnselDLLLoaded && ansel::isAnselAvailable();
}

void FNVAnselCaptureCameraPhotographyPrivate::AnselCameraToFMinimalView(FMinimalViewInfo& InOutPOV, ansel::Camera& AnselCam)
Expand Down Expand Up @@ -202,13 +206,21 @@ bool FNVAnselCaptureCameraPhotographyPrivate::UpdateCamera(FMinimalViewInfo& InO

// if honour roll is true, apply an additional rotation
// obviously ensure the roll rotation is the first one
if (bAnselHonourRoll)
if (AnselCapture::bAnselHonourRoll)
{
FQuat qrot = FQuat::MakeFromEuler(FVector(OriginalView.Rotation.GetComponentForAxis(EAxis::X), 0, 0)) * InOutPOV.Rotation.Quaternion();

InOutPOV.Rotation = qrot.Rotator();
}

// same for pitch
if (AnselCapture::bAnselHonourPitch)
{
FQuat qrot = FQuat::MakeFromEuler(FVector(0, OriginalView.Rotation.GetComponentForAxis(EAxis::Y), 0)) * InOutPOV.Rotation.Quaternion();

InOutPOV.Rotation = qrot.Rotator();
}

// eliminate letterboxing during capture
InOutPOV.bConstrainAspectRatio = false;
}
Expand Down Expand Up @@ -488,7 +500,7 @@ class FAnselCaptureModule : public IAnselCaptureModule
virtual void StartupModule() override
{
ICameraPhotographyModule::StartupModule();
check(!bAnselDLLLoaded);
check(!AnselCapture::bAnselDLLLoaded);

// Late-load Ansel DLL. DLL name has been worked out by the build scripts as ANSEL_DLL
FString AnselDLLName;
Expand All @@ -497,19 +509,19 @@ class FAnselCaptureModule : public IAnselCaptureModule
#define STRINGIFY(X) STRINGIFY2(X)
#define STRINGIFY2(X) #X
AnselDLLName = AnselBinariesRoot + TEXT(STRINGIFY(ANSEL_DLL));
AnselSDKDLLHandle = FPlatformProcess::GetDllHandle(*(AnselDLLName));
AnselCapture::AnselSDKDLLHandle = FPlatformProcess::GetDllHandle(*(AnselDLLName));

bAnselDLLLoaded = AnselSDKDLLHandle != 0;
UE_LOG(LogAnselCapture, Log, TEXT("Tried to load %s : success=%d"), *AnselDLLName, int(bAnselDLLLoaded));
AnselCapture::bAnselDLLLoaded = AnselCapture::AnselSDKDLLHandle != 0;
UE_LOG(LogAnselCapture, Log, TEXT("Tried to load %s : success=%d"), *AnselDLLName, int(AnselCapture::bAnselDLLLoaded));
}

virtual void ShutdownModule() override
{
if (bAnselDLLLoaded)
if (AnselCapture::bAnselDLLLoaded)
{
FPlatformProcess::FreeDllHandle(AnselSDKDLLHandle);
AnselSDKDLLHandle = 0;
bAnselDLLLoaded = false;
FPlatformProcess::FreeDllHandle(AnselCapture::AnselSDKDLLHandle);
AnselCapture::AnselSDKDLLHandle = 0;
AnselCapture::bAnselDLLLoaded = false;
}
ICameraPhotographyModule::ShutdownModule();
}
Expand Down
11 changes: 8 additions & 3 deletions Source/AnselCapture/Private/AnselCaptureFunctionLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
#include "AnselCaptureFunctionLibrary.h"
#include "Camera/CameraPhotography.h"

extern bool bAnselHonourRoll;
namespace AnselCapture
{
extern bool bAnselHonourRoll;
extern bool bAnselHonourPitch;
}

void UAnselCaptureFunctionLibrary::StartAnselCapture(UObject* WorldContextObject, bool bHonourRoll)
void UAnselCaptureFunctionLibrary::StartAnselCapture(UObject* WorldContextObject, bool bHonourRoll, bool bHonourPitch)
{
bAnselHonourRoll = bHonourRoll;
AnselCapture::bAnselHonourRoll = bHonourRoll;
AnselCapture::bAnselHonourPitch = bHonourPitch;
FCameraPhotographyManager::Get().StartSession();
}

Expand Down
2 changes: 1 addition & 1 deletion Source/AnselCapture/Public/AnselCaptureFunctionLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ANSELCAPTURE_API UAnselCaptureFunctionLibrary : public UBlueprintFunctionL
GENERATED_BODY()

UFUNCTION(BlueprintCallable, Category = "Photography", meta = (WorldContext = WorldContextObject))
static void StartAnselCapture(UObject* WorldContextObject, bool bHonourRoll);
static void StartAnselCapture(UObject* WorldContextObject, bool bHonourRoll, bool bHonourPitch);

UFUNCTION(BlueprintCallable, Category = "Photography", meta = (WorldContext = WorldContextObject))
static void StopAnselCapture(UObject* WorldContextObject);
Expand Down

0 comments on commit d906da9

Please sign in to comment.