Blender V4.3
GHOST_XrSession.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include <map>
12#include <memory>
13
14#include "GHOST_Xr_intern.hh"
15
16class GHOST_XrContext;
18struct GHOST_XrDrawInfo;
20
22 public:
27
30
31 void start(const GHOST_XrSessionBeginInfo *begin_info);
32 void requestEnd();
33
34 LifeExpectancy handleStateChangeEvent(const XrEventDataSessionStateChanged &lifecycle);
35
36 bool isRunning() const;
37 bool needsUpsideDownDrawing() const;
38
39 void unbindGraphicsContext(); /* Public so context can ensure it's unbound as needed. */
40
41 void draw(void *draw_customdata);
42
45 bool createActionSet(const GHOST_XrActionSetInfo &info);
46 void destroyActionSet(const char *action_set_name);
47 bool createActions(const char *action_set_name, uint32_t count, const GHOST_XrActionInfo *infos);
48 void destroyActions(const char *action_set_name,
50 const char *const *action_names);
51 bool createActionBindings(const char *action_set_name,
53 const GHOST_XrActionProfileInfo *infos);
54 void destroyActionBindings(const char *action_set_name,
56 const char *const *action_names,
57 const char *const *profile_paths);
58 bool attachActionSets();
59
64 bool syncActions(const char *action_set_name = nullptr);
65 bool applyHapticAction(const char *action_set_name,
66 const char *action_name,
67 const char *subaction_path,
68 const int64_t &duration,
69 const float &frequency,
70 const float &amplitude);
71 void stopHapticAction(const char *action_set_name,
72 const char *action_name,
73 const char *subaction_path);
74
75 /* Custom data (owned by Blender, not GHOST) accessors. */
76 void *getActionSetCustomdata(const char *action_set_name);
77 void *getActionCustomdata(const char *action_set_name, const char *action_name);
78 uint32_t getActionCount(const char *action_set_name);
79 void getActionCustomdataArray(const char *action_set_name, void **r_customdata_array);
80
82 bool loadControllerModel(const char *subaction_path);
83 void unloadControllerModel(const char *subaction_path);
84 bool updateControllerModelComponents(const char *subaction_path);
85 bool getControllerModelData(const char *subaction_path, GHOST_XrControllerModelData &r_data);
86
87 private:
90 class GHOST_XrContext *m_context;
91
92 std::unique_ptr<OpenXRSessionData> m_oxr; /* Could use stack, but PImpl is preferable. */
93
95 class GHOST_Context *m_gpu_ctx = nullptr;
96 std::unique_ptr<class GHOST_IXrGraphicsBinding> m_gpu_binding;
97
99 std::unique_ptr<GHOST_XrDrawInfo> m_draw_info;
100
101 void initSystem();
102 void beginSession();
103 void endSession();
104
105 void bindGraphicsContext();
106
107 void prepareDrawing();
108 XrCompositionLayerProjection drawLayer(
109 std::vector<XrCompositionLayerProjectionView> &r_proj_layer_views, void *draw_customdata);
110 void drawView(GHOST_XrSwapchain &swapchain,
111 XrCompositionLayerProjectionView &r_proj_layer_view,
112 const XrSpaceLocation &view_location,
113 const XrView &view,
114 uint32_t view_idx,
115 void *draw_customdata);
116 void beginFrameDrawing();
117 void endFrameDrawing(std::vector<XrCompositionLayerBaseHeader *> &layers);
118
120 void enablePassthrough();
121};
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