c/main: Use xrt_device_get_view_poses

This commit is contained in:
Jakob Bornecrantz 2022-02-08 01:15:52 +00:00
parent 0511b319ba
commit 3eb921b899

View file

@ -610,34 +610,37 @@ renderer_get_view_projection(struct comp_renderer *r)
{
COMP_TRACE_MARKER();
struct xrt_space_relation relation;
struct xrt_space_relation head_relation = XRT_SPACE_RELATION_ZERO;
struct xrt_fov fovs[2] = {0};
struct xrt_pose poses[2] = {0};
xrt_device_get_tracked_pose( //
r->c->xdev, //
XRT_INPUT_GENERIC_HEAD_POSE, //
r->c->frame.rendering.predicted_display_time_ns, //
&relation); //
struct xrt_vec3 eye_relation = {
0.063000f, /* TODO: get actual ipd_meters */
struct xrt_vec3 default_eye_relation = {
0.063000f, /*! @todo get actual ipd_meters */
0.0f,
0.0f,
};
xrt_device_get_view_poses( //
r->c->xdev, //
&default_eye_relation, //
r->c->frame.rendering.predicted_display_time_ns, //
2, //
&head_relation, //
fovs, //
poses); //
struct xrt_pose base_space_pose = XRT_POSE_IDENTITY;
for (uint32_t i = 0; i < 2; i++) {
struct xrt_fov fov = r->c->xdev->hmd->views[i].fov;
const struct xrt_fov fov = fovs[i];
const struct xrt_pose eye_pose = poses[i];
comp_layer_renderer_set_fov(r->lr, &fov, i);
struct xrt_pose eye_pose;
xrt_device_get_view_pose(r->c->xdev, &eye_relation, i, &eye_pose);
struct xrt_space_relation result = {0};
struct xrt_relation_chain xrc = {0};
m_relation_chain_push_pose_if_not_identity(&xrc, &eye_pose);
m_relation_chain_push_relation(&xrc, &relation);
m_relation_chain_push_relation(&xrc, &head_relation);
m_relation_chain_push_pose_if_not_identity(&xrc, &base_space_pose);
m_relation_chain_resolve(&xrc, &result);
@ -885,32 +888,37 @@ get_view_poses(struct comp_renderer *r, struct xrt_pose out_results[2])
{
COMP_TRACE_MARKER();
struct xrt_space_relation relation;
struct xrt_space_relation head_relation = XRT_SPACE_RELATION_ZERO;
struct xrt_fov fovs[2] = {0};
struct xrt_pose poses[2] = {0};
xrt_device_get_tracked_pose( //
r->c->xdev, //
XRT_INPUT_GENERIC_HEAD_POSE, //
r->c->frame.rendering.predicted_display_time_ns, //
&relation); //
struct xrt_vec3 eye_relation = {
struct xrt_vec3 default_eye_relation = {
0.063000f, /*! @todo get actual ipd_meters */
0.0f,
0.0f,
};
xrt_device_get_view_poses( //
r->c->xdev, //
&default_eye_relation, //
r->c->frame.rendering.predicted_display_time_ns, //
2, //
&head_relation, //
fovs, //
poses); //
struct xrt_pose base_space_pose = XRT_POSE_IDENTITY;
for (uint32_t i = 0; i < 2; i++) {
struct xrt_fov fov = r->c->xdev->hmd->views[i].fov;
const struct xrt_fov fov = fovs[i];
const struct xrt_pose eye_pose = poses[i];
comp_layer_renderer_set_fov(r->lr, &fov, i);
struct xrt_pose eye_pose = XRT_POSE_IDENTITY;
xrt_device_get_view_pose(r->c->xdev, &eye_relation, i, &eye_pose);
struct xrt_space_relation result = {0};
struct xrt_relation_chain xrc = {0};
m_relation_chain_push_pose_if_not_identity(&xrc, &eye_pose);
m_relation_chain_push_relation(&xrc, &relation);
m_relation_chain_push_relation(&xrc, &head_relation);
m_relation_chain_push_pose_if_not_identity(&xrc, &base_space_pose);
m_relation_chain_resolve(&xrc, &result);
out_results[i] = result.pose;