Fix for bug 1800: mouse over sensor doesn't work for ortho cameras.
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Tue, 23 Nov 2004 10:10:21 +0000 (10:10 +0000)
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Tue, 23 Nov 2004 10:10:21 +0000 (10:10 +0000)
The camera -> world transform wasn't being calculated properly for 'ortho' cameras: getOrigin()[2] should be scaled by 100 (like the render transform in KX_KetsjiEngine)

source/gameengine/Ketsji/KX_MouseFocusSensor.cpp

index 9380ef6f2fae78a39ce36c3257bf977c7f4d6b0d..0e30e324e8735b384495824e47ee57db0cc42838 100644 (file)
@@ -207,7 +207,13 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
        );
 
        /* camera to world  */
-       MT_Matrix4x4 camcs_wcs_matrix = MT_Matrix4x4(cam->GetCameraToWorld());
+       MT_Transform wcs_camcs_tranform = cam->GetWorldToCamera();
+       if (!cam->GetCameraData()->m_perspective)
+               wcs_camcs_tranform.getOrigin()[2] *= 100.0;
+       MT_Transform cams_wcs_transform;
+       cams_wcs_transform.invert(wcs_camcs_tranform);
+       
+       MT_Matrix4x4 camcs_wcs_matrix = MT_Matrix4x4(cams_wcs_transform);
 
        /* badly defined, the first time round.... I wonder why... I might
         * want to guard against floating point errors here.*/