summaryrefslogtreecommitdiff
path: root/servers/arvr/arvr_positional_tracker.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-08-03 13:34:14 +0200
committerGitHub <noreply@github.com>2017-08-03 13:34:14 +0200
commitc51354f504a7892483fdce721d720aada4c53671 (patch)
tree14bc6ebac9bcc60beaa6e86efca40e093a7216b5 /servers/arvr/arvr_positional_tracker.cpp
parent0257ced05bf85fdd727f4c68a6ddf4c5c1876694 (diff)
parente7aed24adde416bc0fad058ee35b9ce3dfe00c10 (diff)
Merge pull request #10062 from BastiaanOlij/arvr_add_anchor
Added ARVRAnchor support and a few small enhancements
Diffstat (limited to 'servers/arvr/arvr_positional_tracker.cpp')
-rw-r--r--servers/arvr/arvr_positional_tracker.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp
index 4215363d16..9f3d01267b 100644
--- a/servers/arvr/arvr_positional_tracker.cpp
+++ b/servers/arvr/arvr_positional_tracker.cpp
@@ -40,6 +40,13 @@ void ARVRPositionalTracker::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_tracks_position"), &ARVRPositionalTracker::get_tracks_position);
ClassDB::bind_method(D_METHOD("get_position"), &ARVRPositionalTracker::get_position);
ClassDB::bind_method(D_METHOD("get_transform", "adjust_by_reference_frame"), &ARVRPositionalTracker::get_transform);
+
+ // these functions we don't want to expose to normal users but do need to be callable from GDNative
+ ClassDB::bind_method(D_METHOD("_set_type", "type"), &ARVRPositionalTracker::set_type);
+ ClassDB::bind_method(D_METHOD("_set_name", "name"), &ARVRPositionalTracker::set_name);
+ ClassDB::bind_method(D_METHOD("_set_joy_id", "joy_id"), &ARVRPositionalTracker::set_joy_id);
+ ClassDB::bind_method(D_METHOD("_set_orientation", "orientation"), &ARVRPositionalTracker::set_orientation);
+ ClassDB::bind_method(D_METHOD("_set_rw_position", "rw_position"), &ARVRPositionalTracker::set_rw_position);
};
void ARVRPositionalTracker::set_type(ARVRServer::TrackerType p_type) {
@@ -102,14 +109,36 @@ bool ARVRPositionalTracker::get_tracks_position() const {
void ARVRPositionalTracker::set_position(const Vector3 &p_position) {
_THREAD_SAFE_METHOD_
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+ real_t world_scale = arvr_server->get_world_scale();
+ ERR_FAIL_COND(world_scale == 0);
+
tracks_position = true; // obviously we have this
- position = p_position;
+ rw_position = p_position / world_scale;
};
Vector3 ARVRPositionalTracker::get_position() const {
_THREAD_SAFE_METHOD_
- return position;
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, rw_position);
+ real_t world_scale = arvr_server->get_world_scale();
+
+ return rw_position * world_scale;
+};
+
+void ARVRPositionalTracker::set_rw_position(const Vector3 &p_rw_position) {
+ _THREAD_SAFE_METHOD_
+
+ tracks_position = true; // obviously we have this
+ rw_position = p_rw_position;
+};
+
+Vector3 ARVRPositionalTracker::get_rw_position() const {
+ _THREAD_SAFE_METHOD_
+
+ return rw_position;
};
Transform ARVRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const {