[Bf-blender-cvs] [faecac0b5e1] master: Fix T62815: Camera frame shift issue + stereo frame working

Dalai Felinto noreply at git.blender.org
Fri Mar 22 22:59:01 CET 2019


Commit: faecac0b5e14ef9f79b02b379980a9b8a919a121
Author: Dalai Felinto
Date:   Fri Mar 22 18:38:54 2019 -0300
Branches: master
https://developer.blender.org/rBfaecac0b5e14ef9f79b02b379980a9b8a919a121

Fix T62815: Camera frame shift issue + stereo frame working

While I broke the non-stereo camera frame in rBf1fef41863b I came to
realize after further tests that the stereo camera frame was NEVER
correct.

It is now, regardless of the camera shift, the camera pivot, if you are
looking through the left, right or stereo eyes.

In the end all that was missing was to multiply the shift we needed to
offset the frame, by the frame width.

I also took the opportunity to perform some cleanup/refactor regarding
names. It was too confusing even for me.

Note: Non-uniformally scaled cameras still draw slightly wrong.

===================================================================

M	source/blender/draw/modes/object_mode.c

===================================================================

diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 084a589c3c5..2e83a23ebae 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -1676,13 +1676,11 @@ static void batch_camera_path_free(ListBase *camera_paths)
 	}
 }
 
-static bool camera_view3d_is_stereo3d(Scene *scene, View3D *v3d)
-{
-	return (scene->r.scemode & R_MULTIVIEW) != 0 &&
-	       (v3d->stereo3d_flag);
-}
-
-static void camera_stereo3d(
+/**
+ * Draw the stereo 3d support elements (cameras, plane, volume).
+ * They are only visible when not looking through the camera:
+ */
+static void camera_view3d_stereoscopy_display_extra(
         OBJECT_ShadingGroupList *sgl,
         Scene *scene, ViewLayer *view_layer, View3D *v3d,
         Object *ob, Camera *cam,
@@ -1979,9 +1977,10 @@ static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLay
 	const bool is_select = DRW_state_is_select();
 	const bool is_active = (ob == camera_object);
 	const bool look_through = (is_active && (rv3d->persp == RV3D_CAMOB));
+
 	const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
-	const bool is_stereo3d = is_active && camera_view3d_is_stereo3d(scene, v3d);
 	const bool is_stereo3d_view = (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D);
+	const bool is_stereo3d_display_extra = is_active && is_multiview && (!look_through) && ((v3d->stereo3d_flag) != 0);
 	const bool is_stereo3d_cameras = (ob == scene->camera) &&
 	                                 is_multiview &&
 	                                 is_stereo3d_view &&
@@ -2028,15 +2027,16 @@ static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLay
 	if (look_through) {
 		/* Only draw the frame. */
 		float mat[4][4];
-		if (is_stereo3d_view) {
+		if (is_multiview) {
 			const bool is_left = v3d->multiview_eye == STEREO_LEFT_ID;
 			const char *view_name = is_left ? STEREO_LEFT_NAME : STEREO_RIGHT_NAME;
 			BKE_camera_multiview_model_matrix(&scene->r, ob, view_name, mat);
 			const float shiftx = BKE_camera_multiview_shift_x(&scene->r, ob, view_name);
-			cam->runtime.drw_corners[0][0][0] += shiftx;
-			cam->runtime.drw_corners[0][1][0] += shiftx;
-			cam->runtime.drw_corners[0][2][0] += shiftx;
-			cam->runtime.drw_corners[0][3][0] += shiftx;
+			const float delta_shiftx = shiftx - cam->shiftx;
+			const float width = cam->runtime.drw_corners[0][2][0] - cam->runtime.drw_corners[0][0][0];
+			for (int i = 0; i < 4; i++) {
+				cam->runtime.drw_corners[0][i][0] -= delta_shiftx * width;
+			}
 		}
 		else {
 			copy_m4_m4(mat, ob->obmat);
@@ -2101,9 +2101,9 @@ static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLay
 		}
 	}
 
-	/* Stereo cameras drawing. */
-	if (is_stereo3d && !look_through) {
-		camera_stereo3d(sgl, scene, view_layer, v3d, ob, cam, vec, drawsize, scale);
+	/* Stereo cameras, volumes, plane drawing. */
+	if (is_stereo3d_display_extra) {
+		camera_view3d_stereoscopy_display_extra(sgl, scene, view_layer, v3d, ob, cam, vec, drawsize, scale);
 	}
 
 	/* Motion Tracking. */



More information about the Bf-blender-cvs mailing list