Browse Source

Move projectionView retrieving to camera system

master
Riyyi 3 years ago
parent
commit
f47643d257
  1. 8
      inferno/src/inferno/scene/scene.cpp
  2. 19
      inferno/src/inferno/systems/camera.cpp
  3. 2
      inferno/src/inferno/systems/camera.h

8
inferno/src/inferno/scene/scene.cpp

@ -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();
}
}

19
inferno/src/inferno/systems/camera.cpp

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

2
inferno/src/inferno/systems/camera.h

@ -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; }

Loading…
Cancel
Save