Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/xr/intern/wm_xr_action.c
- This file was moved from source/blender/windowmanager/xr/intern/wm_xr_actions.c.
| Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | void WM_xr_action_set_destroy(wmXrData *xr, const char *action_set_name) | ||||
| wmXrActionSet *action_set = action_set_find(xr, action_set_name); | wmXrActionSet *action_set = action_set_find(xr, action_set_name); | ||||
| if (!action_set) { | if (!action_set) { | ||||
| return; | return; | ||||
| } | } | ||||
| wmXrSessionState *session_state = &xr->runtime->session_state; | wmXrSessionState *session_state = &xr->runtime->session_state; | ||||
| if (action_set == session_state->active_action_set) { | if (action_set == session_state->active_action_set) { | ||||
| if (action_set->controller_pose_action) { | if (action_set->controller_grip_action || action_set->controller_aim_action) { | ||||
| wm_xr_session_controller_data_clear(session_state); | wm_xr_session_controller_data_clear(session_state); | ||||
| action_set->controller_pose_action = NULL; | action_set->controller_grip_action = action_set->controller_aim_action = NULL; | ||||
| } | } | ||||
| if (action_set->active_modal_action) { | if (action_set->active_modal_action) { | ||||
| action_set->active_modal_action = NULL; | action_set->active_modal_action = NULL; | ||||
| } | } | ||||
| session_state->active_action_set = NULL; | session_state->active_action_set = NULL; | ||||
| } | } | ||||
| GHOST_XrDestroyActionSet(xr->runtime->context, action_set_name); | GHOST_XrDestroyActionSet(xr->runtime->context, action_set_name); | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
| void WM_xr_action_destroy(wmXrData *xr, const char *action_set_name, const char *action_name) | void WM_xr_action_destroy(wmXrData *xr, const char *action_set_name, const char *action_name) | ||||
| { | { | ||||
| wmXrActionSet *action_set = action_set_find(xr, action_set_name); | wmXrActionSet *action_set = action_set_find(xr, action_set_name); | ||||
| if (!action_set) { | if (!action_set) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (action_set->controller_pose_action && | wmXrAction *action = action_find(xr, action_set_name, action_name); | ||||
| STREQ(action_set->controller_pose_action->name, action_name)) { | if (!action) { | ||||
| return; | |||||
| } | |||||
| if ((action_set->controller_grip_action && | |||||
| STREQ(action_set->controller_grip_action->name, action_name)) || | |||||
| (action_set->controller_aim_action && | |||||
| STREQ(action_set->controller_aim_action->name, action_name))) { | |||||
| if (action_set == xr->runtime->session_state.active_action_set) { | if (action_set == xr->runtime->session_state.active_action_set) { | ||||
| wm_xr_session_controller_data_clear(&xr->runtime->session_state); | wm_xr_session_controller_data_clear(&xr->runtime->session_state); | ||||
| } | } | ||||
| action_set->controller_pose_action = NULL; | action_set->controller_grip_action = action_set->controller_aim_action = NULL; | ||||
| } | |||||
| if (action_set->active_modal_action && | |||||
| STREQ(action_set->active_modal_action->name, action_name)) { | |||||
| action_set->active_modal_action = NULL; | |||||
| } | } | ||||
| wmXrAction *action = action_find(xr, action_set_name, action_name); | GHOST_XrDestroyActions(xr->runtime->context, action_set_name, 1, &action_name); | ||||
| if (!action) { | |||||
| return; | |||||
| } | |||||
| } | } | ||||
| bool WM_xr_action_space_create(wmXrData *xr, | bool WM_xr_action_space_create(wmXrData *xr, | ||||
| const char *action_set_name, | const char *action_set_name, | ||||
| const char *action_name, | const char *action_name, | ||||
| unsigned int count_subaction_paths, | unsigned int count_subaction_paths, | ||||
| const char **subaction_paths, | const char **subaction_paths, | ||||
| const wmXrPose *poses) | const wmXrPose *poses) | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | if (active_action_set) { | ||||
| } | } | ||||
| active_action_set->active_modal_action = NULL; | active_action_set->active_modal_action = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| xr->runtime->session_state.active_action_set = action_set; | xr->runtime->session_state.active_action_set = action_set; | ||||
| if (action_set->controller_pose_action) { | if (action_set->controller_grip_action && action_set->controller_aim_action) { | ||||
| wm_xr_session_controller_data_populate(action_set->controller_pose_action, xr); | wm_xr_session_controller_data_populate( | ||||
| action_set->controller_grip_action, action_set->controller_aim_action, xr); | |||||
| } | |||||
| else { | |||||
| wm_xr_session_controller_data_clear(&xr->runtime->session_state); | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool WM_xr_controller_pose_action_set(wmXrData *xr, | bool WM_xr_controller_pose_actions_set(wmXrData *xr, | ||||
| const char *action_set_name, | const char *action_set_name, | ||||
| const char *action_name) | const char *grip_action_name, | ||||
| const char *aim_action_name) | |||||
| { | { | ||||
| wmXrActionSet *action_set = action_set_find(xr, action_set_name); | wmXrActionSet *action_set = action_set_find(xr, action_set_name); | ||||
| if (!action_set) { | if (!action_set) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| wmXrAction *action = action_find(xr, action_set_name, action_name); | wmXrAction *grip_action = action_find(xr, action_set_name, grip_action_name); | ||||
| if (!action) { | if (!grip_action) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| action_set->controller_pose_action = action; | wmXrAction *aim_action = action_find(xr, action_set_name, aim_action_name); | ||||
| if (!aim_action) { | |||||
| return false; | |||||
| } | |||||
| /* Ensure consistent subaction paths. */ | |||||
| const unsigned int count = grip_action->count_subaction_paths; | |||||
| if (count != aim_action->count_subaction_paths) { | |||||
| return false; | |||||
| } | |||||
| for (unsigned int i = 0; i < count; ++i) { | |||||
| if (!STREQ(grip_action->subaction_paths[i], aim_action->subaction_paths[i])) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| action_set->controller_grip_action = grip_action; | |||||
| action_set->controller_aim_action = aim_action; | |||||
| if (action_set == xr->runtime->session_state.active_action_set) { | if (action_set == xr->runtime->session_state.active_action_set) { | ||||
| wm_xr_session_controller_data_populate(action, xr); | wm_xr_session_controller_data_populate(grip_action, aim_action, xr); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool WM_xr_action_state_get(const wmXrData *xr, | bool WM_xr_action_state_get(const wmXrData *xr, | ||||
| const char *action_set_name, | const char *action_set_name, | ||||
| const char *action_name, | const char *action_name, | ||||
| ▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines | |||||