Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_XrSession.cpp
| Show First 20 Lines • Show All 604 Lines • ▼ Show 20 Lines | if (action_set == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (uint32_t i = 0; i < count; ++i) { | for (uint32_t i = 0; i < count; ++i) { | ||||
| action_set->destroyAction(action_names[i]); | action_set->destroyAction(action_names[i]); | ||||
| } | } | ||||
| } | } | ||||
| bool GHOST_XrSession::createActionSpaces(const char *action_set_name, | |||||
| uint32_t count, | |||||
| const GHOST_XrActionSpaceInfo *infos) | |||||
| { | |||||
| GHOST_XrActionSet *action_set = find_action_set(m_oxr.get(), action_set_name); | |||||
| if (action_set == nullptr) { | |||||
| return false; | |||||
| } | |||||
| XrInstance instance = m_context->getInstance(); | |||||
| XrSession session = m_oxr->session; | |||||
| for (uint32_t action_idx = 0; action_idx < count; ++action_idx) { | |||||
| const GHOST_XrActionSpaceInfo &info = infos[action_idx]; | |||||
| GHOST_XrAction *action = action_set->findAction(info.action_name); | |||||
| if (action == nullptr) { | |||||
| continue; | |||||
| } | |||||
| if (!action->createSpace(instance, session, info)) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return true; | |||||
| } | |||||
| void GHOST_XrSession::destroyActionSpaces(const char *action_set_name, | |||||
| uint32_t count, | |||||
| const GHOST_XrActionSpaceInfo *infos) | |||||
| { | |||||
| GHOST_XrActionSet *action_set = find_action_set(m_oxr.get(), action_set_name); | |||||
| if (action_set == nullptr) { | |||||
| return; | |||||
| } | |||||
| for (uint32_t action_idx = 0; action_idx < count; ++action_idx) { | |||||
| const GHOST_XrActionSpaceInfo &info = infos[action_idx]; | |||||
| GHOST_XrAction *action = action_set->findAction(info.action_name); | |||||
| if (action == nullptr) { | |||||
| continue; | |||||
| } | |||||
| for (uint32_t subaction_idx = 0; subaction_idx < info.count_subaction_paths; ++subaction_idx) { | |||||
| action->destroySpace(info.subaction_paths[subaction_idx]); | |||||
| } | |||||
| } | |||||
| } | |||||
| bool GHOST_XrSession::createActionBindings(const char *action_set_name, | bool GHOST_XrSession::createActionBindings(const char *action_set_name, | ||||
| uint32_t count, | uint32_t count, | ||||
| const GHOST_XrActionProfileInfo *infos) | const GHOST_XrActionProfileInfo *infos) | ||||
| { | { | ||||
| GHOST_XrActionSet *action_set = find_action_set(m_oxr.get(), action_set_name); | GHOST_XrActionSet *action_set = find_action_set(m_oxr.get(), action_set_name); | ||||
| if (action_set == nullptr) { | if (action_set == nullptr) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| XrInstance instance = m_context->getInstance(); | XrInstance instance = m_context->getInstance(); | ||||
| XrSession session = m_oxr->session; | |||||
| for (uint32_t profile_idx = 0; profile_idx < count; ++profile_idx) { | for (uint32_t profile_idx = 0; profile_idx < count; ++profile_idx) { | ||||
| const GHOST_XrActionProfileInfo &info = infos[profile_idx]; | const GHOST_XrActionProfileInfo &info = infos[profile_idx]; | ||||
| const char *profile_path = info.profile_path; | |||||
| for (uint32_t binding_idx = 0; binding_idx < info.count_bindings; ++binding_idx) { | |||||
| const GHOST_XrActionBindingInfo &binding = info.bindings[binding_idx]; | |||||
| GHOST_XrAction *action = action_set->findAction(binding.action_name); | GHOST_XrAction *action = action_set->findAction(info.action_name); | ||||
| if (action == nullptr) { | if (action == nullptr) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| action->createBinding(instance, profile_path, binding); | action->createBinding(instance, session, info); | ||||
| } | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| void GHOST_XrSession::destroyActionBindings(const char *action_set_name, | void GHOST_XrSession::destroyActionBindings(const char *action_set_name, | ||||
| uint32_t count, | uint32_t count, | ||||
| const GHOST_XrActionProfileInfo *infos) | const char *const *action_names, | ||||
| const char *const *profile_paths) | |||||
| { | { | ||||
| GHOST_XrActionSet *action_set = find_action_set(m_oxr.get(), action_set_name); | GHOST_XrActionSet *action_set = find_action_set(m_oxr.get(), action_set_name); | ||||
| if (action_set == nullptr) { | if (action_set == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (uint32_t profile_idx = 0; profile_idx < count; ++profile_idx) { | for (uint32_t i = 0; i < count; ++i) { | ||||
| const GHOST_XrActionProfileInfo &info = infos[profile_idx]; | GHOST_XrAction *action = action_set->findAction(action_names[i]); | ||||
| const char *profile_path = info.profile_path; | |||||
| for (uint32_t binding_idx = 0; binding_idx < info.count_bindings; ++binding_idx) { | |||||
| const GHOST_XrActionBindingInfo &binding = info.bindings[binding_idx]; | |||||
| GHOST_XrAction *action = action_set->findAction(binding.action_name); | |||||
| if (action == nullptr) { | if (action == nullptr) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| action->destroyBinding(profile_path); | action->destroyBinding(profile_paths[i]); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| bool GHOST_XrSession::attachActionSets() | bool GHOST_XrSession::attachActionSets() | ||||
| { | { | ||||
| /* Suggest action bindings for all action sets. */ | /* Suggest action bindings for all action sets. */ | ||||
| std::map<XrPath, std::vector<XrActionSuggestedBinding>> profile_bindings; | std::map<XrPath, std::vector<XrActionSuggestedBinding>> profile_bindings; | ||||
| for (auto &[name, action_set] : m_oxr->action_sets) { | for (auto &[name, action_set] : m_oxr->action_sets) { | ||||
| ▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines | |||||