Blender  V3.3
GHOST_XrSession.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include <map>
10 #include <memory>
11 
12 #include "GHOST_Xr_intern.h"
13 
14 class GHOST_XrContext;
15 class GHOST_XrSwapchain;
16 struct GHOST_XrDrawInfo;
17 struct OpenXRSessionData;
18 
20  public:
24  };
25 
26  GHOST_XrSession(GHOST_XrContext &xr_context);
28 
29  void start(const GHOST_XrSessionBeginInfo *begin_info);
30  void requestEnd();
31 
32  LifeExpectancy handleStateChangeEvent(const XrEventDataSessionStateChanged &lifecycle);
33 
34  bool isRunning() const;
35  bool needsUpsideDownDrawing() const;
36 
37  void unbindGraphicsContext(); /* Public so context can ensure it's unbound as needed. */
38 
39  void draw(void *draw_customdata);
40 
43  bool createActionSet(const GHOST_XrActionSetInfo &info);
44  void destroyActionSet(const char *action_set_name);
45  bool createActions(const char *action_set_name, uint32_t count, const GHOST_XrActionInfo *infos);
46  void destroyActions(const char *action_set_name,
48  const char *const *action_names);
49  bool createActionBindings(const char *action_set_name,
51  const GHOST_XrActionProfileInfo *infos);
52  void destroyActionBindings(const char *action_set_name,
54  const char *const *action_names,
55  const char *const *profile_paths);
56  bool attachActionSets();
57 
62  bool syncActions(const char *action_set_name = nullptr);
63  bool applyHapticAction(const char *action_set_name,
64  const char *action_name,
65  const char *subaction_path,
66  const int64_t &duration,
67  const float &frequency,
68  const float &amplitude);
69  void stopHapticAction(const char *action_set_name,
70  const char *action_name,
71  const char *subaction_path);
72 
73  /* Custom data (owned by Blender, not GHOST) accessors. */
74  void *getActionSetCustomdata(const char *action_set_name);
75  void *getActionCustomdata(const char *action_set_name, const char *action_name);
76  uint32_t getActionCount(const char *action_set_name);
77  void getActionCustomdataArray(const char *action_set_name, void **r_customdata_array);
78 
80  bool loadControllerModel(const char *subaction_path);
81  void unloadControllerModel(const char *subaction_path);
82  bool updateControllerModelComponents(const char *subaction_path);
83  bool getControllerModelData(const char *subaction_path, GHOST_XrControllerModelData &r_data);
84 
85  private:
88  class GHOST_XrContext *m_context;
89 
90  std::unique_ptr<OpenXRSessionData> m_oxr; /* Could use stack, but PImpl is preferable. */
91 
93  class GHOST_Context *m_gpu_ctx = nullptr;
94  std::unique_ptr<class GHOST_IXrGraphicsBinding> m_gpu_binding;
95 
97  std::unique_ptr<GHOST_XrDrawInfo> m_draw_info;
98 
99  void initSystem();
100  void beginSession();
101  void endSession();
102 
103  void bindGraphicsContext();
104 
105  void prepareDrawing();
106  XrCompositionLayerProjection drawLayer(
107  std::vector<XrCompositionLayerProjectionView> &r_proj_layer_views, void *draw_customdata);
108  void drawView(GHOST_XrSwapchain &swapchain,
109  XrCompositionLayerProjectionView &r_proj_layer_view,
110  XrSpaceLocation &view_location,
111  XrView &view,
112  uint32_t view_idx,
113  void *draw_customdata);
114  void beginFrameDrawing();
115  void endFrameDrawing(std::vector<XrCompositionLayerBaseHeader *> &layers);
116 };
static AppView * view
static void initSystem(LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh, float(*vertexCos)[3], int verts_num)
Main GHOST container to manage OpenXR through.
void destroyActionBindings(const char *action_set_name, uint32_t count, const char *const *action_names, const char *const *profile_paths)
void destroyActionSet(const char *action_set_name)
void draw(void *draw_customdata)
bool createActionSet(const GHOST_XrActionSetInfo &info)
void * getActionCustomdata(const char *action_set_name, const char *action_name)
void unloadControllerModel(const char *subaction_path)
void * getActionSetCustomdata(const char *action_set_name)
bool updateControllerModelComponents(const char *subaction_path)
bool createActionBindings(const char *action_set_name, uint32_t count, const GHOST_XrActionProfileInfo *infos)
GHOST_XrSession(GHOST_XrContext &xr_context)
void stopHapticAction(const char *action_set_name, const char *action_name, const char *subaction_path)
bool isRunning() const
LifeExpectancy handleStateChangeEvent(const XrEventDataSessionStateChanged &lifecycle)
void getActionCustomdataArray(const char *action_set_name, void **r_customdata_array)
bool loadControllerModel(const char *subaction_path)
bool syncActions(const char *action_set_name=nullptr)
bool needsUpsideDownDrawing() const
void start(const GHOST_XrSessionBeginInfo *begin_info)
void destroyActions(const char *action_set_name, uint32_t count, const char *const *action_names)
bool applyHapticAction(const char *action_set_name, const char *action_name, const char *subaction_path, const int64_t &duration, const float &frequency, const float &amplitude)
uint32_t getActionCount(const char *action_set_name)
bool getControllerModelData(const char *subaction_path, GHOST_XrControllerModelData &r_data)
bool createActions(const char *action_set_name, uint32_t count, const GHOST_XrActionInfo *infos)
int count
unsigned int uint32_t
Definition: stdint.h:80
__int64 int64_t
Definition: stdint.h:89