Commit: cfc5c1b46d6d4191e08f8fc172e9ae5ec1dafa0c Author: Peter Kim Date: Sun Oct 11 16:24:56 2020 +0900 Branches: xr-actions-D9124 https://developer.blender.org/rBcfc5c1b46d6d4191e08f8fc172e9ae5ec1dafa0c
Improve error logging and controller data management. =================================================================== M intern/ghost/intern/GHOST_XrSession.cpp M source/blender/makesrna/intern/rna_xr.c M source/blender/windowmanager/xr/intern/wm_xr_actions.c M source/blender/windowmanager/xr/intern/wm_xr_intern.h M source/blender/windowmanager/xr/intern/wm_xr_operators.c M source/blender/windowmanager/xr/intern/wm_xr_session.c =================================================================== diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp index a2f4af94aca..22b20d4cd23 100644 --- a/intern/ghost/intern/GHOST_XrSession.cpp +++ b/intern/ghost/intern/GHOST_XrSession.cpp @@ -609,7 +609,10 @@ bool GHOST_XrSession::createActionSet(const GHOST_XrActionSetInfo *info) OpenXRActionSet action_set; CHECK_XR_ND_BUF(xrCreateActionSet(m_context->getInstance(), &action_set_info, &action_set.set), - (std::string("Failed to create action set \"") + info->name + "\".").c_str(), + (std::string("Failed to create action set \"") + info->name + "\".\n" + + "Name must not contain upper case letters or special characters other than " + "'-', '_', or '.'.") + .c_str(), g_error_msg_buf); std::map<std::string, OpenXRActionSet> &action_sets = m_oxr->action_sets; @@ -708,7 +711,11 @@ bool GHOST_XrSession::createActions(const char *action_set_name, OpenXRAction action; CHECK_XR_ND_BUF(xrCreateAction(action_set->set, &action_info, &action.action), - (std::string("Failed to create action \"") + info.name + "\".").c_str(), + (std::string("Failed to create action \"") + info.name + "\".\n" + + "Action name and/or paths are invalid.\n" + + "Name must not contain upper case letters or special characters other than " + "'-', '_', or '.'.") + .c_str(), g_error_msg_buf); if (actions.find(info.name) == actions.end()) { @@ -917,7 +924,8 @@ bool GHOST_XrSession::createActionBindings(const char *action_set_name, CHECK_XR_ND_BUF(xrSuggestInteractionProfileBindings(instance, &bindings_info), (std::string("Failed to create bindings for profile \"") + - interaction_profile_path + "\".") + interaction_profile_path + "\".\n" + + "Are the profile and action paths correct?") .c_str(), g_error_msg_buf); @@ -1026,7 +1034,7 @@ void GHOST_XrSession::destroyActionBindings(const char *action_set_name, CHECK_XR_BUF(xrSuggestInteractionProfileBindings(instance, &bindings_info), (std::string("Failed to destroy bindings for profile \"") + - interaction_profile_path + "\".") + interaction_profile_path + "\".\n" + "Are the profile and action paths correct?") .c_str(), g_error_msg_buf); @@ -1078,7 +1086,7 @@ bool GHOST_XrSession::attachActionSets() attach_info.actionSets = action_sets.data(); CHECK_XR_ND(xrAttachSessionActionSets(m_oxr->session, &attach_info), - "Failed to attach action sets."); + "Failed to attach XR action sets."); return true; } @@ -1097,7 +1105,7 @@ bool GHOST_XrSession::syncActions(const char *action_set_name) std::vector<XrActiveActionSet> active_action_sets(sync_info.countActiveActionSets); if (action_set_name != nullptr) { OpenXRActionSet *action_set = find_action_set(m_oxr.get(), action_set_name); - if (action_set == nullptr) { + if (action_set == nullptr || action_set->actions.size() < 1) { return false; } @@ -1108,15 +1116,25 @@ bool GHOST_XrSession::syncActions(const char *action_set_name) else { uint32_t i = 0; for (auto &action_set : action_sets) { + if (action_set.second.actions.size() < 1) { + active_action_sets.pop_back(); + --sync_info.countActiveActionSets; + continue; + } + XrActiveActionSet &active_action_set = active_action_sets[i]; active_action_set.actionSet = action_set.second.set; active_action_set.subactionPath = XR_NULL_PATH; ++i; } + + if (sync_info.countActiveActionSets < 1) { + return false; + } } sync_info.activeActionSets = active_action_sets.data(); - CHECK_XR(xrSyncActions(m_oxr->session, &sync_info), "Failed to sync actions."); + CHECK_XR(xrSyncActions(m_oxr->session, &sync_info), "Failed to synchronize XR actions."); return true; } diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c index fdd7e30c863..91024fa0087 100644 --- a/source/blender/makesrna/intern/rna_xr.c +++ b/source/blender/makesrna/intern/rna_xr.c @@ -588,7 +588,13 @@ static void rna_def_xr_session_state(BlenderRNA *brna) RNA_def_function_flag(func, FUNC_NO_SELF); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "name", NULL, 64, "Action Set", "Action set name"); + parm = RNA_def_string(func, + "name", + NULL, + 64, + "Action Set", + "Action set name (must not contain upper case letters or special " + "characters other than '-', '_', or '.'"); RNA_def_parameter_flags(parm, PROP_STRING, PARM_REQUIRED); parm = RNA_def_boolean(func, "result", 0, "Result", ""); RNA_def_function_return(func, parm); @@ -600,7 +606,13 @@ static void rna_def_xr_session_state(BlenderRNA *brna) RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_string(func, "action_set_name", NULL, 64, "Action Set", "Action set name"); RNA_def_parameter_flags(parm, PROP_STRING, PARM_REQUIRED); - parm = RNA_def_string(func, "name", NULL, 64, "Action", "Action name"); + parm = RNA_def_string(func, + "name", + NULL, + 64, + "Action", + "Action name (must not contain upper case letters or special characters " + "other than '-', '_', or '.'"); RNA_def_parameter_flags(parm, PROP_STRING, PARM_REQUIRED); parm = RNA_def_enum(func, "type", action_types, 0, "Type", "Action type"); RNA_def_parameter_flags(parm, PROP_ENUM, PARM_REQUIRED); diff --git a/source/blender/windowmanager/xr/intern/wm_xr_actions.c b/source/blender/windowmanager/xr/intern/wm_xr_actions.c index 0e05bdb8d08..93ddea9b28f 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_actions.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_actions.c @@ -184,22 +184,30 @@ void WM_xr_action_set_destroy(wmXrData *xr, const char *action_set_name, bool re wmXrSessionState *session_state = &xr->runtime->session_state; GHash *action_sets = session_state->action_sets; wmXrActionSet *action_set = BLI_ghash_lookup(action_sets, action_set_name); + if (!action_set) { + return; + } - if (action_set) { - if (action_set->actions) { - BLI_ghash_free(action_set->actions, NULL, action_destroy); + if (action_set == session_state->active_action_set) { + if (action_set->controller_pose_action) { + wm_xr_session_controller_data_clear( + action_set->controller_pose_action->count_subaction_paths, + xr->runtime->bcontext, + &xr->runtime->session_state); + action_set->controller_pose_action = NULL; } + session_state->active_action_set = NULL; + } - if (session_state->active_action_set == action_set) { - session_state->active_action_set = NULL; - } + if (action_set->actions) { + BLI_ghash_free(action_set->actions, NULL, action_destroy); + } - if (remove_reference) { - BLI_ghash_remove(action_sets, action_set_name, NULL, action_set_destroy); - } - else { - action_set_destroy(action_set); - } + if (remove_reference) { + BLI_ghash_remove(action_sets, action_set_name, NULL, action_set_destroy); + } + else { + action_set_destroy(action_set); } } @@ -255,6 +263,8 @@ void WM_xr_actions_destroy(wmXrData *xr, /* Save name of controller pose action in case the action is removed from the GHash. */ char controller_pose_name[64]; strcpy(controller_pose_name, action_set->controller_pose_action->name); + const unsigned int controller_pose_count = + action_set->controller_pose_action->count_subaction_paths; GHash *actions = action_set->actions; for (unsigned int i = 0; i < count; ++i) { @@ -262,6 +272,10 @@ void WM_xr_actions_destroy(wmXrData *xr, } if (!action_find(action_set, controller_pose_name)) { + if (action_set == xr->runtime->session_state.active_action_set) { + wm_xr_session_controller_data_clear( + controller_pose_count, xr->runtime->bcontext, &xr->runtime->session_state); + } action_set->controller_pose_action = NULL; } } @@ -311,6 +325,12 @@ bool WM_xr_active_action_set_set(wmXrData *xr, const char *action_set_name) } xr->runtime->session_state.active_action_set = action_set; + + if (action_set->controller_pose_action) { + wm_xr_session_controller_data_populate( + action_set->controller_pose_action, xr->runtime->bcontext, &xr->runtime->session_state); + } + return true; } @@ -330,6 +350,11 @@ bool WM_xr_controller_pose_action_set(wmXrData *xr, action_set->controller_pose_action = action; + if (action_set == xr->runtime->session_state.active_action_set) { + wm_xr_session_controller_data_populate( + action, xr->runtime->bcontext, &xr->runtime->session_state); + } + return true; } diff --git a/source/blender/windowmanager/xr/intern/wm_xr_intern.h b/source/blender/windowmanager/xr/intern/wm_xr_intern.h index 61ef1890c78..0fc8f8c3ead 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_intern.h +++ b/source/blender/windowmanager/xr/intern/wm_xr_intern.h @@ -155,8 +155,12 @@ void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle context); void wm_xr_session_actions_init(wmXrData *xr); void wm_xr_session_actions_update(wmXrData *xr); void wm_xr_session_actions_uninit(wmXrData *xr); -void wm_xr_session_controller_data_create(wmXrData *xr); -void wm_xr_session_controller_data_free(wmXrData *xr); +void wm_xr_session_controller_data_populate(const wmXrAction *controller_pose_action, + struct bContex @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs