Skip to content
Merged
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
5 changes: 2 additions & 3 deletions OSVRUnreal/Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ r.DefaultFeature.AutoExposure=True
r.DefaultFeature.AutoExposure.Method=0
r.DefaultFeature.MotionBlur=True
r.DefaultFeature.LensFlare=False
r.DefaultFeature.AntiAliasing=2
r.DefaultFeature.AntiAliasing=0
r.EarlyZPass=3
r.EarlyZPassMovable=False
r.DBuffer=False
Expand All @@ -60,6 +60,7 @@ vr.InstancedStereo=True
r.WireframeCullThreshold=5.000000
UIScaleRule=ShortestSide
UIScaleCurve=(EditorCurveData=(PreInfinityExtrap=RCCE_Constant,PostInfinityExtrap=RCCE_Constant,Keys=,DefaultValue=340282346638528859811704183484516925440.000000),ExternalCurve=None)
r.ForwardShading=True

[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/Maps/basic.basic
Expand All @@ -86,5 +87,3 @@ AppliedDefaultGraphicsPerformance=Maximum
+TargetedRHIs=GLSL_150
MinimumOSVersion=MSOS_Vista
AudioDevice=


Binary file modified OSVRUnreal/Content/Maps/basic.umap
Binary file not shown.
Binary file added OSVRUnreal/Content/Maps/basic_BuiltData.uasset
Binary file not shown.
2 changes: 1 addition & 1 deletion OSVRUnreal/OSVRUnreal.uproject
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"FileVersion": 3,
"EngineAssociation": "4.13",
"EngineAssociation": "4.14",
"Category": "",
"Description": "",
"Modules": [
Expand Down
14 changes: 14 additions & 0 deletions OSVRUnreal/Plugins/OSVR/Source/OSVR/Private/OSVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ class FOSVR : public IOSVR
virtual void ShutdownModule() override;

/** IHeadMountedDisplayModule implementation */
#if OSVR_UNREAL_4_14
/** Returns the key into the HMDPluginPriority section of the config file for this module */
FString GetModuleKeyName() const override
{
return FString(TEXT("OSVR"));
}
#else
/** Returns the key into the HMDPluginPriority section of the config file for this module */
virtual FString GetModulePriorityKeyName() const override
{
return FString(TEXT("OSVR"));
}
#endif

virtual TSharedPtr<class IHeadMountedDisplay, ESPMode::ThreadSafe> CreateHeadMountedDisplay() override;
#if OSVR_UNREAL_4_12
virtual bool IsHMDConnected() override;
Expand Down
30 changes: 18 additions & 12 deletions OSVRUnreal/Plugins/OSVR/Source/OSVR/Private/OSVRHMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ void FOSVRHMD::UpdateHeadPose(bool renderThread, FQuat& lastHmdOrientation, FVec
lastHmdPosition = _lastHmdPosition;
hmdOrientation = _curHmdOrientation;
hmdPosition = _curHmdPosition;

mLastUpdateFrameNumber = GFrameNumber;
}

bool FOSVRHMD::DoesSupportPositionalTracking() const
Expand Down Expand Up @@ -298,6 +296,10 @@ bool FOSVRHMD::OnStartGameFrame(FWorldContext& WorldContext)
sFinishCurrentFrame->Set(0);
bHmdOverridesApplied = true;
}
if (bStereoEnabled != bNewStereoEnabled)
{
bStereoEnabled = EnableStereo(bNewStereoEnabled);
}
return true;
}

Expand Down Expand Up @@ -336,7 +338,10 @@ void FOSVRHMD::RebaseObjectOrientationAndPosition(FVector& Position, FQuat& Orie

void FOSVRHMD::ApplyHmdRotation(APlayerController* PC, FRotator& ViewRotation)
{
CheckUpdateFrameNumber();
FQuat lastHmdOrientation, curHmdOrientation;
FVector lastHmdPosition, curHmdPosition;
UpdateHeadPose(false, lastHmdOrientation, lastHmdPosition, curHmdOrientation, curHmdPosition);

ViewRotation.Normalize();

const FRotator DeltaRot = ViewRotation - PC->GetControlRotation();
Expand All @@ -349,15 +354,15 @@ void FOSVRHMD::ApplyHmdRotation(APlayerController* PC, FRotator& ViewRotation)
DeltaControlRotation.Roll = 0;
DeltaControlOrientation = DeltaControlRotation.Quaternion();

ViewRotation = FRotator(DeltaControlOrientation * CurHmdOrientation);
ViewRotation = FRotator(DeltaControlOrientation * curHmdOrientation);
}

#if OSVR_UNREAL_4_11
bool FOSVRHMD::UpdatePlayerCamera(FQuat& CurrentOrientation, FVector& CurrentPosition)
{
CheckUpdateFrameNumber();
CurrentOrientation = CurHmdOrientation;
CurrentPosition = CurHmdPosition;
FQuat lastHmdOrientation;
FVector lastHmdPosition;
UpdateHeadPose(false, lastHmdOrientation, lastHmdPosition, CurrentOrientation, CurrentPosition);
return true;
}
#else
Expand Down Expand Up @@ -479,12 +484,12 @@ bool FOSVRHMD::IsStereoEnabled() const

bool FOSVRHMD::EnableStereo(bool bStereo)
{
bool bNewSteroEnabled = IsHMDConnected() ? bStereo : false;
if (bNewSteroEnabled == bStereoEnabled)
bNewStereoEnabled = IsHMDConnected() ? bStereo : false;
if (bNewStereoEnabled == bStereoEnabled)
{
return bStereoEnabled;
}
bStereoEnabled = bNewSteroEnabled;
bStereoEnabled = bNewStereoEnabled;

if (bStereoEnabled)
{
Expand Down Expand Up @@ -540,12 +545,13 @@ bool FOSVRHMD::EnableStereo(bool bStereo)

if (!sceneViewport)
{
UE_LOG(OSVRHMDLog, Warning, TEXT("OSVR scene viewport does not exist"));
//UE_LOG(OSVRHMDLog, Warning, TEXT("FOSVRHMD::EnableStereo() - OSVR scene viewport does not exist. Will try again later."));
bStereoEnabled = false;
return false;
}
else
{
//UE_LOG(OSVRHMDLog, Warning, TEXT("OSVR scene viewport exists"));
//UE_LOG(OSVRHMDLog, Warning, TEXT("FOSVRHMD::EnableStereo() - OSVR scene viewport exists. Enabling stereo."));
#if !WITH_EDITOR
auto window = sceneViewport->FindWindow();
#endif
Expand Down
14 changes: 1 addition & 13 deletions OSVRUnreal/Plugins/OSVR/Source/OSVR/Private/OSVRHMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,6 @@ class FOSVRHMD : public IHeadMountedDisplay, public ISceneViewExtension, public
IRendererModule* RendererModule = nullptr;

/** Player's orientation tracking */
bool CheckUpdateFrameNumber()
{
check(IsInGameThread());
if (mLastUpdateFrameNumber != GFrameNumber)
{
UE_LOG(OSVRHMDLog, Warning,
TEXT("CheckUpdateFrameNumber: last update from a previous frame"));
return false;
}
return true;
}

mutable uint32 mLastUpdateFrameNumber = UINT_MAX;
FRotator DeltaControlRotation = FRotator::ZeroRotator; // same as DeltaControlOrientation but as rotator
FQuat DeltaControlOrientation = FQuat::Identity; // same as DeltaControlRotation but as quat

Expand All @@ -209,6 +196,7 @@ class FOSVRHMD : public IHeadMountedDisplay, public ISceneViewExtension, public
bool bHmdPosTracking = false;
bool bHaveVisionTracking = false;

bool bNewStereoEnabled = false;
bool bStereoEnabled = false;
bool bHmdEnabled = false;
bool bHmdConnected = false;
Expand Down
3 changes: 3 additions & 0 deletions OSVRUnreal/Plugins/OSVR/Source/OSVR/Private/OSVRRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ void FOSVRHMD::RenderTexture_RenderThread(FRHICommandListImmediate& rhiCmdList,
SetGlobalBoundShaderState(rhiCmdList, featureLevel, boundShaderState, RendererModule->GetFilterVertexDeclaration().VertexDeclarationRHI, *vertexShader, *pixelShader);

pixelShader->SetParameters(rhiCmdList, TStaticSamplerState<SF_Bilinear>::GetRHI(), srcTexture);

#if !OSVR_UNREAL_4_14
rhiCmdList.Clear(true, FLinearColor::Black, true, 0, true, 0, FIntRect());
#endif

// @todo: do we need to ask mCustomPresent whether we should draw the preview or not?
RendererModule->DrawRectangle(
Expand Down
7 changes: 2 additions & 5 deletions OSVRUnreal/Plugins/OSVR/Source/OSVR/Public/IOSVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#define OSVR_UNREAL_4_11 1
#define OSVR_UNREAL_4_12 1
#define OSVR_UNREAL_4_13 1
#define OSVR_UNREAL_4_14 1

class OSVREntryPoint;
class FOSVRHMD;
Expand All @@ -32,11 +34,6 @@ class FOSVRHMD;
OSVR_API class IOSVR : public IHeadMountedDisplayModule
{
public:
/** Returns the key into the HMDPluginPriority section of the config file for this module */
virtual FString GetModulePriorityKeyName() const
{
return FString(TEXT("OSVR"));
}

/**
* Singleton-like access to this module's interface. This is just for convenience!
Expand Down