Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/openxr/openxr_structure.cpp
11322 views
1
/**************************************************************************/
2
/* openxr_structure.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
31
#include "openxr_structure.h"
32
33
void OpenXRStructureBase::_bind_methods() {
34
ClassDB::bind_method(D_METHOD("get_structure_type"), &OpenXRStructureBase::_get_structure_type);
35
36
ClassDB::bind_method(D_METHOD("set_next", "entity"), &OpenXRStructureBase::set_next);
37
ClassDB::bind_method(D_METHOD("get_next"), &OpenXRStructureBase::get_next);
38
39
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next", PROPERTY_HINT_RESOURCE_TYPE, "OpenXRStructureBase"), "set_next", "get_next");
40
41
GDVIRTUAL_BIND(_get_header, "next");
42
}
43
44
void OpenXRStructureBase::set_next(const Ref<OpenXRStructureBase> p_next) {
45
next = p_next;
46
}
47
48
Ref<OpenXRStructureBase> OpenXRStructureBase::get_next() const {
49
return next;
50
}
51
52
void *OpenXRStructureBase::get_header(void *p_next) {
53
void *n = p_next;
54
if (get_next().is_valid()) {
55
n = get_next()->get_header(p_next);
56
}
57
58
uint64_t pointer = 0;
59
60
if (GDVIRTUAL_CALL(_get_header, (uint64_t)n, pointer)) {
61
return reinterpret_cast<void *>(pointer);
62
}
63
64
return n;
65
}
66
67
XrStructureType OpenXRStructureBase::get_structure_type() {
68
// By default we call get_header to get the structure type so we have a guaranteed implementation.
69
70
// The first member of our header is always the structure type, so this works:
71
XrStructureType *header = (XrStructureType *)get_header();
72
if (header == nullptr) {
73
// Header can return nullptr for valid reasons, so we do not error here!
74
return XR_TYPE_UNKNOWN;
75
} else {
76
return *header;
77
}
78
}
79
80
// Return structure type as uint64_t to GDScript
81
uint64_t OpenXRStructureBase::_get_structure_type() {
82
return (uint64_t)get_structure_type();
83
}
84
85