openxr_spatial_entities.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. /**************************************************************************/
  2. /* openxr_spatial_entities.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "openxr_spatial_entities.h"
  31. #include "../../openxr_api.h"
  32. #include "core/variant/native_ptr.h"
  33. #include "openxr_spatial_entity_extension.h"
  34. ////////////////////////////////////////////////////////////////////////////
  35. // OpenXRSpatialCapabilityConfigurationBaseHeader
  36. void OpenXRSpatialCapabilityConfigurationBaseHeader::_bind_methods() {
  37. ClassDB::bind_method(D_METHOD("has_valid_configuration"), &OpenXRSpatialCapabilityConfigurationBaseHeader::has_valid_configuration);
  38. GDVIRTUAL_BIND(_has_valid_configuration);
  39. GDVIRTUAL_BIND(_get_configuration);
  40. }
  41. bool OpenXRSpatialCapabilityConfigurationBaseHeader::has_valid_configuration() const {
  42. bool is_valid = false;
  43. if (GDVIRTUAL_CALL(_has_valid_configuration, is_valid)) {
  44. return is_valid;
  45. }
  46. return false;
  47. }
  48. XrSpatialCapabilityConfigurationBaseHeaderEXT *OpenXRSpatialCapabilityConfigurationBaseHeader::get_configuration() {
  49. uint64_t pointer = 0;
  50. if (GDVIRTUAL_CALL(_get_configuration, pointer)) {
  51. return reinterpret_cast<XrSpatialCapabilityConfigurationBaseHeaderEXT *>(pointer);
  52. }
  53. return nullptr;
  54. }
  55. ////////////////////////////////////////////////////////////////////////////
  56. // OpenXRSpatialEntityTracker
  57. void OpenXRSpatialEntityTracker::_bind_methods() {
  58. ClassDB::bind_method(D_METHOD("set_entity", "entity"), &OpenXRSpatialEntityTracker::set_entity);
  59. ClassDB::bind_method(D_METHOD("get_entity"), &OpenXRSpatialEntityTracker::get_entity);
  60. ADD_PROPERTY(PropertyInfo(Variant::RID, "entity"), "set_entity", "get_entity");
  61. ClassDB::bind_method(D_METHOD("set_spatial_tracking_state", "spatial_tracking_state"), &OpenXRSpatialEntityTracker::_set_spatial_tracking_state);
  62. ClassDB::bind_method(D_METHOD("get_spatial_tracking_state"), &OpenXRSpatialEntityTracker::_get_spatial_tracking_state);
  63. ADD_PROPERTY(PropertyInfo(Variant::INT, "spatial_tracking_state"), "set_spatial_tracking_state", "get_spatial_tracking_state");
  64. ADD_SIGNAL(MethodInfo("spatial_tracking_state_changed", PropertyInfo(Variant::INT, "spatial_tracking_state")));
  65. BIND_ENUM_CONSTANT(ENTITY_TRACKING_STATE_STOPPED);
  66. BIND_ENUM_CONSTANT(ENTITY_TRACKING_STATE_PAUSED);
  67. BIND_ENUM_CONSTANT(ENTITY_TRACKING_STATE_TRACKING);
  68. }
  69. OpenXRSpatialEntityTracker::OpenXRSpatialEntityTracker() {
  70. set_tracker_type(XRServer::TrackerType::TRACKER_ANCHOR);
  71. }
  72. OpenXRSpatialEntityTracker::~OpenXRSpatialEntityTracker() {
  73. if (spatial_entity.is_valid()) {
  74. OpenXRSpatialEntityExtension *se_extension = OpenXRSpatialEntityExtension::get_singleton();
  75. if (se_extension) {
  76. se_extension->free_spatial_entity(spatial_entity);
  77. spatial_entity = RID();
  78. }
  79. }
  80. }
  81. void OpenXRSpatialEntityTracker::set_entity(const RID &p_entity) {
  82. if (spatial_entity.is_valid()) {
  83. if (spatial_entity == p_entity) {
  84. return;
  85. }
  86. OpenXRSpatialEntityExtension *se_extension = OpenXRSpatialEntityExtension::get_singleton();
  87. if (se_extension) {
  88. se_extension->free_spatial_entity(spatial_entity);
  89. spatial_entity = RID();
  90. }
  91. }
  92. spatial_entity = p_entity;
  93. if (p_entity.is_valid()) {
  94. OpenXRSpatialEntityExtension *se_extension = OpenXRSpatialEntityExtension::get_singleton();
  95. ERR_FAIL_NULL(se_extension);
  96. XrSpatialEntityIdEXT entity_id = se_extension->get_spatial_entity_id(p_entity);
  97. String tracker_name = String("openxr/spatial_entity/") + String::num_int64(entity_id);
  98. set_tracker_name(tracker_name);
  99. } else {
  100. set_tracker_name("openxr/spatial_entity/null");
  101. }
  102. }
  103. RID OpenXRSpatialEntityTracker::get_entity() const {
  104. return spatial_entity;
  105. }
  106. void OpenXRSpatialEntityTracker::set_spatial_tracking_state(const XrSpatialEntityTrackingStateEXT p_state) {
  107. if (spatial_tracking_state != p_state) {
  108. spatial_tracking_state = p_state;
  109. emit_signal(SNAME("spatial_tracking_state_changed"), spatial_tracking_state);
  110. }
  111. }
  112. void OpenXRSpatialEntityTracker::_set_spatial_tracking_state(const EntityTrackingState p_state) {
  113. set_spatial_tracking_state((XrSpatialEntityTrackingStateEXT)p_state);
  114. }
  115. XrSpatialEntityTrackingStateEXT OpenXRSpatialEntityTracker::get_spatial_tracking_state() const {
  116. return spatial_tracking_state;
  117. }
  118. OpenXRSpatialEntityTracker::EntityTrackingState OpenXRSpatialEntityTracker::_get_spatial_tracking_state() const {
  119. return (EntityTrackingState)get_spatial_tracking_state();
  120. }
  121. ////////////////////////////////////////////////////////////////////////////
  122. // OpenXRSpatialComponentData
  123. void OpenXRSpatialComponentData::_bind_methods() {
  124. ClassDB::bind_method(D_METHOD("set_capacity", "capacity"), &OpenXRSpatialComponentData::set_capacity);
  125. GDVIRTUAL_BIND(_set_capacity, "capacity");
  126. GDVIRTUAL_BIND(_get_component_type);
  127. GDVIRTUAL_BIND(_get_structure_data, "next");
  128. }
  129. void OpenXRSpatialComponentData::set_capacity(uint32_t p_capacity) {
  130. GDVIRTUAL_CALL(_set_capacity, p_capacity);
  131. }
  132. XrSpatialComponentTypeEXT OpenXRSpatialComponentData::get_component_type() const {
  133. uint64_t component_type = XR_SPATIAL_COMPONENT_TYPE_MAX_ENUM_EXT;
  134. if (GDVIRTUAL_CALL(_get_component_type, component_type)) {
  135. return (XrSpatialComponentTypeEXT)component_type;
  136. }
  137. return XR_SPATIAL_COMPONENT_TYPE_MAX_ENUM_EXT;
  138. }
  139. void *OpenXRSpatialComponentData::get_structure_data(void *p_next) {
  140. uint64_t pointer = 0;
  141. if (GDVIRTUAL_CALL(_get_structure_data, (uint64_t)p_next, pointer)) {
  142. return reinterpret_cast<void *>(pointer);
  143. }
  144. return p_next;
  145. }
  146. ////////////////////////////////////////////////////////////////////////////
  147. // Spatial component bounded2d list
  148. void OpenXRSpatialComponentBounded2DList::_bind_methods() {
  149. ClassDB::bind_method(D_METHOD("get_center_pose", "index"), &OpenXRSpatialComponentBounded2DList::get_center_pose);
  150. ClassDB::bind_method(D_METHOD("get_size", "index"), &OpenXRSpatialComponentBounded2DList::get_size);
  151. }
  152. void OpenXRSpatialComponentBounded2DList::set_capacity(uint32_t p_capacity) {
  153. bounded2d_data.resize(p_capacity);
  154. bounded2d_list.boundCount = uint32_t(bounded2d_data.size());
  155. bounded2d_list.bounds = bounded2d_data.ptrw();
  156. }
  157. XrSpatialComponentTypeEXT OpenXRSpatialComponentBounded2DList::get_component_type() const {
  158. return XR_SPATIAL_COMPONENT_TYPE_BOUNDED_2D_EXT;
  159. }
  160. void *OpenXRSpatialComponentBounded2DList::get_structure_data(void *p_next) {
  161. bounded2d_list.next = p_next;
  162. return &bounded2d_list;
  163. }
  164. Transform3D OpenXRSpatialComponentBounded2DList::get_center_pose(int64_t p_index) const {
  165. ERR_FAIL_INDEX_V(p_index, bounded2d_data.size(), Transform3D());
  166. OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
  167. ERR_FAIL_NULL_V(openxr_api, Transform3D());
  168. return openxr_api->transform_from_pose(bounded2d_data[p_index].center);
  169. }
  170. Vector2 OpenXRSpatialComponentBounded2DList::get_size(int64_t p_index) const {
  171. ERR_FAIL_INDEX_V(p_index, bounded2d_data.size(), Vector2());
  172. OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
  173. ERR_FAIL_NULL_V(openxr_api, Vector2());
  174. const XrExtent2Df &extents = bounded2d_data[p_index].extents;
  175. return Vector2(extents.width, extents.height);
  176. }
  177. ////////////////////////////////////////////////////////////////////////////
  178. // Spatial component bounded3d list
  179. void OpenXRSpatialComponentBounded3DList::_bind_methods() {
  180. ClassDB::bind_method(D_METHOD("get_center_pose", "index"), &OpenXRSpatialComponentBounded3DList::get_center_pose);
  181. ClassDB::bind_method(D_METHOD("get_size", "index"), &OpenXRSpatialComponentBounded3DList::get_size);
  182. }
  183. void OpenXRSpatialComponentBounded3DList::set_capacity(uint32_t p_capacity) {
  184. bounded3d_data.resize(p_capacity);
  185. bounded3d_list.boundCount = uint32_t(bounded3d_data.size());
  186. bounded3d_list.bounds = bounded3d_data.ptrw();
  187. }
  188. XrSpatialComponentTypeEXT OpenXRSpatialComponentBounded3DList::get_component_type() const {
  189. return XR_SPATIAL_COMPONENT_TYPE_BOUNDED_3D_EXT;
  190. }
  191. void *OpenXRSpatialComponentBounded3DList::get_structure_data(void *p_next) {
  192. bounded3d_list.next = p_next;
  193. return &bounded3d_list;
  194. }
  195. Transform3D OpenXRSpatialComponentBounded3DList::get_center_pose(int64_t p_index) const {
  196. ERR_FAIL_INDEX_V(p_index, bounded3d_data.size(), Transform3D());
  197. OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
  198. ERR_FAIL_NULL_V(openxr_api, Transform3D());
  199. return openxr_api->transform_from_pose(bounded3d_data[p_index].center);
  200. }
  201. Vector3 OpenXRSpatialComponentBounded3DList::get_size(int64_t p_index) const {
  202. ERR_FAIL_INDEX_V(p_index, bounded3d_data.size(), Vector3());
  203. OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
  204. ERR_FAIL_NULL_V(openxr_api, Vector3());
  205. const XrExtent3Df &extents = bounded3d_data[p_index].extents;
  206. return Vector3(extents.width, extents.height, extents.depth);
  207. }
  208. ////////////////////////////////////////////////////////////////////////////
  209. // Spatial component parent list
  210. void OpenXRSpatialComponentParentList::_bind_methods() {
  211. ClassDB::bind_method(D_METHOD("get_parent", "index"), &OpenXRSpatialComponentParentList::get_parent);
  212. }
  213. void OpenXRSpatialComponentParentList::set_capacity(uint32_t p_capacity) {
  214. parent_data.resize(p_capacity);
  215. parent_list.parentCount = uint32_t(parent_data.size());
  216. parent_list.parents = parent_data.ptrw();
  217. }
  218. XrSpatialComponentTypeEXT OpenXRSpatialComponentParentList::get_component_type() const {
  219. return XR_SPATIAL_COMPONENT_TYPE_PARENT_EXT;
  220. }
  221. void *OpenXRSpatialComponentParentList::get_structure_data(void *p_next) {
  222. parent_list.next = p_next;
  223. return &parent_list;
  224. }
  225. RID OpenXRSpatialComponentParentList::get_parent(int64_t p_index) const {
  226. ERR_FAIL_INDEX_V(p_index, parent_data.size(), RID());
  227. OpenXRSpatialEntityExtension *se_extension = OpenXRSpatialEntityExtension::get_singleton();
  228. ERR_FAIL_NULL_V(se_extension, RID());
  229. return se_extension->find_spatial_entity(parent_data[p_index]);
  230. }
  231. ////////////////////////////////////////////////////////////////////////////
  232. // Spatial component mesh2d list
  233. void OpenXRSpatialComponentMesh2DList::_bind_methods() {
  234. ClassDB::bind_method(D_METHOD("get_transform", "index"), &OpenXRSpatialComponentMesh2DList::get_transform);
  235. ClassDB::bind_method(D_METHOD("get_vertices", "snapshot", "index"), &OpenXRSpatialComponentMesh2DList::get_vertices);
  236. ClassDB::bind_method(D_METHOD("get_indices", "snapshot", "index"), &OpenXRSpatialComponentMesh2DList::get_indices);
  237. }
  238. void OpenXRSpatialComponentMesh2DList::set_capacity(uint32_t p_capacity) {
  239. mesh2d_data.resize(p_capacity);
  240. mesh2d_list.meshCount = uint32_t(mesh2d_data.size());
  241. mesh2d_list.meshes = mesh2d_data.ptrw();
  242. }
  243. XrSpatialComponentTypeEXT OpenXRSpatialComponentMesh2DList::get_component_type() const {
  244. return XR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXT;
  245. }
  246. void *OpenXRSpatialComponentMesh2DList::get_structure_data(void *p_next) {
  247. mesh2d_list.next = p_next;
  248. return &mesh2d_list;
  249. }
  250. Transform3D OpenXRSpatialComponentMesh2DList::get_transform(int64_t p_index) const {
  251. ERR_FAIL_INDEX_V(p_index, mesh2d_data.size(), Transform3D());
  252. OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
  253. ERR_FAIL_NULL_V(openxr_api, Transform3D());
  254. return openxr_api->transform_from_pose(mesh2d_data[p_index].origin);
  255. }
  256. PackedVector2Array OpenXRSpatialComponentMesh2DList::get_vertices(RID p_snapshot, int64_t p_index) const {
  257. ERR_FAIL_INDEX_V(p_index, mesh2d_data.size(), PackedVector2Array());
  258. const XrSpatialBufferEXT &buffer = mesh2d_data[p_index].vertexBuffer;
  259. if (buffer.bufferId == XR_NULL_SPATIAL_BUFFER_ID_EXT) {
  260. // We don't have data (yet).
  261. return PackedVector2Array();
  262. }
  263. ERR_FAIL_COND_V(buffer.bufferType != XR_SPATIAL_BUFFER_TYPE_VECTOR2F_EXT, PackedVector2Array());
  264. OpenXRSpatialEntityExtension *se_extension = OpenXRSpatialEntityExtension::get_singleton();
  265. ERR_FAIL_NULL_V(se_extension, PackedVector2Array());
  266. return se_extension->get_vector2_buffer(p_snapshot, buffer.bufferId);
  267. }
  268. PackedInt32Array OpenXRSpatialComponentMesh2DList::get_indices(RID p_snapshot, int64_t p_index) const {
  269. ERR_FAIL_INDEX_V(p_index, mesh2d_data.size(), PackedInt32Array());
  270. const XrSpatialBufferEXT &buffer = mesh2d_data[p_index].indexBuffer;
  271. if (buffer.bufferId == XR_NULL_SPATIAL_BUFFER_ID_EXT) {
  272. // We don't have data (yet).
  273. return PackedInt32Array();
  274. }
  275. OpenXRSpatialEntityExtension *se_extension = OpenXRSpatialEntityExtension::get_singleton();
  276. ERR_FAIL_NULL_V(se_extension, PackedInt32Array());
  277. PackedInt32Array ret;
  278. switch (buffer.bufferType) {
  279. case XR_SPATIAL_BUFFER_TYPE_UINT8_EXT: {
  280. PackedByteArray data = se_extension->get_uint8_buffer(p_snapshot, buffer.bufferId);
  281. ret.resize(data.size());
  282. int count = ret.size();
  283. int32_t *ptr = ret.ptrw();
  284. for (int i = 0; i < count; i++) {
  285. ptr[i] = data[i];
  286. }
  287. } break;
  288. case XR_SPATIAL_BUFFER_TYPE_UINT16_EXT: {
  289. Vector<uint16_t> data = se_extension->get_uint16_buffer(p_snapshot, buffer.bufferId);
  290. ret.resize(data.size());
  291. int count = ret.size();
  292. int32_t *ptr = ret.ptrw();
  293. for (int i = 0; i < count; i++) {
  294. ptr[i] = data[i];
  295. }
  296. } break;
  297. case XR_SPATIAL_BUFFER_TYPE_UINT32_EXT: {
  298. Vector<uint32_t> data = se_extension->get_uint32_buffer(p_snapshot, buffer.bufferId);
  299. ret.resize(data.size());
  300. int count = ret.size();
  301. int32_t *ptr = ret.ptrw();
  302. for (int i = 0; i < count; i++) {
  303. ptr[i] = data[i];
  304. }
  305. } break;
  306. default: {
  307. ERR_FAIL_V_MSG(PackedInt32Array(), "OpenXR: Unsupported buffer type for indices.");
  308. } break;
  309. }
  310. return ret;
  311. }
  312. ////////////////////////////////////////////////////////////////////////////
  313. // Spatial component mesh3d list
  314. void OpenXRSpatialComponentMesh3DList::_bind_methods() {
  315. ClassDB::bind_method(D_METHOD("get_transform", "index"), &OpenXRSpatialComponentMesh3DList::get_transform);
  316. ClassDB::bind_method(D_METHOD("get_mesh", "index"), &OpenXRSpatialComponentMesh3DList::get_mesh);
  317. }
  318. void OpenXRSpatialComponentMesh3DList::set_capacity(uint32_t p_capacity) {
  319. mesh3d_data.resize(p_capacity);
  320. mesh3d_list.meshCount = uint32_t(mesh3d_data.size());
  321. mesh3d_list.meshes = mesh3d_data.ptrw();
  322. }
  323. XrSpatialComponentTypeEXT OpenXRSpatialComponentMesh3DList::get_component_type() const {
  324. return XR_SPATIAL_COMPONENT_TYPE_MESH_3D_EXT;
  325. }
  326. void *OpenXRSpatialComponentMesh3DList::get_structure_data(void *p_next) {
  327. mesh3d_list.next = p_next;
  328. return &mesh3d_list;
  329. }
  330. Transform3D OpenXRSpatialComponentMesh3DList::get_transform(int64_t p_index) const {
  331. ERR_FAIL_INDEX_V(p_index, mesh3d_data.size(), Transform3D());
  332. OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
  333. ERR_FAIL_NULL_V(openxr_api, Transform3D());
  334. return openxr_api->transform_from_pose(mesh3d_data[p_index].origin);
  335. }
  336. Ref<Mesh> OpenXRSpatialComponentMesh3DList::get_mesh(int64_t p_index) const {
  337. ERR_FAIL_INDEX_V(p_index, mesh3d_data.size(), nullptr);
  338. // TODO implement, need to convert mesh data to Godot mesh resource
  339. return nullptr;
  340. }
  341. ////////////////////////////////////////////////////////////////////////////
  342. // OpenXRSpatialQueryResultData
  343. void OpenXRSpatialQueryResultData::_bind_methods() {
  344. ClassDB::bind_method(D_METHOD("get_capacity"), &OpenXRSpatialQueryResultData::get_capacity);
  345. ClassDB::bind_method(D_METHOD("get_entity_id", "index"), &OpenXRSpatialQueryResultData::_get_entity_id);
  346. ClassDB::bind_method(D_METHOD("get_entity_state", "index"), &OpenXRSpatialQueryResultData::_get_entity_state);
  347. }
  348. void OpenXRSpatialQueryResultData::set_capacity(uint32_t p_capacity) {
  349. entity_ids.resize(p_capacity);
  350. entity_states.resize(p_capacity);
  351. query_result.entityIdCapacityInput = entity_ids.size();
  352. query_result.entityIds = entity_ids.ptrw();
  353. query_result.entityStateCapacityInput = entity_states.size();
  354. query_result.entityStates = entity_states.ptrw();
  355. }
  356. XrSpatialComponentTypeEXT OpenXRSpatialQueryResultData::get_component_type() const {
  357. // This component is always included and has no type.
  358. return XR_SPATIAL_COMPONENT_TYPE_MAX_ENUM_EXT;
  359. }
  360. void *OpenXRSpatialQueryResultData::get_structure_data(void *p_next) {
  361. query_result.next = p_next;
  362. query_result.entityIdCountOutput = 0;
  363. query_result.entityStateCountOutput = 0;
  364. return &query_result;
  365. }
  366. XrSpatialEntityIdEXT OpenXRSpatialQueryResultData::get_entity_id(int64_t p_index) const {
  367. ERR_FAIL_INDEX_V(p_index, entity_ids.size(), XR_NULL_ENTITY);
  368. return entity_ids[p_index];
  369. }
  370. uint64_t OpenXRSpatialQueryResultData::_get_entity_id(int64_t p_index) const {
  371. return (uint64_t)get_entity_id(p_index);
  372. }
  373. XrSpatialEntityTrackingStateEXT OpenXRSpatialQueryResultData::get_entity_state(int64_t p_index) const {
  374. ERR_FAIL_INDEX_V(p_index, entity_states.size(), XR_SPATIAL_ENTITY_TRACKING_STATE_MAX_ENUM_EXT);
  375. return entity_states[p_index];
  376. }
  377. OpenXRSpatialEntityTracker::EntityTrackingState OpenXRSpatialQueryResultData::_get_entity_state(int64_t p_index) const {
  378. return (OpenXRSpatialEntityTracker::EntityTrackingState)get_entity_state(p_index);
  379. }
  380. String OpenXRSpatialQueryResultData::get_entity_tracking_state_name(XrSpatialEntityTrackingStateEXT p_tracking_state) {
  381. XR_ENUM_SWITCH(XrSpatialEntityTrackingStateEXT, p_tracking_state)
  382. }