Move projectionView retrieving to camera system
This commit is contained in:
@@ -99,13 +99,7 @@ namespace Inferno {
|
||||
|
||||
glm::mat4 Scene::cameraProjectionView()
|
||||
{
|
||||
auto view = m_registry->view<TransformComponent, PerspectiveCameraComponent>();
|
||||
|
||||
for(auto&& [entity, transform, perspective] : view.each()) {
|
||||
return perspective.projection * transform.transform;
|
||||
}
|
||||
|
||||
return glm::mat4 { 1.0f };
|
||||
return CameraSystem::the().cameraProjectionView();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,25 @@ namespace Inferno {
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
glm::mat4 CameraSystem::cameraProjectionView()
|
||||
{
|
||||
auto orthoView = m_registry->view<TransformComponent, OrthographicCameraComponment>();
|
||||
|
||||
for(auto&& [entity, transform, orthographic] : orthoView.each()) {
|
||||
return orthographic.projection * transform.transform;
|
||||
}
|
||||
|
||||
auto perspectiveView = m_registry->view<TransformComponent, PerspectiveCameraComponent>();
|
||||
|
||||
for(auto&& [entity, transform, perspective] : perspectiveView.each()) {
|
||||
return perspective.projection * transform.transform;
|
||||
}
|
||||
|
||||
ASSERT_NOT_REACHED();
|
||||
|
||||
return glm::mat4 { 1.0f };
|
||||
}
|
||||
|
||||
void CameraSystem::updateOrthographic(TransformComponent& transform, OrthographicCameraComponment& orthographic)
|
||||
{
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace Inferno {
|
||||
void update();
|
||||
void destroy();
|
||||
|
||||
glm::mat4 cameraProjectionView();
|
||||
|
||||
void setRegistry(const std::shared_ptr<entt::registry>& registry) { m_registry = registry; };
|
||||
|
||||
static inline CameraSystem& the() { return *s_instance; }
|
||||
|
||||
Reference in New Issue
Block a user