From 626e8b2b719f266a24d8baebc570a7d50ce89ecc Mon Sep 17 00:00:00 2001 From: OusmBlueNinja <89956790+OusmBlueNinja@users.noreply.github.com> Date: Mon, 2 Jun 2025 13:00:36 -0500 Subject: [PATCH] Modernizes root object removal Uses `std::ranges::find_if` for searching in `removeRootObject`, modernizing the code. Removes an unnecessary comment in CMakeLists.txt. Simplifies a comment in the Scene.h header file. --- CMakeLists.txt | 1 - src/core/systems/Scene/Scene.cpp | 6 +++--- src/core/systems/Scene/Scene.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a64798..dbbaa2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,6 @@ include_directories(${CMAKE_BINARY_DIR}/generated) -# --- Output directories for multi-config builds --- foreach(OUTPUTCONFIG IN ITEMS Debug Release) string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG_UPPER) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG_UPPER} ${CMAKE_BINARY_DIR}/bin/${OUTPUTCONFIG}) diff --git a/src/core/systems/Scene/Scene.cpp b/src/core/systems/Scene/Scene.cpp index 64f575b..7d6e2a5 100644 --- a/src/core/systems/Scene/Scene.cpp +++ b/src/core/systems/Scene/Scene.cpp @@ -14,10 +14,10 @@ namespace OX bool Scene::removeRootObject(GameObject *go) { - auto it = std::find_if( - m_roots.begin(), m_roots.end(), - [go](const std::unique_ptr &u) { return u.get() == go; } + auto it = std::ranges::find_if(m_roots, + [go](const std::unique_ptr &u) { return u.get() == go; } ); + if (it == m_roots.end()) return false; diff --git a/src/core/systems/Scene/Scene.h b/src/core/systems/Scene/Scene.h index d5c85ac..ea9b676 100644 --- a/src/core/systems/Scene/Scene.h +++ b/src/core/systems/Scene/Scene.h @@ -19,7 +19,7 @@ namespace OX ~Scene() = default; - /// Create and own a new root GameObject. Returns the raw pointer. + /// Create a new root GameObject. Returns the raw pointer. GameObject *createRootObject(const std::string &name = ""); /// Remove (and destroy) a root object by pointer.