From 9fd25e8b10b1291525a18c8b3e34256ca6151dd6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 22 Mar 2025 11:50:31 +0000 Subject: Add ManyPtr which tracks specified subclasses This removes the need to repeated dynamic_cast the pointer. Provides interface which enforces the fastest option for the required types. --- ui/gameMainWindow.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ui') diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index d88bab5..b58f3dc 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -75,9 +75,9 @@ GameMainWindow::render() const void GameMainWindow::content(const SceneShader & shader, const Frustum & frustum) const { - for (const auto & [id, asset] : gameState->assets) { - if (const auto r = std::dynamic_pointer_cast(asset)) { - r->render(shader, frustum); + for (const auto & [assetId, asset] : gameState->assets) { + if (const auto renderable = asset.getAs()) { + renderable->render(shader, frustum); } } gameState->world.apply(&Renderable::render, shader, frustum); @@ -99,9 +99,9 @@ GameMainWindow::lights(const SceneShader & shader) const void GameMainWindow::shadows(const ShadowMapper & shadowMapper, const Frustum & frustum) const { - for (const auto & [id, asset] : gameState->assets) { - if (const auto r = std::dynamic_pointer_cast(asset)) { - r->shadows(shadowMapper, frustum); + for (const auto & [assetId, asset] : gameState->assets) { + if (const auto renderable = asset.getAs()) { + renderable->shadows(shadowMapper, frustum); } } gameState->world.apply(&Renderable::shadows, shadowMapper, frustum); -- cgit v1.2.3