1
0
Fork 0

ICamera: Adding getProjectionViewMatrix()

This commit is contained in:
Henrik Hautakoski 2016-06-27 15:48:32 +02:00
parent 6db9d81f45
commit 8686151215
3 changed files with 24 additions and 1 deletions

View file

@ -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) {