2021-09-15 17:12:43 +00:00
|
|
|
// Copyright 2021, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Small utility for keeping track of the history of an xrt_space_relation, ie. for knowing where a HMD or
|
|
|
|
* controller was in the past
|
|
|
|
* @author Moses Turner <moses@collabora.com>
|
|
|
|
* @ingroup drv_ht
|
|
|
|
*/
|
2021-12-02 21:11:11 +00:00
|
|
|
#pragma once
|
2021-09-15 17:12:43 +00:00
|
|
|
|
|
|
|
#include "xrt/xrt_defines.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-12-02 21:11:11 +00:00
|
|
|
/**
|
|
|
|
* @brief Opaque type for storing the history of a space relation in a ring buffer
|
2021-09-15 17:12:43 +00:00
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2021-12-02 21:11:11 +00:00
|
|
|
struct m_relation_history;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Describes how the resulting space relation for the desired time stamp was generated.
|
|
|
|
*
|
|
|
|
* @relates m_relation_history
|
|
|
|
*/
|
|
|
|
enum m_relation_history_result
|
|
|
|
{
|
|
|
|
M_RELATION_HISTORY_RESULT_INVALID = 0, //!< The supplied timestamp was invalid (0) or buffer was empty
|
|
|
|
M_RELATION_HISTORY_RESULT_EXACT, //!< The exact desired timestamp was found
|
|
|
|
M_RELATION_HISTORY_RESULT_INTERPOLATED, //!< The desired timestamp was between two entries
|
|
|
|
M_RELATION_HISTORY_RESULT_PREDICTED, //!< The desired timestamp was newer than the most recent entry
|
|
|
|
M_RELATION_HISTORY_RESULT_REVERSE_PREDICTED, //!< The desired timestamp was older than the oldest entry
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Creates an opaque relation_history object.
|
|
|
|
*
|
|
|
|
* @public @memberof m_relation_history
|
|
|
|
*/
|
2021-09-15 17:12:43 +00:00
|
|
|
void
|
|
|
|
m_relation_history_create(struct m_relation_history **rh);
|
|
|
|
|
|
|
|
/*!
|
2021-12-02 21:11:11 +00:00
|
|
|
* Pushes a new pose to the history.
|
2021-09-15 17:12:43 +00:00
|
|
|
*
|
2021-12-02 21:11:11 +00:00
|
|
|
* If the history is full, it will also pop a pose out of the other side of the buffer.
|
|
|
|
*
|
|
|
|
* @public @memberof m_relation_history
|
2021-09-15 17:12:43 +00:00
|
|
|
*/
|
|
|
|
void
|
2021-12-03 13:28:46 +00:00
|
|
|
m_relation_history_push(struct m_relation_history *rh, struct xrt_space_relation const *in_relation, uint64_t ts);
|
2021-09-15 17:12:43 +00:00
|
|
|
|
|
|
|
/*!
|
2021-12-02 21:11:11 +00:00
|
|
|
* @brief Interpolates or extrapolates to the desired timestamp.
|
2021-09-15 17:12:43 +00:00
|
|
|
*
|
2021-12-02 21:11:11 +00:00
|
|
|
* Read-only operation - doesn't remove anything from the buffer or anything like that - you can call this as often as
|
|
|
|
* you want.
|
|
|
|
*
|
|
|
|
* @public @memberof m_relation_history
|
2021-09-15 17:12:43 +00:00
|
|
|
*/
|
2021-12-02 21:11:11 +00:00
|
|
|
enum m_relation_history_result
|
2021-12-03 13:38:53 +00:00
|
|
|
m_relation_history_get(struct m_relation_history *rh, uint64_t at_time_ns, struct xrt_space_relation *out_relation);
|
2021-09-15 17:12:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Destroys an opaque relation_history object.
|
|
|
|
*
|
2021-12-02 21:11:11 +00:00
|
|
|
* @public @memberof m_relation_history
|
2021-09-15 17:12:43 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
m_relation_history_destroy(struct m_relation_history **rh);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|