[Bf-blender-cvs] [6920906f75b] xr-actions-D9124: XR: Remove "replace existing" param from action bindings creation
Peter Kim
noreply at git.blender.org
Wed Oct 14 17:44:21 CEST 2020
Commit: 6920906f75b44fb9371077bd154477aa176d191c
Author: Peter Kim
Date: Thu Oct 15 00:23:48 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rB6920906f75b44fb9371077bd154477aa176d191c
XR: Remove "replace existing" param from action bindings creation
Since action bindings are only created once at the beginning of an XR
session, overwriting all existing bindings will not be needed.
===================================================================
M intern/ghost/GHOST_C-api.h
M intern/ghost/intern/GHOST_C-api.cpp
M intern/ghost/intern/GHOST_XrSession.cpp
M intern/ghost/intern/GHOST_XrSession.h
M source/blender/makesrna/intern/rna_xr.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/xr/intern/wm_xr_actions.c
===================================================================
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 09734506020..77c76d6c5fa 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -1120,8 +1120,7 @@ void GHOST_XrDestroyActionSpaces(GHOST_XrContextHandle xr_context,
int GHOST_XrCreateActionBindings(GHOST_XrContextHandle xr_context,
const char *action_set_name,
GHOST_TUns32 count,
- const GHOST_XrActionBindingsInfo *infos,
- int replace_existing);
+ const GHOST_XrActionBindingsInfo *infos);
/**
* Destroy previously created bindings for OpenXR actions.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index f124d5a92ce..c383505a148 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -1031,13 +1031,11 @@ void GHOST_XrDestroyActionSpaces(GHOST_XrContextHandle xr_contexthandle,
int GHOST_XrCreateActionBindings(GHOST_XrContextHandle xr_contexthandle,
const char *action_set_name,
GHOST_TUns32 count,
- const GHOST_XrActionBindingsInfo *infos,
- int replace_existing)
+ const GHOST_XrActionBindingsInfo *infos)
{
GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
GHOST_XrSession *xr_session = xr_context->getSession();
- GHOST_XR_CAPI_CALL_RET(xr_session->createActionBindings(
- action_set_name, count, infos, replace_existing ? true : false),
+ GHOST_XR_CAPI_CALL_RET(xr_session->createActionBindings(action_set_name, count, infos),
xr_context);
return 0;
}
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index 22b20d4cd23..371726bbcbd 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -855,8 +855,7 @@ void GHOST_XrSession::destroyActionSpaces(const char *action_set_name,
bool GHOST_XrSession::createActionBindings(const char *action_set_name,
uint32_t count,
- const GHOST_XrActionBindingsInfo *infos,
- bool replace_existing)
+ const GHOST_XrActionBindingsInfo *infos)
{
OpenXRActionSet *action_set = find_action_set(m_oxr.get(), action_set_name);
if (action_set == nullptr) {
@@ -897,25 +896,23 @@ bool GHOST_XrSession::createActionBindings(const char *action_set_name,
nbindings.insert({binding.interaction_path, sbinding.binding});
}
- if (!replace_existing) {
- /* Since xrSuggestInteractionProfileBindings() overwrites all bindings, we
- * need to re-add any existing bindings for the interaction profile. */
- for (auto &action : action_set->actions) {
- OpenXRActionProfile *profile = find_action_profile(&action.second,
- interaction_profile_path);
- if (profile == nullptr) {
+
+ /* Since xrSuggestInteractionProfileBindings() overwrites all bindings, we
+ * need to re-add any existing bindings for the interaction profile. */
+ for (auto &action : action_set->actions) {
+ OpenXRActionProfile *profile = find_action_profile(&action.second, interaction_profile_path);
+ if (profile == nullptr) {
+ continue;
+ }
+ for (auto &binding : profile->bindings) {
+ if (nbindings.find(binding.first) != nbindings.end()) {
continue;
}
- for (auto &binding : profile->bindings) {
- if (nbindings.find(binding.first) != nbindings.end()) {
- continue;
- }
- XrActionSuggestedBinding sbinding;
- sbinding.action = action.second.action;
- sbinding.binding = binding.second;
+ XrActionSuggestedBinding sbinding;
+ sbinding.action = action.second.action;
+ sbinding.binding = binding.second;
- sbindings.push_back(std::move(sbinding));
- }
+ sbindings.push_back(std::move(sbinding));
}
}
diff --git a/intern/ghost/intern/GHOST_XrSession.h b/intern/ghost/intern/GHOST_XrSession.h
index 9777ed18aa6..9412aaaca87 100644
--- a/intern/ghost/intern/GHOST_XrSession.h
+++ b/intern/ghost/intern/GHOST_XrSession.h
@@ -68,8 +68,7 @@ class GHOST_XrSession {
const GHOST_XrActionSpaceInfo *infos);
bool createActionBindings(const char *action_set_name,
uint32_t count,
- const GHOST_XrActionBindingsInfo *infos,
- bool replace_existing);
+ const GHOST_XrActionBindingsInfo *infos);
void destroyActionBindings(const char *action_set_name,
uint32_t count,
const GHOST_XrActionBindingsInfo *infos);
diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c
index 6bff5104e7a..e994b764a5e 100644
--- a/source/blender/makesrna/intern/rna_xr.c
+++ b/source/blender/makesrna/intern/rna_xr.c
@@ -183,8 +183,7 @@ bool rna_XrSessionState_action_binding_create(bContext *C,
const char *profile,
const char *action_name,
const char *interaction_path0,
- const char *interaction_path1,
- bool replace_existing)
+ const char *interaction_path1)
{
# ifdef WITH_XR_OPENXR
wmWindowManager *wm = CTX_wm_manager(C);
@@ -216,7 +215,7 @@ bool rna_XrSessionState_action_binding_create(bContext *C,
}
info.bindings = bindings;
- return WM_xr_action_bindings_create(&wm->xr, action_set_name, 1, &info, replace_existing);
+ return WM_xr_action_bindings_create(&wm->xr, action_set_name, 1, &info);
# else
UNUSED_VARS(C, action_set_name, profile, action_name, interaction_path0, interaction_path1);
return false;
@@ -701,13 +700,6 @@ static void rna_def_xr_session_state(BlenderRNA *brna)
"Interaction Path 1",
"OpenXR interaction (user + component) path 1");
RNA_def_parameter_flags(parm, PROP_STRING, PARM_REQUIRED);
- parm = RNA_def_boolean(
- func,
- "replace_existing",
- false,
- "Replace Existing",
- "Replace all existing bindings for the action that belong to the specified profile");
- RNA_def_parameter_flags(parm, PROP_BOOLEAN, PARM_REQUIRED);
parm = RNA_def_boolean(func, "result", 0, "Result", "");
RNA_def_function_return(func, parm);
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 273e91571b2..754ad209c14 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -912,7 +912,7 @@ void WM_generic_user_data_free(struct wmGenericUserData *wm_userdata);
bool WM_region_use_viewport(struct ScrArea *area, struct ARegion *region);
#ifdef WITH_XR_OPENXR
-/* wm_xr.c */
+/* wm_xr_session.c */
bool WM_xr_session_exists(const wmXrData *xr);
bool WM_xr_session_is_ready(const wmXrData *xr);
struct wmXrSessionState *WM_xr_session_state_handle_get(const wmXrData *xr);
@@ -953,8 +953,7 @@ void WM_xr_action_spaces_destroy(wmXrData *xr,
bool WM_xr_action_bindings_create(wmXrData *xr,
const char *action_set_name,
unsigned int count,
- const struct GHOST_XrActionBindingsInfo *infos,
- bool replace_existing);
+ const struct GHOST_XrActionBindingsInfo *infos);
void WM_xr_action_bindings_destroy(wmXrData *xr,
const char *action_set_name,
unsigned int count,
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_actions.c b/source/blender/windowmanager/xr/intern/wm_xr_actions.c
index 93ddea9b28f..b1a2bd80211 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_actions.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_actions.c
@@ -300,13 +300,9 @@ void WM_xr_action_spaces_destroy(wmXrData *xr,
bool WM_xr_action_bindings_create(wmXrData *xr,
const char *action_set_name,
unsigned int count,
- const GHOST_XrActionBindingsInfo *infos,
- bool replace_existing)
+ const GHOST_XrActionBindingsInfo *infos)
{
- return GHOST_XrCreateActionBindings(
- xr->runtime->context, action_set_name, count, infos, replace_existing ? 1 : 0) ?
- true :
- false;
+ return GHOST_XrCreateActionBindings(xr->runtime->context, action_set_name, count, infos);
}
void WM_xr_action_bindings_destroy(wmXrData *xr,
More information about the Bf-blender-cvs
mailing list