BGE : Fix T43800: getScreenVect()/getScreenPosition()/modelview_matrix returns incorrect results

The getScreenVect(), getScreenPosition() and modelview_matrixmethod returns an incorrect results if called after the camera has been translated on the same frame.
The model view matrix will be update only once per frame with Cam->SetModelviewMatrix in KX_KetsjiEngine::RenderFrame.
Using GetWorldToCamera as model view matrix to get an actual view matrix even if the camera is moved.

Reviewers: sergey, dfelinto, brita_, sybren, hg1, campbellbarton

Reviewed By: hg1, campbellbarton

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1170
This commit is contained in:
Thomas Szepe 2015-04-10 20:20:52 +02:00
parent 35812e65f4
commit 465a5d29c0
2 changed files with 4 additions and 4 deletions

@ -886,7 +886,7 @@ int KX_Camera::pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_D
PyObject *KX_Camera::pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) PyObject *KX_Camera::pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{ {
KX_Camera* self = static_cast<KX_Camera*>(self_v); KX_Camera* self = static_cast<KX_Camera*>(self_v);
return PyObjectFrom(self->GetModelviewMatrix()); return PyObjectFrom(self->GetWorldToCamera());
} }
PyObject *KX_Camera::pyattr_get_camera_to_world(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) PyObject *KX_Camera::pyattr_get_camera_to_world(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@ -995,7 +995,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition,
GLdouble modelmatrix[16]; GLdouble modelmatrix[16];
GLdouble projmatrix[16]; GLdouble projmatrix[16];
MT_Matrix4x4 m_modelmatrix = this->GetModelviewMatrix(); MT_Matrix4x4 m_modelmatrix = this->GetWorldToCamera();
MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix(); MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix();
m_modelmatrix.getValue(modelmatrix); m_modelmatrix.getValue(modelmatrix);
@ -1038,7 +1038,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenVect,
GLdouble modelmatrix[16]; GLdouble modelmatrix[16];
GLdouble projmatrix[16]; GLdouble projmatrix[16];
MT_Matrix4x4 m_modelmatrix = this->GetModelviewMatrix(); MT_Matrix4x4 m_modelmatrix = this->GetWorldToCamera();
MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix(); MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix();
m_modelmatrix.getValue(modelmatrix); m_modelmatrix.getValue(modelmatrix);

@ -192,7 +192,7 @@ public:
void InvalidateProjectionMatrix(bool valid = false); void InvalidateProjectionMatrix(bool valid = false);
/** Gets the modelview matrix that is used by the rasterizer. /** 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. * \warning If the Camera is a dynamic object then this method may return garbage. Use GetWorldToCamera() instead.
*/ */
const MT_Matrix4x4& GetModelviewMatrix() const; const MT_Matrix4x4& GetModelviewMatrix() const;