51 MEM_SAFE_DELETE(action_set->
name);
56 MEM_delete(action_set);
67 const ListBaseT<XrUserPath> *user_paths,
70 const char *haptic_name,
72 const float *haptic_frequency,
73 const float *haptic_amplitude,
82 const uint count =
uint(user_paths->count());
86 for (
auto [subaction_idx, user_path] : user_paths->enumerate()) {
99 size =
sizeof(
float) * 2;
102 size =
sizeof(GHOST_XrPose);
111 const bool is_button_action = (is_float_action || type ==
XR_BOOLEAN_INPUT);
112 if (is_float_action) {
115 if (is_button_action) {
141 MEM_SAFE_DELETE(action->
name);
144 if (subaction_paths) {
146 MEM_SAFE_DELETE(subaction_paths[i]);
148 MEM_delete(subaction_paths);
151 MEM_SAFE_DELETE_VOID(action->
states);
176 GHOST_XrActionSetInfo info{};
177 info.name = action_set_name;
179 info.customdata = action_set;
213 const char *action_set_name,
214 const char *action_name,
216 const ListBaseT<XrUserPath> *user_paths,
219 const char *haptic_name,
220 const int64_t *haptic_duration,
221 const float *haptic_frequency,
222 const float *haptic_amplitude,
227 if (
action_find(xr, action_set_name, action_name)) {
244 const uint count =
uint(user_paths->count());
248 for (
auto [subaction_idx, user_path] : user_paths->enumerate()) {
249 subaction_paths[subaction_idx] = (
char *)user_path.path;
252 GHOST_XrActionInfo info{};
253 info.name = action_name;
254 info.count_subaction_paths = count;
255 info.subaction_paths =
const_cast<const char **
>(subaction_paths);
256 info.states = action->
states;
260 info.customdata = action;
264 info.type = GHOST_kXrActionTypeBooleanInput;
267 info.type = GHOST_kXrActionTypeFloatInput;
270 info.type = GHOST_kXrActionTypeVector2fInput;
273 info.type = GHOST_kXrActionTypePoseInput;
276 info.type = GHOST_kXrActionTypeVibrationOutput;
283 MEM_delete(subaction_paths);
313 if (
STREQ(active_modal_action->
name, action_name)) {
320 if (
STREQ(ha.action->name, action_name)) {
329 const char *action_set_name,
330 const char *action_name,
331 const char *profile_path,
332 const ListBaseT<XrUserPath> *user_paths,
333 const ListBaseT<XrComponentPath> *component_paths,
334 const float *float_thresholds,
336 const wmXrPose *poses)
338 const uint count =
uint(user_paths->count());
342 count,
"XrActionBinding_Infos");
345 "XrActionBinding_SubactionPathPointers");
347 for (
uint i = 0; i < count; ++i) {
348 GHOST_XrActionBindingInfo *binding_info = &binding_infos[i];
353 subaction_paths[i] =
const_cast<char *
>(user_path->
path);
355 binding_info->component_path = component_path->
path;
356 if (float_thresholds) {
357 binding_info->float_threshold = float_thresholds[i];
360 binding_info->axis_flag = axis_flags[i];
363 copy_v3_v3(binding_info->pose.position, poses[i].position);
364 copy_qt_qt(binding_info->pose.orientation_quat, poses[i].orientation_quat);
368 GHOST_XrActionProfileInfo profile_info{};
369 profile_info.action_name = action_name;
370 profile_info.profile_path = profile_path;
371 profile_info.count_subaction_paths = count;
372 profile_info.subaction_paths =
const_cast<const char **
>(subaction_paths);
373 profile_info.bindings = binding_infos;
378 MEM_delete(subaction_paths);
379 MEM_delete(binding_infos);
385 const char *action_set_name,
386 const char *action_name,
387 const char *profile_path)
410 if (active_action_set) {
430 const char *action_set_name,
431 const char *grip_action_name,
432 const char *aim_action_name)
455 for (
uint i = 0; i < count; ++i) {
472 const char *action_set_name,
473 const char *action_name,
474 const char *subaction_path,
475 wmXrActionState *r_state)
482 r_state->type = int(action->
type);
487 switch (action->
type) {
489 r_state->state_boolean = (
static_cast<bool *
>(action->
states))[i];
492 r_state->state_float = (
static_cast<float *
>(action->
states))[i];
495 copy_v2_v2(r_state->state_vector2f, (
static_cast<float (*)[2]
>(action->
states))[i]);
498 const GHOST_XrPose *
pose = &((GHOST_XrPose *)action->
states)[i];
500 copy_qt_qt(r_state->state_pose.orientation_quat,
pose->orientation_quat);
515 const char *action_set_name,
516 const char *action_name,
517 const char *subaction_path,
520 const float *amplitude)
534 const char *action_set_name,
535 const char *action_name,
536 const char *subaction_path)
Abstraction for XR (VR, AR, MR, ..) access via OpenXR.
void GHOST_XrDestroyActionSet(GHOST_IXrContext *xr_context, const char *action_set_name)
int GHOST_XrCreateActions(GHOST_IXrContext *xr_context, const char *action_set_name, uint32_t count, const GHOST_XrActionInfo *infos)
void GHOST_XrDestroyActions(GHOST_IXrContext *xr_context, const char *action_set_name, uint32_t count, const char *const *action_names)
int GHOST_XrCreateActionSet(GHOST_IXrContext *xr_context, const GHOST_XrActionSetInfo *info)
void * GHOST_XrGetActionCustomdata(GHOST_IXrContext *xr_context, const char *action_set_name, const char *action_name)
int GHOST_XrCreateActionBindings(GHOST_IXrContext *xr_context, const char *action_set_name, uint32_t count, const GHOST_XrActionProfileInfo *infos)
void GHOST_XrStopHapticAction(GHOST_IXrContext *xr_context_handle, const char *action_set_name, const char *action_name, const char *subaction_path)
void * GHOST_XrGetActionSetCustomdata(GHOST_IXrContext *xr_context, const char *action_set_name)
void GHOST_XrDestroyActionBindings(GHOST_IXrContext *xr_context, const char *action_set_name, uint32_t count, const char *const *action_names, const char *const *profile_paths)
int GHOST_XrApplyHapticAction(GHOST_IXrContext *xr_context_handle, const char *action_set_name, const char *action_name, const char *subaction_path, const int64_t *duration, const float *frequency, const float *amplitude)
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static SpaceLink * action_create(const ScrArea *area, const Scene *scene)
void wm_xr_session_controller_data_populate(const wmXrAction *grip_action, const wmXrAction *aim_action, wmXrData *xr)
char * STRNCPY(char(&dst)[N], const char *src)
static wmXrAction * action_find(wmXrData *xr, const char *action_set_name, const char *action_name)
static wmXrActionSet * action_set_create(const char *action_set_name)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void WM_xr_action_binding_destroy(wmXrData *xr, const char *action_set_name, const char *action_name, const char *profile_path)
MINLINE void copy_v2_v2(float r[2], const float a[2])
static void action_set_destroy(void *val)
bool WM_xr_controller_pose_actions_set(wmXrData *xr, const char *action_set_name, const char *grip_action_name, const char *aim_action_name)
void wm_xr_session_controller_data_clear(wmXrSessionState *state)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
static wmXrActionSet * action_set_find(wmXrData *xr, const char *action_set_name)
void WM_xr_action_set_destroy(wmXrData *xr, const char *action_set_name)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void copy_qt_qt(float q[4], const float a[4])
void WM_xr_haptic_action_stop(wmXrData *xr, const char *action_set_name, const char *action_name, const char *subaction_path)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
bool WM_xr_action_create(wmXrData *xr, const char *action_set_name, const char *action_name, eXrActionType type, const ListBaseT< XrUserPath > *user_paths, wmOperatorType *ot, IDProperty *op_properties, const char *haptic_name, const int64_t *haptic_duration, const float *haptic_frequency, const float *haptic_amplitude, eXrOpFlag op_flag, eXrActionFlag action_flag, eXrHapticFlag haptic_flag)
bool WM_xr_active_action_set_set(wmXrData *xr, const char *action_set_name, bool delayed)
static void action_destroy(void *val)
bool WM_xr_action_state_get(const wmXrData *xr, const char *action_set_name, const char *action_name, const char *subaction_path, wmXrActionState *r_state)
bool WM_xr_haptic_action_apply(wmXrData *xr, const char *action_set_name, const char *action_name, const char *subaction_path, const int64_t *duration, const float *frequency, const float *amplitude)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
void WM_xr_action_destroy(wmXrData *xr, const char *action_set_name, const char *action_name)
bool WM_xr_action_binding_create(wmXrData *xr, const char *action_set_name, const char *action_name, const char *profile_path, const ListBaseT< XrUserPath > *user_paths, const ListBaseT< XrComponentPath > *component_paths, const float *float_thresholds, const eXrAxisFlag *axis_flags, const wmXrPose *poses)
bool WM_xr_action_set_create(wmXrData *xr, const char *action_set_name)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
wmXrAction * controller_aim_action
ListBaseT< LinkData > active_modal_actions
wmXrAction * controller_grip_action
ListBaseT< wmXrHapticAction > active_haptic_actions
IDProperty * op_properties
eXrHapticFlag haptic_flag
eXrActionFlag action_flag
struct wmOperatorType * ot
unsigned int count_subaction_paths
struct wmXrRuntimeData * runtime
wmXrSessionState session_state
GHOST_IXrContext * ghost_context
char active_action_set_next[64]
struct wmXrActionSet * active_action_set