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:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-04-26 11:19:18 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-04-26 11:19:18 +0400
commit5df9926f491f532422b20cb3315321e245480129 (patch)
tree721cc3c04546ed023f074d9f124faf7428aa33bb /source/gameengine
parentf331fc8fbbae05530fe0d28b510a5c0deeb03968 (diff)
Fix MouseFocus Sensor objects for dynamic cameras. (Bug 1165)
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_Camera.h8
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp9
3 files changed, 14 insertions, 13 deletions
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index c99e4824851..cc970d90339 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -46,6 +46,8 @@ KX_Camera::KX_Camera(void* sgReplicationInfo,
{
// setting a name would be nice...
m_name = "cam";
+ m_projection_matrix.setIdentity();
+ m_modelview_matrix.setIdentity();
SetProperty("camera",new CIntValue(1));
}
@@ -138,9 +140,9 @@ void KX_Camera::SetModelviewMatrix(const MT_Matrix4x4 & mat)
/**
* Gets the projection matrix that is used by the rasterizer.
*/
-void KX_Camera::GetProjectionMatrix(MT_Matrix4x4 & mat)
+const MT_Matrix4x4& KX_Camera::GetProjectionMatrix()
{
- mat = m_projection_matrix;
+ return m_projection_matrix;
}
@@ -148,9 +150,9 @@ void KX_Camera::GetProjectionMatrix(MT_Matrix4x4 & mat)
/**
* Gets the modelview matrix that is used by the rasterizer.
*/
-void KX_Camera::GetModelviewMatrix(MT_Matrix4x4 & mat)
+const MT_Matrix4x4& KX_Camera::GetModelviewMatrix()
{
- mat = m_modelview_matrix;
+ return m_modelview_matrix;
}
diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h
index 25a3b891e01..0185a0ba9d5 100644
--- a/source/gameengine/Ketsji/KX_Camera.h
+++ b/source/gameengine/Ketsji/KX_Camera.h
@@ -96,10 +96,12 @@ public:
void SetModelviewMatrix(const MT_Matrix4x4 & mat);
/** Gets the projection matrix that is used by the rasterizer. */
- void GetProjectionMatrix(MT_Matrix4x4 & mat);
+ const MT_Matrix4x4& GetProjectionMatrix();
- /** Gets the modelview matrix that is used by the rasterizer. */
- void GetModelviewMatrix(MT_Matrix4x4 & mat);
+ /** Gets the modelview matrix that is used by the rasterizer.
+ * @warning If the Camera is a dynamic object then this method may return garbage. Use GetCameraToWorld() instead.
+ */
+ const MT_Matrix4x4& GetModelviewMatrix();
/** Gets the focal lenght. */
float GetLens();
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
index 6f6f86bd782..3d6264674bc 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
@@ -208,14 +208,11 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
);
/* camera to world */
- MT_Matrix4x4 camcs_wcs_matrix;
- cam->GetModelviewMatrix(camcs_wcs_matrix);
- camcs_wcs_matrix.invert();
+ MT_Matrix4x4 camcs_wcs_matrix = MT_Matrix4x4(cam->GetCameraToWorld());
- MT_Matrix4x4 clip_camcs_matrix;
/* badly defined, the first time round.... I wonder why... I might
* want to guard against floating point errors here.*/
- cam->GetProjectionMatrix(clip_camcs_matrix);
+ MT_Matrix4x4 clip_camcs_matrix = MT_Matrix4x4(cam->GetProjectionMatrix());
clip_camcs_matrix.invert();
/* shoot-points: clip to cam to wcs . win to clip was already done.*/
@@ -223,7 +220,7 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
topoint = clip_camcs_matrix * topoint;
frompoint = camcs_wcs_matrix * frompoint;
topoint = camcs_wcs_matrix * topoint;
-
+
/* from hom wcs to 3d wcs: */
MT_Point3 frompoint3 = MT_Point3(frompoint[0]/frompoint[3],
frompoint[1]/frompoint[3],