[Bf-blender-cvs] [14fc1c73e89] xr-controller-support: Update with changes from D10943
Peter Kim
noreply at git.blender.org
Fri Aug 6 09:42:35 CEST 2021
Commit: 14fc1c73e89ca83e79c76ff5f367671bfc800fd6
Author: Peter Kim
Date: Fri Aug 6 15:58:41 2021 +0900
Branches: xr-controller-support
https://developer.blender.org/rB14fc1c73e89ca83e79c76ff5f367671bfc800fd6
Update with changes from D10943
===================================================================
M intern/ghost/GHOST_C-api.h
M intern/ghost/intern/GHOST_C-api.cpp
M intern/ghost/intern/GHOST_XrAction.cpp
M intern/ghost/intern/GHOST_XrAction.h
M intern/ghost/intern/GHOST_XrSession.cpp
M intern/ghost/intern/GHOST_XrSession.h
M source/blender/makesdna/DNA_xr_types.h
M source/blender/makesrna/intern/rna_internal.h
M source/blender/makesrna/intern/rna_xr.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_event_system.c
M source/blender/windowmanager/xr/intern/wm_xr_action.c
M source/blender/windowmanager/xr/intern/wm_xr_actionmap.c
M source/blender/windowmanager/xr/intern/wm_xr_intern.h
M source/blender/windowmanager/xr/intern/wm_xr_session.c
===================================================================
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 7fb4235f648..ae6e26229af 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -1136,9 +1136,9 @@ unsigned int GHOST_XrGetActionCount(GHOST_XrContextHandle xr_context, const char
/**
* Get custom data for all actions in an action set.
*/
-void GHOST_XrGetActionCustomdatas(GHOST_XrContextHandle xr_context,
- const char *action_set_name,
- void **r_customdatas);
+void GHOST_XrGetActionCustomdataArray(GHOST_XrContextHandle xr_context,
+ const char *action_set_name,
+ void **r_customdata_array);
/* controller model */
/**
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 22335994ae6..c5fce153d9d 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -1059,13 +1059,14 @@ unsigned int GHOST_XrGetActionCount(GHOST_XrContextHandle xr_contexthandle,
return 0;
}
-void GHOST_XrGetActionCustomdatas(GHOST_XrContextHandle xr_contexthandle,
- const char *action_set_name,
- void **r_customdatas)
+void GHOST_XrGetActionCustomdataArray(GHOST_XrContextHandle xr_contexthandle,
+ const char *action_set_name,
+ void **r_customdata_array)
{
GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
GHOST_XrSession *xr_session = xr_context->getSession();
- GHOST_XR_CAPI_CALL(xr_session->getActionCustomdatas(action_set_name, r_customdatas), xr_context);
+ GHOST_XR_CAPI_CALL(xr_session->getActionCustomdataArray(action_set_name, r_customdata_array),
+ xr_context);
}
int GHOST_XrLoadControllerModel(GHOST_XrContextHandle xr_contexthandle, const char *subaction_path)
diff --git a/intern/ghost/intern/GHOST_XrAction.cpp b/intern/ghost/intern/GHOST_XrAction.cpp
index dfd7172c9c6..5b0d8389f96 100644
--- a/intern/ghost/intern/GHOST_XrAction.cpp
+++ b/intern/ghost/intern/GHOST_XrAction.cpp
@@ -389,7 +389,7 @@ void GHOST_XrAction::applyHapticFeedback(XrSession session,
haptic_info.action = m_action;
if (subaction_path_str != nullptr) {
- std::map<std::string, uint32_t>::iterator it = m_subaction_indices.find(*subaction_path_str);
+ SubactionIndexMap::iterator it = m_subaction_indices.find(*subaction_path_str);
if (it != m_subaction_indices.end()) {
haptic_info.subactionPath = m_subaction_paths[it->second];
CHECK_XR(
@@ -415,7 +415,7 @@ void GHOST_XrAction::stopHapticFeedback(XrSession session,
haptic_info.action = m_action;
if (subaction_path_str != nullptr) {
- std::map<std::string, uint32_t>::iterator it = m_subaction_indices.find(*subaction_path_str);
+ SubactionIndexMap::iterator it = m_subaction_indices.find(*subaction_path_str);
if (it != m_subaction_indices.end()) {
haptic_info.subactionPath = m_subaction_paths[it->second];
CHECK_XR(xrStopHapticFeedback(session, &haptic_info),
@@ -540,11 +540,11 @@ uint32_t GHOST_XrActionSet::getActionCount() const
return (uint32_t)m_actions.size();
}
-void GHOST_XrActionSet::getActionCustomdatas(void **r_customdatas)
+void GHOST_XrActionSet::getActionCustomdataArray(void **r_customdata_array)
{
uint32_t i = 0;
for (auto &[name, action] : m_actions) {
- r_customdatas[i++] = action.getCustomdata();
+ r_customdata_array[i++] = action.getCustomdata();
}
}
diff --git a/intern/ghost/intern/GHOST_XrAction.h b/intern/ghost/intern/GHOST_XrAction.h
index 099c99bf03a..9975385ea97 100644
--- a/intern/ghost/intern/GHOST_XrAction.h
+++ b/intern/ghost/intern/GHOST_XrAction.h
@@ -18,8 +18,8 @@
* \ingroup GHOST
*/
-/* Note: Requires OpenXR headers to be included before this one for OpenXR types (XrInstance,
- * XrSession, etc.). */
+/* NOTE: Requires OpenXR headers to be included before this one for OpenXR types
+ * (XrSpace, XrPath, etc.). */
#pragma once
@@ -79,9 +79,9 @@ class GHOST_XrActionProfile {
private:
XrPath m_profile = XR_NULL_PATH;
- /** Subaction data identified by user (subaction) path. */
+ /** Sub-action data identified by user `subaction` path. */
std::map<std::string, GHOST_XrSubactionData> m_subaction_data;
- /** Bindings identified by interaction (user (subaction) + component) path. */
+ /** Bindings identified by interaction (user `subaction` + component) path. */
std::map<std::string, XrPath> m_bindings;
};
@@ -114,9 +114,11 @@ class GHOST_XrAction {
void getBindings(std::map<XrPath, std::vector<XrActionSuggestedBinding>> &r_bindings) const;
private:
+ using SubactionIndexMap = std::map<std::string, uint32_t>;
+
XrAction m_action = XR_NULL_HANDLE;
GHOST_XrActionType m_type;
- std::map<std::string, uint32_t> m_subaction_indices;
+ SubactionIndexMap m_subaction_indices;
std::vector<XrPath> m_subaction_paths;
/** States for each subaction path. */
void *m_states;
@@ -149,7 +151,7 @@ class GHOST_XrActionSet {
XrActionSet getActionSet() const;
void *getCustomdata();
uint32_t getActionCount() const;
- void getActionCustomdatas(void **r_customdatas);
+ void getActionCustomdataArray(void **r_customdata_array);
void getBindings(std::map<XrPath, std::vector<XrActionSuggestedBinding>> &r_bindings) const;
private:
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index 22bafc62161..f54fab4e6cf 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -830,14 +830,15 @@ uint32_t GHOST_XrSession::getActionCount(const char *action_set_name)
return action_set->getActionCount();
}
-void GHOST_XrSession::getActionCustomdatas(const char *action_set_name, void **r_customdatas)
+void GHOST_XrSession::getActionCustomdataArray(const char *action_set_name,
+ void **r_customdata_array)
{
GHOST_XrActionSet *action_set = find_action_set(m_oxr.get(), action_set_name);
if (action_set == nullptr) {
return;
}
- action_set->getActionCustomdatas(r_customdatas);
+ action_set->getActionCustomdataArray(r_customdata_array);
}
/** \} */ /* Actions */
diff --git a/intern/ghost/intern/GHOST_XrSession.h b/intern/ghost/intern/GHOST_XrSession.h
index 624c03bf4f9..abe9372124a 100644
--- a/intern/ghost/intern/GHOST_XrSession.h
+++ b/intern/ghost/intern/GHOST_XrSession.h
@@ -86,7 +86,7 @@ class GHOST_XrSession {
void *getActionSetCustomdata(const char *action_set_name);
void *getActionCustomdata(const char *action_set_name, const char *action_name);
uint32_t getActionCount(const char *action_set_name);
- void getActionCustomdatas(const char *action_set_name, void **r_customdatas);
+ void getActionCustomdataArray(const char *action_set_name, void **r_customdata_array);
/** Controller model functions. */
bool loadControllerModel(const char *subaction_path);
diff --git a/source/blender/makesdna/DNA_xr_types.h b/source/blender/makesdna/DNA_xr_types.h
index 58c7dca2c2c..b307eca7a33 100644
--- a/source/blender/makesdna/DNA_xr_types.h
+++ b/source/blender/makesdna/DNA_xr_types.h
@@ -112,25 +112,35 @@ typedef enum eXrActionType {
XR_VIBRATION_OUTPUT = 100,
} eXrActionType;
+/** Determines how XR action operators are executed. */
+typedef enum eXrOpFlag {
+ XR_OP_PRESS = 0,
+ XR_OP_RELEASE = 1,
+ XR_OP_MODAL = 2,
+} eXrOpFlag;
+
typedef enum eXrActionFlag {
- /** Determines how the operator will be executed (mutually exclusive). */
- XR_ACTION_PRESS = (1 << 0),
- XR_ACTION_RELEASE = (1 << 1),
- XR_ACTION_MODAL = (1 << 2),
- /** Action depends on two subaction paths (i.e. two-handed/bimanual action). */
- XR_ACTION_BIMANUAL = (1 << 3),
- /** Whether to apply haptics to matching user paths. */
- XR_ACTION_HAPTIC_MATCHUSERPATHS = (1 << 4),
- /** Determines how haptics will be applied ("repeat" is mutually exclusive with
- "press"/"release"). */
- XR_ACTION_HAPTIC_PRESS = (1 << 5),
- XR_ACTION_HAPTIC_RELEASE = (1 << 6),
- XR_ACTION_HAPTIC_REPEAT = (1 << 7),
+ /** Action depends on two sub-action paths (i.e. two-handed/bi-manual action). */
+ XR_ACTION_BIMANUAL = (1 << 0),
} eXrActionFlag;
+typedef enum eXrHapticFlag {
+ /** Whether to apply haptics to corresponding user paths for an action and its haptic action. */
+ XR_HAPTIC_MATCHUSERPATHS = (1 << 0),
+ /**
+ * Determines how haptics will be applied
+ * ("repeat" is mutually exclusive with "press"/"release").
+ */
+ XR_HAPTIC_PRESS = (1 << 1),
+ XR_HAPTIC_RELEASE = (1 << 2),
+ XR_HAPTIC_REPEAT = (1 << 3),
+} eXrHapticFlag;
+
typedef enum eXrAxisFlag {
- /** For axis-based inputs (thumbstick/trackpad/etc). Determines the region for operator execution
- (mutually exclusive per axis). */
+ /**
+ * For axis-based inputs (thumb-stick/track-pad/etc).
+ * Determines the region for action execution (mutually exclusive per axis).
+ */
XR_AXIS0_POS = (1 << 0),
XR_AXIS0_NEG = (1 << 1),
XR_AXIS1_POS = (1 << 2),
@@ -149,7 +159,7 @@ typedef struct XrActionMapBinding {
struct XrActionMapBinding *next, *prev;
/** Unique name. */
- char idname[64];
+ char name[64]; /* MAX_NAME */
/** OpenXR interaction profile path. */
char profile[256];
@@ -167,15 +177,16 @@ typedef struct XrActionMapBinding {
float pose_rotation[3];
} XrActionMapBinding;
-#define XR_AMB_MAX_NAME 64
-
/* -------------------------------------------------------------------- */
typedef struct XrActionMapItem {
struct XrActionMapItem *next, *prev;
/** Unique name. */
- char idname[64];
+ char name[64]; /* MAX_NAME */
+ /** Type. */
+ char type; /** eXrActionType */
+ char _pad[7];
/** OpenXR user paths. */
char user_path0[64];
@@ -188,40 +199,36 @@ typedef struct XrActionMapItem {
/** RNA pointer to access properties. */
struct PointerRNA *op_properties_ptr;
- /** Type. */
- char type; /** eXrActionType */
- char _pad[3];
-
+ short op_flag; /* eXrOpFlag */
short action_flag; /* eXrActionFlag */
+ short haptic_fla
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list