vrapi: cleanup; fix getPose for non-head/hands devices;
@@ -195,6 +195,10 @@ static const float* vrapi_getBoundsGeometry(uint32_t* count) {
}
static bool vrapi_getPose(Device device, float* position, float* orientation) {
+ if (device != DEVICE_HAND_LEFT && device != DEVICE_HAND_RIGHT && device != DEVICE_HEAD) {
+ return false;
+ }
+
ovrPosef* pose;
bool valid;
@@ -211,9 +215,9 @@ static bool vrapi_getPose(Device device, float* position, float* orientation) {
vec3_set(position, pose->Position.x, pose->Position.y + state.offset, pose->Position.z);
quat_init(orientation, &pose->Orientation.x);
- // make tracked hands face -Z
+ // Make tracked hands face -Z
if (index < 2 && state.hands[index].Type == ovrControllerType_Hand) {
- float rotation[4] = {0,0,0,1};
+ float rotation[4];
if (device == DEVICE_HAND_LEFT) {
float q[4];
quat_fromAngleAxis(rotation, (float) M_PI, 0.f, 0.f, 1.f);
@@ -224,7 +228,6 @@ static bool vrapi_getPose(Device device, float* position, float* orientation) {
quat_mul(orientation, orientation, rotation);
}
-
return valid;
}
