Repository navigation
Expand file tree
/
Copy pathHorizonDualPolicyProbe.cpp
More file actions
41 lines (41 loc) · 2.5 KB
/
Copy pathHorizonDualPolicyProbe.cpp
File metadata and controls
41 lines (41 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "HeadTrackingMath.h"
#include "DualFirePolicy.h"
#include <cstdio>
using namespace HeadTrackingMath;
bool Near(float a,float b){return std::abs(a-b)<.0001f;}
int main(){
const PackedCamera level{{1,0,0,0,0,1,0,-1,0,10,20,30}};
const Transport::Pose zero{{0,0,0,1},{0,0,0}};
// Game yaw remains live; native pitch/roll cannot alter the horizon.
for(float yaw:{-.8f,0.f,1.2f})for(float pitch:{-1.1f,0.f,1.1f})for(float roll:{-.5f,0.f,.5f}){
Q y{0,std::sin(yaw/2),0,std::cos(yaw/2)},x{std::sin(pitch/2),0,0,std::cos(pitch/2)},z{0,0,std::sin(roll/2),std::cos(roll/2)};
Transport::Pose native{Multiply(Multiply(y,x),z),{0,0,0}},yawOnly{y,{0,0,0}};
auto camera=EyeCamera(level,zero,native,1),expected=EyeCamera(level,zero,yawOnly,1),before=camera;
if(!LevelCamera(camera))return 1;
for(unsigned i=0;i<12;++i)if(!Near(camera.v[i],expected.v[i]))return 2;
for(unsigned i=9;i<12;++i)if(camera.v[i]!=before.v[i])return 3;
// HMD and controller pitch is applied AFTER leveling, including after
// recentering with the head tilted. Positional eye separation survives.
Transport::Pose tilted{Multiply(y,x),{.02f,.3f,-.1f}};
auto anchor=HorizonAnchor(tilted);
if(!Near(anchor.orientation.x,0)||!Near(anchor.orientation.z,0)||!Near(anchor.orientation.y,y.y))return 4;
auto tracked=EyeCamera(camera,zero,tilted,1);
auto expectedTracked=EyeCamera(expected,zero,tilted,1);
for(unsigned i=0;i<12;++i)if(!Near(tracked.v[i],expectedTracked.v[i]))return 5;
if(pitch!=0&&std::abs(tracked.v[8])<.1f)return 6;
}
DualFirePolicy::Triggers t;
t.Update(1,255,255);if(t.AnyHeld()||t.AnyPending())return 7;
t.Update(2,0,0);t.Update(3,255,0);
if(!t.Pending(0)||t.Pending(1))return 8;
t.Accept(0);t.Update(3,0,255);if(t.Pending(0)||t.Pending(1)||!t.Held(0))return 9;
t.Update(4,255,255);if(!t.Pending(1)||t.Pending(0))return 10;
t.Accept(1);t.Update(5,0,255);
if(!t.TakeRelease(0)||t.TakeRelease(0)||t.TakeRelease(1)||!t.Held(1))return 11;
t.Update(6,255,255);if(!t.Pending(0)||t.Pending(1))return 12;
t.Update(7,100,100);if(!t.Held(0)||!t.Held(1))return 13;
t.Update(8,0,0);if(t.AnyHeld()||t.AnyPending()||!t.TakeRelease(0)||!t.TakeRelease(1))return 14;
t.Reset();t.Update(9,0,0);t.Update(10,255,255);
if(!t.Pending(0)||!t.Pending(1))return 15;
puts("PASS: rendered horizon preserves yaw/position and XR pitch; dual trigger overlap, release, hysteresis, reset and duplicate-poll rules.");
}