Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2017-03-06 02:40:48 +0300
committerJulian Eisel <eiseljulian@gmail.com>2017-03-06 03:32:35 +0300
commit80444effc62ac91b127cd7811f84c1689eabd7c8 (patch)
treefa7eaed2e96b42b1b42fd34cb1ed072e0c10c63b /source/blender/windowmanager/intern/wm_stereo.c
parente72af060ab106d261449b56022258d125b231041 (diff)
Multi-View: Map cursor coordinates to visual coordinates
When rendering multi-view in side-by-side or top-bottom mode, we squash the UI to half of its size and draw it twice on screen. That means the cursor coordinates used for UI interaction don't match what's visible on screen. This commit is a little event system hack (tm) to fix this. It has some small glitches with cursor grabbing, but nothing to bad. We'll also use it for viewport HMD support. D1350, thanks for the feedback @dfelinto!
Diffstat (limited to 'source/blender/windowmanager/intern/wm_stereo.c')
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 46cee907991..66ebf18c9e1 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -345,6 +345,32 @@ bool WM_stereo3d_enabled(wmWindow *win, bool skip_stereo3d_check)
return true;
}
+/**
+ * If needed, this adjusts \a r_mouse_xy so that drawn cursor and handled mouse position are matching visually.
+*/
+void wm_stereo3d_mouse_offset_apply(wmWindow *win, int *r_mouse_xy)
+{
+ if (!WM_stereo3d_enabled(win, false))
+ return;
+
+ if (win->stereo3d_format->display_mode == S3D_DISPLAY_SIDEBYSIDE) {
+ const int half_x = win->sizex / 2;
+ /* right half of the screen */
+ if (r_mouse_xy[0] > half_x) {
+ r_mouse_xy[0] -= half_x;
+ }
+ r_mouse_xy[0] *= 2;
+ }
+ else if (win->stereo3d_format->display_mode == S3D_DISPLAY_TOPBOTTOM) {
+ const int half_y = win->sizey / 2;
+ /* upper half of the screen */
+ if (r_mouse_xy[1] > half_y) {
+ r_mouse_xy[1] -= half_y;
+ }
+ r_mouse_xy[1] *= 2;
+ }
+}
+
/************************** Stereo 3D operator **********************************/
typedef struct Stereo3dData {
Stereo3dFormat stereo3d_format;