diff options
| author | Bastiaan Olij | 2017-12-21 23:10:44 +1100 |
|---|---|---|
| committer | Bastiaan Olij | 2017-12-22 01:21:23 +1100 |
| commit | 6fd51b6a1b1467937126334f9ffd7be3d3efbad0 (patch) | |
| tree | 94407961212ff31a74db0514c3040ea35a780100 /servers/arvr | |
| parent | b068961c8fe51daa388cfd14021712b00fd9aec7 (diff) | |
| download | godot-6fd51b6a1b1467937126334f9ffd7be3d3efbad0.tar.gz godot-6fd51b6a1b1467937126334f9ffd7be3d3efbad0.tar.zst godot-6fd51b6a1b1467937126334f9ffd7be3d3efbad0.zip | |
Reserved controller ids 1 and 2 for left and right hand controllers and added new center on hmd option
Diffstat (limited to 'servers/arvr')
| -rw-r--r-- | servers/arvr/arvr_positional_tracker.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp index fc0270615..fb97d5b86 100644 --- a/servers/arvr/arvr_positional_tracker.cpp +++ b/servers/arvr/arvr_positional_tracker.cpp @@ -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 { |
