| 170 | */ |
| 171 | |
| 172 | void RenderSystem::OnUpdate(float /*elapsedTime*/) |
| 173 | { |
| 174 | // Invalidate every renderable if the coordinate system changed |
| 175 | if (m_coordinateSystemInvalidated) |
| 176 | { |
| 177 | for (const Ndk::EntityHandle& drawable : m_drawables) |
| 178 | { |
| 179 | GraphicsComponent& graphicsComponent = drawable->GetComponent<GraphicsComponent>(); |
| 180 | graphicsComponent.InvalidateTransformMatrix(); |
| 181 | } |
| 182 | |
| 183 | m_coordinateSystemInvalidated = false; |
| 184 | } |
| 185 | |
| 186 | UpdateDynamicReflections(); |
| 187 | UpdatePointSpotShadowMaps(); |
| 188 | |
| 189 | for (const Ndk::EntityHandle& camera : m_cameras) |
| 190 | { |
| 191 | CameraComponent& camComponent = camera->GetComponent<CameraComponent>(); |
| 192 | |
| 193 | //UpdateDirectionalShadowMaps(camComponent); |
| 194 | |
| 195 | Nz::AbstractRenderQueue* renderQueue = m_renderTechnique->GetRenderQueue(); |
| 196 | |
| 197 | // To make sure the bounding volume used by the culling list is updated |
| 198 | for (const Ndk::EntityHandle& drawable : m_drawables) |
| 199 | { |
| 200 | GraphicsComponent& graphicsComponent = drawable->GetComponent<GraphicsComponent>(); |
| 201 | graphicsComponent.EnsureBoundingVolumeUpdate(); |
| 202 | } |
| 203 | |
| 204 | bool forceInvalidation = false; |
| 205 | |
| 206 | std::size_t visibilityHash = m_drawableCulling.Cull(camComponent.GetFrustum(), &forceInvalidation); |
| 207 | |
| 208 | // Always regenerate renderqueue if particle groups are present for now (FIXME) |
| 209 | if (!m_particleGroups.empty()) |
| 210 | forceInvalidation = true; |
| 211 | |
| 212 | if (camComponent.UpdateVisibility(visibilityHash) || m_forceRenderQueueInvalidation || forceInvalidation) |
| 213 | { |
| 214 | renderQueue->Clear(); |
| 215 | for (const GraphicsComponent* gfxComponent : m_drawableCulling) |
| 216 | gfxComponent->AddToRenderQueue(renderQueue); |
| 217 | |
| 218 | for (const Ndk::EntityHandle& light : m_lights) |
| 219 | { |
| 220 | LightComponent& lightComponent = light->GetComponent<LightComponent>(); |
| 221 | NodeComponent& lightNode = light->GetComponent<NodeComponent>(); |
| 222 | |
| 223 | ///TODO: Cache somehow? |
| 224 | lightComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::ConcatenateAffine(m_coordinateSystemMatrix, lightNode.GetTransformMatrix())); |
| 225 | } |
| 226 | |
| 227 | for (const Ndk::EntityHandle& particleGroup : m_particleGroups) |
| 228 | { |
| 229 | ParticleGroupComponent& groupComponent = particleGroup->GetComponent<ParticleGroupComponent>(); |
nothing calls this directly
no test coverage detected