summaryrefslogtreecommitdiff
path: root/servers/arvr/arvr_positional_tracker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/arvr/arvr_positional_tracker.cpp')
-rw-r--r--servers/arvr/arvr_positional_tracker.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp
index fc0270615c..08b5bab641 100644
--- a/servers/arvr/arvr_positional_tracker.cpp
+++ b/servers/arvr/arvr_positional_tracker.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -62,13 +62,15 @@ void ARVRPositionalTracker::_bind_methods() {
void ARVRPositionalTracker::set_type(ARVRServer::TrackerType p_type) {
if (type != p_type) {
type = p_type;
+ hand = ARVRPositionalTracker::TRACKER_HAND_UNKNOWN;
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
// get a tracker id for our type
+ // note if this is a controller this will be 3 or higher but we may change it later.
tracker_id = arvr_server->get_free_tracker_id_for_type(p_type);
- }
+ };
};
ARVRServer::TrackerType ARVRPositionalTracker::get_type() const {
@@ -156,7 +158,24 @@ ARVRPositionalTracker::TrackerHand ARVRPositionalTracker::get_hand() const {
};
void ARVRPositionalTracker::set_hand(const ARVRPositionalTracker::TrackerHand p_hand) {
- hand = p_hand;
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ if (hand != p_hand) {
+ // we can only set this if we've previously set this to be a controller!!
+ ERR_FAIL_COND((type != ARVRServer::TRACKER_CONTROLLER) && (p_hand != ARVRPositionalTracker::TRACKER_HAND_UNKNOWN));
+
+ hand = p_hand;
+ if (hand == ARVRPositionalTracker::TRACKER_LEFT_HAND) {
+ if (!arvr_server->is_tracker_id_in_use_for_type(type, 1)) {
+ tracker_id = 1;
+ };
+ } else if (hand == ARVRPositionalTracker::TRACKER_RIGHT_HAND) {
+ if (!arvr_server->is_tracker_id_in_use_for_type(type, 2)) {
+ tracker_id = 2;
+ };
+ };
+ };
};
Transform ARVRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const {