Skip to content

Commit bfdb58d

Browse files
authored
Merge pull request #139 from OSVR/4-14-fixes
4 14 fixes
2 parents 5d63aac + 333ad94 commit bfdb58d

File tree

9 files changed

+41
-34
lines changed

9 files changed

+41
-34
lines changed

OSVRUnreal/Config/DefaultEngine.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ r.DefaultFeature.AutoExposure=True
4747
r.DefaultFeature.AutoExposure.Method=0
4848
r.DefaultFeature.MotionBlur=True
4949
r.DefaultFeature.LensFlare=False
50-
r.DefaultFeature.AntiAliasing=2
50+
r.DefaultFeature.AntiAliasing=0
5151
r.EarlyZPass=3
5252
r.EarlyZPassMovable=False
5353
r.DBuffer=False
@@ -60,6 +60,7 @@ vr.InstancedStereo=True
6060
r.WireframeCullThreshold=5.000000
6161
UIScaleRule=ShortestSide
6262
UIScaleCurve=(EditorCurveData=(PreInfinityExtrap=RCCE_Constant,PostInfinityExtrap=RCCE_Constant,Keys=,DefaultValue=340282346638528859811704183484516925440.000000),ExternalCurve=None)
63+
r.ForwardShading=True
6364

6465
[/Script/EngineSettings.GameMapsSettings]
6566
EditorStartupMap=/Game/Maps/basic.basic
@@ -86,5 +87,3 @@ AppliedDefaultGraphicsPerformance=Maximum
8687
+TargetedRHIs=GLSL_150
8788
MinimumOSVersion=MSOS_Vista
8889
AudioDevice=
89-
90-

OSVRUnreal/Content/Maps/basic.umap

-115 KB
Binary file not shown.
118 KB
Binary file not shown.

OSVRUnreal/OSVRUnreal.uproject

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"FileVersion": 3,
3-
"EngineAssociation": "4.13",
3+
"EngineAssociation": "4.14",
44
"Category": "",
55
"Description": "",
66
"Modules": [

OSVRUnreal/Plugins/OSVR/Source/OSVR/Private/OSVR.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ class FOSVR : public IOSVR
3737
virtual void ShutdownModule() override;
3838

3939
/** IHeadMountedDisplayModule implementation */
40+
#if OSVR_UNREAL_4_14
41+
/** Returns the key into the HMDPluginPriority section of the config file for this module */
42+
FString GetModuleKeyName() const override
43+
{
44+
return FString(TEXT("OSVR"));
45+
}
46+
#else
47+
/** Returns the key into the HMDPluginPriority section of the config file for this module */
48+
virtual FString GetModulePriorityKeyName() const override
49+
{
50+
return FString(TEXT("OSVR"));
51+
}
52+
#endif
53+
4054
virtual TSharedPtr<class IHeadMountedDisplay, ESPMode::ThreadSafe> CreateHeadMountedDisplay() override;
4155
#if OSVR_UNREAL_4_12
4256
virtual bool IsHMDConnected() override;

OSVRUnreal/Plugins/OSVR/Source/OSVR/Private/OSVRHMD.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ void FOSVRHMD::UpdateHeadPose(bool renderThread, FQuat& lastHmdOrientation, FVec
258258
lastHmdPosition = _lastHmdPosition;
259259
hmdOrientation = _curHmdOrientation;
260260
hmdPosition = _curHmdPosition;
261-
262-
mLastUpdateFrameNumber = GFrameNumber;
263261
}
264262

265263
bool FOSVRHMD::DoesSupportPositionalTracking() const
@@ -298,6 +296,10 @@ bool FOSVRHMD::OnStartGameFrame(FWorldContext& WorldContext)
298296
sFinishCurrentFrame->Set(0);
299297
bHmdOverridesApplied = true;
300298
}
299+
if (bStereoEnabled != bNewStereoEnabled)
300+
{
301+
bStereoEnabled = EnableStereo(bNewStereoEnabled);
302+
}
301303
return true;
302304
}
303305

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

337339
void FOSVRHMD::ApplyHmdRotation(APlayerController* PC, FRotator& ViewRotation)
338340
{
339-
CheckUpdateFrameNumber();
341+
FQuat lastHmdOrientation, curHmdOrientation;
342+
FVector lastHmdPosition, curHmdPosition;
343+
UpdateHeadPose(false, lastHmdOrientation, lastHmdPosition, curHmdOrientation, curHmdPosition);
344+
340345
ViewRotation.Normalize();
341346

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

352-
ViewRotation = FRotator(DeltaControlOrientation * CurHmdOrientation);
357+
ViewRotation = FRotator(DeltaControlOrientation * curHmdOrientation);
353358
}
354359

355360
#if OSVR_UNREAL_4_11
356361
bool FOSVRHMD::UpdatePlayerCamera(FQuat& CurrentOrientation, FVector& CurrentPosition)
357362
{
358-
CheckUpdateFrameNumber();
359-
CurrentOrientation = CurHmdOrientation;
360-
CurrentPosition = CurHmdPosition;
363+
FQuat lastHmdOrientation;
364+
FVector lastHmdPosition;
365+
UpdateHeadPose(false, lastHmdOrientation, lastHmdPosition, CurrentOrientation, CurrentPosition);
361366
return true;
362367
}
363368
#else
@@ -479,12 +484,12 @@ bool FOSVRHMD::IsStereoEnabled() const
479484

480485
bool FOSVRHMD::EnableStereo(bool bStereo)
481486
{
482-
bool bNewSteroEnabled = IsHMDConnected() ? bStereo : false;
483-
if (bNewSteroEnabled == bStereoEnabled)
487+
bNewStereoEnabled = IsHMDConnected() ? bStereo : false;
488+
if (bNewStereoEnabled == bStereoEnabled)
484489
{
485490
return bStereoEnabled;
486491
}
487-
bStereoEnabled = bNewSteroEnabled;
492+
bStereoEnabled = bNewStereoEnabled;
488493

489494
if (bStereoEnabled)
490495
{
@@ -540,12 +545,13 @@ bool FOSVRHMD::EnableStereo(bool bStereo)
540545

541546
if (!sceneViewport)
542547
{
543-
UE_LOG(OSVRHMDLog, Warning, TEXT("OSVR scene viewport does not exist"));
548+
//UE_LOG(OSVRHMDLog, Warning, TEXT("FOSVRHMD::EnableStereo() - OSVR scene viewport does not exist. Will try again later."));
549+
bStereoEnabled = false;
544550
return false;
545551
}
546552
else
547553
{
548-
//UE_LOG(OSVRHMDLog, Warning, TEXT("OSVR scene viewport exists"));
554+
//UE_LOG(OSVRHMDLog, Warning, TEXT("FOSVRHMD::EnableStereo() - OSVR scene viewport exists. Enabling stereo."));
549555
#if !WITH_EDITOR
550556
auto window = sceneViewport->FindWindow();
551557
#endif

OSVRUnreal/Plugins/OSVR/Source/OSVR/Private/OSVRHMD.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,6 @@ class FOSVRHMD : public IHeadMountedDisplay, public ISceneViewExtension, public
171171
IRendererModule* RendererModule = nullptr;
172172

173173
/** Player's orientation tracking */
174-
bool CheckUpdateFrameNumber()
175-
{
176-
check(IsInGameThread());
177-
if (mLastUpdateFrameNumber != GFrameNumber)
178-
{
179-
UE_LOG(OSVRHMDLog, Warning,
180-
TEXT("CheckUpdateFrameNumber: last update from a previous frame"));
181-
return false;
182-
}
183-
return true;
184-
}
185-
186-
mutable uint32 mLastUpdateFrameNumber = UINT_MAX;
187174
FRotator DeltaControlRotation = FRotator::ZeroRotator; // same as DeltaControlOrientation but as rotator
188175
FQuat DeltaControlOrientation = FQuat::Identity; // same as DeltaControlRotation but as quat
189176

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

199+
bool bNewStereoEnabled = false;
212200
bool bStereoEnabled = false;
213201
bool bHmdEnabled = false;
214202
bool bHmdConnected = false;

OSVRUnreal/Plugins/OSVR/Source/OSVR/Private/OSVRRender.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ void FOSVRHMD::RenderTexture_RenderThread(FRHICommandListImmediate& rhiCmdList,
6868
SetGlobalBoundShaderState(rhiCmdList, featureLevel, boundShaderState, RendererModule->GetFilterVertexDeclaration().VertexDeclarationRHI, *vertexShader, *pixelShader);
6969

7070
pixelShader->SetParameters(rhiCmdList, TStaticSamplerState<SF_Bilinear>::GetRHI(), srcTexture);
71+
72+
#if !OSVR_UNREAL_4_14
7173
rhiCmdList.Clear(true, FLinearColor::Black, true, 0, true, 0, FIntRect());
74+
#endif
7275

7376
// @todo: do we need to ask mCustomPresent whether we should draw the preview or not?
7477
RendererModule->DrawRectangle(

OSVRUnreal/Plugins/OSVR/Source/OSVR/Public/IOSVR.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#define OSVR_UNREAL_4_11 1
2323
#define OSVR_UNREAL_4_12 1
24+
#define OSVR_UNREAL_4_13 1
25+
#define OSVR_UNREAL_4_14 1
2426

2527
class OSVREntryPoint;
2628
class FOSVRHMD;
@@ -32,11 +34,6 @@ class FOSVRHMD;
3234
OSVR_API class IOSVR : public IHeadMountedDisplayModule
3335
{
3436
public:
35-
/** Returns the key into the HMDPluginPriority section of the config file for this module */
36-
virtual FString GetModulePriorityKeyName() const
37-
{
38-
return FString(TEXT("OSVR"));
39-
}
4037

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

0 commit comments

Comments
 (0)