mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-16 20:05:29 +00:00
st/oxr: Add env vars for global tracking origin offset
This commit is a band aid until a more proper room setup is implemented. It allows moving the tracking offset for the device roles head, left and right by a fixed value. A y tracking offset OXR_TRACKING_ORIGIN_OFFSET_Y=1.0 would tell monado that the current tracking origin is 1 meter above the desired tracking origin, e.g. when the headset was calibrated to a (0,0,0) position while sitting on table 1 meter above the floor. This environment variable affects STAGE space, but not LOCAL space.
This commit is contained in:
parent
345e9eab56
commit
3848d2be3f
|
@ -352,10 +352,19 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
apply_offset(struct xrt_vec3 *position, struct xrt_vec3 *offset)
|
||||
{
|
||||
position->x += offset->x;
|
||||
position->y += offset->y;
|
||||
position->z += offset->z;
|
||||
}
|
||||
|
||||
void
|
||||
u_device_setup_tracking_origins(struct xrt_device *head,
|
||||
struct xrt_device *left,
|
||||
struct xrt_device *right)
|
||||
struct xrt_device *right,
|
||||
struct xrt_vec3 *global_tracking_origin_offset)
|
||||
{
|
||||
if (head->tracking_origin->type == XRT_TRACKING_TYPE_NONE) {
|
||||
// "nominal height" 1.6m
|
||||
|
@ -377,4 +386,25 @@ u_device_setup_tracking_origins(struct xrt_device *head,
|
|||
right->tracking_origin->offset.position.y = 1.3f;
|
||||
right->tracking_origin->offset.position.z = -0.5f;
|
||||
}
|
||||
|
||||
struct xrt_tracking_origin *head_origin =
|
||||
head ? head->tracking_origin : NULL;
|
||||
struct xrt_tracking_origin *left_origin =
|
||||
left ? left->tracking_origin : NULL;
|
||||
struct xrt_tracking_origin *right_origin =
|
||||
right ? right->tracking_origin : NULL;
|
||||
|
||||
if (head_origin) {
|
||||
apply_offset(&head_origin->offset.position,
|
||||
global_tracking_origin_offset);
|
||||
}
|
||||
if (left_origin && left_origin != head_origin) {
|
||||
apply_offset(&left->tracking_origin->offset.position,
|
||||
global_tracking_origin_offset);
|
||||
}
|
||||
if (right_origin && right_origin != head_origin &&
|
||||
right_origin != left_origin) {
|
||||
apply_offset(&right->tracking_origin->offset.position,
|
||||
global_tracking_origin_offset);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,8 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs,
|
|||
void
|
||||
u_device_setup_tracking_origins(struct xrt_device *head,
|
||||
struct xrt_device *left,
|
||||
struct xrt_device *right);
|
||||
struct xrt_device *right,
|
||||
struct xrt_vec3 *global_tracking_origin_offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -48,6 +48,16 @@ DEBUG_GET_ONCE_FLOAT_OPTION(lfov_right, "OXR_OVERRIDE_LFOV_RIGHT", 0.0f)
|
|||
DEBUG_GET_ONCE_FLOAT_OPTION(lfov_up, "OXR_OVERRIDE_LFOV_UP", 0.0f)
|
||||
DEBUG_GET_ONCE_FLOAT_OPTION(lfov_down, "OXR_OVERRIDE_LFOV_DOWN", 0.0f)
|
||||
|
||||
DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_x,
|
||||
"OXR_TRACKING_ORIGIN_OFFSET_X",
|
||||
0.0f)
|
||||
DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_y,
|
||||
"OXR_TRACKING_ORIGIN_OFFSET_Y",
|
||||
0.0f)
|
||||
DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_z,
|
||||
"OXR_TRACKING_ORIGIN_OFFSET_Z",
|
||||
0.0f)
|
||||
|
||||
/* ---- HACK ---- */
|
||||
extern int
|
||||
oxr_sdl2_hack_create(void **out_hack);
|
||||
|
@ -255,8 +265,14 @@ oxr_instance_create(struct oxr_logger *log,
|
|||
return ret;
|
||||
}
|
||||
|
||||
struct xrt_vec3 global_tracking_origin_offset = {
|
||||
debug_get_float_option_tracking_origin_offset_x(),
|
||||
debug_get_float_option_tracking_origin_offset_y(),
|
||||
debug_get_float_option_tracking_origin_offset_z()};
|
||||
|
||||
u_device_setup_tracking_origins(dev, GET_XDEV_BY_ROLE(sys, left),
|
||||
GET_XDEV_BY_ROLE(sys, right));
|
||||
GET_XDEV_BY_ROLE(sys, right),
|
||||
&global_tracking_origin_offset);
|
||||
|
||||
const float left_override = debug_get_float_option_lfov_left();
|
||||
if (left_override != 0.0f) {
|
||||
|
|
|
@ -1294,7 +1294,9 @@ CServerDriver_Monado::Init(vr::IVRDriverContext *pDriverContext)
|
|||
ovrd_log("Left Controller: %s\n", left_xdev ? left_xdev->str : "");
|
||||
ovrd_log("Right Controller: %s\n", right_xdev ? right_xdev->str : "");
|
||||
|
||||
u_device_setup_tracking_origins(m_xhmd, left_xdev, right_xdev);
|
||||
// use steamvr room setup instead
|
||||
struct xrt_vec3 offset = {0, 0, 0};
|
||||
u_device_setup_tracking_origins(m_xhmd, left_xdev, right_xdev, &offset);
|
||||
|
||||
if (left != XRT_DEVICE_ROLE_UNASSIGNED) {
|
||||
m_left = new CDeviceDriver_Monado_Controller(m_xinst, left_xdev,
|
||||
|
@ -1347,7 +1349,6 @@ CServerDriver_Monado::HandleHapticEvent(vr::VREvent_t *event)
|
|||
float amp = event->data.hapticVibration.fAmplitude;
|
||||
float duration = event->data.hapticVibration.fDurationSeconds;
|
||||
|
||||
|
||||
ovrd_log("Haptic vibration %fs %fHz %famp\n", duration, freq, amp);
|
||||
|
||||
struct xrt_device *xdev = NULL;
|
||||
|
|
Loading…
Reference in a new issue