d/all: Standardize use of get_view_poses helper

This commit is contained in:
Jakob Bornecrantz 2023-11-15 18:30:18 +00:00
parent 1254e5041c
commit 9149352c55
20 changed files with 69 additions and 216 deletions

View file

@ -185,19 +185,6 @@ android_device_get_tracked_pose(struct xrt_device *xdev,
XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT);
}
static void
android_device_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
/*
*
@ -225,7 +212,7 @@ android_device_create()
d->base.destroy = android_device_destroy;
d->base.update_inputs = u_device_noop_update_inputs;
d->base.get_tracked_pose = android_device_get_tracked_pose;
d->base.get_view_poses = android_device_get_view_poses;
d->base.get_view_poses = u_device_get_view_poses;
d->base.compute_distortion = android_device_compute_distortion;
d->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;
d->base.device_type = XRT_DEVICE_TYPE_HMD;

View file

@ -155,19 +155,6 @@ euroc_device_get_tracked_pose(struct xrt_device *xdev,
XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT);
}
static void
euroc_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
static void
euroc_device_destroy(struct xrt_device *xdev)
{
@ -247,7 +234,9 @@ euroc_device_create(struct xrt_prober *xp)
xd->get_tracked_pose = euroc_device_get_tracked_pose;
xd->destroy = euroc_device_destroy;
if (is_hmd) {
xd->get_view_poses = euroc_get_view_poses;
xd->get_view_poses = u_device_get_view_poses;
} else {
xd->get_view_poses = u_device_ni_get_view_poses;
}
u_var_add_root(ed, dev_name, false);

View file

@ -250,19 +250,6 @@ hdk_device_get_tracked_pose(struct xrt_device *xdev,
hd->quat.w, hd->ang_vel_quat.x, hd->ang_vel_quat.y, hd->ang_vel_quat.z);
}
static void
hdk_device_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
static void *
hdk_device_run_thread(void *ptr)
{
@ -305,7 +292,7 @@ hdk_device_create(struct os_hid_device *dev, enum HDK_VARIANT variant)
hd->base.update_inputs = u_device_noop_update_inputs;
hd->base.get_tracked_pose = hdk_device_get_tracked_pose;
hd->base.get_view_poses = hdk_device_get_view_poses;
hd->base.get_view_poses = u_device_get_view_poses;
hd->base.destroy = hdk_device_destroy;
hd->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;
hd->base.name = XRT_DEVICE_GENERIC_HMD;

View file

@ -124,19 +124,6 @@ illixr_hmd_get_tracked_pose(struct xrt_device *xdev,
XRT_SPACE_RELATION_POSITION_VALID_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT);
}
static void
illixr_hmd_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
std::vector<std::string>
split(const std::string &s, char delimiter)
{
@ -169,7 +156,7 @@ illixr_hmd_create(const char *path_in, const char *comp_in)
dh = U_DEVICE_ALLOCATE(struct illixr_hmd, flags, 1, 0);
dh->base.update_inputs = u_device_noop_update_inputs;
dh->base.get_tracked_pose = illixr_hmd_get_tracked_pose;
dh->base.get_view_poses = illixr_hmd_get_view_poses;
dh->base.get_view_poses = u_device_get_view_poses;
dh->base.destroy = illixr_hmd_destroy;
dh->base.name = XRT_DEVICE_GENERIC_HMD;
dh->base.device_type = XRT_DEVICE_TYPE_HMD;

View file

@ -397,8 +397,14 @@ ns_hmd_get_view_poses(struct xrt_device *xdev,
NS_DEBUG(ns, "Called!");
// Use this to take care of most stuff, then fix up below.
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
u_device_get_view_poses( //
xdev, //
default_eye_relation, //
at_timestamp_ns, //
view_count, //
out_head_relation, //
out_fovs, //
out_poses); //
// Fix fix.
for (uint32_t i = 0; i < view_count && i < ARRAY_SIZE(ns->config.head_pose_to_eye); i++) {

View file

@ -1070,19 +1070,6 @@ na_hmd_get_tracked_pose(struct xrt_device *xdev,
math_quat_normalize(&out_relation->pose.orientation);
}
static void
na_hmd_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
static void
na_hmd_destroy(struct xrt_device *xdev)
{
@ -1117,7 +1104,7 @@ na_hmd_create_device(struct os_hid_device *sensor_device,
hmd->log_level = log_level;
hmd->base.update_inputs = na_hmd_update_inputs;
hmd->base.get_tracked_pose = na_hmd_get_tracked_pose;
hmd->base.get_view_poses = na_hmd_get_view_poses;
hmd->base.get_view_poses = u_device_get_view_poses;
hmd->base.compute_distortion = na_hmd_compute_distortion;
hmd->base.destroy = na_hmd_destroy;
hmd->base.name = XRT_DEVICE_GENERIC_HMD;

View file

@ -449,18 +449,6 @@ oh_device_get_tracked_pose(struct xrt_device *xdev,
ohd->last_relation = *out_relation;
}
static void
oh_device_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
struct display_info
{
@ -741,7 +729,7 @@ create_hmd(ohmd_context *ctx, int device_idx, int device_flags)
struct oh_device *ohd = U_DEVICE_ALLOCATE(struct oh_device, flags, 1, 0);
ohd->base.update_inputs = oh_device_update_inputs;
ohd->base.get_tracked_pose = oh_device_get_tracked_pose;
ohd->base.get_view_poses = oh_device_get_view_poses;
ohd->base.get_view_poses = u_device_get_view_poses;
ohd->base.destroy = oh_device_destroy;
ohd->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;
ohd->base.name = XRT_DEVICE_GENERIC_HMD;
@ -1057,7 +1045,7 @@ create_controller(ohmd_context *ctx, int device_idx, int device_flags, enum xrt_
ohd->base.update_inputs = oh_device_update_inputs;
ohd->base.set_output = oh_device_set_output;
ohd->base.get_tracked_pose = oh_device_get_tracked_pose;
ohd->base.get_view_poses = oh_device_get_view_poses;
ohd->base.get_view_poses = u_device_ni_get_view_poses;
ohd->base.destroy = oh_device_destroy;
if (oculus_touch) {
ohd->ohmd_device_type = OPENHMD_OCULUS_RIFT_CONTROLLER;

View file

@ -993,19 +993,6 @@ psvr_device_get_tracked_pose(struct xrt_device *xdev,
math_quat_normalize(&out_relation->pose.orientation);
}
static void
psvr_device_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
static void
psvr_device_destroy(struct xrt_device *xdev)
{
@ -1044,7 +1031,7 @@ psvr_device_create_auto_prober(struct hid_device_info *sensor_hid_info,
psvr->log_level = log_level;
psvr->base.update_inputs = psvr_device_update_inputs;
psvr->base.get_tracked_pose = psvr_device_get_tracked_pose;
psvr->base.get_view_poses = psvr_device_get_view_poses;
psvr->base.get_view_poses = u_device_get_view_poses;
psvr->base.compute_distortion = psvr_compute_distortion;
psvr->base.destroy = psvr_device_destroy;
psvr->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;

View file

@ -204,19 +204,6 @@ qwerty_get_tracked_pose(struct xrt_device *xd,
XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
}
static void
qwerty_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
static void
qwerty_destroy(struct xrt_device *xd)
{
@ -274,7 +261,7 @@ qwerty_hmd_create(void)
xd->update_inputs = qwerty_update_inputs;
xd->get_tracked_pose = qwerty_get_tracked_pose;
xd->get_view_poses = qwerty_get_view_poses;
xd->get_view_poses = u_device_get_view_poses;
xd->destroy = qwerty_destroy;
u_distortion_mesh_set_none(xd); // Fill in xd->compute_distortion()

View file

@ -573,19 +573,6 @@ rift_s_controller_get_tracked_pose(struct xrt_device *xdev,
m_relation_chain_resolve(&xrc, out_relation);
}
static void
rift_s_controller_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
static void
rift_s_controller_destroy(struct xrt_device *xdev)
{
@ -626,7 +613,7 @@ rift_s_controller_create(struct rift_s_system *sys, enum xrt_device_type device_
ctrl->base.update_inputs = rift_s_controller_update_inputs;
ctrl->base.set_output = rift_s_controller_set_output;
ctrl->base.get_tracked_pose = rift_s_controller_get_tracked_pose;
ctrl->base.get_view_poses = rift_s_controller_get_view_poses;
ctrl->base.get_view_poses = u_device_get_view_poses;
ctrl->base.destroy = rift_s_controller_destroy;
ctrl->base.name = XRT_DEVICE_TOUCH_CONTROLLER;
ctrl->base.device_type = device_type;

View file

@ -62,19 +62,6 @@ rift_s_get_tracked_pose(struct xrt_device *xdev,
rift_s_tracker_get_tracked_pose(hmd->tracker, RIFT_S_TRACKER_POSE_DEVICE, at_timestamp_ns, out_relation);
}
static void
rift_s_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
void
rift_s_hmd_handle_report(struct rift_s_hmd *hmd, timepoint_ns local_ts, rift_s_hmd_report_t *report)
{
@ -227,7 +214,7 @@ rift_s_hmd_create(struct rift_s_system *sys, const unsigned char *hmd_serial_no,
hmd->base.update_inputs = u_device_noop_update_inputs;
hmd->base.get_tracked_pose = rift_s_get_tracked_pose;
hmd->base.get_view_poses = rift_s_get_view_poses;
hmd->base.get_view_poses = u_device_get_view_poses;
hmd->base.destroy = rift_s_hmd_destroy;
hmd->base.name = XRT_DEVICE_GENERIC_HMD;
hmd->base.device_type = XRT_DEVICE_TYPE_HMD;

View file

@ -447,19 +447,6 @@ rokid_hmd_get_tracked_pose(struct xrt_device *xdev,
os_mutex_unlock(&rokid->fusion.mutex);
}
static void
rokid_hmd_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
static struct xrt_device *
rokid_hmd_create(struct xrt_prober_device *prober_device)
{
@ -494,7 +481,7 @@ rokid_hmd_create(struct xrt_prober_device *prober_device)
rokid->base.update_inputs = u_device_noop_update_inputs;
rokid->base.get_tracked_pose = rokid_hmd_get_tracked_pose;
rokid->base.get_view_poses = rokid_hmd_get_view_poses;
rokid->base.get_view_poses = u_device_get_view_poses;
rokid->base.destroy = rokid_hmd_destroy;
// Setup input.

View file

@ -110,8 +110,18 @@ sample_hmd_get_view_poses(struct xrt_device *xdev,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
/*
* For HMDs you can call this function or directly set
* the `get_view_poses` function on the device to it.
*/
u_device_get_view_poses( //
xdev, //
default_eye_relation, //
at_timestamp_ns, //
view_count, //
out_head_relation, //
out_fovs, //
out_poses); //
}
bool

View file

@ -108,10 +108,14 @@ svr_hmd_get_view_poses(struct xrt_device *xdev,
//!@todo: default_eye_relation inherits from the env var OXR_DEBUG_IPD_MM / oxr_session.c
// probably needs a lot more attention
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
u_device_get_view_poses( //
xdev, //
default_eye_relation, //
at_timestamp_ns, //
view_count, //
out_head_relation, //
out_fovs, //
out_poses); //
//!@todo you may need to invert this - I can't test locally
float turn_vals[2] = {5.0, -5.0};

View file

@ -143,19 +143,6 @@ simulated_hmd_get_tracked_pose(struct xrt_device *xdev,
XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT);
}
static void
simulated_hmd_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
static xrt_result_t
simulated_ref_space_usage(struct xrt_device *xdev,
enum xrt_reference_space_type type,
@ -205,7 +192,7 @@ simulated_hmd_create(enum simulated_movement movement, const struct xrt_pose *ce
struct simulated_hmd *dh = U_DEVICE_ALLOCATE(struct simulated_hmd, flags, 1, 0);
dh->base.update_inputs = u_device_noop_update_inputs;
dh->base.get_tracked_pose = simulated_hmd_get_tracked_pose;
dh->base.get_view_poses = simulated_hmd_get_view_poses;
dh->base.get_view_poses = u_device_get_view_poses;
dh->base.ref_space_usage = simulated_ref_space_usage;
dh->base.destroy = simulated_hmd_destroy;
dh->base.name = XRT_DEVICE_GENERIC_HMD;

View file

@ -521,8 +521,14 @@ HmdDevice::get_view_poses(const xrt_vec3 *default_eye_relation,
struct xrt_vec3 eye_relation = *default_eye_relation;
eye_relation.x = ipd;
u_device_get_view_poses(this, &eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
u_device_get_view_poses( //
this, //
&eye_relation, //
at_timestamp_ns, //
view_count, //
out_head_relation, //
out_fovs, //
out_poses); //
out_poses[0].orientation = this->eye[0].orientation;
out_poses[0].position.z = this->eye[0].position.z;

View file

@ -528,8 +528,14 @@ survive_device_get_view_poses(struct xrt_device *xdev,
eye_relation.x = survive->hmd.ipd;
}
u_device_get_view_poses(xdev, &eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
u_device_get_view_poses( //
xdev, //
&eye_relation, //
at_timestamp_ns, //
view_count, //
out_head_relation, //
out_fovs, //
out_poses); //
// This is for the Index' canted displays, on the Vive [Pro] they are identity.
for (uint32_t i = 0; i < view_count && i < ARRAY_SIZE(survive->hmd.config.display.rot); i++) {

View file

@ -205,8 +205,14 @@ vive_device_get_view_poses(struct xrt_device *xdev,
// Only supports two views.
assert(view_count <= 2);
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
u_device_get_view_poses( //
xdev, //
default_eye_relation, //
at_timestamp_ns, //
view_count, //
out_head_relation, //
out_fovs, //
out_poses); //
// This is for the Index' canted displays, on the Vive [Pro] they are identity.
struct vive_device *d = vive_device(xdev);

View file

@ -1177,19 +1177,6 @@ wmr_hmd_get_tracked_pose(struct xrt_device *xdev,
math_pose_transform(&wh->offset, &out_relation->pose, &out_relation->pose);
}
static void
wmr_hmd_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs,
out_poses);
}
static void
wmr_hmd_destroy(struct xrt_device *xdev)
{
@ -1889,7 +1876,7 @@ wmr_hmd_create(enum wmr_headset_type hmd_type,
// Populate the base members.
wh->base.update_inputs = u_device_noop_update_inputs;
wh->base.get_tracked_pose = wmr_hmd_get_tracked_pose;
wh->base.get_view_poses = wmr_hmd_get_view_poses;
wh->base.get_view_poses = u_device_get_view_poses;
wh->base.destroy = wmr_hmd_destroy;
wh->base.name = XRT_DEVICE_GENERIC_HMD;
wh->base.device_type = XRT_DEVICE_TYPE_HMD;

View file

@ -39,25 +39,6 @@ sdl_hmd_get_tracked_pose(struct xrt_device *xdev,
*out_relation = relation;
}
static void
sdl_hmd_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
struct xrt_space_relation *out_head_relation,
struct xrt_fov *out_fovs,
struct xrt_pose *out_poses)
{
u_device_get_view_poses( //
xdev, //
default_eye_relation, //
at_timestamp_ns, //
view_count, //
out_head_relation, //
out_fovs, //
out_poses); //
}
static void
sdl_hmd_destroy(struct xrt_device *xdev)
{
@ -109,7 +90,7 @@ sdl_device_init(struct sdl_program *sp)
// Function pointers.
xdev->update_inputs = u_device_noop_update_inputs;
xdev->get_tracked_pose = sdl_hmd_get_tracked_pose;
xdev->get_view_poses = sdl_hmd_get_view_poses;
xdev->get_view_poses = u_device_get_view_poses;
xdev->destroy = sdl_hmd_destroy;
// Minimum needed stuff.