The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

a/math: Add m_relation_history_result return from m_relation_history_get

authored by

Ryan Pavlik and committed by
Jakob Bornecrantz
217dee2c 01e3d987

+43 -12
+8 -1
src/xrt/auxiliary/math/m_relation_history.cpp
··· 80 80 os_mutex_unlock(&rh->mutex); 81 81 } 82 82 83 - void 83 + enum m_relation_history_result 84 84 m_relation_history_get(struct m_relation_history *rh, struct xrt_space_relation *out_relation, uint64_t at_timestamp_ns) 85 85 { 86 86 XRT_TRACE_MARKER(); 87 87 os_mutex_lock(&rh->mutex); 88 + m_relation_history_result ret = M_RELATION_HISTORY_RESULT_INVALID; 89 + 88 90 if (rh->has_first_sample == 0) { 89 91 // Do nothing. You push nothing to the buffer you get nothing from the buffer. 90 92 goto end; ··· 104 106 U_LOG_T("Extrapolating %f s after the head of the buffer!", delta_s); 105 107 106 108 m_predict_relation(&rh->impl[0]->relation, delta_s, out_relation); 109 + ret = M_RELATION_HISTORY_RESULT_PREDICTED; 107 110 goto end; 108 111 109 112 } else if (at_timestamp_ns < oldest_in_buffer) { ··· 114 117 double delta_s = time_ns_to_s(diff_prediction_ns); 115 118 U_LOG_T("Extrapolating %f s before the tail of the buffer!", delta_s); 116 119 m_predict_relation(&rh->impl[rh->impl.length() - 1]->relation, delta_s, out_relation); 120 + ret = M_RELATION_HISTORY_RESULT_REVERSE_PREDICTED; 121 + 117 122 goto end; 118 123 } 119 124 U_LOG_T("Interpolating within buffer!"); ··· 196 201 m_vec3_lerp(before.angular_velocity, after.angular_velocity, amount_to_lerp); 197 202 out_relation->linear_velocity = 198 203 m_vec3_lerp(before.linear_velocity, after.linear_velocity, amount_to_lerp); 204 + ret = M_RELATION_HISTORY_RESULT_INTERPOLATED; 199 205 } 200 206 end: 201 207 os_mutex_unlock(&rh->mutex); 208 + return ret; 202 209 } 203 210 204 211 void
+35 -11
src/xrt/auxiliary/math/m_relation_history.h
··· 7 7 * @author Moses Turner <moses@collabora.com> 8 8 * @ingroup drv_ht 9 9 */ 10 + #pragma once 10 11 11 12 #include "xrt/xrt_defines.h" 12 - struct m_relation_history; 13 13 14 14 #ifdef __cplusplus 15 15 extern "C" { 16 16 #endif 17 17 18 - /*! 19 - * Creates an opaque relation_history object. 18 + /** 19 + * @brief Opaque type for storing the history of a space relation in a ring buffer 20 20 * 21 21 * @ingroup aux_util 22 22 */ 23 + struct m_relation_history; 24 + 25 + /** 26 + * @brief Describes how the resulting space relation for the desired time stamp was generated. 27 + * 28 + * @relates m_relation_history 29 + */ 30 + enum m_relation_history_result 31 + { 32 + M_RELATION_HISTORY_RESULT_INVALID = 0, //!< The supplied timestamp was invalid (0) or buffer was empty 33 + M_RELATION_HISTORY_RESULT_EXACT, //!< The exact desired timestamp was found 34 + M_RELATION_HISTORY_RESULT_INTERPOLATED, //!< The desired timestamp was between two entries 35 + M_RELATION_HISTORY_RESULT_PREDICTED, //!< The desired timestamp was newer than the most recent entry 36 + M_RELATION_HISTORY_RESULT_REVERSE_PREDICTED, //!< The desired timestamp was older than the oldest entry 37 + }; 38 + 39 + /*! 40 + * @brief Creates an opaque relation_history object. 41 + * 42 + * @public @memberof m_relation_history 43 + */ 23 44 void 24 45 m_relation_history_create(struct m_relation_history **rh); 25 46 26 47 /*! 27 - * Pushes a new pose to the history - if the history is full, it will also pop a pose out of the other side of the 28 - * buffer. 48 + * Pushes a new pose to the history. 29 49 * 30 - * @ingroup aux_util 50 + * If the history is full, it will also pop a pose out of the other side of the buffer. 51 + * 52 + * @public @memberof m_relation_history 31 53 */ 32 54 void 33 55 m_relation_history_push(struct m_relation_history *rh, struct xrt_space_relation *in_relation, uint64_t ts); 34 56 35 57 /*! 36 - * Interpolates or extrapolates to the desired timestamp. Read-only operation - doesn't remove anything from the buffer 37 - * or anything like that - you can call this as often as you want. 58 + * @brief Interpolates or extrapolates to the desired timestamp. 38 59 * 39 - * @ingroup aux_util 60 + * Read-only operation - doesn't remove anything from the buffer or anything like that - you can call this as often as 61 + * you want. 62 + * 63 + * @public @memberof m_relation_history 40 64 */ 41 - void 65 + enum m_relation_history_result 42 66 m_relation_history_get(struct m_relation_history *rh, struct xrt_space_relation *out_relation, uint64_t at_time_ns); 43 67 44 68 /*! 45 69 * Destroys an opaque relation_history object. 46 70 * 47 - * @ingroup aux_util 71 + * @public @memberof m_relation_history 48 72 */ 49 73 void 50 74 m_relation_history_destroy(struct m_relation_history **rh);