1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-02 20:43:35 +00:00

Fix OpenVR head pose;

This commit is contained in:
bjorn 2019-08-17 22:50:35 -07:00
parent c703092f87
commit e6bedba0bc
3 changed files with 501 additions and 497 deletions

View file

@ -82,7 +82,7 @@ static struct {
VRActionHandle_t axisActions[2][MAX_AXES]; VRActionHandle_t axisActions[2][MAX_AXES];
VRActionHandle_t skeletonActions[2]; VRActionHandle_t skeletonActions[2];
VRActionHandle_t hapticActions[2]; VRActionHandle_t hapticActions[2];
TrackedDevicePose_t renderPose; TrackedDevicePose_t headPose;
RenderModel_t* deviceModels[16]; RenderModel_t* deviceModels[16];
RenderModel_TextureMap_t* deviceTextures[16]; RenderModel_TextureMap_t* deviceTextures[16];
Canvas* canvas; Canvas* canvas;
@ -311,6 +311,12 @@ static const float* openvr_getBoundsGeometry(uint32_t* count) {
} }
static bool getTransform(Device device, mat4 transform) { static bool getTransform(Device device, mat4 transform) {
if (device == DEVICE_HEAD) {
mat4_fromMat34(transform, state.headPose.mDeviceToAbsoluteTracking.m);
transform[13] += state.offset;
return true;
}
if (!state.poseActions[device]) { if (!state.poseActions[device]) {
return false; return false;
} }
@ -569,7 +575,7 @@ static void openvr_renderTo(void (*callback)(void*), void* userdata) {
Camera camera = { .canvas = state.canvas, .viewMatrix = { MAT4_IDENTITY, MAT4_IDENTITY } }; Camera camera = { .canvas = state.canvas, .viewMatrix = { MAT4_IDENTITY, MAT4_IDENTITY } };
float head[16], eye[16]; float head[16], eye[16];
mat4_fromMat34(head, state.renderPose.mDeviceToAbsoluteTracking.m); mat4_fromMat34(head, state.headPose.mDeviceToAbsoluteTracking.m);
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
EVREye vrEye = (i == 0) ? EVREye_Eye_Left : EVREye_Eye_Right; EVREye vrEye = (i == 0) ? EVREye_Eye_Left : EVREye_Eye_Right;
@ -599,7 +605,7 @@ static Texture* openvr_getMirrorTexture(void) {
} }
static void openvr_update(float dt) { static void openvr_update(float dt) {
state.compositor->WaitGetPoses(&state.renderPose, 1, NULL, 0); state.compositor->WaitGetPoses(&state.headPose, 1, NULL, 0);
VRActiveActionSet_t activeActionSet = { .ulActionSet = state.actionSet }; VRActiveActionSet_t activeActionSet = { .ulActionSet = state.actionSet };
state.input->UpdateActionState(&activeActionSet, sizeof(activeActionSet), 1); state.input->UpdateActionState(&activeActionSet, sizeof(activeActionSet), 1);

View file

@ -3,7 +3,6 @@
{ "name" : "/actions/lovr", "usage" : "leftright" } { "name" : "/actions/lovr", "usage" : "leftright" }
], ],
"actions" : [ "actions" : [
{ "name" : "/actions/lovr/in/headPose", "type" : "pose" },
{ "name" : "/actions/lovr/in/leftHandPose", "type" : "pose" }, { "name" : "/actions/lovr/in/leftHandPose", "type" : "pose" },
{ "name" : "/actions/lovr/in/rightHandPose", "type" : "pose" }, { "name" : "/actions/lovr/in/rightHandPose", "type" : "pose" },
{ "name" : "/actions/lovr/in/leftTriggerDown", "type" : "boolean" }, { "name" : "/actions/lovr/in/leftTriggerDown", "type" : "boolean" },
@ -61,7 +60,6 @@
], ],
"localization" : [ "localization" : [
{ {
"/actions/lovr/in/headPose": "Head Pose",
"/actions/lovr/in/leftHandPose": "Left Hand Pose", "/actions/lovr/in/leftHandPose": "Left Hand Pose",
"/actions/lovr/in/rightHandPose": "Right Hand Pose", "/actions/lovr/in/rightHandPose": "Right Hand Pose",
"/actions/lovr/in/leftTriggerDown": "Left Trigger Press", "/actions/lovr/in/leftTriggerDown": "Left Trigger Press",

File diff suppressed because it is too large Load diff