The open source OpenXR runtime
0
fork

Configure Feed

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

a/math: Extend m_relation_history to pass the tests.

authored by

Ryan Pavlik and committed by
Jakob Bornecrantz
2b64e5b9 217dee2c

+20 -3
+20 -3
src/xrt/auxiliary/math/m_relation_history.cpp
··· 87 87 os_mutex_lock(&rh->mutex); 88 88 m_relation_history_result ret = M_RELATION_HISTORY_RESULT_INVALID; 89 89 90 - if (rh->has_first_sample == 0) { 90 + if (rh->has_first_sample == 0 || at_timestamp_ns == 0) { 91 91 // Do nothing. You push nothing to the buffer you get nothing from the buffer. 92 92 goto end; 93 93 } ··· 156 156 idx -= step; 157 157 continue; 158 158 } 159 + if (ts_before == at_timestamp_ns || ts_after == at_timestamp_ns) { 160 + // exact match 161 + break; 162 + } 159 163 if ((ts_before < at_timestamp_ns) && (ts_after > at_timestamp_ns)) { 160 - // Found what we're looking for - at_timestamp_ns is between the reading before us and 161 - // the reading after us. Break out of the loop 164 + // Found what we're looking for - at_timestamp_ns is between the reading before 165 + // us and the reading after us. Break out of the loop 162 166 break; 163 167 } 164 168 ··· 181 185 // Do the thing. 182 186 struct xrt_space_relation before = rh->impl[idx]->relation; 183 187 struct xrt_space_relation after = rh->impl[idx - 1]->relation; 188 + 189 + if (rh->impl[idx]->timestamp == at_timestamp_ns) { 190 + // exact match: before 191 + *out_relation = before; 192 + ret = M_RELATION_HISTORY_RESULT_EXACT; 193 + goto end; 194 + } 195 + if (rh->impl[idx - 1]->timestamp == at_timestamp_ns) { 196 + // exact match: after 197 + *out_relation = after; 198 + ret = M_RELATION_HISTORY_RESULT_EXACT; 199 + goto end; 200 + } 184 201 int64_t diff_before, diff_after = 0; 185 202 diff_before = at_timestamp_ns - rh->impl[idx]->timestamp; 186 203 diff_after = rh->impl[idx - 1]->timestamp - at_timestamp_ns;