From 0cfd2d6f4b24a7703be4faf615eb47d9448d355c Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 28 Apr 2020 23:16:29 +0200 Subject: VR: Reset pose offsets when changing base pose The offsets are applied after toggling positional tracking off, so that the view does not jump at that moment. But when changing the base pose, keeping that offset doesn't make sense. Especially with landmarks, which are supposed to give precise positions/rotations to jump to. For that part the VR Scene Inspection Add-on will need a little adjustment though. Also exposes an explicit function to the Python API to reset the offsets, to be used by the Add-on. This is mostly untested since I don't have access to an HMD currently. --- source/blender/makesrna/intern/rna_xr.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c index b08e48a4b17..04a8500d136 100644 --- a/source/blender/makesrna/intern/rna_xr.c +++ b/source/blender/makesrna/intern/rna_xr.c @@ -45,6 +45,16 @@ static bool rna_XrSessionState_is_running(bContext *C) # endif } +static void rna_XrSessionState_reset_to_base_pose(bContext *C) +{ +# ifdef WITH_XR_OPENXR + wmWindowManager *wm = CTX_wm_manager(C); + WM_xr_session_base_pose_reset(&wm->xr); +# else + UNUSED_VARS(C); +# endif +} + # ifdef WITH_XR_OPENXR static wmXrData *rna_XrSessionState_wm_xr_data_get(PointerRNA *ptr) { @@ -197,6 +207,12 @@ static void rna_def_xr_session_state(BlenderRNA *brna) parm = RNA_def_boolean(func, "result", 0, "Result", ""); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "reset_to_base_pose", "rna_XrSessionState_reset_to_base_pose"); + RNA_def_function_ui_description(func, "Force resetting of position and rotation deltas"); + RNA_def_function_flag(func, FUNC_NO_SELF); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + prop = RNA_def_property(srna, "viewer_pose_location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_XrSessionState_viewer_pose_location_get", NULL, NULL); -- cgit v1.2.3