MCPcopy Create free account
hub / github.com/JeanPhilippeKernel/RendererEngine / Update

Method Update

ZEngine/src/GraphicScene.cpp:74–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72 }
73
74 void GraphicScene::Update(Core::TimeStep dt) {
75 m_entity_registry->view<CameraComponent>().each([&dt, this](CameraComponent& component) {
76 if (component.IsPrimaryCamera) {
77 m_scene_camera = component.GetCamera();
78 component.GetCameraController()->Update(dt);
79 }
80 });
81
82 if ((m_scene_requested_size.first > 0.0f) && (m_scene_requested_size.second > 0.0f)) {
83 m_entity_registry->view<CameraComponent>().each([&, this](CameraComponent& component) {
84 if (component.IsPrimaryCamera) {
85 auto controller = component.GetCameraController();
86 controller->SetAspectRatio(m_scene_requested_size.first / m_scene_requested_size.second);
87 controller->UpdateProjectionMatrix();
88 m_renderer->GetFrameBuffer()->Resize(m_scene_requested_size.first, m_scene_requested_size.second);
89 }
90 });
91 m_scene_requested_size = {0.0f, 0.0f};
92 }
93
94 // Todo : Should be refactored
95 auto view_light_component = m_entity_registry->view<LightComponent, TransformComponent, GeometryComponent, MaterialComponent>();
96 for (auto entity : view_light_component) {
97 auto [light_component, transform_component, geometry_component, material_component] =
98 view_light_component.get<LightComponent, TransformComponent, GeometryComponent, MaterialComponent>(entity);
99
100 auto geometry = geometry_component.GetGeometry();
101 geometry->SetPosition(transform_component.GetPosition());
102 geometry->SetRotationAxis(transform_component.GetRotationAxis());
103 geometry->SetRotationAngle(transform_component.GetRotationAngle());
104 geometry->SetScaleSize(transform_component.GetScaleSize());
105
106 // We update light position with is geometry position, so we have the correct light's source position
107 light_component.GetLight()->SetPosition(geometry->GetPosition());
108 auto mesh = CreateRef<Meshes::Mesh>(std::move(geometry), material_component.GetMaterial());
109 m_mesh_list.push_back(std::move(mesh));
110 }
111
112 auto views = m_entity_registry->view<TransformComponent, GeometryComponent, MaterialComponent>();
113 for (auto entity : views) {
114 auto [transform_component, geometry_component, material_component] = views.get<TransformComponent, GeometryComponent, MaterialComponent>(entity);
115
116 auto geometry = geometry_component.GetGeometry();
117 geometry->SetPosition(transform_component.GetPosition());
118 geometry->SetRotationAxis(transform_component.GetRotationAxis());
119 geometry->SetRotationAngle(transform_component.GetRotationAngle());
120 geometry->SetScaleSize(transform_component.GetScaleSize());
121
122 auto mesh = CreateRef<Meshes::Mesh>(std::move(geometry), material_component.GetMaterial());
123 m_mesh_list.push_back(std::move(mesh));
124 }
125 }
126
127 void GraphicScene::Render() {
128 if (m_scene_camera) {

Callers

nothing calls this directly

Calls 15

GetCameraControllerMethod · 0.80
SetAspectRatioMethod · 0.80
ResizeMethod · 0.80
GetGeometryMethod · 0.80
GetRotationAxisMethod · 0.80
GetScaleSizeMethod · 0.80
GetLightMethod · 0.80
GetMaterialMethod · 0.80
GetCameraMethod · 0.45
SetPositionMethod · 0.45
GetPositionMethod · 0.45

Tested by

no test coverage detected