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:
Diffstat (limited to 'source/gameengine/Ketsji/KX_MouseFocusSensor.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
index e1978263a12..34f5c26415d 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
@@ -240,23 +240,29 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam)
/* build the from and to point in normalized device coordinates
- * Normalized device coordinates are [-1,1] in x, y, z
+ * Looks like normailized device coordinates are [-1,1] in x [-1,1] in y
+ * [0,-1] in z
*
* The actual z coordinates used don't have to be exact just infront and
* behind of the near and far clip planes.
*/
frompoint.setValue( (2 * (m_x-x_lb) / width) - 1.0,
1.0 - (2 * (m_y_inv - y_lb) / height),
- -1.0,
+ /*cam->GetCameraData()->m_perspective ? 0.0:cdata->m_clipstart,*/ /* real clipstart is scaled in ortho for some reason, zero is ok */
+ 0.0, /* nearclip, see above comments */
1.0 );
topoint.setValue( (2 * (m_x-x_lb) / width) - 1.0,
1.0 - (2 * (m_y_inv-y_lb) / height),
- 1.0,
+ cam->GetCameraData()->m_perspective ? 1.0:cam->GetCameraData()->m_clipend, /* farclip, see above comments */
1.0 );
-
+
/* camera to world */
- MT_Matrix4x4 camcs_wcs_matrix = MT_Matrix4x4(cam->GetCameraToWorld());
+ MT_Transform wcs_camcs_tranform = cam->GetWorldToCamera();
+ 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.*/
@@ -266,8 +272,6 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam)
/* shoot-points: clip to cam to wcs . win to clip was already done.*/
frompoint = clip_camcs_matrix * frompoint;
topoint = clip_camcs_matrix * topoint;
- /* clipstart = - (frompoint[2] / frompoint[3])
- * clipend = - (topoint[2] / topoint[3]) */
frompoint = camcs_wcs_matrix * frompoint;
topoint = camcs_wcs_matrix * topoint;