[Bf-blender-cvs] [c1cf70f] blender-v2.75-release: Fix T45034: MirrorBall rendering on wrong camera axis

Sergey Sharybin noreply at git.blender.org
Mon Jun 29 16:18:04 CEST 2015


Commit: c1cf70fbca15b33012c8fbb699a2ceac3d576ac2
Author: Sergey Sharybin
Date:   Mon Jun 22 20:04:46 2015 +0200
Branches: blender-v2.75-release
https://developer.blender.org/rBc1cf70fbca15b33012c8fbb699a2ceac3d576ac2

Fix T45034: MirrorBall rendering on wrong camera axis

This was a mistake in the original code from D1079.

With the current way how direction ot mirror ball works camera should look
into negative Y direction. Corrected it in the camera matrix synchronization,
so no extra calculations are needed at the render time.

That's a bit annoying, but we'd better port it to the release branch, or
otherwise we'll end up with files created with wrong camera mapping after
2.75 release.

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

M	intern/cycles/blender/blender_camera.cpp

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

diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index 3d23b5e..90b42ea 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -207,19 +207,34 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::RenderEngine b_e
 	}
 }
 
-static Transform blender_camera_matrix(const Transform& tfm, CameraType type)
+static Transform blender_camera_matrix(const Transform& tfm,
+                                       const CameraType type,
+                                       const PanoramaType panorama_type)
 {
 	Transform result;
 
 	if(type == CAMERA_PANORAMA) {
-		/* make it so environment camera needs to be pointed in the direction
-		 * of the positive x-axis to match an environment texture, this way
-		 * it is looking at the center of the texture */
-		result = tfm *
-			make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
-			                0.0f,  0.0f, 1.0f, 0.0f,
-			               -1.0f,  0.0f, 0.0f, 0.0f,
-			                0.0f,  0.0f, 0.0f, 1.0f);
+		if(panorama_type == PANORAMA_MIRRORBALL) {
+			/* Mirror ball camera is looking into the negative Y direction
+			 * which matches texture mirror ball mapping.
+			 */
+			result = tfm *
+				make_transform(1.0f, 0.0f, 0.0f, 0.0f,
+				               0.0f, 0.0f, 1.0f, 0.0f,
+				               0.0f, 1.0f, 0.0f, 0.0f,
+				               0.0f, 0.0f, 0.0f, 1.0f);
+		}
+		else {
+			/* Make it so environment camera needs to be pointed in the direction
+			 * of the positive x-axis to match an environment texture, this way
+			 * it is looking at the center of the texture
+			 */
+			result = tfm *
+				make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
+				                0.0f,  0.0f, 1.0f, 0.0f,
+				               -1.0f,  0.0f, 0.0f, 0.0f,
+				                0.0f,  0.0f, 0.0f, 1.0f);
+		}
 	}
 	else {
 		/* note the blender camera points along the negative z-axis */
@@ -365,7 +380,9 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
 	cam->bladesrotation = bcam->aperturerotation;
 
 	/* transform */
-	cam->matrix = blender_camera_matrix(bcam->matrix, bcam->type);
+	cam->matrix = blender_camera_matrix(bcam->matrix,
+	                                    bcam->type,
+	                                    bcam->panorama_type);
 	cam->motion.pre = cam->matrix;
 	cam->motion.post = cam->matrix;
 	cam->use_motion = false;
@@ -424,7 +441,7 @@ void BlenderSync::sync_camera_motion(BL::Object b_ob, float motion_time)
 	BL::Array<float, 16> b_ob_matrix;
 	b_engine.camera_model_matrix(b_ob, b_ob_matrix);
 	Transform tfm = get_transform(b_ob_matrix);
-	tfm = blender_camera_matrix(tfm, cam->type);
+	tfm = blender_camera_matrix(tfm, cam->type, cam->panorama_type);
 
 	if(tfm != cam->matrix) {
 		VLOG(1) << "Camera " << b_ob.name() << " motion detected.";




More information about the Bf-blender-cvs mailing list