[Bf-blender-cvs] [1bd403430d1] xr-controller-support: Remove duplicate file
Peter Kim
noreply at git.blender.org
Fri Jun 18 14:37:17 CEST 2021
Commit: 1bd403430d17b6bfb421817b146da393fc25f27f
Author: Peter Kim
Date: Fri Jun 18 21:14:13 2021 +0900
Branches: xr-controller-support
https://developer.blender.org/rB1bd403430d17b6bfb421817b146da393fc25f27f
Remove duplicate file
Was renamed to "wm_xr_action.c".
===================================================================
D source/blender/windowmanager/xr/intern/wm_xr_actions.c
===================================================================
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_actions.c b/source/blender/windowmanager/xr/intern/wm_xr_actions.c
deleted file mode 100644
index 51ed3dcfd3c..00000000000
--- a/source/blender/windowmanager/xr/intern/wm_xr_actions.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup wm
- *
- * \name Window-Manager XR Actions
- *
- * Uses the Ghost-XR API to manage OpenXR actions.
- * All functions are designed to be usable by RNA / the Python API.
- */
-
-#include "BLI_math.h"
-
-#include "GHOST_C-api.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "wm_xr_intern.h"
-
-/* -------------------------------------------------------------------- */
-/** \name XR-Action API
- *
- * API functions for managing OpenXR actions.
- *
- * \{ */
-
-static wmXrActionSet *action_set_create(const char *action_set_name)
-{
- wmXrActionSet *action_set = MEM_callocN(sizeof(*action_set), __func__);
- action_set->name = MEM_mallocN(strlen(action_set_name) + 1, "XrActionSet_Name");
- strcpy(action_set->name, action_set_name);
-
- return action_set;
-}
-
-static void action_set_destroy(void *val)
-{
- wmXrActionSet *action_set = val;
-
- MEM_SAFE_FREE(action_set->name);
-
- MEM_freeN(action_set);
-}
-
-static wmXrActionSet *action_set_find(wmXrData *xr, const char *action_set_name)
-{
- return GHOST_XrGetActionSetCustomdata(xr->runtime->context, action_set_name);
-}
-
-static wmXrAction *action_create(const char *action_name,
- eXrActionType type,
- unsigned int count_subaction_paths,
- const char **subaction_paths,
- const float *float_threshold,
- wmOperatorType *ot,
- IDProperty *op_properties,
- eXrOpFlag op_flag)
-{
- wmXrAction *action = MEM_callocN(sizeof(*action), __func__);
- action->name = MEM_mallocN(strlen(action_name) + 1, "XrAction_Name");
- strcpy(action->name, action_name);
- action->type = type;
-
- const unsigned int count = count_subaction_paths;
- action->count_subaction_paths = count;
-
- action->subaction_paths = MEM_mallocN(sizeof(*action->subaction_paths) * count,
- "XrAction_SubactionPaths");
- for (unsigned int i = 0; i < count; ++i) {
- action->subaction_paths[i] = MEM_mallocN(strlen(subaction_paths[i]) + 1,
- "XrAction_SubactionPath");
- strcpy(action->subaction_paths[i], subaction_paths[i]);
- }
-
- size_t size;
- switch (type) {
- case XR_BOOLEAN_INPUT:
- size = sizeof(bool);
- break;
- case XR_FLOAT_INPUT:
- size = sizeof(float);
- break;
- case XR_VECTOR2F_INPUT:
- size = sizeof(float) * 2;
- break;
- case XR_POSE_INPUT:
- size = sizeof(GHOST_XrPose);
- break;
- case XR_VIBRATION_OUTPUT:
- return action;
- }
- action->states = MEM_calloc_arrayN(count, size, "XrAction_States");
- action->states_prev = MEM_calloc_arrayN(count, size, "XrAction_StatesPrev");
-
- if (float_threshold) {
- BLI_assert(type == XR_FLOAT_INPUT || type == XR_VECTOR2F_INPUT);
- action->float_threshold = *float_threshold;
- CLAMP(action->float_threshold, 0.0f, 1.0f);
- }
-
- action->ot = ot;
- action->op_properties = op_properties;
- action->op_flag = op_flag;
-
- return action;
-}
-
-static void action_destroy(void *val)
-{
- wmXrAction *action = val;
-
- MEM_SAFE_FREE(action->name);
-
- const unsigned int count = action->count_subaction_paths;
- char **subaction_paths = action->subaction_paths;
- if (subaction_paths) {
- for (unsigned int i = 0; i < count; ++i) {
- MEM_SAFE_FREE(subaction_paths[i]);
- }
- MEM_freeN(subaction_paths);
- }
-
- MEM_SAFE_FREE(action->states);
- MEM_SAFE_FREE(action->states_prev);
-
- MEM_freeN(action);
-}
-
-static wmXrAction *action_find(wmXrData *xr, const char *action_set_name, const char *action_name)
-{
- return GHOST_XrGetActionCustomdata(xr->runtime->context, action_set_name, action_name);
-}
-
-bool WM_xr_action_set_create(wmXrData *xr, const char *action_set_name)
-{
- if (action_set_find(xr, action_set_name)) {
- return false;
- }
-
- wmXrActionSet *action_set = action_set_create(action_set_name);
-
- GHOST_XrActionSetInfo info = {
- .name = action_set_name,
- .customdata_free_fn = action_set_destroy,
- .customdata = action_set,
- };
-
- if (!GHOST_XrCreateActionSet(xr->runtime->context, &info)) {
- return false;
- }
-
- return true;
-}
-
-void WM_xr_action_set_destroy(wmXrData *xr, const char *action_set_name)
-{
- wmXrActionSet *action_set = action_set_find(xr, action_set_name);
- if (!action_set) {
- return;
- }
-
- wmXrSessionState *session_state = &xr->runtime->session_state;
-
- if (action_set == session_state->active_action_set) {
- if (action_set->controller_pose_action) {
- wm_xr_session_controller_data_clear(session_state);
- action_set->controller_pose_action = NULL;
- }
- if (action_set->active_modal_action) {
- action_set->active_modal_action = NULL;
- }
- session_state->active_action_set = NULL;
- }
-
- GHOST_XrDestroyActionSet(xr->runtime->context, action_set_name);
-}
-
-bool WM_xr_action_create(wmXrData *xr,
- const char *action_set_name,
- const char *action_name,
- eXrActionType type,
- unsigned int count_subaction_paths,
- const char **subaction_paths,
- const float *float_threshold,
- wmOperatorType *ot,
- IDProperty *op_properties,
- eXrOpFlag op_flag)
-{
- if (action_find(xr, action_set_name, action_name)) {
- return false;
- }
-
- wmXrAction *action = action_create(action_name,
- type,
- count_subaction_paths,
- subaction_paths,
- float_threshold,
- ot,
- op_properties,
- op_flag);
-
- GHOST_XrActionInfo info = {
- .name = action_name,
- .count_subaction_paths = count_subaction_paths,
- .subaction_paths = subaction_paths,
- .states = action->states,
- .customdata_free_fn = action_destroy,
- .customdata = action,
- };
-
- switch (type) {
- case XR_BOOLEAN_INPUT:
- info.type = GHOST_kXrActionTypeBooleanInput;
- break;
- case XR_FLOAT_INPUT:
- info.type = GHOST_kXrActionTypeFloatInput;
- break;
- case XR_VECTOR2F_INPUT:
- info.type = GHOST_kXrActionTypeVector2fInput;
- break;
- case XR_POSE_INPUT:
- info.type = GHOST_kXrActionTypePoseInput;
- break;
- case XR_VIBRATION_OUTPUT:
- info.type = GHOST_kXrActionTypeVibrationOutput;
- break;
- }
-
- if (!GHOST_XrCreateActions(xr->runtime->context, action_set_name, 1, &info)) {
- return false;
- }
-
- return true;
-}
-
-void WM_xr_action_destroy(wmXrData *xr, const char *action_set_name, const char *action_name)
-{
- wmXrActionSet *action_set = action_set_find(xr, action_set_name);
- if (!action_set) {
- return;
- }
-
- if (action_set->controller_pose_action &&
- STREQ(action_set->controller_pose_action->name, action_name)) {
- if (action_set == xr->runtime->session_state.active_action_set) {
- wm_xr_session_controller_data_clear(&xr->runtime->session_state);
- }
- action_set->controller_pose_action = NULL;
- }
- if (action_set->active_modal_action &&
- STREQ(action_set->active_modal_action->name, action_name)) {
- action_set->active_modal_action = NULL;
- }
-
- wmXrAction *action = action_find(xr, action_set_name, action_name);
- if (!action) {
- return;
- }
-}
-
-bool WM_xr_action_space_create(wmXrData *xr,
- const char *action_set_name,
- const char *action_name,
- unsigned int count_subaction_paths,
- const char **subaction_paths,
- const wmXrPose *poses)
-{
- GHOST_XrActionSpaceInfo info = {
- .action_name = action_name,
- .count_subaction_paths = count_subaction_paths,
- .subaction_paths = subaction_paths,
- };
-
- GHOST_XrPose *ghost_poses = MEM_malloc_arrayN(
- count_subaction_paths, sizeof(*ghost_poses), __func__);
- for (unsigned int i = 0; i < count_subaction_paths; ++i) {
- const wmXrPose *pose = &poses[i];
- GHOST_XrPose *ghost_pose = &ghost_poses[i];
- copy_v3_v3(ghost_pose->position, pose->position);
- copy_qt_qt(ghost_pose->orientation_quat, pose->orientation_quat);
- }
- info.poses = ghost_poses;
-
- bool ret = GHOST_XrCreateActionSpaces(xr->runtime->context, action_set_name, 1, &info) ? true :
- false;
- MEM_freeN(ghost_poses);
- return ret;
-}
-
-void WM_xr_action_space_destroy(wmXrData *xr,
- const char *action_set_name,
- const char *action_name,
- unsigned int count_subaction_paths,
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list