Add Quest offsets for palm
This commit is contained in:
@@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
#include "android/battery.h"
|
#include "android/battery.h"
|
||||||
#include "android/jnipp.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using tid = to_headset::tracking_control::id;
|
using tid = to_headset::tracking_control::id;
|
||||||
@@ -169,6 +168,32 @@ static T & from_pool(std::vector<T> & container, std::vector<T> & pool)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static xr::spaces device_to_space(device_id id)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case device_id::HEAD:
|
||||||
|
return xr::spaces::view;
|
||||||
|
case device_id::EYE_GAZE:
|
||||||
|
return xr::spaces::eye_gaze;
|
||||||
|
case device_id::LEFT_AIM:
|
||||||
|
return xr::spaces::aim_left;
|
||||||
|
case device_id::LEFT_GRIP:
|
||||||
|
return xr::spaces::grip_left;
|
||||||
|
case device_id::LEFT_PALM:
|
||||||
|
return xr::spaces::palm_left;
|
||||||
|
case device_id::RIGHT_AIM:
|
||||||
|
return xr::spaces::aim_right;
|
||||||
|
case device_id::RIGHT_GRIP:
|
||||||
|
return xr::spaces::grip_right;
|
||||||
|
case device_id::RIGHT_PALM:
|
||||||
|
return xr::spaces::palm_right;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
__builtin_unreachable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void scenes::stream::tracking()
|
void scenes::stream::tracking()
|
||||||
{
|
{
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
@@ -179,17 +204,20 @@ void scenes::stream::tracking()
|
|||||||
const XrDuration battery_check_interval = 30'000'000'000; // 30s
|
const XrDuration battery_check_interval = 30'000'000'000; // 30s
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<std::pair<device_id, XrSpace>> spaces = {
|
std::vector<std::pair<device_id, XrSpace>> spaces;
|
||||||
{device_id::HEAD, application::space(xr::spaces::view)},
|
for (auto id: {
|
||||||
{device_id::LEFT_AIM, application::space(xr::spaces::aim_left)},
|
device_id::HEAD,
|
||||||
{device_id::LEFT_GRIP, application::space(xr::spaces::grip_left)},
|
device_id::LEFT_AIM,
|
||||||
{device_id::RIGHT_AIM, application::space(xr::spaces::aim_right)},
|
device_id::LEFT_GRIP,
|
||||||
{device_id::RIGHT_GRIP, application::space(xr::spaces::grip_right)}};
|
device_id::LEFT_PALM,
|
||||||
|
device_id::RIGHT_AIM,
|
||||||
if (XrSpace palm = application::space(xr::spaces::palm_left))
|
device_id::RIGHT_GRIP,
|
||||||
spaces.emplace_back(device_id::LEFT_PALM, palm);
|
device_id::RIGHT_PALM,
|
||||||
if (XrSpace palm = application::space(xr::spaces::palm_right))
|
})
|
||||||
spaces.emplace_back(device_id::RIGHT_PALM, palm);
|
{
|
||||||
|
if (XrSpace space = application::space(device_to_space(id)))
|
||||||
|
spaces.emplace_back(id, space);
|
||||||
|
}
|
||||||
|
|
||||||
const auto & config = application::get_config();
|
const auto & config = application::get_config();
|
||||||
|
|
||||||
@@ -423,51 +451,92 @@ void scenes::stream::operator()(to_headset::tracking_control && packet)
|
|||||||
tracking_control.min_offset = std::min(tracking_control.min_offset, tracking_control.max_offset);
|
tracking_control.min_offset = std::min(tracking_control.min_offset, tracking_control.max_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static device_id derived_from(device_id target)
|
||||||
|
{
|
||||||
|
switch (target)
|
||||||
|
{
|
||||||
|
case device_id::LEFT_AIM:
|
||||||
|
case device_id::LEFT_PALM:
|
||||||
|
return device_id::LEFT_GRIP;
|
||||||
|
case device_id::RIGHT_AIM:
|
||||||
|
case device_id::RIGHT_PALM:
|
||||||
|
return device_id::RIGHT_GRIP;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
__builtin_unreachable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void scenes::stream::on_interaction_profile_changed(const XrEventDataInteractionProfileChanged &)
|
void scenes::stream::on_interaction_profile_changed(const XrEventDataInteractionProfileChanged &)
|
||||||
{
|
{
|
||||||
auto now = instance.now();
|
auto now = instance.now();
|
||||||
for (auto [target, space]: {
|
for (device_id target: {
|
||||||
std::tuple{device_id::LEFT_AIM, application::space(xr::spaces::aim_left)},
|
device_id::LEFT_AIM,
|
||||||
{device_id::LEFT_PALM, application::space(xr::spaces::palm_left)},
|
device_id::LEFT_PALM,
|
||||||
{device_id::RIGHT_AIM, application::space(xr::spaces::aim_right)},
|
device_id::RIGHT_AIM,
|
||||||
{device_id::RIGHT_PALM, application::space(xr::spaces::palm_right)},
|
device_id::RIGHT_PALM,
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
device_id source;
|
auto source = derived_from(target);
|
||||||
XrSpace source_space = XR_NULL_HANDLE;
|
auto source_space = application::space(device_to_space(source));
|
||||||
switch (target)
|
auto target_space = application::space(device_to_space(target));
|
||||||
{
|
|
||||||
case device_id::LEFT_AIM:
|
|
||||||
case device_id::LEFT_PALM:
|
|
||||||
source = device_id::LEFT_GRIP;
|
|
||||||
source_space = application::space(xr::spaces::grip_left);
|
|
||||||
break;
|
|
||||||
case device_id::RIGHT_AIM:
|
|
||||||
case device_id::RIGHT_PALM:
|
|
||||||
source = device_id::RIGHT_GRIP;
|
|
||||||
source_space = application::space(xr::spaces::grip_right);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (not(source_space and space))
|
|
||||||
continue;
|
|
||||||
auto pose = locate_space(target, space, source_space, now);
|
|
||||||
|
|
||||||
if (pose.flags & from_headset::tracking::position_valid and pose.flags & from_headset::tracking::orientation_valid)
|
if (not(source_space and target_space))
|
||||||
{
|
{
|
||||||
network_session->send_control(from_headset::derived_pose{
|
// This may happen if the runtime does not support palm ext
|
||||||
.source = source,
|
// check if we have a device specific offset
|
||||||
.target = target,
|
switch (guess_model())
|
||||||
.relation = pose.pose,
|
{
|
||||||
});
|
case model::oculus_quest:
|
||||||
|
case model::oculus_quest_2:
|
||||||
|
case model::meta_quest_pro:
|
||||||
|
case model::meta_quest_3:
|
||||||
|
case model::meta_quest_3s:
|
||||||
|
switch (target)
|
||||||
|
{
|
||||||
|
case device_id::LEFT_PALM:
|
||||||
|
case device_id::RIGHT_PALM: {
|
||||||
|
glm::quat q(glm::vec3(glm::radians(-60.), 0, 0));
|
||||||
|
network_session->send_control(from_headset::derived_pose{
|
||||||
|
.source = source,
|
||||||
|
.target = target,
|
||||||
|
.relation = {
|
||||||
|
.orientation = {
|
||||||
|
.x = q.x,
|
||||||
|
.y = q.y,
|
||||||
|
.z = q.z,
|
||||||
|
.w = q.w,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
network_session->send_control(from_headset::derived_pose{
|
if (auto pose = locate_space(target, target_space, source_space, now);
|
||||||
.source = target,
|
pose.flags & from_headset::tracking::position_valid and pose.flags & from_headset::tracking::orientation_valid)
|
||||||
.target = target,
|
{
|
||||||
});
|
network_session->send_control(from_headset::derived_pose{
|
||||||
|
.source = source,
|
||||||
|
.target = target,
|
||||||
|
.relation = pose.pose,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// source == target means that the pose cannot be derived
|
||||||
|
network_session->send_control(from_headset::derived_pose{
|
||||||
|
.source = target,
|
||||||
|
.target = target,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user