ICamera: Adding getProjectionViewMatrix()
This commit is contained in:
parent
6db9d81f45
commit
8686151215
3 changed files with 24 additions and 1 deletions
|
|
@ -56,6 +56,8 @@ public :
|
|||
|
||||
const Matrix4f& getProjectionMatrix() const;
|
||||
|
||||
const Matrix4f& getProjectionViewMatrix() const;
|
||||
|
||||
const Transform& getTransform() const;
|
||||
|
||||
protected :
|
||||
|
|
@ -73,6 +75,9 @@ protected :
|
|||
// Projection matrix. transforms eye -> Clipping space.
|
||||
mutable Matrix4f m_proj;
|
||||
mutable bool m_projNeedsUpdate;
|
||||
|
||||
mutable Matrix4f m_projView;
|
||||
mutable bool m_projViewNeedsUpdate;
|
||||
};
|
||||
|
||||
#endif /* SPECTRE_SCENE_CAMERA2D_H */
|
||||
|
|
@ -13,6 +13,8 @@ public :
|
|||
virtual const Matrix4f& getViewMatrix() const = 0;
|
||||
|
||||
virtual const Matrix4f& getProjectionMatrix() const = 0;
|
||||
|
||||
virtual const Matrix4f& getProjectionViewMatrix() const = 0;
|
||||
};
|
||||
|
||||
#endif /* SPECTRE_SCENE_ICAMERA_H */
|
||||
|
|
@ -22,8 +22,10 @@ m_zoom (1.0f),
|
|||
m_size (size),
|
||||
m_viewNeedsUpdate (true),
|
||||
m_projNeedsUpdate (true),
|
||||
m_projViewNeedsUpdate (true),
|
||||
m_view (Matrix4f::Identity),
|
||||
m_proj (Matrix4f::Identity)
|
||||
m_proj (Matrix4f::Identity),
|
||||
m_projView (Matrix4f::Identity)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +36,7 @@ void Camera2D::reset(const Vector2f& position, const Vector2f& size)
|
|||
|
||||
m_projNeedsUpdate = true;
|
||||
m_viewNeedsUpdate = true;
|
||||
m_projViewNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void Camera2D::setPosition(float x, float y)
|
||||
|
|
@ -41,6 +44,7 @@ void Camera2D::setPosition(float x, float y)
|
|||
m_position.x = x;
|
||||
m_position.y = y;
|
||||
m_viewNeedsUpdate = true;
|
||||
m_projViewNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void Camera2D::setPosition(const Vector2f& position)
|
||||
|
|
@ -83,6 +87,7 @@ void Camera2D::setSize(const Vector2u& size)
|
|||
m_size = size;
|
||||
m_viewNeedsUpdate = true;
|
||||
m_projNeedsUpdate = true;
|
||||
m_projViewNeedsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +108,7 @@ void Camera2D::setZoom(float factor)
|
|||
}
|
||||
m_zoom = factor;
|
||||
m_viewNeedsUpdate = true;
|
||||
m_projViewNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void Camera2D::zoom(float factor)
|
||||
|
|
@ -114,6 +120,7 @@ void Camera2D::setRotation(float angle)
|
|||
{
|
||||
m_rotation = angle;
|
||||
m_viewNeedsUpdate = true;
|
||||
m_projViewNeedsUpdate = true;
|
||||
}
|
||||
|
||||
float Camera2D::getRotation() const
|
||||
|
|
@ -142,6 +149,15 @@ const Matrix4f& Camera2D::getProjectionMatrix() const
|
|||
return m_proj;
|
||||
}
|
||||
|
||||
const Matrix4f& Camera2D::getProjectionViewMatrix() const
|
||||
{
|
||||
if (m_projViewNeedsUpdate) {
|
||||
m_projView = getProjectionMatrix() * getViewMatrix();
|
||||
m_projViewNeedsUpdate = false;
|
||||
}
|
||||
return m_projView;
|
||||
}
|
||||
|
||||
const Transform& Camera2D::getTransform() const
|
||||
{
|
||||
if (m_viewNeedsUpdate) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue