[Bf-extensions-cvs] [01d64102] xr-actions-D9124: VR: Enable switching action sets during session
Peter Kim
noreply at git.blender.org
Sun Nov 15 15:52:00 CET 2020
Commit: 01d6410222fb5e1b4b513f86c92cd906f0832708
Author: Peter Kim
Date: Sun Nov 15 23:47:10 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBA01d6410222fb5e1b4b513f86c92cd906f0832708
VR: Enable switching action sets during session
===================================================================
M viewport_vr_preview.py
===================================================================
diff --git a/viewport_vr_preview.py b/viewport_vr_preview.py
index 5facfc9c..4744d71f 100644
--- a/viewport_vr_preview.py
+++ b/viewport_vr_preview.py
@@ -397,46 +397,58 @@ def vr_create_actions(context: bpy.context):
# Create all vr action sets and actions.
context = bpy.context
wm = context.window_manager
- action_set = VRActionSet.get_active_action_set(context)
+ scene = context.scene
+ action_sets = scene.vr_action_sets
- if wm.xr_session_state and action_set and len(action_set.actions) > 0:
- ok = wm.xr_session_state.create_action_set(context, action_set.name)
- if not ok:
- return
- actions = action_set.actions
+ if wm.xr_session_state and action_sets:
+ for action_set in action_sets:
+ if len(action_set.actions) > 0:
+ ok = wm.xr_session_state.create_action_set(context, action_set.name)
+ if not ok:
+ return
+ actions = action_set.actions
- interaction_path0 = ""
- interaction_path1 = ""
+ interaction_path0 = ""
+ interaction_path1 = ""
- for action in actions:
- ok = wm.xr_session_state.create_action(context, action_set.name, action.name, action.type,
- action.user_path0, action.user_path1, action.threshold, action.op, action.op_flag)
- if not ok:
- return
+ for action in actions:
+ ok = wm.xr_session_state.create_action(context, action_set.name, action.name, action.type,
+ action.user_path0, action.user_path1, action.threshold, action.op, action.op_flag)
+ if not ok:
+ return
- if action.type == 'POSE':
- ok = wm.xr_session_state.create_action_space(context, action_set.name, action.name,
- action.user_path0, action.user_path1,
- action.pose_location, action.pose_rotation)
- if not ok:
- return
-
- if action.pose_is_controller:
- ok = wm.xr_session_state.set_controller_pose_action(context, action_set.name, action.name)
+ if action.type == 'POSE':
+ ok = wm.xr_session_state.create_action_space(context, action_set.name, action.name,
+ action.user_path0, action.user_path1,
+ action.pose_location, action.pose_rotation)
+ if not ok:
+ return
+
+ if action.pose_is_controller:
+ ok = wm.xr_session_state.set_controller_pose_action(context, action_set.name, action.name)
+ if not ok:
+ return
+
+ interaction_path0 = action.user_path0 + action.component_path0
+ interaction_path1 = action.user_path1 + action.component_path1
+
+ ok = wm.xr_session_state.create_action_binding(context, action_set.name, action_set.profile, action.name,
+ interaction_path0, interaction_path1)
if not ok:
return
- interaction_path0 = action.user_path0 + action.component_path0
- interaction_path1 = action.user_path1 + action.component_path1
+ # Set active action set.
+ active_action_set = action_sets[scene.vr_action_sets_active]
+ if active_action_set and len(active_action_set.actions) > 0:
+ wm.xr_session_state.set_active_action_set(context, active_action_set.name)
- ok = wm.xr_session_state.create_action_binding(context, action_set.name, action_set.profile, action.name,
- interaction_path0, interaction_path1)
- if not ok:
- return
- ok = wm.xr_session_state.set_active_action_set(context, action_set.name)
- if not ok:
- return
+def xr_action_set_active_update(self, context):
+ wm = context.window_manager
+ if wm.xr_session_state:
+ action_set = VRActionSet.get_active_action_set(context)
+ if action_set:
+ wm.xr_session_state.set_active_action_set(context, action_set.name)
class VRAction(PropertyGroup):
@@ -2179,7 +2191,7 @@ def register():
)
bpy.types.Scene.vr_action_sets_active = IntProperty(
default=0,
- #update=xr_action_set_active_update,
+ update=xr_action_set_active_update,
)
# View3DShading is the only per 3D-View struct with custom property
# support, so "abusing" that to get a per 3D-View option.
More information about the Bf-extensions-cvs
mailing list