diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2020-03-14 21:53:40 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2020-03-14 21:53:40 +0300 |
commit | 3b693a9aacc687440fd4b6e4b6ab5dcea1cfd558 (patch) | |
tree | 5b0d1f1c409f27067cf975a853763b7e7fc9a570 /source | |
parent | 8e841ed71ec147a3bee8a05a705a7b6ab677d7fe (diff) |
Fix memory errors and drawing glitches on some systems
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/intern/wm_xr.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c index 499674f8f01..a7a0ae73666 100644 --- a/source/blender/windowmanager/intern/wm_xr.c +++ b/source/blender/windowmanager/intern/wm_xr.c @@ -255,11 +255,14 @@ static void wm_xr_draw_data_populate(const XrRuntimeSessionState *state, const Scene *scene, wmXrDrawData *r_draw_data) { - const bool position_tracking_toggled = (state->prev_settings_flag & - XR_SESSION_USE_POSITION_TRACKING) != - (settings->flag & XR_SESSION_USE_POSITION_TRACKING); + const bool position_tracking_toggled = !state->is_initialized || + ((state->prev_settings_flag & + XR_SESSION_USE_POSITION_TRACKING) != + (settings->flag & XR_SESSION_USE_POSITION_TRACKING)); const bool use_position_tracking = settings->flag & XR_SESSION_USE_POSITION_TRACKING; + memset(r_draw_data, 0, sizeof(r_draw_data)); + wm_xr_reference_pose_calc(scene, settings, &r_draw_data->reference_pose); if (position_tracking_toggled) { @@ -301,7 +304,8 @@ static void wm_xr_runtime_session_state_update(XrRuntimeSessionState *state, viewer_pose.position[2] += draw_view->local_pose.position[1]; } - state->viewer_pose = viewer_pose; + copy_v3_v3(state->viewer_pose.position, viewer_pose.position); + copy_qt_qt(state->viewer_pose.orientation_quat, viewer_pose.orientation_quat); wm_xr_pose_to_viewmat(&viewer_pose, state->viewer_viewmat); /* No idea why, but multiplying by two seems to make it match the VR view more. */ state->focal_len = 2.0f * @@ -649,7 +653,7 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata) wmXrDrawData draw_data; Scene *scene = CTX_data_scene(C); - const float display_flags = V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS | settings->draw_flags; + const int display_flags = V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS | settings->draw_flags; float viewmat[4][4], winmat[4][4]; @@ -669,6 +673,8 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata) /* In case a framebuffer is still bound from drawing the last eye. */ GPU_framebuffer_restore(); + /* Some systems have drawing glitches without this. */ + GPU_clear(GPU_DEPTH_BIT); /* Draws the view into the surface_data->viewport's framebuffers */ ED_view3d_draw_offscreen_simple(CTX_data_ensure_evaluated_depsgraph(C), |