|
Blender
V2.93
|
#include "BKE_context.h"#include "BKE_main.h"#include "BKE_scene.h"#include "BLI_listbase.h"#include "BLI_math.h"#include "DEG_depsgraph.h"#include "DNA_camera_types.h"#include "DRW_engine.h"#include "GHOST_C-api.h"#include "GPU_viewport.h"#include "MEM_guardedalloc.h"#include "WM_api.h"#include "WM_types.h"#include "wm_surface.h"#include "wm_window.h"#include "wm_xr_intern.h"Go to the source code of this file.
Typedefs | |
| typedef enum wmXrSessionStateEvent | wmXrSessionStateEvent |
Enumerations | |
| enum | wmXrSessionStateEvent { SESSION_STATE_EVENT_NONE = 0 , SESSION_STATE_EVENT_START , SESSION_STATE_EVENT_RESET_TO_BASE_POSE , SESSION_STATE_EVENT_POSITON_TRACKING_TOGGLE } |
Variables | |
| static wmSurface * | g_xr_surface = NULL |
| static CLG_LogRef | LOG = {"wm.xr"} |
| typedef enum wmXrSessionStateEvent wmXrSessionStateEvent |
| Enumerator | |
|---|---|
| SESSION_STATE_EVENT_NONE | |
| SESSION_STATE_EVENT_START | |
| SESSION_STATE_EVENT_RESET_TO_BASE_POSE | |
| SESSION_STATE_EVENT_POSITON_TRACKING_TOGGLE | |
Definition at line 205 of file wm_xr_session.c.
|
static |
Definition at line 117 of file wm_xr_session.c.
References axis_angle_to_quat_single(), XrSessionSettings::base_pose_angle, XrSessionSettings::base_pose_location, XrSessionSettings::base_pose_object, XrSessionSettings::base_pose_type, Scene::camera, copy_v3_fl(), copy_v3_v3(), eul_to_quat(), M_PI_2, mat4_to_loc_quat(), mul_qt_qtqt(), Object::obmat, quat_to_eul(), scene, XR_BASE_POSE_CUSTOM, and XR_BASE_POSE_OBJECT.
Referenced by wm_xr_session_draw_data_populate().
| void WM_xr_session_base_pose_reset | ( | wmXrData * | xr | ) |
Definition at line 104 of file wm_xr_session.c.
References wmXrSessionState::force_reset_to_base_pose, wmXrData::runtime, and wmXrRuntimeData::session_state.
|
static |
Definition at line 65 of file wm_xr_session.c.
References wm_xr_session_exit_cb().
Referenced by wm_xr_session_toggle().
|
static |
Definition at line 212 of file wm_xr_session.c.
References XrSessionSettings::base_pose_object, XrSessionSettings::base_pose_type, XrSessionSettings::flag, state, and XR_SESSION_USE_POSITION_TRACKING.
Referenced by wm_xr_session_state_to_event().
|
static |
Definition at line 152 of file wm_xr_session.c.
References wmXrDrawData::base_pose, wmSurface::customdata, depsgraph, wmXrDrawData::depsgraph, g_xr_surface, scene, wmXrDrawData::scene, wmXrData::session_settings, wmXrDrawData::surface_data, wm_xr_session_base_pose_calc(), and wmXrDrawData::xr_data.
Referenced by wm_xr_session_surface_draw().
| void wm_xr_session_draw_data_update | ( | const wmXrSessionState * | state, |
| const XrSessionSettings * | settings, | ||
| const GHOST_XrDrawViewInfo * | draw_view, | ||
| wmXrDrawData * | draw_data | ||
| ) |
Definition at line 243 of file wm_xr_session.c.
References copy_v3_fl(), copy_v3_v3(), wmXrDrawData::eye_position_ofs, XrSessionSettings::flag, SESSION_STATE_EVENT_NONE, SESSION_STATE_EVENT_POSITON_TRACKING_TOGGLE, SESSION_STATE_EVENT_RESET_TO_BASE_POSE, SESSION_STATE_EVENT_START, state, wm_xr_session_state_to_event(), and XR_SESSION_USE_POSITION_TRACKING.
Referenced by wm_xr_draw_view().
| bool WM_xr_session_exists | ( | const wmXrData * | xr | ) |
Check if the XR-Session was triggered. If an error happened while trying to start a session, this returns false too.
Definition at line 99 of file wm_xr_session.c.
References wmXrRuntimeData::context, wmXrSessionState::is_started, wmXrData::runtime, and wmXrRuntimeData::session_state.
Referenced by WM_xr_session_is_ready(), and wm_xr_session_toggle().
|
static |
Definition at line 52 of file wm_xr_session.c.
References wmXrRuntimeData::exit_fn, wmXrSessionState::is_started, wmXrData::runtime, wmXrRuntimeData::session_state, and wm_xr_runtime_data_free().
Referenced by wm_xr_session_begin_info_create().
| void* wm_xr_session_gpu_binding_context_create | ( | void | ) |
Definition at line 493 of file wm_xr_session.c.
References NC_WM, ND_XR_DATA_CHANGED, NULL, surface, WM_main_add_notifier(), wm_surface_add(), and wm_xr_session_surface_create().
Referenced by wm_xr_init().
| void wm_xr_session_gpu_binding_context_destroy | ( | GHOST_ContextHandle | UNUSEDcontext | ) |
Definition at line 506 of file wm_xr_session.c.
References g_xr_surface, NC_WM, ND_XR_DATA_CHANGED, NULL, WM_main_add_notifier(), wm_surface_remove(), and wm_window_reset_drawable().
| bool WM_xr_session_is_ready | ( | const wmXrData * | xr | ) |
Check if the session is running, according to the OpenXR definition.
Definition at line 112 of file wm_xr_session.c.
References wmXrRuntimeData::context, wmXrData::runtime, and WM_xr_session_exists().
Referenced by wm_xr_draw_view(), WM_xr_session_state_viewer_pose_location_get(), WM_xr_session_state_viewer_pose_matrix_info_get(), and WM_xr_session_state_viewer_pose_rotation_get().
|
static |
Definition at line 168 of file wm_xr_session.c.
References BLI_findindex(), ListBase::first, wmXrRuntimeData::session_root_win, and wmWindowManager::windows.
Referenced by wm_xr_session_scene_and_evaluated_depsgraph_get().
|
static |
Get the scene and depsgraph shown in the VR session's root window (the window the session was started from) if still available. If it's not available, use some fallback window.
It's important that the VR session follows some existing window, otherwise it would need to have an own depsgraph, which is an expense we should avoid.
Definition at line 187 of file wm_xr_session.c.
References BKE_scene_get_depsgraph(), BKE_scene_graph_evaluated_ensure(), BLI_assert, depsgraph, wmXrData::runtime, scene, WM_window_get_active_scene(), WM_window_get_active_view_layer(), wm_xr_session_root_window_or_fallback_get(), and wmWindowManager::xr.
Referenced by wm_xr_session_surface_draw().
| wmXrSessionState* WM_xr_session_state_handle_get | ( | const wmXrData * | xr | ) |
Definition at line 333 of file wm_xr_session.c.
References NULL, wmXrData::runtime, and wmXrRuntimeData::session_state.
|
static |
Definition at line 223 of file wm_xr_session.c.
References XrSessionSettings::flag, SESSION_STATE_EVENT_NONE, SESSION_STATE_EVENT_POSITON_TRACKING_TOGGLE, SESSION_STATE_EVENT_RESET_TO_BASE_POSE, SESSION_STATE_EVENT_START, state, wm_xr_session_draw_data_needs_reset_to_base_pose(), and XR_SESSION_USE_POSITION_TRACKING.
Referenced by wm_xr_session_draw_data_update().
| void wm_xr_session_state_update | ( | const XrSessionSettings * | settings, |
| const wmXrDrawData * | draw_data, | ||
| const GHOST_XrDrawViewInfo * | draw_view, | ||
| wmXrSessionState * | state | ||
| ) |
Update information that is only stored for external state queries. E.g. for Python API to request the current (as in, last known) viewer pose.
Definition at line 293 of file wm_xr_session.c.
References wmXrDrawData::base_pose, XrSessionSettings::base_pose_object, XrSessionSettings::base_pose_type, copy_qt_qt(), copy_v3_v3(), DEFAULT_SENSOR_WIDTH, wmXrDrawData::eye_position_ofs, XrSessionSettings::flag, fov_to_focallength(), mul_qt_qtqt(), state, wm_xr_pose_to_viewmat(), and XR_SESSION_USE_POSITION_TRACKING.
Referenced by wm_xr_draw_view().
Definition at line 338 of file wm_xr_session.c.
References copy_v3_v3(), wmXrSessionState::is_view_data_set, wmXrData::runtime, wmXrRuntimeData::session_state, wmXrSessionState::viewer_pose, WM_xr_session_is_ready(), and zero_v3().
| bool WM_xr_session_state_viewer_pose_matrix_info_get | ( | const wmXrData * | xr, |
| float | r_viewmat[4][4], | ||
| float * | r_focal_len | ||
| ) |
Definition at line 360 of file wm_xr_session.c.
References copy_m4_m4(), wmXrSessionState::focal_len, wmXrSessionState::is_view_data_set, wmXrData::runtime, wmXrRuntimeData::session_state, unit_m4(), wmXrSessionState::viewer_viewmat, and WM_xr_session_is_ready().
Definition at line 349 of file wm_xr_session.c.
References copy_v4_v4(), wmXrSessionState::is_view_data_set, wmXrData::runtime, wmXrRuntimeData::session_state, unit_qt(), wmXrSessionState::viewer_pose, and WM_xr_session_is_ready().
|
static |
Definition at line 468 of file wm_xr_session.c.
References BLI_assert, data, g_xr_surface, MEM_callocN, surface, wm_xr_session_surface_draw(), and wm_xr_session_surface_free_data().
Referenced by wm_xr_session_gpu_binding_context_create().
|
static |
Call Ghost-XR to draw a frame.
Draw callback for the XR-session surface. It's expected to be called on each main loop iteration and tells Ghost-XR to submit a new frame by drawing its views. Note that for drawing each view, wm_xr_draw_view() will be called through Ghost-XR (see GHOST_XrDrawViewFunc()).
Definition at line 391 of file wm_xr_session.c.
References C, wmXrRuntimeData::context, CTX_data_main(), CTX_wm_manager(), wmSurface::customdata, depsgraph, g_xr_surface, GPU_offscreen_unbind(), wmXrSurfaceData::offscreen, wmXrData::runtime, scene, wm_xr_session_draw_data_populate(), wm_xr_session_scene_and_evaluated_depsgraph_get(), and wmWindowManager::xr.
Referenced by wm_xr_session_surface_create().
|
static |
Definition at line 452 of file wm_xr_session.c.
References data, g_xr_surface, GPU_offscreen_free(), GPU_viewport_free(), MEM_freeN, NULL, and surface.
Referenced by wm_xr_session_surface_create().
| bool wm_xr_session_surface_offscreen_ensure | ( | wmXrSurfaceData * | surface_data, |
| const GHOST_XrDrawViewInfo * | draw_view | ||
| ) |
Definition at line 412 of file wm_xr_session.c.
References BLI_assert, CLOG_ERROR, GPU_offscreen_create(), GPU_offscreen_free(), GPU_offscreen_height(), GPU_offscreen_width(), GPU_viewport_create(), GPU_viewport_free(), LOG, wmXrSurfaceData::offscreen, and wmXrSurfaceData::viewport.
Referenced by wm_xr_draw_view().
| void wm_xr_session_toggle | ( | wmWindowManager * | wm, |
| wmWindow * | session_root_win, | ||
| wmXrSessionExitFn | session_exit_fn | ||
| ) |
Definition at line 74 of file wm_xr_session.c.
References wmXrRuntimeData::context, wmXrRuntimeData::exit_fn, wmXrSessionState::is_started, wmXrData::runtime, wmXrRuntimeData::session_root_win, wmXrRuntimeData::session_state, wm_xr_session_begin_info_create(), WM_xr_session_exists(), and wmWindowManager::xr.
Definition at line 47 of file wm_xr_session.c.
Referenced by wm_xr_session_draw_data_populate(), wm_xr_session_gpu_binding_context_destroy(), wm_xr_session_surface_create(), wm_xr_session_surface_draw(), and wm_xr_session_surface_free_data().
|
static |
Definition at line 48 of file wm_xr_session.c.
Referenced by wm_xr_session_surface_offscreen_ensure().