[Bf-blender-cvs] [5190beb5e9b] soc-2020-xr-input: Many changes to API.
Peter Klimenko
noreply at git.blender.org
Mon Jun 22 18:29:12 CEST 2020
Commit: 5190beb5e9b70681662bf29a2f065399647ca69d
Author: Peter Klimenko
Date: Tue Jun 23 02:29:03 2020 +1000
Branches: soc-2020-xr-input
https://developer.blender.org/rB5190beb5e9b70681662bf29a2f065399647ca69d
Many changes to API.
===================================================================
A attached)
A git
M intern/ghost/GHOST_IXrContext.h
M intern/ghost/GHOST_Types.h
M intern/ghost/intern/GHOST_C-api.cpp
M intern/ghost/intern/GHOST_XrContext.cpp
M intern/ghost/intern/GHOST_XrContext.h
M intern/ghost/intern/GHOST_XrSession.cpp
M intern/ghost/intern/GHOST_XrSession.h
M release/scripts/addons
===================================================================
diff --git a/attached) b/attached)
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/git b/git
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/intern/ghost/GHOST_IXrContext.h b/intern/ghost/GHOST_IXrContext.h
index 3076de96690..29cd835afba 100644
--- a/intern/ghost/GHOST_IXrContext.h
+++ b/intern/ghost/GHOST_IXrContext.h
@@ -39,6 +39,8 @@ class GHOST_IXrContext {
virtual void setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn) = 0;
virtual bool needsUpsideDownDrawing() const = 0;
+
+ virtual GHOST_XrPose getSpacePose(GHOST_XrSpace space) const = 0;
};
#endif // __GHOST_IXRCONTEXT_H__
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index b8de31df6c6..a047f48552f 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -17,29 +17,32 @@
* All rights reserved.
*/
+#include <stdbool.h>
+#include <stdint.h>
+
/** \file
* \ingroup GHOST
*/
#ifndef __GHOST_TYPES_H__
-#define __GHOST_TYPES_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-# include "MEM_guardedalloc.h"
-#endif
-
-#if defined(WITH_CXX_GUARDEDALLOC) && defined(__cplusplus)
-# define GHOST_DECLARE_HANDLE(name) \
- typedef struct name##__ { \
- int unused; \
- MEM_CXX_CLASS_ALLOC_FUNCS(#name) \
- } * name
-#else
-# define GHOST_DECLARE_HANDLE(name) \
- typedef struct name##__ { \
- int unused; \
- } * name
-#endif
+# define __GHOST_TYPES_H__
+
+# ifdef WITH_CXX_GUARDEDALLOC
+# include "MEM_guardedalloc.h"
+# endif
+
+# if defined(WITH_CXX_GUARDEDALLOC) && defined(__cplusplus)
+# define GHOST_DECLARE_HANDLE(name) \
+ typedef struct name##__ { \
+ int unused; \
+ MEM_CXX_CLASS_ALLOC_FUNCS(#name) \
+ } * name
+# else
+# define GHOST_DECLARE_HANDLE(name) \
+ typedef struct name##__ { \
+ int unused; \
+ } * name
+# endif
/**
* Creates a "handle" for a C++ GHOST object.
@@ -57,6 +60,9 @@ GHOST_DECLARE_HANDLE(GHOST_EventConsumerHandle);
GHOST_DECLARE_HANDLE(GHOST_ContextHandle);
GHOST_DECLARE_HANDLE(GHOST_XrContextHandle);
+GHOST_DECLARE_HANDLE(GHOST_XrActionSetHandle);
+GHOST_DECLARE_HANDLE(GHOST_XrActionHandle);
+
typedef char GHOST_TInt8;
typedef unsigned char GHOST_TUns8;
typedef short GHOST_TInt16;
@@ -79,13 +85,13 @@ typedef enum GHOST_DialogOptions {
GHOST_DialogError = (1 << 1),
} GHOST_DialogOptions;
-#ifdef _MSC_VER
+# ifdef _MSC_VER
typedef __int64 GHOST_TInt64;
typedef unsigned __int64 GHOST_TUns64;
-#else
+# else
typedef long long GHOST_TInt64;
typedef unsigned long long GHOST_TUns64;
-#endif
+# endif
typedef void *GHOST_TUserDataPtr;
@@ -157,9 +163,9 @@ typedef enum { GHOST_kWindowOrderTop = 0, GHOST_kWindowOrderBottom } GHOST_TWind
typedef enum {
GHOST_kDrawingContextTypeNone = 0,
GHOST_kDrawingContextTypeOpenGL,
-#ifdef WIN32
+# ifdef WIN32
GHOST_kDrawingContextTypeD3D,
-#endif
+# endif
} GHOST_TDrawingContextType;
typedef enum {
@@ -183,10 +189,10 @@ typedef enum {
GHOST_kEventWheel, /// Mouse wheel event
GHOST_kEventTrackpad, /// Trackpad event
-#ifdef WITH_INPUT_NDOF
+# ifdef WITH_INPUT_NDOF
GHOST_kEventNDOFMotion, /// N degree of freedom device motion event
GHOST_kEventNDOFButton, /// N degree of freedom device button event
-#endif
+# endif
GHOST_kEventKeyDown,
GHOST_kEventKeyUp,
@@ -519,7 +525,7 @@ typedef enum {
GHOST_kFinished
} GHOST_TProgress;
-#ifdef WITH_INPUT_NDOF
+# ifdef WITH_INPUT_NDOF
typedef struct {
/** N-degree of freedom device data v3 [GSoC 2010] */
// Each component normally ranges from -1 to +1, but can exceed that.
@@ -539,7 +545,7 @@ typedef struct {
GHOST_TButtonAction action;
short button;
} GHOST_TEventNDOFButtonData;
-#endif // WITH_INPUT_NDOF
+# endif // WITH_INPUT_NDOF
typedef struct {
/** The key code. */
@@ -574,29 +580,29 @@ typedef struct {
GHOST_TUns32 frequency;
} GHOST_DisplaySetting;
-#ifdef _WIN32
+# ifdef _WIN32
typedef void *GHOST_TEmbedderWindowID;
-#endif // _WIN32
+# endif // _WIN32
-#ifndef _WIN32
+# ifndef _WIN32
// I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
typedef int GHOST_TEmbedderWindowID;
-#endif // _WIN32
+# endif // _WIN32
/**
* A timer task callback routine.
* \param task The timer task object.
* \param time The current time.
*/
-#ifdef __cplusplus
+# ifdef __cplusplus
class GHOST_ITimerTask;
typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask *task, GHOST_TUns64 time);
-#else
+# else
struct GHOST_TimerTaskHandle__;
typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__ *task, GHOST_TUns64 time);
-#endif
+# endif
-#ifdef WITH_XR_OPENXR
+# ifdef WITH_XR_OPENXR
struct GHOST_XrDrawViewInfo;
struct GHOST_XrError;
@@ -610,9 +616,9 @@ struct GHOST_XrError;
typedef enum GHOST_TXrGraphicsBinding {
GHOST_kXrGraphicsUnknown = 0,
GHOST_kXrGraphicsOpenGL,
-# ifdef WIN32
+# ifdef WIN32
GHOST_kXrGraphicsD3D11,
-# endif
+# endif
/* For later */
// GHOST_kXrGraphicsVulkan,
} GHOST_TXrGraphicsBinding;
@@ -676,6 +682,37 @@ typedef struct GHOST_XrError {
void *customdata;
} GHOST_XrError;
-#endif
+/* Nanoseconds */
+typedef int64_t GHOST_XrTime;
+
+typedef struct GHOST_XrActionStateBoolean {
+ bool currentState;
+ GHOST_XrTime lastChangeTime;
+ bool changedSinceSync;
+ bool isActive;
+} GHOST_XrActionStateBool;
+
+typedef struct GHOST_XrActionStateFloat {
+ float currentState;
+ GHOST_XrTime lastChangeTime;
+ bool changedSinceSync;
+ bool isActive;
+} GHOST_XrActionStateFloat;
+
+typedef struct GHOST_XrActionStateVector2f {
+ float currentX;
+ float currentY;
+ GHOST_XrTime lastChangeTime;
+ bool changedSinceSync;
+ bool isActive;
+} GHOST_XrActionStateVector2f;
+
+typedef enum GHOST_XrSpace {
+ GHOST_SPACE_VIEW,
+ GHOST_SPACE_LEFT_HAND,
+ GHOST_SPACE_RIGHT_HAND,
+} GHOST_XrSpace;
+
+# endif
#endif // __GHOST_TYPES_H__
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 843684b6d2e..8eeee3c8c9b 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -966,5 +966,12 @@ int GHOST_XrSessionNeedsUpsideDownDrawing(const GHOST_XrContextHandle xr_context
GHOST_XR_CAPI_CALL_RET(xr_context->needsUpsideDownDrawing(), xr_context);
return 0; /* Only reached if exception is thrown. */
}
+GHOST_XrPose GHOST_XrGetSpacePose(const GHOST_XrContextHandle xr_contexthandle, GHOST_XrSpace space)
+{
+ GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
+ GHOST_XR_CAPI_CALL_RET(xr_context->getSpacePose(space), xr_context);
+
+ return GHOST_XrPose{};
+}
#endif
diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp
index 3aab420a9b6..5d7f7437cf8 100644
--- a/intern/ghost/intern/GHOST_XrContext.cpp
+++ b/intern/ghost/intern/GHOST_XrContext.cpp
@@ -526,6 +526,12 @@ bool GHOST_XrContext::needsUpsideDownDrawing() const
return m_session->needsUpsideDownDrawing();
}
+GHOST_XrPose GHOST_XrContext::getSpacePose(GHOST_XrSpace space) const
+{
+ assert(m_session);
+ return m_session->getSpacePose(space);
+}
+
/** \} */ /* Public Accessors and Mutators */
/* -------------------------------------------------------------------- */
diff --git a/intern/ghost/intern/GHOST_XrContext.h b/intern/ghost/intern/GHOST_XrContext.h
index 7dbd0a0d011..083af4ae8f8 100644
--- a/intern/ghost/intern/GHOST_XrContext.h
+++ b/intern/ghost/intern/GHOST_XrContext.h
@@ -80,6 +80,8 @@ class GHOST_XrContext : public GHOST_IXrContext {
void setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn) override;
bool needsUpsideDownDrawing() const override;
+ GHOST_XrPose getSpacePose(GHOST_XrSpace space) const override;
+
void handleSessionStateChange(const XrEventDataSessionStateChanged *lifecycle);
GHOST_TXrOpenXRRuntimeID getOpenXRRuntimeID() const;
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index ded14fb187a..1c6fadc84c4 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -18,11 +18,11 @@
* \ingroup GHOST
*/
-#include <iterator>
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cstdio>
+#include <iterator>
#include <list>
#include <sstream>
@@ -36,11 +36,35 @@
#include "GHOST_XrSession.h"
+struct GHOST_XrActionCreateInfo {
+ std::string name;
+ std::string localizedName;
+ XrActionType actionType;
+};
+
+struct GHOST_XrSubactionInfo {
+ std::string path;
+ std::string name;
+};
+
+struct GHOST_XrSubactionsCreateInfo {
+ std::string parentName;
+ std::string localizedParentName;
+ XrActionType actionType;
+ std::vector<GHOST_XrSubactionInfo> subactions;
+};
+
struct OpenXRActionData {
- std::map<std::string, GHOST_XrActionSet> actionSetMap;
+ /* Has the lifecycle of the session gone past attaching action sets? */
+ bool attached;
- XrPath controlPaths[2];
- XrSpace controlSpaces[2];
+ GHOST_XrActionSetMap actionSetMap;
+ GHOST_XrInteractionMap interactionMap;
+
+ XrSpace handSpaces[2];
+ XrPosef handPoses[2];
+
+ XrPosef viewPose;
};
struct OpenXRSessionData {
@@ -54,13 +78,16 @@ struct OpenXRSessionData {
XrSpace view_space;
std::vector<XrView> views;
std::vector<GHOST_XrSwapchain> swapchains;
+
OpenXRActionData actionData;
};
-GHOST_XrAction::GHOST_XrAction(XrAction action, XrActionType actionType)
+GHOST_XrAction::GHOST_XrAction(XrSession xrSession,
+ XrInstance xrInstance,
+ XrAction handle,
+ XrPath subpath)
+ : xrSession(xrSession), xrInstance(xrInstance), handle(handle), subPath(subpath)
{
- handle = action;
- this->actionType = actionType;
}
GHOST_XrActionSet::~GHOST_XrActionSet()
@@ -68,55 +95,304 @@ GHOST_XrActionSet::~GHOST_XrActionSet()
xrDestroyActionSet(handle);
}
-XrAction GHOST_XrActionSet::createAction(XrActionCreateInfo *info)
+XrPath stringToPath(XrInstance xrInstance, const std::string &path)
+{
+ XrPath xrPath;
+ CHECK_XR(xrStringToPath(xrInstance, path.c_str(), &xrPath), "Failed to convert string to path.");
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list